@leafer-draw/node 1.0.0-rc.10 → 1.0.0-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -674,9 +674,6 @@ Object.assign(core.Creator, {
674
674
  });
675
675
  core.Platform.layout = Layouter.fullLayout;
676
676
 
677
- const PaintImage = {};
678
- const PaintGradient = {};
679
-
680
677
  function fillText(ui, canvas) {
681
678
  let row;
682
679
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
@@ -704,7 +701,7 @@ function fills(fills, ui, canvas) {
704
701
  const { windingRule, __font } = ui.__;
705
702
  for (let i = 0, len = fills.length; i < len; i++) {
706
703
  item = fills[i];
707
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
704
+ if (item.image && draw.PaintImage.checkImage(ui, canvas, item, !__font))
708
705
  continue;
709
706
  if (item.style) {
710
707
  canvas.fillStyle = item.style;
@@ -784,7 +781,7 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
784
781
  let item;
785
782
  for (let i = 0, len = strokes.length; i < len; i++) {
786
783
  item = strokes[i];
787
- if (item.image && PaintImage.checkImage(ui, canvas, item, false))
784
+ if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
788
785
  continue;
789
786
  if (item.style) {
790
787
  canvas.strokeStyle = item.style;
@@ -928,7 +925,7 @@ function compute(attrName, ui) {
928
925
  let paints = data.__input[attrName], hasOpacityPixel;
929
926
  if (!(paints instanceof Array))
930
927
  paints = [paints];
931
- recycleMap = PaintImage.recycleImage(attrName, data);
928
+ recycleMap = draw.PaintImage.recycleImage(attrName, data);
932
929
  for (let i = 0, len = paints.length, item; i < len; i++) {
933
930
  item = getLeafPaint(attrName, paints[i], ui);
934
931
  if (item)
@@ -953,13 +950,13 @@ function getLeafPaint(attrName, paint, ui) {
953
950
  let { type, blendMode, color, opacity } = paint;
954
951
  return { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
955
952
  case 'image':
956
- return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
953
+ return draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
957
954
  case 'linear':
958
- return PaintGradient.linearGradient(paint, boxBounds);
955
+ return draw.PaintGradient.linearGradient(paint, boxBounds);
959
956
  case 'radial':
960
- return PaintGradient.radialGradient(paint, boxBounds);
957
+ return draw.PaintGradient.radialGradient(paint, boxBounds);
961
958
  case 'angular':
962
- return PaintGradient.conicGradient(paint, boxBounds);
959
+ return draw.PaintGradient.conicGradient(paint, boxBounds);
963
960
  default:
964
961
  return paint.r ? { type: 'solid', style: draw.ColorConvert.string(paint) } : undefined;
965
962
  }
@@ -2131,7 +2128,8 @@ const ExportModule = {
2131
2128
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
2132
2129
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2133
2130
  options = core.FileHelper.getExportOptions(options);
2134
- const { scale, pixelRatio, slice, trim } = options;
2131
+ const { scale, slice, trim } = options;
2132
+ const pixelRatio = options.pixelRatio || 1;
2135
2133
  const screenshot = options.screenshot || leaf.isApp;
2136
2134
  const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
2137
2135
  const needFill = core.FileHelper.isOpaqueImage(filename) || fill, matrix = new core.Matrix();
@@ -2151,7 +2149,7 @@ const ExportModule = {
2151
2149
  width *= scale, height *= scale;
2152
2150
  scaleX *= scale, scaleY *= scale;
2153
2151
  }
2154
- let canvas = core.Creator.canvas({ width, height, pixelRatio });
2152
+ let canvas = core.Creator.canvas({ width: Math.ceil(width), height: Math.ceil(height), pixelRatio });
2155
2153
  const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
2156
2154
  if (slice) {
2157
2155
  leaf = leafer;
@@ -2170,7 +2168,7 @@ const ExportModule = {
2170
2168
  if (needFill)
2171
2169
  canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
2172
2170
  const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
2173
- over({ data, renderBounds, trimBounds });
2171
+ over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
2174
2172
  }));
2175
2173
  }
2176
2174
  else {
package/dist/node.esm.js CHANGED
@@ -2,7 +2,7 @@ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, FileHelp
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { writeFileSync } from 'fs';
5
- import { ColorConvert, Export, Group, TextConvert, Paint, PaintImage as PaintImage$1, PaintGradient as PaintGradient$1, Effect } from '@leafer-ui/draw';
5
+ import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
6
6
  export * from '@leafer-ui/draw';
7
7
 
8
8
  /******************************************************************************
@@ -675,9 +675,6 @@ Object.assign(Creator, {
675
675
  });
676
676
  Platform.layout = Layouter.fullLayout;
677
677
 
678
- const PaintImage = {};
679
- const PaintGradient = {};
680
-
681
678
  function fillText(ui, canvas) {
682
679
  let row;
683
680
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
@@ -2132,7 +2129,8 @@ const ExportModule = {
2132
2129
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
2133
2130
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2134
2131
  options = FileHelper.getExportOptions(options);
2135
- const { scale, pixelRatio, slice, trim } = options;
2132
+ const { scale, slice, trim } = options;
2133
+ const pixelRatio = options.pixelRatio || 1;
2136
2134
  const screenshot = options.screenshot || leaf.isApp;
2137
2135
  const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
2138
2136
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -2152,7 +2150,7 @@ const ExportModule = {
2152
2150
  width *= scale, height *= scale;
2153
2151
  scaleX *= scale, scaleY *= scale;
2154
2152
  }
2155
- let canvas = Creator.canvas({ width, height, pixelRatio });
2153
+ let canvas = Creator.canvas({ width: Math.ceil(width), height: Math.ceil(height), pixelRatio });
2156
2154
  const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
2157
2155
  if (slice) {
2158
2156
  leaf = leafer;
@@ -2171,7 +2169,7 @@ const ExportModule = {
2171
2169
  if (needFill)
2172
2170
  canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
2173
2171
  const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
2174
- over({ data, renderBounds, trimBounds });
2172
+ over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
2175
2173
  }));
2176
2174
  }
2177
2175
  else {
@@ -2192,8 +2190,8 @@ function addTask(task) {
2192
2190
  Object.assign(TextConvert, TextConvertModule);
2193
2191
  Object.assign(ColorConvert, ColorConvertModule);
2194
2192
  Object.assign(Paint, PaintModule);
2195
- Object.assign(PaintImage$1, PaintImageModule);
2196
- Object.assign(PaintGradient$1, PaintGradientModule);
2193
+ Object.assign(PaintImage, PaintImageModule);
2194
+ Object.assign(PaintGradient, PaintGradientModule);
2197
2195
  Object.assign(Effect, EffectModule);
2198
2196
  Object.assign(Export, ExportModule);
2199
2197
 
@@ -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 _,LeafBoundsHelper as p,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,ImageEvent as k,PointHelper as E,Direction4 as S,TwoPointBoundsHelper as L,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{ColorConvert as T,Export as M,Group as C,TextConvert as I,Paint as D,PaintImage as F,PaintGradient as P,Effect as Y}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function U(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;class G extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,n(this.context.__proto__))}__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}}const{mineType:N,fileType:X}=o;function V(t,n){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:i}=n;e.origin={createCanvas:(e,n,i)=>new t(e,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),loadImage:i},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:i}=n;e.origin={createCanvas:(e,n,i)=>new t(e,n,i),canvasToDataURL:(t,e,n)=>t.toDataURL(N(e),n),canvasToBolb:(t,e,n)=>U(this,void 0,void 0,(function*(){return t.toBuffer(N(e),n)})),canvasSaveAs:(t,e,n)=>U(this,void 0,void 0,(function*(){return O(e,t.toBuffer(N(X(e)),n))})),loadImage:i}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=i.canvas()}}Object.assign(i,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class j{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:Z}=f;const{worldBounds:$}=p,J={x:0,y:0,width:1e5,height:1e5};class K{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix: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),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||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){const e=this.extraBlock||(this.extraBlock=new K([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}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 _,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){return this.rendering?st.warn("rendering"):this.times>3?st.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),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,void(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 _(i);n.save(),s&&!g.showRepaint?n.clear():(i.spread(1+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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:n}=t.old;new _(0,0,e,n).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||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=null,this.canvas=null,this.config=null)}}Object.assign(i,{watcher:(t,e)=>new j(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 at={},rt={};function dt(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 lt(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?ut(t,!0,e,n):ht(e,n);break;case"inside":ct("inside",t,s,e,n);break;case"outside":ct("outside",t,s,e,n)}}function ct(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?ut(e,!0,i,r):ht(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(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 ht(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 ut(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&at.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?ht(n,i):i.stroke(),i.restoreBlendMode()):e?ht(n,i):i.stroke())}const{getSpread:ft,getOuterOf:_t,getByMove:pt,getIntersectData:gt}=B;let wt;function yt(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:T.string(a,r)};case"image":return at.image(n,t,e,i,!wt||!wt[e.url]);case"linear":return rt.linearGradient(e,i);case"radial":return rt.radialGradient(e,i);case"angular":return rt.conicGradient(e,i);default:return e.r?{type:"solid",style:T.string(e)}:void 0}}const mt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),wt=at.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=yt(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?dt(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&&at.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?dt(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?dt(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?dt(e,n):s?n.fill(s):n.fill())},fillText:dt,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)lt(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)lt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),ut(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),ut(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),ut(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:lt,drawTextStroke:ht,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=gt(i?ft(e.bounds,i*l,i*c):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=_t(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 vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:kt,rotate:Et}=R;function St(t,e,n,i,s,o){const a=xt(),r=o&&180!==o,d=n.width/(r?s:i),l=n.height/(r?i:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-s*c)/2;Bt(a,h,u),kt(a,c),o&&bt(a,{x:n.x+n.width/2,y:n.y+n.height/2},o),t.scaleX=t.scaleY=c,t.transform=a}function Lt(t,e,n,i,s,o,a){const r=xt();Bt(r,e.x,e.y),(n||i)&&Bt(r,n,i),s&&(kt(r,s,o),t.scaleX=r.a,t.scaleY=r.d),a&&Et(r,a),t.transform=r}function At(t,e,n,i,s,o,a,r,d){const l=xt();if(d)switch(Et(l,d),d){case 90:Bt(l,i,0);break;case 180:Bt(l,n,i);break;case 270:Bt(l,0,n)}vt.x=e.x,vt.y=e.y,(s||o)&&(vt.x+=s,vt.y+=o),Bt(l,vt.x,vt.y),a&&(Rt(l,vt,a,r),t.scaleX=a,t.scaleY=r),t.transform=l}const{get:Wt,translate:Ot}=R;function Tt(t,e,n,i){let{width:s,height:o}=e;const{opacity:a,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,_=i.width===s&&i.height===o;u&&(t.blendMode=u);const p=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/o):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":_||(s=i.width,o=i.height),(i.x||i.y)&&(p.transform=Wt(),Ot(p.transform,i.x,i.y));break;case"clip":(d||y||h)&&Lt(p,i,g,w,y,m,h);break;case"repeat":(!_||y||h)&&At(p,i,s,o,g,w,y,m,h),f||(p.repeat="repeat");break;default:_&&!h||St(p,r,i,s,o,h)}p.width=s,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Mt,Ct=new _;const{isSame:It}=B;function Dt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,e.__autoWidth||e.__autoHeight)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,k.LOAD,e)}function Pt(t,e){Ut(t,k.LOADED,e)}function Yt(t,e,n){e.error=n,t.forceUpdate("surface"),Ut(t,k.ERROR,e)}function Ut(t,e,n){t.hasEvent(e)&&t.emitEvent(new k(e,n))}const{get:Gt,scale:Nt,copy:Xt}=R,{round:Vt,abs:jt}=Math;function qt(t,n,i){let{scaleX:s,scaleY:o}=t.__world;const a=s+"-"+o;if(n.patternId===a||t.destroyed)return!1;{s=jt(s),o=jt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Gt(),Xt(l,p),Nt(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),(p||1!==s||1!==o)&&(l||(l=Gt(),p&&Xt(l,p)),Nt(l,1/s,1/o));const m=t.getCanvas(c<1?1:Vt(c),h<1?1:Vt(h),_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}const{abs:zt}=Math;const Ht={image:function(t,e,n,i,s){let o,a;const r=v.get(n);return Mt&&n===Mt.paint&&It(i,Mt.boxBounds)?o=Mt.leafPaint:(o={type:n.type},o.image=r,Mt=r.use>1?{leafPaint:o,paint:n,boxBounds:Ct.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Dt(t,e,n,r,o,i),s&&(Ft(t,a),Pt(t,a))):r.error?s&&Yt(t,a,r.error):(s&&Ft(t,a),o.loadId=r.load((()=>{t.destroyed||(Dt(t,e,n,r,o,i)&&t.forceUpdate("surface"),Pt(t,a)),o.loadId=null}),(e=>{Yt(t,a,e),o.loadId=null}))),o},createData:Tt,fillOrFitMode:St,clipMode:Lt,repeatMode:At,createPattern:qt,checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=t.__world;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*=zt(o)*n.pixelRatio,i*=zt(a)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize}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||M.running?qt(t,i,n.pixelRatio):i.patternTask||(i.patternTask=v.patternTasker.add((()=>U(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__world)&&qt(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},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}},Qt={x:.5,y:0},Zt={x:.5,y:1};function $t(t,e,n){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],t.addColorStop(i.offset,T.string(i.color,n))}const{set:Jt,getAngle:Kt,getDistance:te}=E,{get:ee,rotateOfOuter:ne,scaleOfOuter:ie}=R,se={x:.5,y:.5},oe={x:.5,y:1},ae={},re={};const{set:de,getAngle:le,getDistance:ce}=E,{get:he,rotateOfOuter:ue,scaleOfOuter:fe}=R,_e={x:.5,y:.5},pe={x:.5,y:1},ge={},we={};const ye={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;i||(i=Qt),s||(s=Zt);const d=e.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);$t(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;i||(i=se),s||(s=oe);const{x:l,y:c,width:h,height:u}=n;let f;Jt(ae,l+i.x*h,c+i.y*u),Jt(re,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=ee(),ie(f,ae,h/u*(d||1),1),ne(f,ae,Kt(ae,re)+90));const _=e.canvas.createRadialGradient(ae.x,ae.y,0,ae.x,ae.y,te(ae,re));$t(_,t.stops,a);const p={type:o,style:_,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;i||(i=_e),s||(s=pe);const{x:l,y:c,width:h,height:u}=n;de(ge,l+i.x*h,c+i.y*u),de(we,l+s.x*h,c+s.y*u);const f=he(),_=le(ge,we);e.conicGradientRotate90?(fe(f,ge,h/u*(d||1),1),ue(f,ge,_+90)):(fe(f,ge,1,h/u*(d||1)),ue(f,ge,_));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,ge.x,ge.y):e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,ce(ge,we));$t(p,t.stops,a);const g={type:o,style:p,transform:f};return r&&(g.blendMode=r),g}},{copy:me,toOffsetOutBounds:ve}=B,xe={},be={};function Be(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(me(xe,t.bounds),xe.x+=n.x-a.x,xe.y+=n.y-a.y,i){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),xe.width*=i,xe.height*=i}t.copyWorld(s.canvas,t.bounds,xe)}else i&&(me(xe,n),xe.x-=n.width/2*(i-1),xe.y-=n.height/2*(i-1),xe.width*=i,xe.height*=i),t.copyWorld(s.canvas,a,i?xe:n)}const{toOffsetOutBounds:Re}=B,ke={};const Ee={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(),_=r.length-1;ve(l,be),r.forEach(((r,p)=>{f.setWorldShadow(be.offsetX+r.x*h,be.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,be,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<_&&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(),_=r.length-1;Re(l,ke),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,ke,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<_&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__world.a),n.copyWorldToInner(e,t.__world,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Se}=p;function Le(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),We(t,e,n,1)}(t,n,i,s);break;case"opacity-path":We(t,n,i,o);break;case"path":n.restore()}}function Ae(t){return t.getSameCanvas(!1,!0)}function We(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}C.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&&(Le(this,a,t,s,i,o),i=s=null),"path"===n.__.maskType?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ae(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Ae(t)),s||(s=Ae(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Se(n,e)||n.__render(s||t,e);Le(this,a,t,s,i,o)};const Oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Te=Oe+"_#~&*+\\=|≮≯≈≠=…",Me=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 Ie=Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Ce("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Fe=Ce(Oe),Pe=Ce(Te),Ye=Ce("- —/~|┆·");var Ue;!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"}(Ue||(Ue={}));const{Letter:Ge,Single:Ne,Before:Xe,After:Ve,Symbol:je,Break:qe}=Ue;function ze(t){return Ie[t]?Ge:Ye[t]?qe:De[t]?Xe:Fe[t]?Ve:Pe[t]?je:Me.test(t)?Ne:Ge}const He={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}=He,{Letter:$e,Single:Je,Before:Ke,After:tn,Symbol:en,Break:nn}=Ue;let sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn,mn,vn=[];function xn(t,e){un&&!hn&&(hn=un),sn.data.push({char:t,width:e}),an+=e}function bn(){rn+=an,sn.width=an,on.words.push(sn),sn={data:[]},an=0}function Bn(){wn&&(yn.paraNumber++,on.paraStart=!0,wn=!1),un&&(on.startCharSize=hn,on.endCharSize=un,hn=0),on.width=rn,mn.width&&Ze(on),vn.push(on),on={words:[]},rn=0}const Rn=0,kn=1,En=2;const{top:Sn,right:Ln,bottom:An,left:Wn}=S;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 Tn={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[Wn],o-=l[Ln]+l[Wn]),a&&(s=l[Sn],a-=l[Sn]+l[An]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){yn=t,vn=t.rows,mn=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=mn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;wn=!0,_n=null,hn=cn=un=an=rn=0,sn={data:[]},on={words:[]};for(let i=0,l=n.length;i<l;i++)ln=n[i],"\n"===ln?(an&&bn(),on.paraEnd=!0,Bn(),wn=!0):(fn=ze(ln),fn===$e&&"none"!==a&&(ln=Qe(ln,a,!an)),cn=r.measureText(ln).width,s&&(s<0&&(un=cn),cn+=s),pn=fn===Je&&(_n===Je||_n===$e)||_n===Je&&fn!==tn,gn=!(fn!==Ke&&fn!==Je||_n!==en&&_n!==tn),dn=wn&&o?d-o:d,t&&d&&rn+an+cn>dn&&(e?(an&&bn(),Bn()):(gn||(gn=fn===$e&&_n==tn),pn||gn||fn===nn||fn===Ke||fn===Je||an+cn>dn?(an&&bn(),Bn()):Bn()))," "===ln&&!0!==wn&&rn+an===0||(fn===nn?(" "===ln&&an&&bn(),xn(ln,cn),bn()):pn||gn?(an&&bn(),xn(ln,cn)):xn(ln,cn)),_n=fn);an&&bn(),rn&&Bn(),vn.length>0&&(vn[vn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{yn.paraNumber++,vn.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[Wn]);break;case"right":On(e,"x",-t[Ln])}if(!s)switch(n.verticalAlign){case"top":On(e,"y",t[Sn]);break;case"bottom":On(e,"y",-t[An])}}(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:_,y:p,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":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,l=n.length;o<l;o++){switch(h=n[o],h.x=_,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=p,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?Rn: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)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n){const{rows:i,overflow:s}=t;let{textOverflow:o}=n;if(i.splice(s),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).width,d=n.x+n.width-r;("none"===n.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],a=t.x+t.width,!(i===n&&a<d));i--){if(a<d&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n),"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){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:Cn,addPoint:In,toBounds:Dn}=L;const Fn={export(t,e,n){return this.running=!0,function(t){Pn||(Pn=new A);return new Promise((e=>{Pn.add((()=>U(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((a=>{const r=t=>{s(t),a(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>U(this,void 0,void 0,(function*(){let s,a,l=1,c=1;n=o.getExportOptions(n);const{scale:h,pixelRatio:u,slice:f,trim:p}=n,g=n.screenshot||t.isApp,w=void 0===n.fill?t.isLeafer&&g?t.fill:"":n.fill,y=o.isOpaqueImage(e)||w,m=new W;if(g)s=!0===g?t.isLeafer?d.canvas.bounds:t.worldRenderBounds:g;else{const{localTransform:e,__world:n}=t;m.set(n).divide(e).invert(),l=1/(n.scaleX/t.scaleX),c=1/(n.scaleY/t.scaleY),s=t.getBounds("render","local")}let{x:v,y:x,width:b,height:B}=s;h&&(m.scale(h),b*=h,B*=h,l*=h,c*=h);let R=i.canvas({width:b,height:B,pixelRatio:u});const k={matrix:m.translate(-v,-x).withScale(l,c)};if(f&&(t=d,k.bounds=R.bounds),R.save(),t.__render(R,k),R.restore(),p){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?In(a,s,o):Cn(a={},s,o)),r++;const d=new _;return Dn(a,d),d.scale(1/t.pixelRatio).ceil()}(R);const t=R,{width:e,height:n}=a,s={x:0,y:0,width:e,height:n,pixelRatio:u};R=i.canvas(s),R.copyWorld(t,a,s)}y&&R.fillWorld(R.bounds,w||"#FFFFFF","destination-over");const E="canvas"===e?R:yield R.export(e,n);r({data:E,renderBounds:s,trimBounds:a})})))):r({data:!1})}))))}};let Pn;Object.assign(I,Tn),Object.assign(T,Mn),Object.assign(D,mt),Object.assign(F,Ht),Object.assign(P,ye),Object.assign(Y,Ee),Object.assign(M,Fn);export{it as Layouter,G as LeaferCanvas,ot as Renderer,j as Watcher,V as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,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 _,LeafBoundsHelper as p,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,ImageEvent as k,PointHelper as E,Direction4 as S,TwoPointBoundsHelper as L,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{PaintImage as T,ColorConvert as M,PaintGradient as C,Export as I,Group as D,TextConvert as F,Paint as P,Effect as Y}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function U(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class N extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:X,fileType:G}=o;function V(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),loadImage:n},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(X(e),i),canvasToBolb:(t,e,i)=>U(this,void 0,void 0,(function*(){return t.toBuffer(X(e),i)})),canvasSaveAs:(t,e,i)=>U(this,void 0,void 0,(function*(){return O(e,t.toBuffer(X(G(e)),i))})),loadImage:n}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new N(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class j{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,i=e.length;t<i;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:Z}=f;const{worldBounds:$}=p,J={x:0,y:0,width:1e5,height:1e5};class K{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:tt,updateAllChange:et}=u,it=g.get("Layouter");class nt{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){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(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:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&Q(t,e),Z(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||z(n[t])}z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&H(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(o,r,this.times)),i.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:i,LAYOUT:n,AFTER:s}=y,o=this.getBlocks(new a(e));e.emitEvent(new y(i,o,this.times)),nt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,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){const e=this.extraBlock||(this.extraBlock=new K([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}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,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,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){return this.rendering?st.warn("rendering"):this.times>3?st.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),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,void(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:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new _(n);i.save(),s&&!g.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(n),g.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||st.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}function at(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function rt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ct(t,!0,e,i):lt(e,i);break;case"inside":dt("inside",t,s,e,i);break;case"outside":dt("outside",t,s,e,i)}}function dt(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ct(e,!0,n,r):lt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",at(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ct(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&T.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?lt(i,n):n.stroke(),n.restoreBlendMode()):e?lt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=nt.fullLayout;const{getSpread:ht,getOuterOf:ut,getByMove:ft,getIntersectData:_t}=B;let pt;function gt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:M.string(a,r)};case"image":return T.image(i,t,e,n,!pt||!pt[e.url]);case"linear":return C.linearGradient(e,n);case"radial":return C.radialGradient(e,n);case"angular":return C.conicGradient(e,n);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}const wt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),pt=T.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=gt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?at(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&T.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?at(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?at(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?at(e,i):s?i.fill(s):i.fill())},fillText:at,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)rt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)rt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ct(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ct(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ct(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:rt,drawTextStroke:lt,shape:function(t,e,i){const n=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=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?ht(e.bounds,n*l,n*c):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=ut(s,a),o=ft(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,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,i,n,s,o){const a=mt(),r=o&&180!==o,d=i.width/(r?s:n),l=i.height/(r?n:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=i.x+(i.width-n*c)/2,u=i.y+(i.height-s*c)/2;xt(a,h,u),Bt(a,c),o&&vt(a,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=c,t.transform=a}function Et(t,e,i,n,s,o,a){const r=mt();xt(r,e.x,e.y),(i||n)&&xt(r,i,n),s&&(Bt(r,s,o),t.scaleX=r.a,t.scaleY=r.d),a&&Rt(r,a),t.transform=r}function St(t,e,i,n,s,o,a,r,d){const l=mt();if(d)switch(Rt(l,d),d){case 90:xt(l,n,0);break;case 180:xt(l,i,n);break;case 270:xt(l,0,i)}yt.x=e.x,yt.y=e.y,(s||o)&&(yt.x+=s,yt.y+=o),xt(l,yt.x,yt.y),a&&(bt(l,yt,a,r),t.scaleX=a,t.scaleY=r),t.transform=l}const{get:Lt,translate:At}=R;function Wt(t,e,i,n){let{width:s,height:o}=e;const{opacity:a,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=i,_=n.width===s&&n.height===o;u&&(t.blendMode=u);const p=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/o):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":_||(s=n.width,o=n.height),(n.x||n.y)&&(p.transform=Lt(),At(p.transform,n.x,n.y));break;case"clip":(d||y||h)&&Et(p,n,g,w,y,m,h);break;case"repeat":(!_||y||h)&&St(p,n,s,o,g,w,y,m,h),f||(p.repeat="repeat");break;default:_&&!h||kt(p,r,n,s,o,h)}p.width=s,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Ot,Tt=new _;const{isSame:Mt}=B;function Ct(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width,e.__naturalHeight=n.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Wt(s,n,i,o),!0}function It(t,e){Pt(t,k.LOAD,e)}function Dt(t,e){Pt(t,k.LOADED,e)}function Ft(t,e,i){e.error=i,t.forceUpdate("surface"),Pt(t,k.ERROR,e)}function Pt(t,e,i){t.hasEvent(e)&&t.emitEvent(new k(e,i))}const{get:Yt,scale:Ut,copy:Nt}=R,{round:Xt,abs:Gt}=Math;function Vt(t,i,n){let{scaleX:s,scaleY:o}=t.__world;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=Gt(s),o=Gt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Yt(),Nt(l,p),Ut(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,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),(p||1!==s||1!==o)&&(l||(l=Yt(),p&&Nt(l,p)),Ut(l,1/s,1/o));const m=t.getCanvas(c<1?1:Xt(c),h<1?1:Xt(h),_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}const{abs:jt}=Math;const qt={image:function(t,e,i,n,s){let o,a;const r=v.get(i);return Ot&&i===Ot.paint&&Mt(n,Ot.boxBounds)?o=Ot.leafPaint:(o={type:i.type},o.image=r,Ot=r.use>1?{leafPaint:o,paint:i,boxBounds:Tt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ct(t,e,i,r,o,n),s&&(It(t,a),Dt(t,a))):r.error?s&&Ft(t,a,r.error):(s&&It(t,a),o.loadId=r.load((()=>{t.destroyed||(Ct(t,e,i,r,o,n)&&t.forceUpdate("surface"),Dt(t,a)),o.loadId=null}),(e=>{Ft(t,a,e),o.loadId=null}))),o},createData:Wt,fillOrFitMode:kt,clipMode:Et,repeatMode:St,createPattern:Vt,checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=t.__world;if(n.data&&n.patternId!==o+"-"+a){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=jt(o)*i.pixelRatio,n*=jt(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||I.running?Vt(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>U(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__world)&&Vt(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,v.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null}},zt={x:.5,y:0},Ht={x:.5,y:1};function Qt(t,e,i){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],t.addColorStop(n.offset,M.string(n.color,i))}const{set:Zt,getAngle:$t,getDistance:Jt}=E,{get:Kt,rotateOfOuter:te,scaleOfOuter:ee}=R,ie={x:.5,y:.5},ne={x:.5,y:1},se={},oe={};const{set:ae,getAngle:re,getDistance:de}=E,{get:le,rotateOfOuter:ce,scaleOfOuter:he}=R,ue={x:.5,y:.5},fe={x:.5,y:1},_e={},pe={};const ge={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;n||(n=zt),s||(s=Ht);const d=e.canvas.createLinearGradient(i.x+n.x*i.width,i.y+n.y*i.height,i.x+s.x*i.width,i.y+s.y*i.height);Qt(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;n||(n=ie),s||(s=ne);const{x:l,y:c,width:h,height:u}=i;let f;Zt(se,l+n.x*h,c+n.y*u),Zt(oe,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=Kt(),ee(f,se,h/u*(d||1),1),te(f,se,$t(se,oe)+90));const _=e.canvas.createRadialGradient(se.x,se.y,0,se.x,se.y,Jt(se,oe));Qt(_,t.stops,a);const p={type:o,style:_,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;n||(n=ue),s||(s=fe);const{x:l,y:c,width:h,height:u}=i;ae(_e,l+n.x*h,c+n.y*u),ae(pe,l+s.x*h,c+s.y*u);const f=le(),_=re(_e,pe);e.conicGradientRotate90?(he(f,_e,h/u*(d||1),1),ce(f,_e,_+90)):(he(f,_e,1,h/u*(d||1)),ce(f,_e,_));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,de(_e,pe));Qt(p,t.stops,a);const g={type:o,style:p,transform:f};return r&&(g.blendMode=r),g}},{copy:we,toOffsetOutBounds:ye}=B,me={},ve={};function xe(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(we(me,t.bounds),me.x+=i.x-a.x,me.y+=i.y-a.y,n){const{matrix:t}=s;me.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),me.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),me.width*=n,me.height*=n}t.copyWorld(s.canvas,t.bounds,me)}else n&&(we(me,i),me.x-=i.width/2*(n-1),me.y-=i.height/2*(n-1),me.width*=n,me.height*=n),t.copyWorld(s.canvas,a,n?me:i)}const{toOffsetOutBounds:be}=B,Be={};const Re={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;ye(l,ve),r.forEach(((r,p)=>{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,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;be(l,Be),r.forEach(((r,p)=>{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,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ke}=p;function Ee(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Le(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Le(t,i,n,o);break;case"path":i.restore()}}function Se(t){return t.getSameCanvas(!1,!0)}function Le(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}D.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Ee(this,a,t,s,n,o),n=s=null),"path"===i.__.maskType?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Se(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Se(t)),s||(s=Se(t)),i.__render(n,e)),"clipping"!==i.__.maskType)||ke(i,e)||i.__render(s||t,e);Ee(this,a,t,s,n,o)};const Ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Ae+"_#~&*+\\=|≮≯≈≠=…",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 Te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Te(Ae),De=Te(We),Fe=Te("- —/~|┆·");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:Ye,Single:Ue,Before:Ne,After:Xe,Symbol:Ge,Break:Ve}=Pe;function je(t){return Me[t]?Ye:Fe[t]?Ve:Ce[t]?Ne:Ie[t]?Xe:De[t]?Ge:Oe.test(t)?Ue:Ye}const qe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ze(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:He}=qe,{Letter:Qe,Single:Ze,Before:$e,After:Je,Symbol:Ke,Break:ti}=Pe;let ei,ii,ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,_i,pi,gi,wi=[];function yi(t,e){li&&!di&&(di=li),ei.data.push({char:t,width:e}),ni+=e}function mi(){si+=ni,ei.width=ni,ii.words.push(ei),ei={data:[]},ni=0}function vi(){_i&&(pi.paraNumber++,ii.paraStart=!0,_i=!1),li&&(ii.startCharSize=di,ii.endCharSize=li,di=0),ii.width=si,gi.width&&He(ii),wi.push(ii),ii={words:[]},si=0}const xi=0,bi=1,Bi=2;const{top:Ri,right:ki,bottom:Ei,left:Si}=S;function Li(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ai={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Si],o-=l[ki]+l[Si]),a&&(s=l[Ri],a-=l[Ri]+l[Ei]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){pi=t,wi=t.rows,gi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=gi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;_i=!0,hi=null,di=ri=li=ni=si=0,ei={data:[]},ii={words:[]};for(let n=0,l=i.length;n<l;n++)ai=i[n],"\n"===ai?(ni&&mi(),ii.paraEnd=!0,vi(),_i=!0):(ci=je(ai),ci===Qe&&"none"!==a&&(ai=ze(ai,a,!ni)),ri=r.measureText(ai).width,s&&(s<0&&(li=ri),ri+=s),ui=ci===Ze&&(hi===Ze||hi===Qe)||hi===Ze&&ci!==Je,fi=!(ci!==$e&&ci!==Ze||hi!==Ke&&hi!==Je),oi=_i&&o?d-o:d,t&&d&&si+ni+ri>oi&&(e?(ni&&mi(),vi()):(fi||(fi=ci===Qe&&hi==Je),ui||fi||ci===ti||ci===$e||ci===Ze||ni+ri>oi?(ni&&mi(),vi()):vi()))," "===ai&&!0!==_i&&si+ni===0||(ci===ti?(" "===ai&&ni&&mi(),yi(ai,ri),mi()):ui||fi?(ni&&mi(),yi(ai,ri)):yi(ai,ri)),hi=ci);ni&&mi(),si&&vi(),wi.length>0&&(wi[wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{pi.paraNumber++,wi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Li(e,"x",t[Si]);break;case"right":Li(e,"x",-t[ki])}if(!s)switch(i.verticalAlign){case"top":Li(e,"y",t[Ri]);break;case"bottom":Li(e,"y",-t[Ei])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:_,y:p,width:g,height:w}=n,y=s*i.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,l=i.length;o<l;o++){switch(h=i[o],h.x=_,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<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=y}(c,i),function(t,e,i,n){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=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?xi:l>.01?bi:Bi,t.isOverflow&&!r&&(t.textMode=!0),h===Bi?(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===bi?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:o}=i;if(n.splice(s),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).width,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],a=t.x+t.width,!(n===i&&a<d));n--){if(a<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Wi={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Oi,addPoint:Ti,toBounds:Mi}=L;const Ci={export(t,e,i){return this.running=!0,function(t){Ii||(Ii=new A);return new Promise((e=>{Ii.add((()=>U(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((a=>{const r=t=>{s(t),a(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>U(this,void 0,void 0,(function*(){let s,a,l=1,c=1;i=o.getExportOptions(i);const{scale:h,slice:u,trim:f}=i,p=i.pixelRatio||1,g=i.screenshot||t.isApp,w=void 0===i.fill?t.isLeafer&&g?t.fill:"":i.fill,y=o.isOpaqueImage(e)||w,m=new W;if(g)s=!0===g?t.isLeafer?d.canvas.bounds:t.worldRenderBounds:g;else{const{localTransform:e,__world:i}=t;m.set(i).divide(e).invert(),l=1/(i.scaleX/t.scaleX),c=1/(i.scaleY/t.scaleY),s=t.getBounds("render","local")}let{x:v,y:x,width:b,height:B}=s;h&&(m.scale(h),b*=h,B*=h,l*=h,c*=h);let R=n.canvas({width:Math.ceil(b),height:Math.ceil(B),pixelRatio:p});const k={matrix:m.translate(-v,-x).withScale(l,c)};if(u&&(t=d,k.bounds=R.bounds),R.save(),t.__render(R,k),R.restore(),f){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Ti(a,s,o):Oi(a={},s,o)),r++;const d=new _;return Mi(a,d),d.scale(1/t.pixelRatio).ceil()}(R);const t=R,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:p};R=n.canvas(s),R.copyWorld(t,a,s)}y&&R.fillWorld(R.bounds,w||"#FFFFFF","destination-over");const E="canvas"===e?R:yield R.export(e,i);r({data:E,width:R.pixelWidth,height:R.pixelHeight,renderBounds:s,trimBounds:a})})))):r({data:!1})}))))}};let Ii;Object.assign(F,Ai),Object.assign(M,Wi),Object.assign(P,wt),Object.assign(T,qt),Object.assign(C,ge),Object.assign(Y,Re),Object.assign(I,Ci);export{nt as Layouter,N as LeaferCanvas,ot as Renderer,j as Watcher,V as useCanvas};
package/dist/node.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/draw");function s(t,e,n,s){return new(n||(n=Promise))((function(i,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class i extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.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}}const{mineType:a,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.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 t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:d,updateBounds:l,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,f),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:g,updateAllChange:y}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(i);f.forEach((t=>t.setBefore())),s.emitEvent(new t.LayoutEvent(a,f,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?(d(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(i,this.__levelList),function(t){let e,n,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){s=n.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||l(s[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),s.emitEvent(new t.LayoutEvent(o,f,this.times)),s.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:s,LAYOUT:i,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(s,o,this.times)),m.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(i,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new _([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new _(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,s&&(this.config=t.DataHelper.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?v.warn("rendering"):this.times>3?v.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:s}=this,i=e.getIntersect(s.bounds),a=e.includes(this.target.__world),o=new t.Bounds(i);s.save(),a&&!t.Debug.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,a,o),s.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,s){const i=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,i),this.renderBounds=s||e,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(i),t.Debug.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:n,height:s}=e.old;new t.Bounds(0,0,n,s).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,s){this.target.emitEvent(new t.RenderEvent(e,this.times,n,s))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,s)=>{}}),t.Platform.layout=m.fullLayout;const B={},b={};function E(t,e){let n;const{rows:s,decorationY:i,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)n=s[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)})),i&&e.fillRect(n.x,n.y+i,n.width,a)}function R(t,e,n){const{strokeAlign:s}=e.__,i="string"!=typeof t;switch(s){case"center":n.setStroke(i?void 0:t,e.__.strokeWidth,e.__),i?S(t,!0,e,n):k(e,n);break;case"inside":L("inside",t,i,e,n);break;case"outside":L("outside",t,i,e,n)}}function L(t,e,n,s,i){const{__strokeWidth:a,__font:o}=s.__,r=i.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,s.__),r.font=o,n?S(e,!0,s,r):k(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",E(s,r),r.blendMode="normal",s.__worldFlipped?i.copyWorldByReset(r,s.__nowWorld):i.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function k(t,e){let n;const{rows:s,decorationY:i,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)n=s[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)})),i&&e.strokeRect(n.x,n.y+i,n.width,a)}function S(t,e,n,s){let i;for(let a=0,o=t.length;a<o;a++)i=t[a],i.image&&B.checkImage(n,s,i,!1)||i.style&&(s.strokeStyle=i.style,i.blendMode?(s.saveBlendMode(i.blendMode),e?k(n,s):s.stroke(),s.restoreBlendMode()):e?k(n,s):s.stroke())}const{getSpread:P,getOuterOf:O,getByMove:A,getIntersectData:C}=t.BoundsHelper;let W;function M(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=s.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:d}=e;return{type:a,blendMode:o,style:n.ColorConvert.string(r,d)};case"image":return B.image(s,t,e,i,!W||!W[e.url]);case"linear":return b.linearGradient(e,i);case"radial":return b.radialGradient(e,i);case"angular":return b.conicGradient(e,i);default:return e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const T={compute:function(t,e){const n=e.__,s=[];let i,a=n.__input[t];a instanceof Array||(a=[a]),W=B.recycleImage(t,n);for(let n,i=0,o=a.length;i<o;i++)n=M(t,a[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(i=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=i:n.__pixelStroke=i},fill:function(t,e,n){n.fillStyle=t,e.__.__font?E(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:i,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&B.checkImage(e,n,s,!a)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),a?E(e,n):i?n.fill(i):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),a?E(e,n):i?n.fill(i):n.fill(),n.restoreBlendMode()):a?E(e,n):i?n.fill(i):n.fill())},fillText:E,stroke:function(t,e,n){const s=e.__,{__strokeWidth:i,strokeAlign:a,__font:o}=s;if(i)if(o)R(t,e,n);else switch(a){case"center":n.setStroke(t,i,s),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*i,s),s.windingRule?n.clip(s.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*i,s),e.__drawRenderPath(a),a.stroke(),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const s=e.__,{__strokeWidth:i,strokeAlign:a,__font:o}=s;if(i)if(o)R(t,e,n);else switch(a){case"center":n.setStroke(void 0,i,s),S(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*i,s),s.windingRule?n.clip(s.windingRule):n.clip(),S(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*i,s),S(t,!1,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:R,drawTextStroke:k,shape:function(t,e,n){const s=e.getSameCanvas(),i=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:c}=i;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(i))d=s,a=r=i;else{const{renderShapeSpread:s}=t.__layout,h=C(s?P(e.bounds,s*l,s*c):e.bounds,i);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=O(i,o),a=A(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(s,n),{canvas:s,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let I={};const{get:D,rotateOfOuter:F,translate:H,scaleOfOuter:Y,scale:j,rotate:G}=t.MatrixHelper;function U(t,e,n,s,i,a){const o=D(),r=a&&180!==a,d=n.width/(r?i:s),l=n.height/(r?s:i),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-s*c)/2,u=n.y+(n.height-i*c)/2;H(o,h,u),j(o,c),a&&F(o,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=c,t.transform=o}function N(t,e,n,s,i,a,o){const r=D();H(r,e.x,e.y),(n||s)&&H(r,n,s),i&&(j(r,i,a),t.scaleX=r.a,t.scaleY=r.d),o&&G(r,o),t.transform=r}function X(t,e,n,s,i,a,o,r,d){const l=D();if(d)switch(G(l,d),d){case 90:H(l,s,0);break;case 180:H(l,n,s);break;case 270:H(l,0,n)}I.x=e.x,I.y=e.y,(i||a)&&(I.x+=i,I.y+=a),H(l,I.x,I.y),o&&(Y(l,I,o,r),t.scaleX=o,t.scaleY=r),t.transform=l}const{get:q,translate:V}=t.MatrixHelper;function z(t,e,n,s){let{width:i,height:a}=e;const{opacity:o,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,p=s.width===i&&s.height===a;u&&(t.blendMode=u);const _=t.data={mode:r};let g,y,w,m;switch(d&&(g=d.x,y=d.y),c?(w=("number"==typeof c?c:c.width)/i,m=("number"==typeof c?c:c.height)/a):l&&(w="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":p||(i=s.width,a=s.height),(s.x||s.y)&&(_.transform=q(),V(_.transform,s.x,s.y));break;case"clip":(d||w||h)&&N(_,s,g,y,w,m,h);break;case"repeat":(!p||w||h)&&X(_,s,i,a,g,y,w,m,h),f||(_.repeat="repeat");break;default:p&&!h||U(_,r,s,i,a,h)}_.width=i,_.height=a,o&&(_.opacity=o),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Q,Z=new t.Bounds;const{isSame:$}=t.BoundsHelper;function J(t,e,n,s,i,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||z(i,s,n,a),!0}function K(e,n){nt(e,t.ImageEvent.LOAD,n)}function tt(e,n){nt(e,t.ImageEvent.LOADED,n)}function et(e,n,s){n.error=s,e.forceUpdate("surface"),nt(e,t.ImageEvent.ERROR,n)}function nt(e,n,s){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,s))}const{get:st,scale:it,copy:at}=t.MatrixHelper,{round:ot,abs:rt}=Math;function dt(e,n,s){let{scaleX:i,scaleY:a}=e.__world;const o=i+"-"+a;if(n.patternId===o||e.destroyed)return!1;{i=rt(i),a=rt(a);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=st(),at(l,_),it(l,1/u,1/f),i*=u,a*=f),i*=s,a*=s,c*=i,h*=a;const y=c*h;if(!g&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(i/=d,a/=d,c/=d,h/=d),u&&(i/=u,a/=f),(_||1!==i||1!==a)&&(l||(l=st(),_&&at(l,_)),it(l,1/i,1/a));const m=e.getCanvas(c<1?1:ot(c),h<1?1:ot(h),p),v=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}const{abs:lt}=Math;const ct={image:function(e,n,s,i,a){let o,r;const d=t.ImageManager.get(s);return Q&&s===Q.paint&&$(i,Q.boxBounds)?o=Q.leafPaint:(o={type:s.type},o.image=d,Q=d.use>1?{leafPaint:o,paint:s,boxBounds:Z.set(i)}:null),(a||d.loading)&&(r={image:d,attrName:n,attrValue:s}),d.ready?(J(e,n,s,d,o,i),a&&(K(e,r),tt(e,r))):d.error?a&&et(e,r,d.error):(a&&K(e,r),o.loadId=d.load((()=>{e.destroyed||(J(e,n,s,d,o,i)&&e.forceUpdate("surface"),tt(e,r)),o.loadId=null}),(t=>{et(e,r,t),o.loadId=null}))),o},createData:z,fillOrFitMode:U,clipMode:N,repeatMode:X,createPattern:dt,checkImage:function(e,i,a,o){const{scaleX:r,scaleY:d}=e.__world;if(a.data&&a.patternId!==r+"-"+d){const{data:l}=a;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=lt(r)*i.pixelRatio,n*=lt(d)*i.pixelRatio,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(i.save(),i.clip(),a.blendMode&&(i.blendMode=a.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(a.image.view,0,0,l.width,l.height),i.restore(),!0):(!a.style||n.Export.running?dt(e,a,i.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(e.__world)&&dt(e,a,i.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const s=n["_"+e];if(s instanceof Array){let i,a,o,r;for(let d=0,l=s.length;d<l;d++)i=s[d].image,r=i&&i.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(i),i.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),i.unload(s[d].loadId,!o.some((t=>t.url===r)))));return a}return null}},ht={x:.5,y:0},ut={x:.5,y:1};function ft(t,e,s){let i;for(let a=0,o=e.length;a<o;a++)i=e[a],t.addColorStop(i.offset,n.ColorConvert.string(i.color,s))}const{set:pt,getAngle:_t,getDistance:gt}=t.PointHelper,{get:yt,rotateOfOuter:wt,scaleOfOuter:mt}=t.MatrixHelper,vt={x:.5,y:.5},xt={x:.5,y:1},Bt={},bt={};const{set:Et,getAngle:Rt,getDistance:Lt}=t.PointHelper,{get:kt,rotateOfOuter:St,scaleOfOuter:Pt}=t.MatrixHelper,Ot={x:.5,y:.5},At={x:.5,y:1},Ct={},Wt={};const Mt={linearGradient:function(e,n){let{from:s,to:i,type:a,blendMode:o,opacity:r}=e;s||(s=ht),i||(i=ut);const d=t.Platform.canvas.createLinearGradient(n.x+s.x*n.width,n.y+s.y*n.height,n.x+i.x*n.width,n.y+i.y*n.height);ft(d,e.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:s,to:i,type:a,opacity:o,blendMode:r,stretch:d}=e;s||(s=vt),i||(i=xt);const{x:l,y:c,width:h,height:u}=n;let f;pt(Bt,l+s.x*h,c+s.y*u),pt(bt,l+i.x*h,c+i.y*u),(h!==u||d)&&(f=yt(),mt(f,Bt,h/u*(d||1),1),wt(f,Bt,_t(Bt,bt)+90));const p=t.Platform.canvas.createRadialGradient(Bt.x,Bt.y,0,Bt.x,Bt.y,gt(Bt,bt));ft(p,e.stops,o);const _={type:a,style:p,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(e,n){let{from:s,to:i,type:a,opacity:o,blendMode:r,stretch:d}=e;s||(s=Ot),i||(i=At);const{x:l,y:c,width:h,height:u}=n;Et(Ct,l+s.x*h,c+s.y*u),Et(Wt,l+i.x*h,c+i.y*u);const f=kt(),p=Rt(Ct,Wt);t.Platform.conicGradientRotate90?(Pt(f,Ct,h/u*(d||1),1),St(f,Ct,p+90)):(Pt(f,Ct,1,h/u*(d||1)),St(f,Ct,p));const _=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ct.x,Ct.y):t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Lt(Ct,Wt));ft(_,e.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g}},{copy:Tt,toOffsetOutBounds:It}=t.BoundsHelper,Dt={},Ft={};function Ht(e,n,s,i){const{bounds:a,shapeBounds:o}=i;if(t.Platform.fullImageShadow){if(Tt(Dt,e.bounds),Dt.x+=n.x-o.x,Dt.y+=n.y-o.y,s){const{matrix:t}=i;Dt.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Dt.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Dt.width*=s,Dt.height*=s}e.copyWorld(i.canvas,e.bounds,Dt)}else s&&(Tt(Dt,n),Dt.x-=n.width/2*(s-1),Dt.y-=n.height/2*(s-1),Dt.width*=s,Dt.height*=s),e.copyWorld(i.canvas,o,s?Dt:n)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,jt={};const Gt={shadow:function(t,e,n){let s,i;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;It(l,Ft),r.forEach(((r,_)=>{f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h,r.color),i=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ht(f,Ft,i,n),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,n){let s,i;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Yt(l,jt),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(jt.offsetX+r.x*h,jt.offsetY+r.y*u,r.blur*h),i=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ht(f,jt,i,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(n.canvas,c,l,"source-out"),s=l),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,n){const{blur:s}=t.__;n.setWorldBlur(s*t.__world.a),n.copyWorldToInner(e,t.__world,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ut}=t.LeafBoundsHelper;function Nt(t,e,n,s,i,a){switch(e){case"alpha":!function(t,e,n,s){const i=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(s,i),s.recycle(i),qt(t,e,n,1)}(t,n,s,i);break;case"opacity-path":qt(t,n,s,a);break;case"path":n.restore()}}function Xt(t){return t.getSameCanvas(!1,!0)}function qt(t,e,n,s){const i=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(n,i),n.recycle(i)}n.Group.prototype.__renderMask=function(t,e){let n,s,i,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Nt(this,o,t,i,s,a),s=i=null),"path"===n.__.maskType?(n.opacity<1?(o="opacity-path",a=n.opacity,i||(i=Xt(t))):(o="path",t.save()),n.__clip(i||t,e)):(o="alpha",s||(s=Xt(t)),i||(i=Xt(t)),n.__render(s,e)),"clipping"!==n.__.maskType)||Ut(n,e)||n.__render(i||t,e);Nt(this,o,t,i,s,a)};const Vt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",zt=Vt+"_#~&*+\\=|≮≯≈≠=…",Qt=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 Zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Zt(Vt),te=Zt(zt),ee=Zt("- —/~|┆·");var ne;!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"}(ne||(ne={}));const{Letter:se,Single:ie,Before:ae,After:oe,Symbol:re,Break:de}=ne;function le(t){return $t[t]?se:ee[t]?de:Jt[t]?ae:Kt[t]?oe:te[t]?re:Qt.test(t)?ie:se}const ce={trimRight(t){const{words:e}=t;let n,s=0,i=e.length;for(let a=i-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)s++,t.width-=n.width;s&&e.splice(i-s,s)}};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:ue}=ce,{Letter:fe,Single:pe,Before:_e,After:ge,Symbol:ye,Break:we}=ne;let me,ve,xe,Be,be,Ee,Re,Le,ke,Se,Pe,Oe,Ae,Ce,We,Me,Te=[];function Ie(t,e){ke&&!Le&&(Le=ke),me.data.push({char:t,width:e}),xe+=e}function De(){Be+=xe,me.width=xe,ve.words.push(me),me={data:[]},xe=0}function Fe(){Ce&&(We.paraNumber++,ve.paraStart=!0,Ce=!1),ke&&(ve.startCharSize=Le,ve.endCharSize=ke,Le=0),ve.width=Be,Me.width&&ue(ve),Te.push(ve),ve={words:[]},Be=0}const He=0,Ye=1,je=2;const{top:Ge,right:Ue,bottom:Ne,left:Xe}=t.Direction4;function qe(t,e,n){const{bounds:s,rows:i}=t;s[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const Ve={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let s=0,i=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(s=l[Xe],a-=l[Ue]+l[Xe]),o&&(i=l[Ge],o-=l[Ge]+l[Ne]));const c={bounds:{x:s,y:i,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,s){We=e,Te=e.rows,Me=e.bounds;const{__letterSpacing:i,paraIndent:a,textCase:o}=s,{canvas:r}=t.Platform,{width:d,height:l}=Me;if(d||l||i||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Ce=!0,Pe=null,Le=Re=ke=xe=Be=0,me={data:[]},ve={words:[]};for(let s=0,l=n.length;s<l;s++)Ee=n[s],"\n"===Ee?(xe&&De(),ve.paraEnd=!0,Fe(),Ce=!0):(Se=le(Ee),Se===fe&&"none"!==o&&(Ee=he(Ee,o,!xe)),Re=r.measureText(Ee).width,i&&(i<0&&(ke=Re),Re+=i),Oe=Se===pe&&(Pe===pe||Pe===fe)||Pe===pe&&Se!==ge,Ae=!(Se!==_e&&Se!==pe||Pe!==ye&&Pe!==ge),be=Ce&&a?d-a:d,t&&d&&Be+xe+Re>be&&(e?(xe&&De(),Fe()):(Ae||(Ae=Se===fe&&Pe==ge),Oe||Ae||Se===we||Se===_e||Se===pe||xe+Re>be?(xe&&De(),Fe()):Fe()))," "===Ee&&!0!==Ce&&Be+xe===0||(Se===we?(" "===Ee&&xe&&De(),Ie(Ee,Re),De()):Oe||Ae?(xe&&De(),Ie(Ee,Re)):Ie(Ee,Re)),Pe=Se);xe&&De(),Be&&Fe(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,Te.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),l&&function(t,e,n,s,i){if(!s)switch(n.textAlign){case"left":qe(e,"x",t[Xe]);break;case"right":qe(e,"x",-t[Ue])}if(!i)switch(n.verticalAlign){case"top":qe(e,"y",t[Ge]);break;case"bottom":qe(e,"y",-t[Ne])}}(l,c,n,a,o),function(t,e){const{rows:n,bounds:s}=t,{__lineHeight:i,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:_,width:g,height:y}=s,w=i*n.length+(c?c*(t.paraNumber-1):0),m=a;if(r&&w>y)w=Math.max(y,i),t.overflow=n.length;else switch(l){case"middle":_+=(y-w)/2;break;case"bottom":_+=y-w}m+=_;for(let a=0,l=n.length;a<l;a++){switch(h=n[a],h.x=p,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&a>0&&(m+=c),h.y=m,m+=i,t.overflow>a&&m>w&&(h.isOverflow=!0,t.overflow=a+1),u=h.x,f=h.width,o<0&&(h.width<0?(f=-h.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}s.y=_,s.height=w}(c,n),function(t,e,n,s){const{rows:i}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;i.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?He:l>.01?Ye:je,t.isOverflow&&!r&&(t.textMode=!0),h===je?(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===Ye?(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)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,a),c.overflow&&function(e,n){const{rows:s,overflow:i}=e;let{textOverflow:a}=n;if(s.splice(i),"hide"!==a){let e,o;"ellipsis"===a&&(a="...");const r=t.Platform.canvas.measureText(a).width,d=n.x+n.width-r;("none"===n.textWrap?s:[s[i-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let s=n;s>-1&&(e=t.data[s],o=e.x+e.width,!(s===n&&o<d));s--){if(o<d&&" "!==e.char){t.data.splice(s+1),t.width-=e.width;break}t.width-=e.width}t.width+=r,t.data.push({char:a,x:o}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n),"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 ze={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:Qe,addPoint:Ze,toBounds:$e}=t.TwoPointBoundsHelper;const Je={export(e,n,i){return this.running=!0,function(e){Ke||(Ke=new t.TaskProcessor);return new Promise((t=>{Ke.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,o=1,l=1;i=t.FileHelper.getExportOptions(i);const{scale:c,pixelRatio:h,slice:u,trim:f}=i,p=i.screenshot||e.isApp,_=void 0===i.fill?e.isLeafer&&p?e.fill:"":i.fill,g=t.FileHelper.isOpaqueImage(n)||_,y=new t.Matrix;if(p)s=!0===p?e.isLeafer?d.canvas.bounds:e.worldRenderBounds:p;else{const{localTransform:t,__world:n}=e;y.set(n).divide(t).invert(),o=1/(n.scaleX/e.scaleX),l=1/(n.scaleY/e.scaleY),s=e.getBounds("render","local")}let{x:w,y:m,width:v,height:x}=s;c&&(y.scale(c),v*=c,x*=c,o*=c,l*=c);let B=t.Creator.canvas({width:v,height:x,pixelRatio:h});const b={matrix:y.translate(-w,-m).withScale(o,l)};if(u&&(e=d,b.bounds=B.bounds),B.save(),e.__render(B,b),B.restore(),f){a=function(e){const{width:n,height:s}=e.view,{data:i}=e.context.getImageData(0,0,n,s);let a,o,r,d=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(a=d%n,o=(d-a)/n,r?Ze(r,a,o):Qe(r={},a,o)),d++;const l=new t.Bounds;return $e(r,l),l.scale(1/e.pixelRatio).ceil()}(B);const e=B,{width:n,height:s}=a,i={x:0,y:0,width:n,height:s,pixelRatio:h};B=t.Creator.canvas(i),B.copyWorld(e,a,i)}g&&B.fillWorld(B.bounds,_||"#FFFFFF","destination-over");const E="canvas"===n?B:yield B.export(n,i);r({data:E,renderBounds:s,trimBounds:a})})))):r({data:!1})}))))}};let Ke;Object.assign(n.TextConvert,Ve),Object.assign(n.ColorConvert,ze),Object.assign(n.Paint,T),Object.assign(n.PaintImage,ct),Object.assign(n.PaintGradient,Mt),Object.assign(n.Effect,Gt),Object.assign(n.Export,Je),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=r,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,s)=>new e(t,n,s),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:r}=i;t.Platform.origin={createCanvas:(t,e,s)=>new n(t,e,s),canvasToDataURL:(t,e,n)=>t.toDataURL(a(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(a(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(a(o(n)),i))})),loadImage:r}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/draw");function i(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(t){try{d(i.throw(t))}catch(t){a(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(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.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}}const{mineType:a,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.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 t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:d,updateBounds:l,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,f),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:g,updateAllChange:y}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,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||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),m.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new _([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new _(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?v.warn("rendering"):this.times>3?v.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:n,height:i}=e.old;new t.Bounds(0,0,n,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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,a)}function b(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?L(t,!0,e,n):R(e,n);break;case"inside":E("inside",t,s,e,n);break;case"outside":E("outside",t,s,e,n)}}function E(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?L(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(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 R(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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,a)}function L(t,e,i,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&n.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?R(i,s):s.stroke(),s.restoreBlendMode()):e?R(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:O}=t.BoundsHelper;let A;function W(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:d}=e;return{type:a,blendMode:o,style:n.ColorConvert.string(r,d)};case"image":return n.PaintImage.image(i,t,e,s,!A||!A[e.url]);case"linear":return n.PaintGradient.linearGradient(e,s);case"radial":return n.PaintGradient.radialGradient(e,s);case"angular":return n.PaintGradient.conicGradient(e,s);default:return e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const C={compute:function(t,e){const i=e.__,s=[];let a,o=i.__input[t];o instanceof Array||(o=[o]),A=n.PaintImage.recycleImage(t,i);for(let n,i=0,a=o.length;i<a;i++)n=W(t,o[i],e),n&&s.push(n);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,d=t.length;r<d;r++)s=t[r],s.image&&n.PaintImage.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?B(e,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?B(e,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):o?B(e,i):a?i.fill(a):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)b(t,e,n);else switch(a){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 a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)b(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),L(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),L(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?k(e.bounds,i*l,i*c):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(s,o),a=P(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let M={};const{get:T,rotateOfOuter:I,translate:D,scaleOfOuter:F,scale:H,rotate:G}=t.MatrixHelper;function Y(t,e,n,i,s,a){const o=T(),r=a&&180!==a,d=n.width/(r?s:i),l=n.height/(r?i:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-s*c)/2;D(o,h,u),H(o,c),a&&I(o,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=c,t.transform=o}function j(t,e,n,i,s,a,o){const r=T();D(r,e.x,e.y),(n||i)&&D(r,n,i),s&&(H(r,s,a),t.scaleX=r.a,t.scaleY=r.d),o&&G(r,o),t.transform=r}function U(t,e,n,i,s,a,o,r,d){const l=T();if(d)switch(G(l,d),d){case 90:D(l,i,0);break;case 180:D(l,n,i);break;case 270:D(l,0,n)}M.x=e.x,M.y=e.y,(s||a)&&(M.x+=s,M.y+=a),D(l,M.x,M.y),o&&(F(l,M,o,r),t.scaleX=o,t.scaleY=r),t.transform=l}const{get:N,translate:X}=t.MatrixHelper;function q(t,e,n,i){let{width:s,height:a}=e;const{opacity:o,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,p=i.width===s&&i.height===a;u&&(t.blendMode=u);const _=t.data={mode:r};let g,y,w,m;switch(d&&(g=d.x,y=d.y),c?(w=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/a):l&&(w="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":p||(s=i.width,a=i.height),(i.x||i.y)&&(_.transform=N(),X(_.transform,i.x,i.y));break;case"clip":(d||w||h)&&j(_,i,g,y,w,m,h);break;case"repeat":(!p||w||h)&&U(_,i,s,a,g,y,w,m,h),f||(_.repeat="repeat");break;default:p&&!h||Y(_,r,i,s,a,h)}_.width=s,_.height=a,o&&(_.opacity=o),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let V,z=new t.Bounds;const{isSame:Q}=t.BoundsHelper;function Z(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||q(s,i,n,a),!0}function $(e,n){tt(e,t.ImageEvent.LOAD,n)}function J(e,n){tt(e,t.ImageEvent.LOADED,n)}function K(e,n,i){n.error=i,e.forceUpdate("surface"),tt(e,t.ImageEvent.ERROR,n)}function tt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}const{get:et,scale:nt,copy:it}=t.MatrixHelper,{round:st,abs:at}=Math;function ot(e,n,i){let{scaleX:s,scaleY:a}=e.__world;const o=s+"-"+a;if(n.patternId===o||e.destroyed)return!1;{s=at(s),a=at(a);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=et(),it(l,_),nt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const y=c*h;if(!g&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(s/=d,a/=d,c/=d,h/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=et(),_&&it(l,_)),nt(l,1/s,1/a));const m=e.getCanvas(c<1?1:st(c),h<1?1:st(h),p),v=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}const{abs:rt}=Math;const dt={image:function(e,n,i,s,a){let o,r;const d=t.ImageManager.get(i);return V&&i===V.paint&&Q(s,V.boxBounds)?o=V.leafPaint:(o={type:i.type},o.image=d,V=d.use>1?{leafPaint:o,paint:i,boxBounds:z.set(s)}:null),(a||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(Z(e,n,i,d,o,s),a&&($(e,r),J(e,r))):d.error?a&&K(e,r,d.error):(a&&$(e,r),o.loadId=d.load((()=>{e.destroyed||(Z(e,n,i,d,o,s)&&e.forceUpdate("surface"),J(e,r)),o.loadId=null}),(t=>{K(e,r,t),o.loadId=null}))),o},createData:q,fillOrFitMode:Y,clipMode:j,repeatMode:U,createPattern:ot,checkImage:function(e,s,a,o){const{scaleX:r,scaleY:d}=e.__world;if(a.data&&a.patternId!==r+"-"+d){const{data:l}=a;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=rt(r)*s.pixelRatio,n*=rt(d)*s.pixelRatio,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(s.save(),s.clip(),a.blendMode&&(s.blendMode=a.blendMode),l.opacity&&(s.opacity*=l.opacity),l.transform&&s.transform(l.transform),s.drawImage(a.image.view,0,0,l.width,l.height),s.restore(),!0):(!a.style||n.Export.running?ot(e,a,s.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){a.patternTask=null,s.bounds.hit(e.__world)&&ot(e,a,s.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let d=0,l=i.length;d<l;d++)s=i[d].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null}},lt={x:.5,y:0},ct={x:.5,y:1};function ht(t,e,i){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],t.addColorStop(s.offset,n.ColorConvert.string(s.color,i))}const{set:ut,getAngle:ft,getDistance:pt}=t.PointHelper,{get:_t,rotateOfOuter:gt,scaleOfOuter:yt}=t.MatrixHelper,wt={x:.5,y:.5},mt={x:.5,y:1},vt={},xt={};const{set:Bt,getAngle:bt,getDistance:Et}=t.PointHelper,{get:Rt,rotateOfOuter:Lt,scaleOfOuter:kt}=t.MatrixHelper,St={x:.5,y:.5},Pt={x:.5,y:1},Ot={},At={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;i||(i=lt),s||(s=ct);const d=t.Platform.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);ht(d,e.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;i||(i=wt),s||(s=mt);const{x:l,y:c,width:h,height:u}=n;let f;ut(vt,l+i.x*h,c+i.y*u),ut(xt,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=_t(),yt(f,vt,h/u*(d||1),1),gt(f,vt,ft(vt,xt)+90));const p=t.Platform.canvas.createRadialGradient(vt.x,vt.y,0,vt.x,vt.y,pt(vt,xt));ht(p,e.stops,o);const _={type:a,style:p,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;i||(i=St),s||(s=Pt);const{x:l,y:c,width:h,height:u}=n;Bt(Ot,l+i.x*h,c+i.y*u),Bt(At,l+s.x*h,c+s.y*u);const f=Rt(),p=bt(Ot,At);t.Platform.conicGradientRotate90?(kt(f,Ot,h/u*(d||1),1),Lt(f,Ot,p+90)):(kt(f,Ot,1,h/u*(d||1)),Lt(f,Ot,p));const _=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,Et(Ot,At));ht(_,e.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g}},{copy:Ct,toOffsetOutBounds:Mt}=t.BoundsHelper,Tt={},It={};function Dt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Ct(Tt,e.bounds),Tt.x+=n.x-o.x,Tt.y+=n.y-o.y,i){const{matrix:t}=s;Tt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Tt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(s.canvas,e.bounds,Tt)}else i&&(Ct(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,o,i?Tt:n)}const{toOffsetOutBounds:Ft}=t.BoundsHelper,Ht={};const Gt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(l,It),r.forEach(((r,_)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Dt(f,It,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ft(l,Ht),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Ht.offsetX+r.x*h,Ht.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Dt(f,Ht,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.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.__world.a),n.copyWorldToInner(e,t.__world,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Yt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,a){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),Nt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Nt(t,n,i,a);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}n.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(jt(this,o,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Ut(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Yt(n,e)||n.__render(s||t,e);jt(this,o,t,s,i,a)};const Xt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=Xt+"_#~&*+\\=|≮≯≈≠=…",Vt=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 zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$t=zt(Xt),Jt=zt(qt),Kt=zt("- —/~|┆·");var te;!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"}(te||(te={}));const{Letter:ee,Single:ne,Before:ie,After:se,Symbol:ae,Break:oe}=te;function re(t){return Qt[t]?ee:Kt[t]?oe:Zt[t]?ie:$t[t]?se:Jt[t]?ae:Vt.test(t)?ne:ee}const de={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function le(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:ce}=de,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:_e,Break:ge}=te;let ye,we,me,ve,xe,Be,be,Ee,Re,Le,ke,Se,Pe,Oe,Ae,We,Ce=[];function Me(t,e){Re&&!Ee&&(Ee=Re),ye.data.push({char:t,width:e}),me+=e}function Te(){ve+=me,ye.width=me,we.words.push(ye),ye={data:[]},me=0}function Ie(){Oe&&(Ae.paraNumber++,we.paraStart=!0,Oe=!1),Re&&(we.startCharSize=Ee,we.endCharSize=Re,Ee=0),we.width=ve,We.width&&ce(we),Ce.push(we),we={words:[]},ve=0}const De=0,Fe=1,He=2;const{top:Ge,right:Ye,bottom:je,left:Ue}=t.Direction4;function Ne(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 Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(i=l[Ue],a-=l[Ye]+l[Ue]),o&&(s=l[Ge],o-=l[Ge]+l[je]));const c={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ae=e,Ce=e.rows,We=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:d,height:l}=We;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,ke=null,Ee=be=Re=me=ve=0,ye={data:[]},we={words:[]};for(let i=0,l=n.length;i<l;i++)Be=n[i],"\n"===Be?(me&&Te(),we.paraEnd=!0,Ie(),Oe=!0):(Le=re(Be),Le===he&&"none"!==o&&(Be=le(Be,o,!me)),be=r.measureText(Be).width,s&&(s<0&&(Re=be),be+=s),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==_e&&ke!==pe),xe=Oe&&a?d-a:d,t&&d&&ve+me+be>xe&&(e?(me&&Te(),Ie()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===ge||Le===fe||Le===ue||me+be>xe?(me&&Te(),Ie()):Ie()))," "===Be&&!0!==Oe&&ve+me===0||(Le===ge?(" "===Be&&me&&Te(),Me(Be,be),Te()):Se||Pe?(me&&Te(),Me(Be,be)):Me(Be,be)),ke=Le);me&&Te(),ve&&Ie(),Ce.length>0&&(Ce[Ce.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,Ce.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ne(e,"x",t[Ue]);break;case"right":Ne(e,"x",-t[Ye])}if(!s)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ge]);break;case"bottom":Ne(e,"y",-t[je])}}(l,c,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:_,width:g,height:y}=i,w=s*n.length+(c?c*(t.paraNumber-1):0),m=a;if(r&&w>y)w=Math.max(y,s),t.overflow=n.length;else switch(l){case"middle":_+=(y-w)/2;break;case"bottom":_+=y-w}m+=_;for(let a=0,l=n.length;a<l;a++){switch(h=n[a],h.x=p,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&a>0&&(m+=c),h.y=m,m+=s,t.overflow>a&&m>w&&(h.isOverflow=!0,t.overflow=a+1),u=h.x,f=h.width,o<0&&(h.width<0?(f=-h.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),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=w}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?De:l>.01?Fe:He,t.isOverflow&&!r&&(t.textMode=!0),h===He?(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===Fe?(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)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,a),c.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let e,o;"ellipsis"===a&&(a="...");const r=t.Platform.canvas.measureText(a).width,d=n.x+n.width-r;("none"===n.textWrap?i:[i[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],o=e.x+e.width,!(i===n&&o<d));i--){if(o<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=r,t.data.push({char:a,x:o}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n),"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 qe={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:Ve,addPoint:ze,toBounds:Qe}=t.TwoPointBoundsHelper;const Ze={export(e,n,s){return this.running=!0,function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>i(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){let i,a,o=1,l=1;s=t.FileHelper.getExportOptions(s);const{scale:c,slice:h,trim:u}=s,f=s.pixelRatio||1,p=s.screenshot||e.isApp,_=void 0===s.fill?e.isLeafer&&p?e.fill:"":s.fill,g=t.FileHelper.isOpaqueImage(n)||_,y=new t.Matrix;if(p)i=!0===p?e.isLeafer?d.canvas.bounds:e.worldRenderBounds:p;else{const{localTransform:t,__world:n}=e;y.set(n).divide(t).invert(),o=1/(n.scaleX/e.scaleX),l=1/(n.scaleY/e.scaleY),i=e.getBounds("render","local")}let{x:w,y:m,width:v,height:x}=i;c&&(y.scale(c),v*=c,x*=c,o*=c,l*=c);let B=t.Creator.canvas({width:Math.ceil(v),height:Math.ceil(x),pixelRatio:f});const b={matrix:y.translate(-w,-m).withScale(o,l)};if(h&&(e=d,b.bounds=B.bounds),B.save(),e.__render(B,b),B.restore(),u){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,o=(d-a)/n,r?ze(r,a,o):Ve(r={},a,o)),d++;const l=new t.Bounds;return Qe(r,l),l.scale(1/e.pixelRatio).ceil()}(B);const e=B,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:f};B=t.Creator.canvas(s),B.copyWorld(e,a,s)}g&&B.fillWorld(B.bounds,_||"#FFFFFF","destination-over");const E="canvas"===n?B:yield B.export(n,s);r({data:E,width:B.pixelWidth,height:B.pixelHeight,renderBounds:i,trimBounds:a})})))):r({data:!1})}))))}};let $e;Object.assign(n.TextConvert,Xe),Object.assign(n.ColorConvert,qe),Object.assign(n.Paint,C),Object.assign(n.PaintImage,dt),Object.assign(n.PaintGradient,Wt),Object.assign(n.Effect,Gt),Object.assign(n.Export,Ze),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=s,exports.Renderer=x,exports.Watcher=r,exports.useCanvas=function(n,s){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=s;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:r}=s;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(a(e),n),canvasToBolb:(t,e,n)=>i(this,void 0,void 0,(function*(){return t.toBuffer(a(e),n)})),canvasSaveAs:(t,n,s)=>i(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(a(o(n)),s))})),loadImage:r}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-draw/node",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.12",
4
4
  "description": "@leafer-draw/node",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  "leaferjs"
32
32
  ],
33
33
  "dependencies": {
34
- "@leafer/node": "1.0.0-rc.10",
35
- "@leafer-draw/partner": "1.0.0-rc.10",
36
- "@leafer-ui/draw": "1.0.0-rc.10",
37
- "@leafer-ui/partner": "1.0.0-rc.10",
38
- "@leafer-ui/interface": "1.0.0-rc.10"
34
+ "@leafer/node": "1.0.0-rc.12",
35
+ "@leafer-draw/partner": "1.0.0-rc.12",
36
+ "@leafer-ui/draw": "1.0.0-rc.12",
37
+ "@leafer-ui/partner": "1.0.0-rc.12",
38
+ "@leafer-ui/interface": "1.0.0-rc.12"
39
39
  }
40
40
  }