@leafer-draw/worker 1.6.6 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.cjs CHANGED
@@ -962,7 +962,7 @@ const PaintModule = {
962
962
  };
963
963
 
964
964
  let origin = {};
965
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = core.MatrixHelper;
965
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
966
966
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
967
967
  const transform = get$3();
968
968
  translate$1(transform, box.x + x, box.y + y);
@@ -971,13 +971,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
971
971
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
972
972
  data.transform = transform;
973
973
  }
974
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
974
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
975
975
  const transform = get$3();
976
- translate$1(transform, box.x + x, box.y + y);
977
- if (scaleX)
978
- scaleHelper(transform, scaleX, scaleY);
979
976
  if (rotation)
980
977
  rotate(transform, rotation);
978
+ if (skew)
979
+ skewHelper(transform, skew.x, skew.y);
980
+ if (scaleX)
981
+ scaleHelper(transform, scaleX, scaleY);
982
+ translate$1(transform, box.x + x, box.y + y);
981
983
  data.transform = transform;
982
984
  }
983
985
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -1014,11 +1016,13 @@ const tempBox = new core.Bounds();
1014
1016
  const tempScaleData = {};
1015
1017
  const tempImage = {};
1016
1018
  function createData(leafPaint, image, paint, box) {
1017
- const { changeful, sync } = paint;
1019
+ const { changeful, sync, editing } = paint;
1018
1020
  if (changeful)
1019
1021
  leafPaint.changeful = changeful;
1020
1022
  if (sync)
1021
1023
  leafPaint.sync = sync;
1024
+ if (editing)
1025
+ leafPaint.editing = editing;
1022
1026
  leafPaint.data = getPatternData(paint, box, image);
1023
1027
  }
1024
1028
  function getPatternData(paint, box, image) {
@@ -1027,7 +1031,7 @@ function getPatternData(paint, box, image) {
1027
1031
  if (paint.mode === 'strench')
1028
1032
  paint.mode = 'stretch';
1029
1033
  let { width, height } = image;
1030
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1034
+ const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
1031
1035
  const sameBox = box.width === width && box.height === height;
1032
1036
  const data = { mode };
1033
1037
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1061,8 +1065,8 @@ function getPatternData(paint, box, image) {
1061
1065
  break;
1062
1066
  case 'normal':
1063
1067
  case 'clip':
1064
- if (tempImage.x || tempImage.y || scaleX || rotation)
1065
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1068
+ if (tempImage.x || tempImage.y || scaleX || rotation || skew)
1069
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
1066
1070
  break;
1067
1071
  case 'repeat':
1068
1072
  if (!sameBox || scaleX || rotation)
@@ -1139,11 +1143,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1139
1143
  }
1140
1144
  onLoadSuccess(ui, event);
1141
1145
  }
1142
- leafPaint.loadId = null;
1146
+ leafPaint.loadId = undefined;
1143
1147
  }, (error) => {
1144
1148
  ignoreRender(ui, false);
1145
1149
  onLoadError(ui, event, error);
1146
- leafPaint.loadId = null;
1150
+ leafPaint.loadId = undefined;
1147
1151
  });
1148
1152
  if (ui.placeholderColor) {
1149
1153
  if (!ui.placeholderDelay)
@@ -1209,6 +1213,8 @@ function createPattern(ui, paint, pixelRatio) {
1209
1213
  const { image, data } = paint;
1210
1214
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1211
1215
  if (sx) {
1216
+ sx = abs$1(sx);
1217
+ sy = abs$1(sy);
1212
1218
  imageMatrix = get$1();
1213
1219
  copy$1(imageMatrix, transform);
1214
1220
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -963,7 +963,7 @@ const PaintModule = {
963
963
  };
964
964
 
965
965
  let origin = {};
966
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
966
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
967
967
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
968
968
  const transform = get$3();
969
969
  translate$1(transform, box.x + x, box.y + y);
@@ -972,13 +972,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
972
972
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
973
973
  data.transform = transform;
974
974
  }
975
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
975
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
976
976
  const transform = get$3();
977
- translate$1(transform, box.x + x, box.y + y);
978
- if (scaleX)
979
- scaleHelper(transform, scaleX, scaleY);
980
977
  if (rotation)
981
978
  rotate(transform, rotation);
979
+ if (skew)
980
+ skewHelper(transform, skew.x, skew.y);
981
+ if (scaleX)
982
+ scaleHelper(transform, scaleX, scaleY);
983
+ translate$1(transform, box.x + x, box.y + y);
982
984
  data.transform = transform;
983
985
  }
984
986
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -1015,11 +1017,13 @@ const tempBox = new Bounds();
1015
1017
  const tempScaleData = {};
1016
1018
  const tempImage = {};
1017
1019
  function createData(leafPaint, image, paint, box) {
1018
- const { changeful, sync } = paint;
1020
+ const { changeful, sync, editing } = paint;
1019
1021
  if (changeful)
1020
1022
  leafPaint.changeful = changeful;
1021
1023
  if (sync)
1022
1024
  leafPaint.sync = sync;
1025
+ if (editing)
1026
+ leafPaint.editing = editing;
1023
1027
  leafPaint.data = getPatternData(paint, box, image);
1024
1028
  }
1025
1029
  function getPatternData(paint, box, image) {
@@ -1028,7 +1032,7 @@ function getPatternData(paint, box, image) {
1028
1032
  if (paint.mode === 'strench')
1029
1033
  paint.mode = 'stretch';
1030
1034
  let { width, height } = image;
1031
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1035
+ const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
1032
1036
  const sameBox = box.width === width && box.height === height;
1033
1037
  const data = { mode };
1034
1038
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1062,8 +1066,8 @@ function getPatternData(paint, box, image) {
1062
1066
  break;
1063
1067
  case 'normal':
1064
1068
  case 'clip':
1065
- if (tempImage.x || tempImage.y || scaleX || rotation)
1066
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1069
+ if (tempImage.x || tempImage.y || scaleX || rotation || skew)
1070
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
1067
1071
  break;
1068
1072
  case 'repeat':
1069
1073
  if (!sameBox || scaleX || rotation)
@@ -1140,11 +1144,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1140
1144
  }
1141
1145
  onLoadSuccess(ui, event);
1142
1146
  }
1143
- leafPaint.loadId = null;
1147
+ leafPaint.loadId = undefined;
1144
1148
  }, (error) => {
1145
1149
  ignoreRender(ui, false);
1146
1150
  onLoadError(ui, event, error);
1147
- leafPaint.loadId = null;
1151
+ leafPaint.loadId = undefined;
1148
1152
  });
