@leafer-draw/worker 1.0.0-rc.30 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, ResizeEvent, BoundsHelper, MatrixHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, ResizeEvent, BoundsHelper, MatrixHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
@@ -71,7 +71,7 @@ function useCanvas(_canvasType, _power) {
71
71
  Platform.name = 'web';
72
72
  Platform.isWorker = true;
73
73
  Platform.requestRender = function (render) { requestAnimationFrame(render); };
74
- Platform.devicePixelRatio = 1;
74
+ defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
75
75
  const { userAgent } = navigator;
76
76
  if (userAgent.indexOf("Firefox") > -1) {
77
77
  Platform.conicGradientRotate90 = true;
@@ -567,14 +567,14 @@ class Renderer {
567
567
  if (Debug.showRepaint)
568
568
  this.canvas.strokeWorld(bounds, 'red');
569
569
  this.target.__render(this.canvas, options);
570
- this.renderBounds = realBounds || bounds;
570
+ this.renderBounds = realBounds = realBounds || bounds;
571
571
  this.renderOptions = options;
572
- this.totalBounds.isEmpty() ? this.totalBounds = this.renderBounds : this.totalBounds.add(this.renderBounds);
572
+ this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
573
573
  if (Debug.showHitView)
574
574
  this.renderHitView(options);
575
575
  if (Debug.showBoundsView)
576
576
  this.renderBoundsView(options);
577
- this.canvas.updateRender();
577
+ this.canvas.updateRender(realBounds);
578
578
  }
579
579
  renderHitView(_options) { }
580
580
  renderBoundsView(_options) { }
@@ -1288,7 +1288,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1288
1288
  const { abs } = Math;
1289
1289
  function checkImage(ui, canvas, paint, allowPaint) {
1290
1290
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1291
- if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
1291
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
1292
1292
  return false;
1293
1293
  }
1294
1294
  else {
@@ -2266,7 +2266,10 @@ const ExportModule = {
2266
2266
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
2267
2267
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
2268
2268
  const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
2269
+ let sliceLeaf;
2269
2270
  if (slice) {
2271
+ sliceLeaf = leaf;
2272
+ sliceLeaf.__worldOpacity = 0;
2270
2273
  leaf = leafer;
2271
2274
  renderOptions.bounds = canvas.bounds;
2272
2275
  }
@@ -2281,6 +2284,8 @@ const ExportModule = {
2281
2284
  leaf.__render(canvas, renderOptions);
2282
2285
  }
2283
2286
  canvas.restore();
2287
+ if (sliceLeaf)
2288
+ sliceLeaf.__updateWorldOpacity();
2284
2289
  if (trim) {
2285
2290
  trimBounds = getTrimBounds(canvas);
2286
2291
  const old = canvas, { width, height } = trimBounds;
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,FileHelper as o,LeafList as a,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as p,LeafBoundsHelper as _,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,AlignHelper as k,ImageEvent as E,AroundHelper as S,PointHelper as L,Direction4 as A,TwoPointBoundsHelper as O,TaskProcessor as W,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as M,ColorConvert as C,PaintGradient as D,Export as I,Group as P,TextConvert as F,Paint as Y,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:N}=o;function j(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:N(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:N(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)},e.devicePixelRatio=1;const{userAgent:X}=navigator;X.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):X.indexOf("Safari")>-1&&-1===X.indexOf("Chrome")&&(e.fullImageShadow=!0),X.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):X.indexOf("Mac")>-1?e.os="Mac":X.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 a;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 a,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===l.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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:z,updateAllWorldOpacity:H}=u,{pushAllChildBranch:Q,pushAllParent:J}=f;const{worldBounds:Z}=_,$={x:0,y:0,width:1e5,height:1e5};class K{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Z)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set($):this.afterBounds.setListWithFn(t,Z),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:tt,updateAllChange:et}=u,nt=g.get("Layouter");class it{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(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=m.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=y,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new y(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&&Q(t,e),J(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),J(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||z(i[t])}z(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&H(t),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new y(o,r,this.times)),n.emitEvent(new y(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=y,o=this.getBlocks(new a(e));e.emitEvent(new y(n,o,this.times)),it.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(i,o,this.times)),e.emitEvent(new y(s,o,this.times)),this.addBlocks(o),m.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new K([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new K(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=g.get("Renderer");class ot{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=r.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new p,st.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return st.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new p(i);n.save(),s&&!g.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(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(i),g.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new p(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 p(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||st.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 d(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function at(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 rt(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?ct(t,!0,e,n):lt(e,n);break;case"inside":dt("inside",t,s,e,n);break;case"outside":dt("outside",t,s,e,n)}}function dt(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?ct(e,!0,i,r):lt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",at(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 lt(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 ct(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?lt(n,i):i.stroke(),i.restoreBlendMode()):e?lt(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new V(t,e),layouter:(t,e)=>new it(t,e),renderer:(t,e,n)=>new ot(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=it.fullLayout;const{getSpread:ht,getOuterOf:ut,getByMove:ft,getIntersectData:pt}=B;let _t;function gt(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:C.string(a,r)};case"image":return M.image(n,t,e,i,!_t||!_t[e.url]);case"linear":return D.linearGradient(e,i);case"radial":return D.radialGradient(e,i);case"angular":return D.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:C.string(e)}:void 0}}const wt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),_t=M.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=gt(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?at(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?at(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?at(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?at(e,n):s?n.fill(s):n.fill())},fillText:at,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)rt(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)rt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),ct(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),ct(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),ct(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:rt,drawTextStroke:lt,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=pt(i?ht(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=ut(s,a),o=ft(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 yt={};const{get:mt,rotateOfOuter:vt,translate:xt,scaleOfOuter:bt,scale:Bt,rotate:Rt}=R;function kt(t,e,n,i,s,o,a){const r=mt();xt(r,e.x+n,e.y+i),Bt(r,s,o),a&&vt(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=mt();xt(r,e.x+n,e.y+i),s&&Bt(r,s,o),a&&Rt(r,a),t.transform=r}function St(t,e,n,i,s,o,a,r,d,l){const c=mt();if(d)if("center"===l)vt(c,{x:n/2,y:i/2},d);else switch(Rt(c,d),d){case 90:xt(c,i,0);break;case 180:xt(c,n,i);break;case 270:xt(c,0,n)}yt.x=e.x+s,yt.y=e.y+o,xt(c,yt.x,yt.y),a&&bt(c,yt,a,r),t.transform=c}const{get:Lt,translate:At}=R,Ot=new p,Wt={};function Tt(t,e,n,i){const{blendMode:s}=n;s&&(t.blendMode=s),t.data=Mt(n,i,e)}function Mt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=Ot.set(e).shrink(t.padding));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)c?(y=("number"==typeof c?c:c.width)/i,m=("number"==typeof c?c:c.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);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,Wt,!0),v+=Wt.x,x+=Wt.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":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)&&St(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=Lt(),At(p.transform,e.x,e.y)),y&&"strench"!==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 Ct,Dt=new p;const{isSame:It}=B;function Pt(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||Tt(s,i,n,o),!0}function Ft(t,e){Ut(t,E.LOAD,e)}function Yt(t,e){Ut(t,E.LOADED,e)}function Gt(t,e,n){e.error=n,t.forceUpdate("surface"),Ut(t,E.ERROR,e)}function Ut(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:Xt,copy:Vt}=R,{ceil:qt,abs:zt}=Math;function Ht(t,n,i){let{scaleX:s,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(n.patternId===a||t.destroyed)return!1;{s=zt(s),o=zt(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(),Vt(l,_),Xt(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(),_&&Vt(l,_)),Xt(l,1/s,1/o));const m=t.getCanvas(qt(c)||1,qt(h)||1,p),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Qt(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:Jt}=Math;const Zt={image:function(t,e,n,i,s){let o,a;const r=v.get(n);return Ct&&n===Ct.paint&&It(i,Ct.boxBounds)?o=Ct.leafPaint:(o={type:n.type,image:r},Ct=r.use>1?{leafPaint:o,paint:n,boxBounds:Dt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Pt(t,e,n,r,o,i),s&&(Ft(t,a),Yt(t,a))):r.error?s&&Gt(t,a,r.error):(Nt(t,!0),s&&Ft(t,a),o.loadId=r.load((()=>{Nt(t,!1),t.destroyed||(Pt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Yt(t,a)),o.loadId=null}),(e=>{Nt(t,!1),Gt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;if(i.data&&i.patternId!==o+"-"+a){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=Jt(o)*n.pixelRatio,i*=Jt(a)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize||I.running}return s?(n.save(),n.clip(),i.blendMode&&(n.blendMode=i.blendMode),r.opacity&&(n.opacity*=r.opacity),r.transform&&n.transform(r.transform),n.drawImage(i.image.view,0,0,r.width,r.height),n.restore(),!0):(!i.style||I.running?Ht(t,i,n.pixelRatio):i.patternTask||(i.patternTask=v.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ht(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:Ht,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,v.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:Tt,getPatternData:Mt,fillOrFitMode:kt,clipMode:Et,repeatMode:St},{toPoint:$t}=S,Kt={},te={};function ee(t,e,n){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),C.string(i,n)):t.addColorStop(i.offset,C.string(i.color,n))}const{getAngle:ne,getDistance:ie}=L,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=S,de={},le={};function ce(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ne(e,n);o=se(),s?(ae(o,e,a/r*(i||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(i||1)),oe(o,e,t))}return o}const{getDistance:he}=L,{toPoint:ue}=S,fe={},pe={};const _e={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;$t(i||"top",n,Kt),$t(s||"bottom",n,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(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;re(i||"center",n,de),re(s||"bottom",n,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ie(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,de,le,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;ue(i||"center",n,fe),ue(s||"bottom",n,pe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,pe));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,fe,pe,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function ve(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-a.x,ye.y+=n.y-a.y,i){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,a,i?ye:n)}const{toOffsetOutBounds:xe}=B,be={};const Be={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;we(l,me),r.forEach(((r,_)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,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;xe(l,be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,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:Re}=_;function ke(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),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,o);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}P.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&&(ke(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ee(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Re(n,e)||n.__render(s||t,e);ke(this,a,t,s,i,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",Oe=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 We(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=We("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=We("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=We(Le),De=We(Ae),Ie=We("- —/~|┆·");var Pe;!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"}(Pe||(Pe={}));const{Letter:Fe,Single:Ye,Before:Ge,After:Ue,Symbol:Ne,Break:je}=Pe;function Xe(t){return Te[t]?Fe:Ie[t]?je:Me[t]?Ge:Ce[t]?Ue:De[t]?Ne:Oe.test(t)?Ye:Fe}const Ve={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 qe(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:ze}=Ve,{Letter:He,Single:Qe,Before:Je,After:Ze,Symbol:$e,Break:Ke}=Pe;let tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn=[];function yn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function mn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function vn(){pn&&(_n.paraNumber++,en.paraStart=!0,pn=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width&&ze(en),wn.push(en),en={words:[]},sn=0}const xn=0,bn=1,Bn=2;const{top:Rn,right:kn,bottom:En,left:Sn}=A;function Ln(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 An={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[Sn],o-=l[kn]+l[Sn]),a&&(s=l[Rn],a-=l[Rn]+l[En]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){_n=t,wn=t.rows,gn=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;pn=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)an=n[i],"\n"===an?(nn&&mn(),en.paraEnd=!0,vn(),pn=!0):(cn=Xe(an),cn===He&&"none"!==a&&(an=qe(an,a,!nn)),rn=r.measureText(an).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===He)||hn===Qe&&cn!==Ze,fn=!(cn!==Je&&cn!==Qe||hn!==$e&&hn!==Ze),on=pn&&o?d-o:d,t&&d&&sn+nn+rn>on&&(e?(nn&&mn(),sn&&vn()):(fn||(fn=cn===He&&hn==Ze),un||fn||cn===Ke||cn===Je||cn===Qe||nn+rn>on?(nn&&mn(),sn&&vn()):sn&&vn()))," "===an&&!0!==pn&&sn+nn===0||(cn===Ke?(" "===an&&nn&&mn(),yn(an,rn),mn()):un||fn?(nn&&mn(),yn(an,rn)):yn(an,rn)),hn=cn);nn&&mn(),sn&&vn(),wn.length>0&&(wn[wn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{_n.paraNumber++,wn.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ln(e,"x",t[Sn]);break;case"right":Ln(e,"x",-t[kn])}if(!s)switch(n.verticalAlign){case"top":Ln(e,"y",t[Rn]);break;case"bottom":Ln(e,"y",-t[En])}}(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}=e;let h,u,f,{x:p,y:_,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,l=n.length;o<l;o++){if(h=n[o],h.x=p,h.width<g||h.width>g&&!r)switch(d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=s,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=y}(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?xn:l>.01?bn:Bn,t.isOverflow&&!r&&(t.textMode=!0),h===Bn?(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===bn?(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 On={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:Wn,addPoint:Tn,toBounds:Mn}=O;const Cn={export(t,n,s){this.running=!0;const a=o.fileType(n);return s=o.getExportOptions(s),function(t){Dn||(Dn=new W);return new Promise((e=>{Dn.add((()=>Qt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const l=t=>{r(t),d(),this.running=!1},{toURL:c}=e,{download:h}=e.origin;if("json"===n)return l({data:t.toJSON(s.json)});if("json"===a)return h(c(JSON.stringify(t.toJSON(s.json)),"text"),n),l({data:!0});if("svg"===n)return l({data:t.toSVG()});if("svg"===a)return h(c(t.toSVG(),"svg"),n),l({data:!0});const{leafer:u}=t;u?(In(t),u.waitViewCompleted((()=>Qt(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:c,isLeafer:h,isFrame:f}=t,{slice:_,trim:g,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;const v=void 0===s.smooth?u.config.smooth:s.smooth,x=s.contextSettings||u.config.contextSettings;t.isApp&&(y*=m,m=t.app.pixelRatio);const b=s.screenshot||t.isApp,B=h&&b&&void 0===s.fill?t.fill:s.fill,R=o.isOpaqueImage(n)||B,k=new T;if(b)e=!0===b?h?u.canvas.bounds:t.worldRenderBounds:b;else{let n=s.relative||(h?"inner":"local");switch(r=c.scaleX,d=c.scaleY,n){case"inner":k.set(c);break;case"local":k.set(c).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":n=t.leafer;default:k.set(c).divide(t.getTransform(n));const e=n.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",n)}const{x:E,y:S,width:L,height:A}=new p(e).scale(y);let O=i.canvas({width:Math.round(L),height:Math.round(A),pixelRatio:m,smooth:v,contextSettings:x});const W={matrix:k.scale(1/y).invert().translate(-E,-S).withScale(1/r*y,1/d*y)};if(_&&(t=u,W.bounds=O.bounds),O.save(),f&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(O,W),t.fill=e}else t.__render(O,W);if(O.restore(),g){a=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?Tn(a,s,o):Wn(a={},s,o)),r++;const d=new p;return Mn(a,d),d.scale(1/t.pixelRatio).ceil()}(O);const t=O,{width:e,height:n}=a,s={x:0,y:0,width:e,height:n,pixelRatio:m};O=i.canvas(s),O.copyWorld(t,a,s)}R&&O.fillWorld(O.bounds,B||"#FFFFFF","destination-over"),w&&w(O);const M="canvas"===n?O:yield O.export(n,s);l({data:M,width:O.pixelWidth,height:O.pixelHeight,renderBounds:e,trimBounds:a})}))))):l({data:!1})}))))}};let Dn;function In(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>In(t)))}const Pn=t.prototype,Fn=g.get("@leafer-ui/export");Pn.export=function(t,e){const{quality:n,blob:i}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):i?this.toBlob(t,n):this.toDataURL(t,n)},Pn.toBlob=function(t,n){return new Promise((i=>{e.origin.canvasToBolb(this.view,t,n).then((t=>{i(t)})).catch((t=>{Fn.error(t),i(null)}))}))},Pn.toDataURL=function(t,n){return e.origin.canvasToDataURL(this.view,t,n)},Pn.saveAs=function(t,n){return new Promise((i=>{e.origin.canvasSaveAs(this.view,t,n).then((()=>{i(!0)})).catch((t=>{Fn.error(t),i(!1)}))}))},Object.assign(F,An),Object.assign(C,On),Object.assign(Y,wt),Object.assign(M,Zt),Object.assign(D,_e),Object.assign(G,Be),Object.assign(I,Cn),j();export{it as Layouter,U as LeaferCanvas,ot as Renderer,V as Watcher,j 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,AnimateEvent as b,ResizeEvent as B,BoundsHelper as R,MatrixHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as O,Direction4 as W,TwoPointBoundsHelper as A,TaskProcessor as T,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as C,ColorConvert as D,PaintGradient as I,Export as P,Group as F,TextConvert as Y,Paint as G,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class N 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:j}=a;function X(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:j(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:j(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 N(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:V}=navigator;V.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):V.indexOf("Safari")>-1&&-1===V.indexOf("Chrome")&&(e.fullImageShadow=!0),V.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):V.indexOf("Mac")>-1?e.os="Mac":V.indexOf("Linux")>-1&&(e.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new 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:z,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?(z(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){t.list.forEach((t=>{t.__layout.opacityChanged&&Q(t),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{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.target.emit(b.FRAME),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&&C.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 q(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}=R;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 C.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=C.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&&C.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}=k;function Et(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 St(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:Ot,translate:Wt}=k,At=new _,Tt={};function Mt(t,e,n,i){const{blendMode:s}=n;s&&(t.blendMode=s),t.data=Ct(n,i,e)}function Ct(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding));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)c?(y=("number"==typeof c?c:c.width)/i,m=("number"==typeof c?c:c.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);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),E.toPoint(r,t,e,Tt,!0),v+=Tt.x,x+=Tt.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&St(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&&Et(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=Ot(),Wt(p.transform,e.x,e.y)),y&&"strench"!==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 Dt,It=new _;const{isSame:Pt}=R;function Ft(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 Yt(t,e){Nt(t,S.LOAD,e)}function Gt(t,e){Nt(t,S.LOADED,e)}function Ut(t,e,n){e.error=n,t.forceUpdate("surface"),Nt(t,S.ERROR,e)}function Nt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function jt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Xt,scale:Vt,copy:qt}=k,{ceil:zt,abs:Ht}=Math;function Qt(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(n.patternId===a||t.destroyed)return!1;{s=Ht(s),o=Ht(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=Xt(),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=Xt(),_&&qt(l,_)),Vt(l,1/s,1/o));const m=t.getCanvas(zt(c)||1,zt(h)||1,p),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Jt(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:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Dt&&n===Dt.paint&&Pt(i,Dt.boxBounds)?o=Dt.leafPaint:(o={type:n.type,image:r},Dt=r.use>1?{leafPaint:o,paint:n,boxBounds:It.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Ft(t,e,n,r,o,i),s&&(Yt(t,a),Gt(t,a))):r.error?s&&Ut(t,a,r.error):(jt(t,!0),s&&Yt(t,a),o.loadId=r.load((()=>{jt(t,!1),t.destroyed||(Ft(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{jt(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;if(!i.data||i.patternId===o+"-"+a&&!P.running)return!1;{const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=Zt(o)*n.pixelRatio,i*=Zt(a)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize||P.running}return s?(n.save(),n.clip(),i.blendMode&&(n.blendMode=i.blendMode),r.opacity&&(n.opacity*=r.opacity),r.transform&&n.transform(r.transform),n.drawImage(i.image.view,0,0,r.width,r.height),n.restore(),!0):(!i.style||P.running?Qt(t,i,n.pixelRatio):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Jt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Qt(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Qt,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:Ct,fillOrFitMode:Et,clipMode:St,repeatMode:Lt},{toPoint:Kt}=L,te={},ee={};function ne(t,e,n){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:ie,getDistance:se}=O,{get:oe,rotateOfOuter:ae,scaleOfOuter:re}=k,{toPoint:de}=L,le={},ce={};function he(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ie(e,n);o=oe(),s?(re(o,e,a/r*(i||1),1),ae(o,e,t+90)):(re(o,e,1,a/r*(i||1)),ae(o,e,t))}return o}const{getDistance:ue}=O,{toPoint:fe}=L,pe={},_e={};const ge={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Kt(i||"top",n,te),Kt(s||"bottom",n,ee);const d=e.canvas.createLinearGradient(te.x,te.y,ee.x,ee.y);ne(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;de(i||"center",n,le),de(s||"bottom",n,ce);const l=e.canvas.createRadialGradient(le.x,le.y,0,le.x,le.y,se(le,ce));ne(l,t.stops,a);const c={type:o,style:l},h=he(n,le,ce,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;fe(i||"center",n,pe),fe(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,ue(pe,_e));ne(l,t.stops,a);const c={type:o,style:l},h=he(n,pe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:he},{copy:we,toOffsetOutBounds:ye}=R,me={},ve={};function xe(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(we(me,t.bounds),me.x+=n.x-a.x,me.y+=n.y-a.y,i){const{matrix:t}=s;me.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),me.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),me.width*=i,me.height*=i}t.copyWorld(s.canvas,t.bounds,me)}else i&&(we(me,n),me.x-=n.width/2*(i-1),me.y-=n.height/2*(i-1),me.width*=i,me.height*=i),t.copyWorld(s.canvas,a,i?me:n)}const{toOffsetOutBounds:be}=R,Be={};const Re={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;ye(l,ve),r.forEach(((r,_)=>{f.setWorldShadow(ve.offsetX+r.x*h,ve.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,ve,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,Be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,Be,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"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Le(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Le(t,n,i,o);break;case"path":n.restore()}}function Se(t){return t.getSameCanvas(!1,!0)}function Le(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=Se(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Se(t)),s||(s=Se(t)),n.__render(i,e)),"clipping"!==n.__.mask)||ke(n,e)||n.__render(s||t,e);Ee(this,a,t,s,i,o)};const Oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Oe+"_#~&*+\\=|≮≯≈≠=…",Ae=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 Te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),De=Te(Oe),Ie=Te(We),Pe=Te("- —/~|┆·");var Fe;!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"}(Fe||(Fe={}));const{Letter:Ye,Single:Ge,Before:Ue,After:Ne,Symbol:je,Break:Xe}=Fe;function Ve(t){return Me[t]?Ye:Pe[t]?Xe:Ce[t]?Ue:De[t]?Ne:Ie[t]?je:Ae.test(t)?Ge:Ye}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 ze(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:He}=qe,{Letter:Qe,Single:Je,Before:Ze,After:$e,Symbol:Ke,Break:tn}=Fe;let en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn,yn=[];function mn(t,e){cn&&!ln&&(ln=cn),en.data.push({char:t,width:e}),sn+=e}function vn(){on+=sn,en.width=sn,nn.words.push(en),en={data:[]},sn=0}function xn(){_n&&(gn.paraNumber++,nn.paraStart=!0,_n=!1),cn&&(nn.startCharSize=ln,nn.endCharSize=cn,ln=0),nn.width=on,wn.width&&He(nn),yn.push(nn),nn={words:[]},on=0}const bn=0,Bn=1,Rn=2;const{top:kn,right:En,bottom:Sn,left:Ln}=W;function On(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 Wn={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[Ln],o-=l[En]+l[Ln]),a&&(s=l[kn],a-=l[kn]+l[Sn]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){gn=t,yn=t.rows,wn=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=wn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,un=null,ln=dn=cn=sn=on=0,en={data:[]},nn={words:[]};for(let i=0,l=n.length;i<l;i++)rn=n[i],"\n"===rn?(sn&&vn(),nn.paraEnd=!0,xn(),_n=!0):(hn=Ve(rn),hn===Qe&&"none"!==a&&(rn=ze(rn,a,!sn)),dn=r.measureText(rn).width,s&&(s<0&&(cn=dn),dn+=s),fn=hn===Je&&(un===Je||un===Qe)||un===Je&&hn!==$e,pn=!(hn!==Ze&&hn!==Je||un!==Ke&&un!==$e),an=_n&&o?d-o:d,t&&d&&on+sn+dn>an&&(e?(sn&&vn(),on&&xn()):(pn||(pn=hn===Qe&&un==$e),fn||pn||hn===tn||hn===Ze||hn===Je||sn+dn>an?(sn&&vn(),on&&xn()):on&&xn()))," "===rn&&!0!==_n&&on+sn===0||(hn===tn?(" "===rn&&sn&&vn(),mn(rn,dn),vn()):fn||pn?(sn&&vn(),mn(rn,dn)):mn(rn,dn)),un=hn);sn&&vn(),on&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{gn.paraNumber++,yn.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":On(e,"x",t[Ln]);break;case"right":On(e,"x",-t[En])}if(!s)switch(n.verticalAlign){case"top":On(e,"y",t[kn]);break;case"bottom":On(e,"y",-t[Sn])}}(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}=e;let h,u,f,{x:p,y:_,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,l=n.length;o<l;o++){if(h=n[o],h.x=p,h.width<g||h.width>g&&!r)switch(d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=s,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=y}(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?bn:l>.01?Bn:Rn,t.isOverflow&&!r&&(t.textMode=!0),h===Rn?(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===Bn?(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 An={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:Tn,addPoint:Mn,toBounds:Cn}=A;const Dn={export(t,n,s){this.running=!0;const o=a.fileType(n);return s=a.getExportOptions(s),function(t){In||(In=new T);return new Promise((e=>{In.add((()=>Jt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const l=t=>{r(t),d(),this.running=!1},{toURL:c}=e,{download:h}=e.origin;if("json"===n)return l({data:t.toJSON(s.json)});if("json"===o)return h(c(JSON.stringify(t.toJSON(s.json)),"text"),n),l({data:!0});if("svg"===n)return l({data:t.toSVG()});if("svg"===o)return h(c(t.toSVG(),"svg"),n),l({data:!0});const{leafer:u}=t;u?(Pn(t),u.waitViewCompleted((()=>Jt(this,void 0,void 0,(function*(){let e,o,r=1,d=1;const{worldTransform:c,isLeafer:h,isFrame:f}=t,{slice:p,trim:g,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;const v=void 0===s.smooth?u.config.smooth:s.smooth,x=s.contextSettings||u.config.contextSettings;t.isApp&&(y*=m,m=t.app.pixelRatio);const b=s.screenshot||t.isApp,B=h&&b&&void 0===s.fill?t.fill:s.fill,R=a.isOpaqueImage(n)||B,k=new M;if(b)e=!0===b?h?u.canvas.bounds:t.worldRenderBounds:b;else{let n=s.relative||(h?"inner":"local");switch(r=c.scaleX,d=c.scaleY,n){case"inner":k.set(c);break;case"local":k.set(c).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":n=t.leafer;default:k.set(c).divide(t.getTransform(n));const e=n.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",n)}const{x:E,y:S,width:L,height:O}=new _(e).scale(y);let W=i.canvas({width:Math.round(L),height:Math.round(O),pixelRatio:m,smooth:v,contextSettings:x});const A={matrix:k.scale(1/y).invert().translate(-E,-S).withScale(1/r*y,1/d*y)};let T;if(p&&(T=t,T.__worldOpacity=0,t=u,A.bounds=W.bounds),W.save(),f&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(W,A),t.fill=e}else t.__render(W,A);if(W.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?Mn(a,s,o):Tn(a={},s,o)),r++;const d=new _;return Cn(a,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:n}=o,s={x:0,y:0,width:e,height:n,pixelRatio:m};W=i.canvas(s),W.copyWorld(t,o,s)}R&&W.fillWorld(W.bounds,B||"#FFFFFF","destination-over"),w&&w(W);const C="canvas"===n?W:yield W.export(n,s);l({data:C,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:o})}))))):l({data:!1})}))))}};let In;function Pn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Pn(t)))}const Fn=t.prototype,Yn=w.get("@leafer-ui/export");Fn.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)},Fn.toBlob=function(t,n){return new Promise((i=>{e.origin.canvasToBolb(this.view,t,n).then((t=>{i(t)})).catch((t=>{Yn.error(t),i(null)}))}))},Fn.toDataURL=function(t,n){return e.origin.canvasToDataURL(this.view,t,n)},Fn.saveAs=function(t,n){return new Promise((i=>{e.origin.canvasSaveAs(this.view,t,n).then((()=>{i(!0)})).catch((t=>{Yn.error(t),i(!1)}))}))},Object.assign(Y,Wn),Object.assign(D,An),Object.assign(G,yt),Object.assign(C,$t),Object.assign(I,ge),Object.assign(U,Re),Object.assign(P,Dn),X();export{st as Layouter,N as LeaferCanvas,at as Renderer,q as Watcher,X as useCanvas};
package/dist/worker.js CHANGED
@@ -51,6 +51,8 @@ var LeaferUI = (function (exports) {
51
51
  const { round, pow: pow$1, PI: PI$4 } = Math;
52
52
  const MathHelper = {
53
53
  within(value, min, max) {
54
+ if (typeof min === 'object')
55
+ max = min.max, min = min.min;
54
56
  if (min !== undefined && value < min)
55
57
  value = min;
56
58
  if (max !== undefined && value > max)
@@ -153,10 +155,10 @@ var LeaferUI = (function (exports) {
153
155
  t.e += x;
154
156
  t.f += y;
155
157
  },
156
- translateInner(t, x, y, isMoveOrigin) {
158
+ translateInner(t, x, y, hasOrigin) {
157
159
  t.e += t.a * x + t.c * y;
158
160
  t.f += t.b * x + t.d * y;
159
- if (isMoveOrigin)
161
+ if (hasOrigin)
160
162
  t.e -= x, t.f -= y;
161
163
  },
162
164
  scale(t, scaleX, scaleY = scaleX) {
@@ -315,7 +317,7 @@ var LeaferUI = (function (exports) {
315
317
  to.y -= (f * a - e * b) * s;
316
318
  }
317
319
  },
318
- setLayout(t, layout, origin, bcChanged) {
320
+ setLayout(t, layout, origin, around, bcChanged) {
319
321
  const { x, y, scaleX, scaleY } = layout;
320
322
  if (bcChanged === undefined)
321
323
  bcChanged = layout.rotation || layout.skewX || layout.skewY;
@@ -347,10 +349,10 @@ var LeaferUI = (function (exports) {
347
349
  }
348
350
  t.e = x;
349
351
  t.f = y;
350
- if (origin)
351
- M$6.translateInner(t, -origin.x, -origin.y, true);
352
+ if (origin = origin || around)
353
+ M$6.translateInner(t, -origin.x, -origin.y, !around);
352
354
  },
353
- getLayout(t, origin, firstSkewY) {
355
+ getLayout(t, origin, around, firstSkewY) {
354
356
  const { a, b, c, d, e, f } = t;
355
357
  let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
356
358
  if (b || c) {
@@ -379,9 +381,11 @@ var LeaferUI = (function (exports) {
379
381
  scaleY = d;
380
382
  rotation = skewX = skewY = 0;
381
383
  }
382
- if (origin) {
384
+ if (origin = around || origin) {
383
385
  x += origin.x * a + origin.y * c;
384
386
  y += origin.x * b + origin.y * d;
387
+ if (!around)
388
+ x -= origin.x, y -= origin.y;
385
389
  }
386
390
  return { x, y, scaleX, scaleY, rotation, skewX, skewY };
387
391
  },
@@ -709,12 +713,12 @@ var LeaferUI = (function (exports) {
709
713
  toInnerPoint(outer, to, distance) {
710
714
  MatrixHelper.toInnerPoint(this, outer, to, distance);
711
715
  }
712
- setLayout(data, origin) {
713
- MatrixHelper.setLayout(this, data, origin);
716
+ setLayout(data, origin, around) {
717
+ MatrixHelper.setLayout(this, data, origin, around);
714
718
  return this;
715
719
  }
716
- getLayout(origin, firstSkewY) {
717
- return MatrixHelper.getLayout(this, origin, firstSkewY);
720
+ getLayout(origin, around, firstSkewY) {
721
+ return MatrixHelper.getLayout(this, origin, around, firstSkewY);
718
722
  }
719
723
  withScale(scaleX, scaleY) {
720
724
  return MatrixHelper.withScale(this, scaleX, scaleY);
@@ -2002,7 +2006,7 @@ var LeaferUI = (function (exports) {
2002
2006
  DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2003
2007
  this.size.pixelRatio || (this.size.pixelRatio = 1);
2004
2008
  this.bounds = new Bounds(0, 0, this.width, this.height);
2005
- if (!this.unreal) {
2009
+ if (this.context && !this.unreal) {
2006
2010
  this.updateViewSize();
2007
2011
  this.smooth = this.config.smooth;
2008
2012
  }
@@ -2175,7 +2179,7 @@ var LeaferUI = (function (exports) {
2175
2179
  this.manager ? this.manager.recycle(this) : this.destroy();
2176
2180
  }
2177
2181
  }
2178
- updateRender() { }
2182
+ updateRender(_bounds) { }
2179
2183
  unrealCanvas() { }
2180
2184
  destroy() {
2181
2185
  this.manager = this.view = this.parentView = null;
@@ -4069,8 +4073,13 @@ var LeaferUI = (function (exports) {
4069
4073
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4070
4074
  copy$6(matrix, t.__localMatrix);
4071
4075
  scaleOfOuter$2(matrix, origin, scaleX, scaleY);
4072
- moveByMatrix(t, matrix);
4073
- t.scaleResize(scaleX, scaleY, resize !== true);
4076
+ if (t.origin || t.around) {
4077
+ L.setTransform(t, matrix, resize);
4078
+ }
4079
+ else {
4080
+ moveByMatrix(t, matrix);
4081
+ t.scaleResize(scaleX, scaleY, resize !== true);
4082
+ }
4074
4083
  },
4075
4084
  rotateOfWorld(t, origin, angle) {
4076
4085
  L.rotateOfLocal(t, getTempLocal(t, origin), angle);
@@ -4078,8 +4087,13 @@ var LeaferUI = (function (exports) {
4078
4087
  rotateOfLocal(t, origin, angle) {
4079
4088
  copy$6(matrix, t.__localMatrix);
4080
4089
  rotateOfOuter$2(matrix, origin, angle);
4081
- moveByMatrix(t, matrix);
4082
- t.rotation = MathHelper.formatRotation(t.rotation + angle);
4090
+ if (t.origin || t.around) {
4091
+ L.setTransform(t, matrix);
4092
+ }
4093
+ else {
4094
+ moveByMatrix(t, matrix);
4095
+ t.rotation = MathHelper.formatRotation(t.rotation + angle);
4096
+ }
4083
4097
  },
4084
4098
  skewOfWorld(t, origin, skewX, skewY, resize) {
4085
4099
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
@@ -4102,7 +4116,7 @@ var LeaferUI = (function (exports) {
4102
4116
  L.setTransform(t, matrix, resize);
4103
4117
  },
4104
4118
  setTransform(t, transform, resize) {
4105
- const layout = getLayout(transform);
4119
+ const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
4106
4120
  if (resize) {
4107
4121
  const scaleX = layout.scaleX / t.scaleX;
4108
4122
  const scaleY = layout.scaleY / t.scaleY;
@@ -4115,13 +4129,19 @@ var LeaferUI = (function (exports) {
4115
4129
  t.set(layout);
4116
4130
  }
4117
4131
  },
4132
+ getFlipTransform(t, axis) {
4133
+ const m = getMatrixData();
4134
+ const sign = axis === 'x' ? 1 : -1;
4135
+ scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
4136
+ return m;
4137
+ },
4118
4138
  getLocalOrigin(t, origin) {
4119
4139
  return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
4120
4140
  },
4121
4141
  getInnerOrigin(t, origin) {
4122
- if (typeof origin === 'string')
4123
- AroundHelper.toPoint(origin, t.boxBounds, origin = {});
4124
- return origin;
4142
+ const innerOrigin = {};
4143
+ AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
4144
+ return innerOrigin;
4125
4145
  },
4126
4146
  getRelativeWorld(t, relative, temp) {
4127
4147
  copy$6(matrix, t.worldTransform);
@@ -4548,7 +4568,10 @@ var LeaferUI = (function (exports) {
4548
4568
  on(type, listener, options) {
4549
4569
  let capture, once;
4550
4570
  if (options) {
4551
- if (typeof options === 'boolean') {
4571
+ if (options === 'once') {
4572
+ once = true;
4573
+ }
4574
+ else if (typeof options === 'boolean') {
4552
4575
  capture = options;
4553
4576
  }
4554
4577
  else {
@@ -4579,7 +4602,7 @@ var LeaferUI = (function (exports) {
4579
4602
  if (listener) {
4580
4603
  let capture;
4581
4604
  if (options)
4582
- capture = typeof options === 'boolean' ? options : options.capture;
4605
+ capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
4583
4606
  let events, index;
4584
4607
  const map = __getListenerMap(this, capture);
4585
4608
  typeList.forEach(type => {
@@ -4881,7 +4904,7 @@ var LeaferUI = (function (exports) {
4881
4904
  const layout = this.__layout, local = this.__local, data = this.__;
4882
4905
  if (layout.affectScaleOrRotation) {
4883
4906
  if (layout.scaleChanged || layout.rotationChanged) {
4884
- setLayout(local, data, null, layout.affectRotation);
4907
+ setLayout(local, data, null, null, layout.affectRotation);
4885
4908
  layout.scaleChanged = layout.rotationChanged = false;
4886
4909
  }
4887
4910
  }
@@ -4889,7 +4912,7 @@ var LeaferUI = (function (exports) {
4889
4912
  local.f = data.y + data.offsetY;
4890
4913
  if (data.around || data.origin) {
4891
4914
  toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
4892
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4915
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
4893
4916
  }
4894
4917
  }
4895
4918
  this.__layout.matrixChanged = false;
@@ -5118,7 +5141,7 @@ var LeaferUI = (function (exports) {
5118
5141
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5119
5142
  const { toOuterOf } = BoundsHelper;
5120
5143
  const { copy: copy$3 } = PointHelper;
5121
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5144
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5122
5145
  exports.Leaf = class Leaf {
5123
5146
  get tag() { return this.__tag; }
5124
5147
  set tag(_value) { }
@@ -5144,6 +5167,8 @@ var LeaferUI = (function (exports) {
5144
5167
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5145
5168
  get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
5146
5169
  get pathInputed() { return this.__.__pathInputed; }
5170
+ set event(map) { let event; for (let key in map)
5171
+ event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
5147
5172
  constructor(data) {
5148
5173
  this.innerId = create(LEAF);
5149
5174
  this.reset(data);
@@ -5403,6 +5428,9 @@ var LeaferUI = (function (exports) {
5403
5428
  skewOfWorld(worldOrigin, skewX, skewY, resize) {
5404
5429
  skewOfWorld(this, worldOrigin, skewX, skewY, resize);
5405
5430
  }
5431
+ flip(axis) {
5432
+ transform(this, getFlipTransform(this, axis));
5433
+ }
5406
5434
  scaleResize(scaleX, scaleY = scaleX, _noResize) {
5407
5435
  this.scaleX *= scaleX;
5408
5436
  this.scaleY *= scaleY;
@@ -5760,7 +5788,7 @@ var LeaferUI = (function (exports) {
5760
5788
  }
5761
5789
  }
5762
5790
 
5763
- const version = "1.0.0-rc.30";
5791
+ const version = "1.0.1";
5764
5792
  const inviteCode = {};
5765
5793
 
5766
5794
  class LeaferCanvas extends LeaferCanvasBase {
@@ -5830,7 +5858,7 @@ var LeaferUI = (function (exports) {
5830
5858
  Platform.name = 'web';
5831
5859
  Platform.isWorker = true;
5832
5860
  Platform.requestRender = function (render) { requestAnimationFrame(render); };
5833
- Platform.devicePixelRatio = 1;
5861
+ defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
5834
5862
  const { userAgent } = navigator;
5835
5863
  if (userAgent.indexOf("Firefox") > -1) {
5836
5864
  Platform.conicGradientRotate90 = true;
@@ -6326,14 +6354,14 @@ var LeaferUI = (function (exports) {
6326
6354
  if (Debug.showRepaint)
6327
6355
  this.canvas.strokeWorld(bounds, 'red');
6328
6356
  this.target.__render(this.canvas, options);
6329
- this.renderBounds = realBounds || bounds;
6357
+ this.renderBounds = realBounds = realBounds || bounds;
6330
6358
  this.renderOptions = options;
6331
- this.totalBounds.isEmpty() ? this.totalBounds = this.renderBounds : this.totalBounds.add(this.renderBounds);
6359
+ this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
6332
6360
  if (Debug.showHitView)
6333
6361
  this.renderHitView(options);
6334
6362
  if (Debug.showBoundsView)
6335
6363
  this.renderBoundsView(options);
6336
- this.canvas.updateRender();
6364
+ this.canvas.updateRender(realBounds);
6337
6365
  }
6338
6366
  renderHitView(_options) { }
6339
6367
  renderBoundsView(_options) { }
@@ -7384,7 +7412,7 @@ var LeaferUI = (function (exports) {
7384
7412
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7385
7413
  if (this.isApp)
7386
7414
  this.__setApp();
7387
- this.__checkAutoLayout(config);
7415
+ this.__checkAutoLayout(config, parentApp);
7388
7416
  this.view = canvas.view;
7389
7417
  if (parentApp) {
7390
7418
  this.__bindApp(parentApp);
@@ -7485,9 +7513,10 @@ var LeaferUI = (function (exports) {
7485
7513
  this.leafer = leafer;
7486
7514
  this.__level = 1;
7487
7515
  }
7488
- __checkAutoLayout(config) {
7489
- if (!config.width || !config.height) {
7490
- this.autoLayout = new AutoBounds(config);
7516
+ __checkAutoLayout(config, parentApp) {
7517
+ if (!parentApp) {
7518
+ if (!config.width || !config.height)
7519
+ this.autoLayout = new AutoBounds(config);
7491
7520
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
7492
7521
  }
7493
7522
  }
@@ -7622,7 +7651,9 @@ var LeaferUI = (function (exports) {
7622
7651
  list.push(item);
7623
7652
  }
7624
7653
  }
7625
- zoom(_zoomType, _padding, _fixedScale) { return undefined; }
7654
+ zoom(_zoomType, _padding, _fixedScale) {
7655
+ return debug$1.error('need @leafer-in/view');
7656
+ }
7626
7657
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
7627
7658
  getValidScale(changeScale) { return changeScale; }
7628
7659
  getWorldPointByClient(clientPoint, updateClient) {
@@ -8149,8 +8180,7 @@ var LeaferUI = (function (exports) {
8149
8180
  destroy() {
8150
8181
  if (this.canvas) {
8151
8182
  this.canvas.destroy();
8152
- this.canvas = null;
8153
- this.context = null;
8183
+ this.canvas = this.context = null;
8154
8184
  }
8155
8185
  super.destroy();
8156
8186
  }
@@ -8994,7 +9024,7 @@ var LeaferUI = (function (exports) {
8994
9024
  const { abs } = Math;
8995
9025
  function checkImage(ui, canvas, paint, allowPaint) {
8996
9026
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
8997
- if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
9027
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
8998
9028
  return false;
8999
9029
  }
9000
9030
  else {
@@ -9972,7 +10002,10 @@ var LeaferUI = (function (exports) {
9972
10002
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
9973
10003
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
9974
10004
  const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
10005
+ let sliceLeaf;
9975
10006
  if (slice) {
10007
+ sliceLeaf = leaf;
10008
+ sliceLeaf.__worldOpacity = 0;
9976
10009
  leaf = leafer;
9977
10010
  renderOptions.bounds = canvas.bounds;
9978
10011
  }
@@ -9987,6 +10020,8 @@ var LeaferUI = (function (exports) {
9987
10020
  leaf.__render(canvas, renderOptions);
9988
10021
  }
9989
10022
  canvas.restore();
10023
+ if (sliceLeaf)
10024
+ sliceLeaf.__updateWorldOpacity();
9990
10025
  if (trim) {
9991
10026
  trimBounds = getTrimBounds(canvas);
9992
10027
  const old = canvas, { width, height } = trimBounds;