1149
1153
  if (ui.placeholderColor) {
1150
1154
  if (!ui.placeholderDelay)
@@ -1210,6 +1214,8 @@ function createPattern(ui, paint, pixelRatio) {
1210
1214
  const { image, data } = paint;
1211
1215
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1212
1216
  if (sx) {
1217
+ sx = abs$1(sx);
1218
+ sy = abs$1(sy);
1213
1219
  imageMatrix = get$1();
1214
1220
  copy$1(imageMatrix, transform);
1215
1221
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,FileHelper as i,Creator as s,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as _,Bounds as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,MatrixHelper as k,MathHelper as E,AlignHelper as S,PointHelper as R,ImageEvent as A,AroundHelper as L,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,Paint as W,ColorConvert as C,PaintGradient as D,Export as M,Group as I,TextConvert as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:Y}=i;function G(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:Y(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:Y(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new U(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:z}=navigator;z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):z.indexOf("Safari")>-1&&-1===z.indexOf("Chrome")&&(e.fullImageShadow=!0),z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):z.indexOf("Mac")>-1?e.os="Mac":z.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:j,updateChange:X}=f,{pushAllChildBranch:H,pushAllParent:V}=p;const{worldBounds:Q}=_;class Z{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Q),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:$,updateAllChange:J}=f,K=w.get("Layouter");class tt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){K.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?K.warn("layouting"):this.times>3?K.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&H(t,e),V(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),V(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||j(i[t])}j(n)}}))}(this.__levelList),function(t){t.list.forEach(X)}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(a,r,this.times)),n.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(n,a,this.times)),tt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){$(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),J(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new Z([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new Z(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const et=w.get("Renderer");class nt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new g,et.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,et.error(t)}et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return et.warn("rendering");if(this.times>3)return et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=x.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=new g(i);n.save(),i.spread(nt.clipSpread).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0),this.__render(i,s),n.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:n}=this,i=t.includes(this.target.__world),s=i?{includes:i}:{bounds:t,includes:i};this.needFill&&n.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(n,t),this.target.__render(n,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),n.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const n=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new g(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||et.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){this.__eventIds=[this.target.on_([[l.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[l.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function it(t,e){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let a;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)a=i[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(s){const{decorationColor:t,decorationHeight:a}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,a)))))}}function st(t,e){t.__.__font?it(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function at(t,e,n){switch(e.__.strokeAlign){case"center":ot(t,1,e,n);break;case"inside":rt(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?ot(t,2,e,n):rt(t,"outside",e,n)}}function ot(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?ct(t,!0,n,i):lt(n,i)}function rt(t,e,n,i){const s=i.getSameCanvas(!0,!0);s.font=n.__.__font,ot(t,2,n,s),s.blendMode="outside"===e?"destination-out":"destination-in",it(n,s),s.blendMode="normal",dt(i,s,n),s.recycle(n.__nowWorld)}function dt(t,n,i){i.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(n,i.__nowWorld):t.copyWorldToInner(n,i.__nowWorld,i.__layout.renderBounds)}function lt(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:a}=i;for(let t=0,i=s.length;t<i;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)}));if(a){const{decorationHeight:t}=i;s.forEach((n=>a.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function ct(t,e,n,i){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?lt(n,i):i.stroke(),i.restoreBlendMode()):e?lt(n,i):i.stroke())}function ht(t,e,n){const i=e.__;if(i.__strokeWidth)if(i.__font)at(t,e,n);else switch(i.strokeAlign){case"center":ut(t,1,e,n);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),ut(t,2,e,n),n.restore()}(t,e,n);break;case"outside":!function(t,e,n){const i=e.__;if(i.__fillAfterStroke)ut(t,2,e,n);else{const{renderBounds:s}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),ut(t,2,e,a),a.clipUI(i),a.clearWorld(s),dt(n,a,e),a.recycle(e.__nowWorld)}}(t,e,n)}}function ut(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?ct(t,!1,n,i):i.stroke(),s.__useArrow&&W.strokeArrow(t,n,i)}nt.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new tt(t,e),renderer:(t,e,n)=>new nt(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=tt.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:_t,getIntersectData:gt}=B;let wt;const{stintSet:yt}=d,{hasTransparent:mt}=C;function xt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let i;const{boxBounds:s}=n.__layout;switch(e.type){case"image":i=O.image(n,t,e,s,!wt||!wt[e.url]);break;case"linear":i=D.linearGradient(e,s);break;case"radial":i=D.radialGradient(e,s);break;case"angular":i=D.conicGradient(e,s);break;case"solid":const{type:a,color:o,opacity:r}=e;i={type:a,style:C.string(o,r)};break;default:void 0!==e.r&&(i={type:"solid",style:C.string(e)})}return i&&("string"==typeof i.style&&mt(i.style)&&(i.isTransparent=!0),e.blendMode&&(i.blendMode=e.blendMode)),i}const vt={compute:function(t,e){const n=e.__,i=[];let s,a,o=n.__input[t];o instanceof Array||(o=[o]),wt=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)(n=xt(t,o[s],e))&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i.every((t=>t.isTransparent))&&(i.some((t=>t.image))&&(s=!0),a=!0),"fill"===t?(yt(n,"__isAlphaPixelFill",s),yt(n,"__isTransparentFill",a)):(yt(n,"__isAlphaPixelStroke",s),yt(n,"__isTransparentStroke",a))},fill:function(t,e,n){n.fillStyle=t,st(e,n)},fills:function(t,e,n){let i;for(let s=0,a=t.length;s<a;s++){if(i=t[s],i.image){if(O.checkImage(e,n,i,!e.__.__font))continue;if(!i.style){!s&&i.image.isPlacehold&&e.drawImagePlaceholder(n,i.image);continue}}n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),st(e,n),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),st(e,n),n.restoreBlendMode()):st(e,n)}},fillPathOrText:st,fillText:it,stroke:ht,strokes:function(t,e,n){ht(t,e,n)},strokeText:at,drawTextStroke:lt,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=gt(i?ft(e.bounds,l===c?i*l:[i*c,i*l]):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=pt(s,o),a=_t(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 bt={};const{get:Bt,rotateOfOuter:kt,translate:Et,scaleOfOuter:St,scale:Rt,rotate:At}=k;function Lt(t,e,n,i,s,a,o){const r=Bt();Et(r,e.x+n,e.y+i),Rt(r,s,a),o&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Tt(t,e,n,i,s,a,o){const r=Bt();Et(r,e.x+n,e.y+i),s&&Rt(r,s,a),o&&At(r,o),t.transform=r}function Ot(t,e,n,i,s,a,o,r,d,l){const c=Bt();if(d)if("center"===l)kt(c,{x:n/2,y:i/2},d);else switch(At(c,d),d){case 90:Et(c,i,0);break;case 180:Et(c,n,i);break;case 270:Et(c,0,n)}bt.x=e.x+s,bt.y=e.y+a,Et(c,bt.x,bt.y),o&&St(c,bt,o,r),t.transform=c}const{get:Wt,translate:Ct}=k,Dt=new g,Mt={},It={};function Pt(t,e,n,i){const{changeful:s,sync:a}=n;s&&(t.changeful=s),a&&(t.sync=a),t.data=Ft(n,i,e)}function Ft(t,e,n){t.padding&&(e=Dt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:i,height:s}=n;const{opacity:a,mode:o,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===i&&e.height===s,_={mode:o},g="center"!==r&&(h||0)%180==90;let w,y;switch(B.set(It,0,0,g?s:i,g?i:s),o&&"cover"!==o&&"fit"!==o?((l||c)&&(E.getScaleData(l,c,n,Mt),w=Mt.scaleX,y=Mt.scaleY),r&&(w&&B.scale(It,w,y,!0),S.toPoint(r,It,e,It,!0,!0))):p&&!h||(w=y=B.getFitScale(e,It,"fit"!==o),B.put(e,n,r,w,!1,It),B.scale(It,w,y,!0)),d&&R.move(It,d),o){case"stretch":p||(i=e.width,s=e.height);break;case"normal":case"clip":(It.x||It.y||w||h)&&Tt(_,e,It.x,It.y,w,y,h);break;case"repeat":(!p||w||h)&&Ot(_,e,i,s,It.x,It.y,w,y,h,r),u||(_.repeat="repeat");break;default:w&&Lt(_,e,It.x,It.y,w,y,h)}return _.transform||(e.x||e.y)&&(_.transform=Wt(),Ct(_.transform,e.x,e.y)),w&&"stretch"!==o&&(_.scaleX=w,_.scaleY=y),_.width=i,_.height=s,a&&(_.opacity=a),f&&(_.filters=f),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Ut,Yt=new g;const{isSame:Gt}=B;function zt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Pt(s,i,n,a),!0}function Nt(t,e){Xt(t,A.LOAD,e)}function qt(t,e){Xt(t,A.LOADED,e)}function jt(t,e,n){e.error=n,t.forceUpdate("surface"),Xt(t,A.ERROR,e)}function Xt(t,e,n){t.hasEvent(e)&&t.emitEvent(new A(e,n))}function Ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Vt,scale:Qt,copy:Zt}=k,{ceil:$t,abs:Jt}=Math;function Kt(t,n,i){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||t.destroyed)return!1;{s=Jt(s),a=Jt(a);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(l=Vt(),Zt(l,p),Qt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const g=c*h;if(!_&&g>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}g>w&&(d=Math.sqrt(g/w)),d&&(s/=d,a/=d,c/=d,h/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=Vt(),p&&Zt(l,p)),Qt(l,1/s,1/a));const y=t.getCanvas($t(c)||1,$t(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,n);return n.style=m,n.patternId=o,!0}}function te(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;const{abs:ee}=Math;const ne={image:function(t,e,n,i,s){let a,o;const r=v.get(n);return Ut&&n===Ut.paint&&Gt(i,Ut.boxBounds)?a=Ut.leafPaint:(a={type:n.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Ut=r.use>1?{leafPaint:a,paint:n,boxBounds:Yt.set(i)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:n}),r.ready?(zt(t,e,n,r,a,i),s&&(Nt(t,o),qt(t,o))):r.error?s&&jt(t,o,r.error):(s&&(Ht(t,!0),Nt(t,o)),a.loadId=r.load((()=>{Ht(t,!1),t.destroyed||(zt(t,e,n,r,a,i)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),qt(t,o)),a.loadId=null}),(e=>{Ht(t,!1),jt(t,o,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,n,i,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n,{data:d}=i;if(!d||i.patternId===a+"-"+o+"-"+r&&!M.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||b.isResizing(t)||M.running)){let{width:t,height:n}=d;t*=ee(a)*r,n*=ee(o)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize}return s?(function(t,e,n,i){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,n,i,d),!0):(!i.style||i.sync||M.running?Kt(t,i,r):i.patternTask||(i.patternTask=v.patternTasker.add((()=>te(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Kt(t,i,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:Kt,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,a,o,r;for(let d=0,l=n.length;d<l;d++)i=n[d],s=i.image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,v.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(n[d].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:Pt,getPatternData:Ft,fillOrFitMode:Lt,clipMode:Tt,repeatMode:Ot},{toPoint:ie}=L,{hasTransparent:se}=C,ae={},oe={};function re(t,e,n,i){if(n){let s,a,o,r;for(let t=0,d=n.length;t<d;t++)s=n[t],"string"==typeof s?(o=t/(d-1),a=C.string(s,i)):(o=s.offset,a=C.string(s.color,i)),e.addColorStop(o,a),!r&&se(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:de,getDistance:le}=R,{get:ce,rotateOfOuter:he,scaleOfOuter:ue}=k,{toPoint:fe}=L,pe={},_e={};function ge(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=de(e,n);a=ce(),s?(ue(a,e,o/r*(i||1),1),he(a,e,t+90)):(ue(a,e,1,o/r*(i||1)),he(a,e,t))}return a}const{getDistance:we}=R,{toPoint:ye}=L,me={},xe={};const ve={linearGradient:function(t,n){let{from:i,to:s,type:a,opacity:o}=t;ie(i||"top",n,ae),ie(s||"bottom",n,oe);const r=e.canvas.createLinearGradient(ae.x,ae.y,oe.x,oe.y),d={type:a,style:r};return re(d,r,t.stops,o),d},radialGradient:function(t,n){let{from:i,to:s,type:a,opacity:o,stretch:r}=t;fe(i||"center",n,pe),fe(s||"bottom",n,_e);const d=e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,le(pe,_e)),l={type:a,style:d};re(l,d,t.stops,o);const c=ge(n,pe,_e,r,!0);return c&&(l.transform=c),l},conicGradient:function(t,n){let{from:i,to:s,type:a,opacity:o,stretch:r}=t;ye(i||"center",n,me),ye(s||"bottom",n,xe);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,me.x,me.y):e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,xe)),l={type:a,style:d};re(l,d,t.stops,o);const c=ge(n,me,xe,r||1,e.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:ge},{copy:be,toOffsetOutBounds:Be}=B,ke={},Ee={};function Se(t,n,i,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(be(ke,t.bounds),ke.x+=n.x-o.x,ke.y+=n.y-o.y,i){const{matrix:t}=s;ke.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),ke.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),ke.width*=i,ke.height*=i}t.copyWorld(s.canvas,t.bounds,ke)}else i&&(be(ke,n),ke.x-=n.width/2*(i-1),ke.y-=n.height/2*(i-1),ke.width*=i,ke.height*=i),t.copyWorld(s.canvas,o,i?ke:n)}const{toOffsetOutBounds:Re}=B,Ae={};const Le={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;Be(l,Ee),r.forEach(((r,_)=>{f.setWorldShadow(Ee.offsetX+r.x*h,Ee.offsetY+r.y*u,r.blur*h,C.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Se(f,Ee,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;Re(l,Ae),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Ae.offsetX+r.x*h,Ae.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Se(f,Ae,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,C.string(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.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Te}=_;function Oe(t,e,n,i,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ce(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ce(t,n,i,a);break;case"path":n.restore()}}function We(t){return t.getSameCanvas(!1,!0)}function Ce(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}I.prototype.__renderMask=function(t,e){let n,i,s,a,o,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(o&&(Oe(this,o,t,s,i,a),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=We(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=We(t)),s||(s=We(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Te(n,e)||n.__render(s||t,e);Oe(this,o,t,s,i,a)};const De=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Me=De+"_#~&*+\\=|≮≯≈≠=…",Ie=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 Pe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Fe=Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ue=Pe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ye=Pe(De),Ge=Pe(Me),ze=Pe("- —/~|┆·");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:qe,Single:je,Before:Xe,After:He,Symbol:Ve,Break:Qe}=Ne;function Ze(t){return Fe[t]?qe:ze[t]?Qe:Ue[t]?Xe:Ye[t]?He:Ge[t]?Ve:Ie.test(t)?je:qe}const $e={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 Je(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:Ke}=$e,{Letter:tn,Single:en,Before:nn,After:sn,Symbol:an,Break:on}=Ne;let rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn,yn,mn,xn,vn,bn,Bn,kn=[];function En(t,e){_n&&!pn&&(pn=_n),rn.data.push({char:t,width:e}),ln+=e}function Sn(){cn+=ln,rn.width=ln,dn.words.push(rn),rn={data:[]},ln=0}function Rn(){xn&&(vn.paraNumber++,dn.paraStart=!0,xn=!1),_n&&(dn.startCharSize=pn,dn.endCharSize=_n,pn=0),dn.width=cn,bn.width?Ke(dn):Bn&&An(),kn.push(dn),dn={words:[]},cn=0}function An(){cn>(vn.maxWidth||0)&&(vn.maxWidth=cn)}const{top:Ln,right:Tn,bottom:On,left:Wn}=T;function Cn(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 Dn={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));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[Wn],a-=l[Tn]+l[Wn]):n.autoSizeAlign||(i=l[Wn]),o?(s=l[Ln],o-=l[Ln]+l[On]):n.autoSizeAlign||(s=l[Ln]));const c={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){vn=t,kn=t.rows,bn=t.bounds,Bn=!bn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=e,{width:d,height:l}=bn;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;xn=!0,wn=null,pn=fn=_n=ln=cn=0,rn={data:[]},dn={words:[]},s&&(n=[...n]);for(let i=0,l=n.length;i<l;i++)un=n[i],"\n"===un?(ln&&Sn(),dn.paraEnd=!0,Rn(),xn=!0):(gn=Ze(un),gn===tn&&"none"!==o&&(un=Je(un,o,!ln)),fn=r.measureText(un).width,s&&(s<0&&(_n=fn),fn+=s),yn=gn===en&&(wn===en||wn===tn)||wn===en&&gn!==sn,mn=!(gn!==nn&&gn!==en||wn!==an&&wn!==sn),hn=xn&&a?d-a:d,t&&d&&cn+ln+fn>hn&&(e?(ln&&Sn(),cn&&Rn()):(mn||(mn=gn===tn&&wn==sn),yn||mn||gn===on||gn===nn||gn===en||ln+fn>hn?(ln&&Sn(),cn&&Rn()):cn&&Rn()))," "===un&&!0!==xn&&cn+ln===0||(gn===on?(" "===un&&ln&&Sn(),En(un,fn),Sn()):yn||mn?(ln&&Sn(),En(un,fn)):En(un,fn)),wn=gn);ln&&Sn(),cn&&Rn(),kn.length>0&&(kn[kn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{vn.paraNumber++,cn=r.measureText(t).width,kn.push({x:a||0,text:t,width:cn,paraStart:!0}),Bn&&An()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Cn(e,"x",t[Wn]);break;case"right":Cn(e,"x",-t[Tn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Cn(e,"y",t[Ln]);break;case"bottom":Cn(e,"y",-t[On])}}(l,c,n,a,o),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:_,height:g}=i,w=a*s+(h?h*(t.paraNumber-1):0),y=o;if(d&&w>g)w=Math.max(g,a),s>1&&(t.overflow=s);else if(g||u)switch(c){case"middle":p+=(g-w)/2;break;case"bottom":p+=g-w}y+=p;let m,x,v,b=_||u?_:t.maxWidth;for(let o=0,c=s;o<c;o++){if(m=n[o],m.x=f,m.width<_||m.width>_&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),x=m.x,v=m.width,r<0&&(m.width<0?(v=-m.width+e.fontSize+r,x-=v,v+=e.fontSize):v-=r),x<i.x&&(i.x=x),v>i.width&&(i.width=v),d&&_&&_<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(c,n),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,d,l,c,h,u;i.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-l)/(u-1):0,c=o||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||n===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,n,a),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,a),"none"!==r&&function(t,e){let n;const{fontSize:i,textDecoration:s}=e;switch(t.decorationHeight=i/11,"object"==typeof s?(n=s.type,s.color&&(t.decorationColor=C.string(s.color))):n=s,n){case"under":t.decorationY=[.15*i];break;case"delete":t.decorationY=[.35*-i];break;case"under-delete":t.decorationY=[.15*i,.35*-i]}}(c,n),c}};const Mn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!C.object)return t;t=C.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(P,Dn),Object.assign(C,Mn),Object.assign(W,vt),Object.assign(O,ne),Object.assign(D,ve),Object.assign(F,Le),G();export{tt as Layouter,U as LeaferCanvas,nt as Renderer,N as Watcher,G as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as _,Bounds as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,MatrixHelper as k,MathHelper as E,AlignHelper as S,PointHelper as R,ImageEvent as A,AroundHelper as L,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,Paint as W,ColorConvert as C,PaintGradient as D,Export as M,Group as I,TextConvert as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:Y}=n;function G(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:Y(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Y(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new U(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:z}=navigator;z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):z.indexOf("Safari")>-1&&-1===z.indexOf("Chrome")&&(e.fullImageShadow=!0),z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):z.indexOf("Mac")>-1?e.os="Mac":z.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:j,updateChange:X}=f,{pushAllChildBranch:H,pushAllParent:V}=p;const{worldBounds:Q}=_;class Z{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Q),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:$,updateAllChange:J}=f,K=w.get("Layouter");class tt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){K.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?K.warn("layouting"):this.times>3?K.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(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&&H(t,e),V(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),V(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||j(n[t])}j(i)}}))}(this.__levelList),function(t){t.list.forEach(X)}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),tt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){$(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),J(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Z([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Z(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const et=w.get("Renderer");class it{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=d.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new g,et.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,et.error(t)}et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return et.warn("rendering");if(this.times>3)return et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new g(n);i.save(),n.spread(it.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||et.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[l.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[l.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function nt(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function st(t,e){t.__.__font?nt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function at(t,e,i){switch(e.__.strokeAlign){case"center":ot(t,1,e,i);break;case"inside":rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ot(t,2,e,i):rt(t,"outside",e,i)}}function ot(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?ct(t,!0,i,n):lt(i,n)}function rt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,ot(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",nt(i,s),s.blendMode="normal",dt(n,s,i),s.recycle(i.__nowWorld)}function dt(t,i,n){n.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,n.__nowWorld):t.copyWorldToInner(i,n.__nowWorld,n.__layout.renderBounds)}function lt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=n;s.forEach((i=>a.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function ct(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&O.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())}function ht(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)at(t,e,i);else switch(n.strokeAlign){case"center":ut(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),ut(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)ut(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),ut(t,2,e,a),a.clipUI(n),a.clearWorld(s),dt(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function ut(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?ct(t,!1,i,n):n.stroke(),s.__useArrow&&W.strokeArrow(t,i,n)}it.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new tt(t,e),renderer:(t,e,i)=>new it(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=tt.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:_t,getIntersectData:gt}=B;let wt;const{stintSet:yt}=d,{hasTransparent:mt}=C;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout;switch(e.type){case"image":n=O.image(i,t,e,s,!wt||!wt[e.url]);break;case"linear":n=D.linearGradient(e,s);break;case"radial":n=D.radialGradient(e,s);break;case"angular":n=D.conicGradient(e,s);break;case"solid":const{type:a,color:o,opacity:r}=e;n={type:a,style:C.string(o,r)};break;default:void 0!==e.r&&(n={type:"solid",style:C.string(e)})}return n&&("string"==typeof n.style&&mt(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const vt={compute:function(t,e){const i=e.__,n=[];let s,a,o=i.__input[t];o instanceof Array||(o=[o]),wt=O.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)(i=xt(t,o[s],e))&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n.every((t=>t.isTransparent))&&(n.some((t=>t.image))&&(s=!0),a=!0),"fill"===t?(yt(i,"__isAlphaPixelFill",s),yt(i,"__isTransparentFill",a)):(yt(i,"__isAlphaPixelStroke",s),yt(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,st(e,i)},fills:function(t,e,i){let n;for(let s=0,a=t.length;s<a;s++){if(n=t[s],n.image){if(O.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),st(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),st(e,i),i.restoreBlendMode()):st(e,i)}},fillPathOrText:st,fillText:nt,stroke:ht,strokes:function(t,e,i){ht(t,e,i)},strokeText:at,drawTextStroke:lt,shape:function(t,e,i){const n=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=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,h=gt(n?ft(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=pt(s,o),a=_t(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let bt={};const{get:Bt,rotateOfOuter:kt,translate:Et,scaleOfOuter:St,scale:Rt,rotate:At,skew:Lt}=k;function Tt(t,e,i,n,s,a,o){const r=Bt();Et(r,e.x+i,e.y+n),Rt(r,s,a),o&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ot(t,e,i,n,s,a,o,r){const d=Bt();o&&At(d,o),r&&Lt(d,r.x,r.y),s&&Rt(d,s,a),Et(d,e.x+i,e.y+n),t.transform=d}function Wt(t,e,i,n,s,a,o,r,d,l){const c=Bt();if(d)if("center"===l)kt(c,{x:i/2,y:n/2},d);else switch(At(c,d),d){case 90:Et(c,n,0);break;case 180:Et(c,i,n);break;case 270:Et(c,0,i)}bt.x=e.x+s,bt.y=e.y+a,Et(c,bt.x,bt.y),o&&St(c,bt,o,r),t.transform=c}const{get:Ct,translate:Dt}=k,Mt=new g,It={},Pt={};function Ft(t,e,i,n){const{changeful:s,sync:a,editing:o}=i;s&&(t.changeful=s),a&&(t.sync=a),o&&(t.editing=o),t.data=Ut(i,n,e)}function Ut(t,e,i){t.padding&&(e=Mt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:o,align:r,offset:d,scale:l,size:c,rotation:h,skew:u,repeat:f,filters:p}=t,_=e.width===n&&e.height===s,g={mode:o},w="center"!==r&&(h||0)%180==90;let y,m;switch(B.set(Pt,0,0,w?s:n,w?n:s),o&&"cover"!==o&&"fit"!==o?((l||c)&&(E.getScaleData(l,c,i,It),y=It.scaleX,m=It.scaleY),r&&(y&&B.scale(Pt,y,m,!0),S.toPoint(r,Pt,e,Pt,!0,!0))):_&&!h||(y=m=B.getFitScale(e,Pt,"fit"!==o),B.put(e,i,r,y,!1,Pt),B.scale(Pt,y,m,!0)),d&&R.move(Pt,d),o){case"stretch":_||(n=e.width,s=e.height);break;case"normal":case"clip":(Pt.x||Pt.y||y||h||u)&&Ot(g,e,Pt.x,Pt.y,y,m,h,u);break;case"repeat":(!_||y||h)&&Wt(g,e,n,s,Pt.x,Pt.y,y,m,h,r),f||(g.repeat="repeat");break;default:y&&Tt(g,e,Pt.x,Pt.y,y,m,h)}return g.transform||(e.x||e.y)&&(g.transform=Ct(),Dt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),p&&(g.filters=p),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let Yt,Gt=new g;const{isSame:zt}=B;function Nt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Ft(s,n,i,a),!0}function qt(t,e){Ht(t,A.LOAD,e)}function jt(t,e){Ht(t,A.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Ht(t,A.ERROR,e)}function Ht(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Zt,copy:$t}=k,{ceil:Jt,abs:Kt}=Math;function te(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=Kt(s),a=Kt(a);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:_}=r;u&&(u=Kt(u),f=Kt(f),l=Qt(),$t(l,p),Zt(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,c*=s,h*=a;const g=c*h;if(!_&&g>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}g>w&&(d=Math.sqrt(g/w)),d&&(s/=d,a/=d,c/=d,h/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=Qt(),p&&$t(l,p)),Zt(l,1/s,1/a));const y=t.getCanvas(Jt(c)||1,Jt(h)||1,r.opacity,r.filters),m=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=o,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(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(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return Yt&&i===Yt.paint&&zt(n,Yt.boxBounds)?a=Yt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Yt=r.use>1?{leafPaint:a,paint:i,boxBounds:Gt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Nt(t,e,i,r,a,n),s&&(qt(t,o),jt(t,o))):r.error?s&&Xt(t,o,r.error):(s&&(Vt(t,!0),qt(t,o)),a.loadId=r.load((()=>{Vt(t,!1),t.destroyed||(Nt(t,e,i,r,a,n)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),jt(t,o)),a.loadId=void 0}),(e=>{Vt(t,!1),Xt(t,o,e),a.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:d}=n;if(!d||n.patternId===a+"-"+o+"-"+r&&!M.running)return!1;if(s)if(d.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||M.running)){let{width:t,height:i}=d;t*=ie(a)*r,i*=ie(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,d),!0):(!n.style||n.sync||M.running?te(t,n,r):n.patternTask||(n.patternTask=v.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&te(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o,r;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,v.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:Ft,getPatternData:Ut,fillOrFitMode:Tt,clipMode:Ot,repeatMode:Wt},{toPoint:se}=L,{hasTransparent:ae}=C,oe={},re={};function de(t,e,i,n){if(i){let s,a,o,r;for(let t=0,d=i.length;t<d;t++)s=i[t],"string"==typeof s?(o=t/(d-1),a=C.string(s,n)):(o=s.offset,a=C.string(s.color,n)),e.addColorStop(o,a),!r&&ae(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:le,getDistance:ce}=R,{get:he,rotateOfOuter:ue,scaleOfOuter:fe}=k,{toPoint:pe}=L,_e={},ge={};function we(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=le(e,i);a=he(),s?(fe(a,e,o/r*(n||1),1),ue(a,e,t+90)):(fe(a,e,1,o/r*(n||1)),ue(a,e,t))}return a}const{getDistance:ye}=R,{toPoint:me}=L,xe={},ve={};const be={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:o}=t;se(n||"top",i,oe),se(s||"bottom",i,re);const r=e.canvas.createLinearGradient(oe.x,oe.y,re.x,re.y),d={type:a,style:r};return de(d,r,t.stops,o),d},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;pe(n||"center",i,_e),pe(s||"bottom",i,ge);const d=e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,ce(_e,ge)),l={type:a,style:d};de(l,d,t.stops,o);const c=we(i,_e,ge,r,!0);return c&&(l.transform=c),l},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;me(n||"center",i,xe),me(s||"bottom",i,ve);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,xe.x,xe.y):e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,ye(xe,ve)),l={type:a,style:d};de(l,d,t.stops,o);const c=we(i,xe,ve,r||1,e.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:we},{copy:Be,toOffsetOutBounds:ke}=B,Ee={},Se={};function Re(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Be(Ee,t.bounds),Ee.x+=i.x-o.x,Ee.y+=i.y-o.y,n){const{matrix:t}=s;Ee.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ee.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ee.width*=n,Ee.height*=n}t.copyWorld(s.canvas,t.bounds,Ee)}else n&&(Be(Ee,i),Ee.x-=i.width/2*(n-1),Ee.y-=i.height/2*(n-1),Ee.width*=n,Ee.height*=n),t.copyWorld(s.canvas,o,n?Ee:i)}const{toOffsetOutBounds:Ae}=B,Le={};const Te={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ke(l,Se),r.forEach(((r,_)=>{f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h,C.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Re(f,Se,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ae(l,Le),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Le.offsetX+r.x*h,Le.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Re(f,Le,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,C.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Oe}=_;function We(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),De(t,e,i,1)}(t,i,n,s);break;case"opacity-path":De(t,i,n,a);break;case"path":i.restore()}}function Ce(t){return t.getSameCanvas(!1,!0)}function De(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}I.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(o&&(We(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ce(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ce(t)),s||(s=Ce(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Oe(i,e)||i.__render(s||t,e);We(this,o,t,s,n,a)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ie=Me+"_#~&*+\\=|≮≯≈≠=…",Pe=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 Fe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ue=Fe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Fe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Fe(Me),ze=Fe(Ie),Ne=Fe("- —/~|┆·");var qe;!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"}(qe||(qe={}));const{Letter:je,Single:Xe,Before:He,After:Ve,Symbol:Qe,Break:Ze}=qe;function $e(t){return Ue[t]?je:Ne[t]?Ze:Ye[t]?He:Ge[t]?Ve:ze[t]?Qe:Pe.test(t)?Xe:je}const Je={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ke(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:ti}=Je,{Letter:ei,Single:ii,Before:ni,After:si,Symbol:ai,Break:oi}=qe;let ri,di,li,ci,hi,ui,fi,pi,_i,gi,wi,yi,mi,xi,vi,bi,Bi,ki=[];function Ei(t,e){_i&&!pi&&(pi=_i),ri.data.push({char:t,width:e}),li+=e}function Si(){ci+=li,ri.width=li,di.words.push(ri),ri={data:[]},li=0}function Ri(){xi&&(vi.paraNumber++,di.paraStart=!0,xi=!1),_i&&(di.startCharSize=pi,di.endCharSize=_i,pi=0),di.width=ci,bi.width?ti(di):Bi&&Ai(),ki.push(di),di={words:[]},ci=0}function Ai(){ci>(vi.maxWidth||0)&&(vi.maxWidth=ci)}const{top:Li,right:Ti,bottom:Oi,left:Wi}=T;function Ci(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 Di={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[Wi],a-=l[Ti]+l[Wi]):i.autoSizeAlign||(n=l[Wi]),o?(s=l[Li],o-=l[Li]+l[Oi]):i.autoSizeAlign||(s=l[Li]));const c={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){vi=t,ki=t.rows,bi=t.bounds,Bi=!bi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=bi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;xi=!0,wi=null,pi=fi=_i=li=ci=0,ri={data:[]},di={words:[]},s&&(i=[...i]);for(let n=0,l=i.length;n<l;n++)ui=i[n],"\n"===ui?(li&&Si(),di.paraEnd=!0,Ri(),xi=!0):(gi=$e(ui),gi===ei&&"none"!==o&&(ui=Ke(ui,o,!li)),fi=r.measureText(ui).width,s&&(s<0&&(_i=fi),fi+=s),yi=gi===ii&&(wi===ii||wi===ei)||wi===ii&&gi!==si,mi=!(gi!==ni&&gi!==ii||wi!==ai&&wi!==si),hi=xi&&a?d-a:d,t&&d&&ci+li+fi>hi&&(e?(li&&Si(),ci&&Ri()):(mi||(mi=gi===ei&&wi==si),yi||mi||gi===oi||gi===ni||gi===ii||li+fi>hi?(li&&Si(),ci&&Ri()):ci&&Ri()))," "===ui&&!0!==xi&&ci+li===0||(gi===oi?(" "===ui&&li&&Si(),Ei(ui,fi),Si()):yi||mi?(li&&Si(),Ei(ui,fi)):Ei(ui,fi)),wi=gi);li&&Si(),ci&&Ri(),ki.length>0&&(ki[ki.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{vi.paraNumber++,ci=r.measureText(t).width,ki.push({x:a||0,text:t,width:ci,paraStart:!0}),Bi&&Ai()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ci(e,"x",t[Wi]);break;case"right":Ci(e,"x",-t[Ti])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ci(e,"y",t[Li]);break;case"bottom":Ci(e,"y",-t[Oi])}}(l,c,i,a,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:_,height:g}=n,w=a*s+(h?h*(t.paraNumber-1):0),y=o;if(d&&w>g)w=Math.max(g,a),s>1&&(t.overflow=s);else if(g||u)switch(c){case"middle":p+=(g-w)/2;break;case"bottom":p+=g-w}y+=p;let m,x,v,b=_||u?_:t.maxWidth;for(let o=0,c=s;o<c;o++){if(m=i[o],m.x=f,m.width<_||m.width>_&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),x=m.x,v=m.width,r<0&&(m.width<0?(v=-m.width+e.fontSize+r,x-=v,v+=e.fontSize):v-=r),x<n.x&&(n.x=x),v>n.width&&(n.width=v),d&&_&&_<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,d,l,c,h,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,c=o||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,a),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=C.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,i),c}};const Mi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!C.object)return t;t=C.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(P,Di),Object.assign(C,Mi),Object.assign(W,vt),Object.assign(O,ne),Object.assign(D,be),Object.assign(F,Te),G();export{tt as Layouter,U as LeaferCanvas,it as Renderer,N as Watcher,G as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map