leafer-draw 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/web.cjs CHANGED
@@ -1143,7 +1143,7 @@ const PaintModule = {
1143
1143
  };
1144
1144
 
1145
1145
  let origin = {};
1146
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = core.MatrixHelper;
1146
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
1147
1147
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1148
1148
  const transform = get$3();
1149
1149
  translate$1(transform, box.x + x, box.y + y);
@@ -1152,13 +1152,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1152
1152
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
1153
1153
  data.transform = transform;
1154
1154
  }
1155
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1155
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
1156
1156
  const transform = get$3();
1157
- translate$1(transform, box.x + x, box.y + y);
1158
- if (scaleX)
1159
- scaleHelper(transform, scaleX, scaleY);
1160
1157
  if (rotation)
1161
1158
  rotate(transform, rotation);
1159
+ if (skew)
1160
+ skewHelper(transform, skew.x, skew.y);
1161
+ if (scaleX)
1162
+ scaleHelper(transform, scaleX, scaleY);
1163
+ translate$1(transform, box.x + x, box.y + y);
1162
1164
  data.transform = transform;
1163
1165
  }
1164
1166
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -1195,11 +1197,13 @@ const tempBox = new core.Bounds();
1195
1197
  const tempScaleData = {};
1196
1198
  const tempImage = {};
1197
1199
  function createData(leafPaint, image, paint, box) {
1198
- const { changeful, sync } = paint;
1200
+ const { changeful, sync, editing } = paint;
1199
1201
  if (changeful)
1200
1202
  leafPaint.changeful = changeful;
1201
1203
  if (sync)
1202
1204
  leafPaint.sync = sync;
1205
+ if (editing)
1206
+ leafPaint.editing = editing;
1203
1207
  leafPaint.data = getPatternData(paint, box, image);
1204
1208
  }
1205
1209
  function getPatternData(paint, box, image) {
@@ -1208,7 +1212,7 @@ function getPatternData(paint, box, image) {
1208
1212
  if (paint.mode === 'strench')
1209
1213
  paint.mode = 'stretch';
1210
1214
  let { width, height } = image;
1211
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1215
+ const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
1212
1216
  const sameBox = box.width === width && box.height === height;
1213
1217
  const data = { mode };
1214
1218
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1242,8 +1246,8 @@ function getPatternData(paint, box, image) {
1242
1246
  break;
1243
1247
  case 'normal':
1244
1248
  case 'clip':
1245
- if (tempImage.x || tempImage.y || scaleX || rotation)
1246
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1249
+ if (tempImage.x || tempImage.y || scaleX || rotation || skew)
1250
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
1247
1251
  break;
1248
1252
  case 'repeat':
1249
1253
  if (!sameBox || scaleX || rotation)
@@ -1320,11 +1324,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1320
1324
  }
1321
1325
  onLoadSuccess(ui, event);
1322
1326
  }
1323
- leafPaint.loadId = null;
1327
+ leafPaint.loadId = undefined;
1324
1328
  }, (error) => {
1325
1329
  ignoreRender(ui, false);
1326
1330
  onLoadError(ui, event, error);
1327
- leafPaint.loadId = null;
1331
+ leafPaint.loadId = undefined;
1328
1332
  });
1329
1333
  if (ui.placeholderColor) {
1330
1334
  if (!ui.placeholderDelay)
@@ -1390,6 +1394,8 @@ function createPattern(ui, paint, pixelRatio) {
1390
1394
  const { image, data } = paint;
1391
1395
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1392
1396
  if (sx) {
1397
+ sx = abs$1(sx);
1398
+ sy = abs$1(sy);
1393
1399
  imageMatrix = get$1();
1394
1400
  copy$1(imageMatrix, transform);
1395
1401
  scale(imageMatrix, 1 / sx, 1 / sy);
package/dist/web.esm.js CHANGED
@@ -1144,7 +1144,7 @@ const PaintModule = {
1144
1144
  };
1145
1145
 
1146
1146
  let origin = {};
1147
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
1147
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
1148
1148
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1149
1149
  const transform = get$3();
1150
1150
  translate$1(transform, box.x + x, box.y + y);
@@ -1153,13 +1153,15 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1153
1153
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
1154
1154
  data.transform = transform;
1155
1155
  }
1156
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1156
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
1157
1157
  const transform = get$3();
1158
- translate$1(transform, box.x + x, box.y + y);
1159
- if (scaleX)
1160
- scaleHelper(transform, scaleX, scaleY);
1161
1158
  if (rotation)
1162
1159
  rotate(transform, rotation);
1160
+ if (skew)
1161
+ skewHelper(transform, skew.x, skew.y);
1162
+ if (scaleX)
1163
+ scaleHelper(transform, scaleX, scaleY);
1164
+ translate$1(transform, box.x + x, box.y + y);
1163
1165
  data.transform = transform;
1164
1166
  }
1165
1167
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -1196,11 +1198,13 @@ const tempBox = new Bounds();
1196
1198
  const tempScaleData = {};
1197
1199
  const tempImage = {};
1198
1200
  function createData(leafPaint, image, paint, box) {
1199
- const { changeful, sync } = paint;
1201
+ const { changeful, sync, editing } = paint;
1200
1202
  if (changeful)
1201
1203
  leafPaint.changeful = changeful;
1202
1204
  if (sync)
1203
1205
  leafPaint.sync = sync;
1206
+ if (editing)
1207
+ leafPaint.editing = editing;
1204
1208
  leafPaint.data = getPatternData(paint, box, image);
1205
1209
  }
1206
1210
  function getPatternData(paint, box, image) {
@@ -1209,7 +1213,7 @@ function getPatternData(paint, box, image) {
1209
1213
  if (paint.mode === 'strench')
1210
1214
  paint.mode = 'stretch';
1211
1215
  let { width, height } = image;
1212
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1216
+ const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
1213
1217
  const sameBox = box.width === width && box.height === height;
1214
1218
  const data = { mode };
1215
1219
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1243,8 +1247,8 @@ function getPatternData(paint, box, image) {
1243
1247
  break;
1244
1248
  case 'normal':
1245
1249
  case 'clip':
1246
- if (tempImage.x || tempImage.y || scaleX || rotation)
1247
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1250
+ if (tempImage.x || tempImage.y || scaleX || rotation || skew)
1251
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
1248
1252
  break;
1249
1253
  case 'repeat':
1250
1254
  if (!sameBox || scaleX || rotation)
@@ -1321,11 +1325,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1321
1325
  }
1322
1326
  onLoadSuccess(ui, event);
1323
1327
  }
1324
- leafPaint.loadId = null;
1328
+ leafPaint.loadId = undefined;
1325
1329
  }, (error) => {
1326
1330
  ignoreRender(ui, false);
1327
1331
  onLoadError(ui, event, error);
1328
- leafPaint.loadId = null;
1332
+ leafPaint.loadId = undefined;
1329
1333
  });
1330
1334
  if (ui.placeholderColor) {
1331
1335
  if (!ui.placeholderDelay)
@@ -1391,6 +1395,8 @@ function createPattern(ui, paint, pixelRatio) {
1391
1395
  const { image, data } = paint;
1392
1396
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1393
1397
  if (sx) {
1398
+ sx = abs$1(sx);
1399
+ sy = abs$1(sy);
1394
1400
  imageMatrix = get$1();
1395
1401
  copy$1(imageMatrix, transform);
1396
1402
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as a,FileHelper as r,Creator as d,LeaferImage as l,defineKey as h,LeafList as c,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,LeafBoundsHelper as y,Bounds as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as E,MatrixHelper as k,MathHelper as R,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as T,Paint as W,ColorConvert as D,PaintGradient as I,Export as M,Group as P,TextConvert as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const U=t.get("LeaferCanvas");class V extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else U.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),U.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:Y,fileType:G}=r;function N(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Y(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,Y(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Y(G(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new V(t,e),image:t=>new l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},h(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):j.indexOf("AppleWebKit")>-1&&(i.fullImageShadow=!0),j.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):j.indexOf("Mac")>-1?i.os="Mac":j.indexOf("Linux")>-1&&(i.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=s.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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[g.CHANGE,this.__onAttrChange,this],[[f.ADD,f.REMOVE],this.__onChildEvent,this],[p.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:X,updateBounds:H,updateChange:Q}=_,{pushAllChildBranch:Z,pushAllParent:$}=w;const{worldBounds:K}=y;class J{constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,K),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}=_,it=t.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){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(p.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(X(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||H(s[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),st.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new J([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new J(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[p.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=t.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=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(u.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(u.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,nt.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(ot.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new m;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 e=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),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 m(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 m(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||nt.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 u(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[u.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[u.AGAIN,this.renderAgain,this],[o.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function at(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function rt(t,e){t.__.__font?at(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dt(t,e,i){switch(e.__.strokeAlign){case"center":lt(t,1,e,i);break;case"inside":ht(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?lt(t,2,e,i):ht(t,"outside",e,i)}}function lt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ft(t,!0,i,s):ut(i,s)}function ht(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,lt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",at(i,n),n.blendMode="normal",ct(s,n,i),n.recycle(i.__nowWorld)}function ct(t,e,s){s.__worldFlipped||i.fullImageShadow?t.copyWorldByReset(e,s.__nowWorld):t.copyWorldToInner(e,s.__nowWorld,s.__layout.renderBounds)}function ut(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=s;n.forEach((i=>o.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function ft(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&T.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ut(i,s):s.stroke(),s.restoreBlendMode()):e?ut(i,s):s.stroke())}function pt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)dt(t,e,i);else switch(s.strokeAlign){case"center":gt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),gt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)gt(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),gt(t,2,e,o),o.clipUI(s),o.clearWorld(n),ct(i,o,e),o.recycle(e.__nowWorld)}}(t,e,i)}}function gt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ft(t,!1,i,s):s.stroke(),n.__useArrow&&W.strokeArrow(t,i,s)}ot.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=st.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=E;let vt;const{stintSet:xt}=s,{hasTransparent:bt}=D;function Bt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=T.image(i,t,e,n,!vt||!vt[e.url]);break;case"linear":s=I.linearGradient(e,n);break;case"radial":s=I.radialGradient(e,n);break;case"angular":s=I.conicGradient(e,n);break;case"solid":const{type:o,color:a,opacity:r}=e;s={type:o,style:D.string(a,r)};break;default:void 0!==e.r&&(s={type:"solid",style:D.string(e)})}return s&&("string"==typeof s.style&&bt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Et={compute:function(t,e){const i=e.__,s=[];let n,o,a=i.__input[t];a instanceof Array||(a=[a]),vt=T.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Bt(t,a[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),o=!0),"fill"===t?(xt(i,"__isAlphaPixelFill",n),xt(i,"__isTransparentFill",o)):(xt(i,"__isAlphaPixelStroke",n),xt(i,"__isTransparentStroke",o))},fill:function(t,e,i){i.fillStyle=t,rt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(T.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),rt(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),rt(e,i),i.restoreBlendMode()):rt(e,i)}},fillPathOrText:rt,fillText:at,stroke:pt,strokes:function(t,e,i){pt(t,e,i)},strokeText:dt,drawTextStroke:ut,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=mt(s?_t(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=wt(n,a),o=yt(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(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let kt={};const{get:Rt,rotateOfOuter:St,translate:Lt,scaleOfOuter:At,scale:Ot,rotate:Ct}=k;function Tt(t,e,i,s,n,o,a){const r=Rt();Lt(r,e.x+i,e.y+s),Ot(r,n,o),a&&St(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Wt(t,e,i,s,n,o,a){const r=Rt();Lt(r,e.x+i,e.y+s),n&&Ot(r,n,o),a&&Ct(r,a),t.transform=r}function Dt(t,e,i,s,n,o,a,r,d,l){const h=Rt();if(d)if("center"===l)St(h,{x:i/2,y:s/2},d);else switch(Ct(h,d),d){case 90:Lt(h,s,0);break;case 180:Lt(h,i,s);break;case 270:Lt(h,0,i)}kt.x=e.x+n,kt.y=e.y+o,Lt(h,kt.x,kt.y),a&&At(h,kt,a,r),t.transform=h}const{get:It,translate:Mt}=k,Pt=new m,zt={},Ft={};function Ut(t,e,i,s){const{changeful:n,sync:o}=i;n&&(t.changeful=n),o&&(t.sync=o),t.data=Vt(i,s,e)}function Vt(t,e,i){t.padding&&(e=Pt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:f}=t,p=e.width===s&&e.height===n,g={mode:a},_="center"!==r&&(c||0)%180==90;let w,y;switch(E.set(Ft,0,0,_?n:s,_?s:n),a&&"cover"!==a&&"fit"!==a?((l||h)&&(R.getScaleData(l,h,i,zt),w=zt.scaleX,y=zt.scaleY),r&&(w&&E.scale(Ft,w,y,!0),S.toPoint(r,Ft,e,Ft,!0,!0))):p&&!c||(w=y=E.getFitScale(e,Ft,"fit"!==a),E.put(e,i,r,w,!1,Ft),E.scale(Ft,w,y,!0)),d&&L.move(Ft,d),a){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(Ft.x||Ft.y||w||c)&&Wt(g,e,Ft.x,Ft.y,w,y,c);break;case"repeat":(!p||w||c)&&Dt(g,e,s,n,Ft.x,Ft.y,w,y,c,r),u||(g.repeat="repeat");break;default:w&&Tt(g,e,Ft.x,Ft.y,w,y,c)}return g.transform||(e.x||e.y)&&(g.transform=It(),Mt(g.transform,e.x,e.y)),w&&"stretch"!==a&&(g.scaleX=w,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Yt,Gt=new m;const{isSame:Nt}=E;function jt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ut(n,s,i,o),!0}function qt(t,e){Qt(t,A.LOAD,e)}function Xt(t,e){Qt(t,A.LOADED,e)}function Ht(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,A.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Zt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:$t,scale:Kt,copy:Jt}=k,{ceil:te,abs:ee}=Math;function ie(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(e.patternId===a||t.destroyed)return!1;{n=ee(n),o=ee(o);const{image:t,data:r}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(l=$t(),Jt(l,p),Kt(l,1/u,1/f),n*=u,o*=f),n*=s,o*=s,h*=n,c*=o;const _=h*c;if(!g&&_>i.image.maxCacheSize)return!1;let w=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(d=Math.sqrt(_/w)),d&&(n/=d,o/=d,h/=d,c/=d),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=$t(),p&&Jt(l,p)),Kt(l,1/n,1/o));const y=t.getCanvas(te(h)||1,te(c)||1,r.opacity,r.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=a,!0}}function se(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{d(s.next(t))}catch(t){o(t)}}function r(t){try{d(s.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ne}=Math;const oe={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Yt&&i===Yt.paint&&Nt(s,Yt.boxBounds)?o=Yt.leafPaint:(o={type:i.type,image:r},r.hasAlphaPixel&&(o.isTransparent=!0),Yt=r.use>1?{leafPaint:o,paint:i,boxBounds:Gt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(jt(t,e,i,r,o,s),n&&(qt(t,a),Xt(t,a))):r.error?n&&Ht(t,a,r.error):(n&&(Zt(t,!0),qt(t,a)),o.loadId=r.load((()=>{Zt(t,!1),t.destroyed||(jt(t,e,i,r,o,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Xt(t,a)),o.loadId=null}),(e=>{Zt(t,!1),Ht(t,a,e),o.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+d&&!M.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||M.running)){let{width:t,height:e}=l;t*=ne(a)*d,e*=ne(r)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||M.running?ie(t,s,d):s.patternTask||(s.patternTask=B.patternTasker.add((()=>se(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&ie(t,s,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:ie,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Ut,getPatternData:Vt,fillOrFitMode:Tt,clipMode:Wt,repeatMode:Dt},{toPoint:ae}=O,{hasTransparent:re}=D,de={},le={};function he(t,e,i,s){if(i){let n,o,a,r;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(a=t/(d-1),o=D.string(n,s)):(a=n.offset,o=D.string(n.color,s)),e.addColorStop(a,o),!r&&re(o)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ce,getDistance:ue}=L,{get:fe,rotateOfOuter:pe,scaleOfOuter:ge}=k,{toPoint:_e}=O,we={},ye={};function me(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=ce(e,i);o=fe(),n?(ge(o,e,a/r*(s||1),1),pe(o,e,t+90)):(ge(o,e,1,a/r*(s||1)),pe(o,e,t))}return o}const{getDistance:ve}=L,{toPoint:xe}=O,be={},Be={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:a}=t;ae(s||"top",e,de),ae(n||"bottom",e,le);const r=i.canvas.createLinearGradient(de.x,de.y,le.x,le.y),d={type:o,style:r};return he(d,r,t.stops,a),d},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;_e(s||"center",e,we),_e(n||"bottom",e,ye);const d=i.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,ue(we,ye)),l={type:o,style:d};he(l,d,t.stops,a);const h=me(e,we,ye,r,!0);return h&&(l.transform=h),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;xe(s||"center",e,be),xe(n||"bottom",e,Be);const d=i.conicGradientSupport?i.canvas.createConicGradient(0,be.x,be.y):i.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,ve(be,Be)),l={type:o,style:d};he(l,d,t.stops,a);const h=me(e,be,Be,r||1,i.conicGradientRotate90);return h&&(l.transform=h),l},getTransform:me},{copy:ke,toOffsetOutBounds:Re}=E,Se={},Le={};function Ae(t,e,s,n){const{bounds:o,shapeBounds:a}=n;if(i.fullImageShadow){if(ke(Se,t.bounds),Se.x+=e.x-a.x,Se.y+=e.y-a.y,s){const{matrix:t}=n;Se.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Se.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Se.width*=s,Se.height*=s}t.copyWorld(n.canvas,t.bounds,Se)}else s&&(ke(Se,e),Se.x-=e.width/2*(s-1),Se.y-=e.height/2*(s-1),Se.width*=s,Se.height*=s),t.copyWorld(n.canvas,a,s?Se:e)}const{toOffsetOutBounds:Oe}=E,Ce={};const Te={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,Le),r.forEach(((r,g)=>{f.setWorldShadow(Le.offsetX+r.x*c,Le.offsetY+r.y*u,r.blur*c,D.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ae(f,Le,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),s=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Oe(l,Ce),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ae(f,Ce,n,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:We}=y;function De(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Me(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Me(t,i,s,o);break;case"path":i.restore()}}function Ie(t){return t.getSameCanvas(!1,!0)}function Me(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}P.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(a&&(De(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ie(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Ie(t)),n||(n=Ie(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||We(i,e)||i.__render(n||t,e);De(this,a,t,n,s,o)};const Pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ze=Pe+"_#~&*+\\=|≮≯≈≠=…",Fe=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 Ue(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ve=Ue("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Ue("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Ue(Pe),Ne=Ue(ze),je=Ue("- —/~|┆·");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:Xe,Single:He,Before:Qe,After:Ze,Symbol:$e,Break:Ke}=qe;function Je(t){return Ve[t]?Xe:je[t]?Ke:Ye[t]?Qe:Ge[t]?Ze:Ne[t]?$e:Fe.test(t)?He:Xe}const ti={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ei(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:ii}=ti,{Letter:si,Single:ni,Before:oi,After:ai,Symbol:ri,Break:di}=qe;let li,hi,ci,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi,Bi,Ei,ki,Ri=[];function Si(t,e){wi&&!_i&&(_i=wi),li.data.push({char:t,width:e}),ci+=e}function Li(){ui+=ci,li.width=ci,hi.words.push(li),li={data:[]},ci=0}function Ai(){bi&&(Bi.paraNumber++,hi.paraStart=!0,bi=!1),wi&&(hi.startCharSize=_i,hi.endCharSize=wi,_i=0),hi.width=ui,Ei.width?ii(hi):ki&&Oi(),Ri.push(hi),hi={words:[]},ui=0}function Oi(){ui>(Bi.maxWidth||0)&&(Bi.maxWidth=ui)}const{top:Ci,right:Ti,bottom:Wi,left:Di}=C;function Ii(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Mi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(s=l[Di],o-=l[Ti]+l[Di]):e.autoSizeAlign||(s=l[Di]),a?(n=l[Ci],a-=l[Ci]+l[Wi]):e.autoSizeAlign||(n=l[Ci]));const h={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){Bi=t,Ri=t.rows,Ei=t.bounds,ki=!Ei.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=i,{width:d,height:l}=Ei;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,i="break"===s.textWrap;bi=!0,mi=null,_i=gi=wi=ci=ui=0,li={data:[]},hi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)pi=e[s],"\n"===pi?(ci&&Li(),hi.paraEnd=!0,Ai(),bi=!0):(yi=Je(pi),yi===si&&"none"!==a&&(pi=ei(pi,a,!ci)),gi=r.measureText(pi).width,n&&(n<0&&(wi=gi),gi+=n),vi=yi===ni&&(mi===ni||mi===si)||mi===ni&&yi!==ai,xi=!(yi!==oi&&yi!==ni||mi!==ri&&mi!==ai),fi=bi&&o?d-o:d,t&&d&&ui+ci+gi>fi&&(i?(ci&&Li(),ui&&Ai()):(xi||(xi=yi===si&&mi==ai),vi||xi||yi===di||yi===oi||yi===ni||ci+gi>fi?(ci&&Li(),ui&&Ai()):ui&&Ai()))," "===pi&&!0!==bi&&ui+ci===0||(yi===di?(" "===pi&&ci&&Li(),Si(pi,gi),Li()):vi||xi?(ci&&Li(),Si(pi,gi)):Si(pi,gi)),mi=yi);ci&&Li(),ui&&Ai(),Ri.length>0&&(Ri[Ri.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Bi.paraNumber++,ui=r.measureText(t).width,Ri.push({x:o||0,text:t,width:ui,paraStart:!0}),ki&&Oi()}))}(h,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ii(e,"x",t[Di]);break;case"right":Ii(e,"x",-t[Ti])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ii(e,"y",t[Ci]);break;case"bottom":Ii(e,"y",-t[Wi])}}(l,h,e,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(c?c*(t.paraNumber-1):0),y=a;if(d&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let a=0,h=n;a<h;a++){if(m=i[a],m.x=f,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(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===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,h=s+n-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char||!s){e.data.splice(s+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)}}))}}(h,e,s,o),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=D.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,e),h}};const Pi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(z,Mi),Object.assign(D,Pi),Object.assign(W,Et),Object.assign(T,oe),Object.assign(I,Ee),Object.assign(F,Te),N();export{st as Layouter,V as LeaferCanvas,ot as Renderer,q as Watcher,N as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as a,FileHelper as r,Creator as d,LeaferImage as l,defineKey as h,LeafList as c,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,LeafBoundsHelper as y,Bounds as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as k,MatrixHelper as E,MathHelper as R,AlignHelper as S,PointHelper as L,ImageEvent as A,AroundHelper as O,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as T,Paint as W,ColorConvert as D,PaintGradient as I,Export as M,Group as P,TextConvert as z,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const U=t.get("LeaferCanvas");class V extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else U.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),U.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:Y,fileType:G}=r;function N(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Y(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,Y(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(Y(G(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new V(t,e),image:t=>new l(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},h(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):j.indexOf("AppleWebKit")>-1&&(i.fullImageShadow=!0),j.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):j.indexOf("Mac")>-1?i.os="Mac":j.indexOf("Linux")>-1&&(i.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=s.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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[g.CHANGE,this.__onAttrChange,this],[[f.ADD,f.REMOVE],this.__onChildEvent,this],[p.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:X,updateBounds:H,updateChange:Q}=_,{pushAllChildBranch:Z,pushAllParent:$}=w;const{worldBounds:K}=y;class J{constructor(t){this.updatedBounds=new m,this.beforeBounds=new m,this.afterBounds=new m,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,K),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}=_,it=t.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){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(p.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(X(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||H(s[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),st.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new J([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new J(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[p.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=t.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=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(u.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(u.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new m,nt.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new m,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new m(s);i.save(),s.spread(ot.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new m;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 e=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),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 m(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 m(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||nt.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 u(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[u.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[u.AGAIN,this.renderAgain,this],[o.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function at(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function rt(t,e){t.__.__font?at(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dt(t,e,i){switch(e.__.strokeAlign){case"center":lt(t,1,e,i);break;case"inside":ht(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?lt(t,2,e,i):ht(t,"outside",e,i)}}function lt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?ft(t,!0,i,s):ut(i,s)}function ht(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,lt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",at(i,n),n.blendMode="normal",ct(s,n,i),n.recycle(i.__nowWorld)}function ct(t,e,s){s.__worldFlipped||i.fullImageShadow?t.copyWorldByReset(e,s.__nowWorld):t.copyWorldToInner(e,s.__nowWorld,s.__layout.renderBounds)}function ut(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=s;n.forEach((i=>o.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function ft(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&T.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ut(i,s):s.stroke(),s.restoreBlendMode()):e?ut(i,s):s.stroke())}function pt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)dt(t,e,i);else switch(s.strokeAlign){case"center":gt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),gt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)gt(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),gt(t,2,e,o),o.clipUI(s),o.clearWorld(n),ct(i,o,e),o.recycle(e.__nowWorld)}}(t,e,i)}}function gt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?ft(t,!1,i,s):s.stroke(),n.__useArrow&&W.strokeArrow(t,i,s)}ot.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=st.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=k;let vt;const{stintSet:xt}=s,{hasTransparent:bt}=D;function Bt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=T.image(i,t,e,n,!vt||!vt[e.url]);break;case"linear":s=I.linearGradient(e,n);break;case"radial":s=I.radialGradient(e,n);break;case"angular":s=I.conicGradient(e,n);break;case"solid":const{type:o,color:a,opacity:r}=e;s={type:o,style:D.string(a,r)};break;default:void 0!==e.r&&(s={type:"solid",style:D.string(e)})}return s&&("string"==typeof s.style&&bt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const kt={compute:function(t,e){const i=e.__,s=[];let n,o,a=i.__input[t];a instanceof Array||(a=[a]),vt=T.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Bt(t,a[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),o=!0),"fill"===t?(xt(i,"__isAlphaPixelFill",n),xt(i,"__isTransparentFill",o)):(xt(i,"__isAlphaPixelStroke",n),xt(i,"__isTransparentStroke",o))},fill:function(t,e,i){i.fillStyle=t,rt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(T.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),rt(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),rt(e,i),i.restoreBlendMode()):rt(e,i)}},fillPathOrText:rt,fillText:at,stroke:pt,strokes:function(t,e,i){pt(t,e,i)},strokeText:dt,drawTextStroke:ut,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=mt(s?_t(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=wt(n,a),o=yt(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(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Et={};const{get:Rt,rotateOfOuter:St,translate:Lt,scaleOfOuter:At,scale:Ot,rotate:Ct,skew:Tt}=E;function Wt(t,e,i,s,n,o,a){const r=Rt();Lt(r,e.x+i,e.y+s),Ot(r,n,o),a&&St(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Dt(t,e,i,s,n,o,a,r){const d=Rt();a&&Ct(d,a),r&&Tt(d,r.x,r.y),n&&Ot(d,n,o),Lt(d,e.x+i,e.y+s),t.transform=d}function It(t,e,i,s,n,o,a,r,d,l){const h=Rt();if(d)if("center"===l)St(h,{x:i/2,y:s/2},d);else switch(Ct(h,d),d){case 90:Lt(h,s,0);break;case 180:Lt(h,i,s);break;case 270:Lt(h,0,i)}Et.x=e.x+n,Et.y=e.y+o,Lt(h,Et.x,Et.y),a&&At(h,Et,a,r),t.transform=h}const{get:Mt,translate:Pt}=E,zt=new m,Ft={},Ut={};function Vt(t,e,i,s){const{changeful:n,sync:o,editing:a}=i;n&&(t.changeful=n),o&&(t.sync=o),a&&(t.editing=a),t.data=Yt(i,s,e)}function Yt(t,e,i){t.padding&&(e=zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,skew:u,repeat:f,filters:p}=t,g=e.width===s&&e.height===n,_={mode:a},w="center"!==r&&(c||0)%180==90;let y,m;switch(k.set(Ut,0,0,w?n:s,w?s:n),a&&"cover"!==a&&"fit"!==a?((l||h)&&(R.getScaleData(l,h,i,Ft),y=Ft.scaleX,m=Ft.scaleY),r&&(y&&k.scale(Ut,y,m,!0),S.toPoint(r,Ut,e,Ut,!0,!0))):g&&!c||(y=m=k.getFitScale(e,Ut,"fit"!==a),k.put(e,i,r,y,!1,Ut),k.scale(Ut,y,m,!0)),d&&L.move(Ut,d),a){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(Ut.x||Ut.y||y||c||u)&&Dt(_,e,Ut.x,Ut.y,y,m,c,u);break;case"repeat":(!g||y||c)&&It(_,e,s,n,Ut.x,Ut.y,y,m,c,r),f||(_.repeat="repeat");break;default:y&&Wt(_,e,Ut.x,Ut.y,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=Mt(),Pt(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=s,_.height=n,o&&(_.opacity=o),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let Gt,Nt=new m;const{isSame:jt}=k;function qt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Vt(n,s,i,o),!0}function Xt(t,e){Zt(t,A.LOAD,e)}function Ht(t,e){Zt(t,A.LOADED,e)}function Qt(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,A.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Kt,scale:Jt,copy:te}=E,{ceil:ee,abs:ie}=Math;function se(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(e.patternId===a||t.destroyed)return!1;{n=ie(n),o=ie(o);const{image:t,data:r}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(u=ie(u),f=ie(f),l=Kt(),te(l,p),Jt(l,1/u,1/f),n*=u,o*=f),n*=s,o*=s,h*=n,c*=o;const _=h*c;if(!g&&_>i.image.maxCacheSize)return!1;let w=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(d=Math.sqrt(_/w)),d&&(n/=d,o/=d,h/=d,c/=d),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=Kt(),p&&te(l,p)),Jt(l,1/n,1/o));const y=t.getCanvas(ee(h)||1,ee(c)||1,r.opacity,r.filters),m=t.getPattern(y,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=a,!0}}function ne(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{d(s.next(t))}catch(t){o(t)}}function r(t){try{d(s.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:oe}=Math;const ae={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Gt&&i===Gt.paint&&jt(s,Gt.boxBounds)?o=Gt.leafPaint:(o={type:i.type,image:r},r.hasAlphaPixel&&(o.isTransparent=!0),Gt=r.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(qt(t,e,i,r,o,s),n&&(Xt(t,a),Ht(t,a))):r.error?n&&Qt(t,a,r.error):(n&&($t(t,!0),Xt(t,a)),o.loadId=r.load((()=>{$t(t,!1),t.destroyed||(qt(t,e,i,r,o,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ht(t,a)),o.loadId=void 0}),(e=>{$t(t,!1),Qt(t,a,e),o.loadId=void 0})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:d}=e,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+d&&!M.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||M.running)){let{width:t,height:e}=l;t*=oe(a)*d,e*=oe(r)*d,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,l),!0):(!s.style||s.sync||M.running?se(t,s,d):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ne(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&se(t,s,d),t.forceUpdate("surface")}))),300)),!1)},createPattern:se,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let d=0,l=i.length;d<l;d++)s=i[d],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[d].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Vt,getPatternData:Yt,fillOrFitMode:Wt,clipMode:Dt,repeatMode:It},{toPoint:re}=O,{hasTransparent:de}=D,le={},he={};function ce(t,e,i,s){if(i){let n,o,a,r;for(let t=0,d=i.length;t<d;t++)n=i[t],"string"==typeof n?(a=t/(d-1),o=D.string(n,s)):(a=n.offset,o=D.string(n.color,s)),e.addColorStop(a,o),!r&&de(o)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:ue,getDistance:fe}=L,{get:pe,rotateOfOuter:ge,scaleOfOuter:_e}=E,{toPoint:we}=O,ye={},me={};function ve(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=ue(e,i);o=pe(),n?(_e(o,e,a/r*(s||1),1),ge(o,e,t+90)):(_e(o,e,1,a/r*(s||1)),ge(o,e,t))}return o}const{getDistance:xe}=L,{toPoint:be}=O,Be={},ke={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:a}=t;re(s||"top",e,le),re(n||"bottom",e,he);const r=i.canvas.createLinearGradient(le.x,le.y,he.x,he.y),d={type:o,style:r};return ce(d,r,t.stops,a),d},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;we(s||"center",e,ye),we(n||"bottom",e,me);const d=i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,fe(ye,me)),l={type:o,style:d};ce(l,d,t.stops,a);const h=ve(e,ye,me,r,!0);return h&&(l.transform=h),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,stretch:r}=t;be(s||"center",e,Be),be(n||"bottom",e,ke);const d=i.conicGradientSupport?i.canvas.createConicGradient(0,Be.x,Be.y):i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,xe(Be,ke)),l={type:o,style:d};ce(l,d,t.stops,a);const h=ve(e,Be,ke,r||1,i.conicGradientRotate90);return h&&(l.transform=h),l},getTransform:ve},{copy:Re,toOffsetOutBounds:Se}=k,Le={},Ae={};function Oe(t,e,s,n){const{bounds:o,shapeBounds:a}=n;if(i.fullImageShadow){if(Re(Le,t.bounds),Le.x+=e.x-a.x,Le.y+=e.y-a.y,s){const{matrix:t}=n;Le.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Le.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(Re(Le,e),Le.x-=e.width/2*(s-1),Le.y-=e.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,a,s?Le:e)}const{toOffsetOutBounds:Ce}=k,Te={};const We={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Se(l,Ae),r.forEach(((r,g)=>{f.setWorldShadow(Ae.offsetX+r.x*c,Ae.offsetY+r.y*u,r.blur*c,D.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Oe(f,Ae,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),s=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ce(l,Te),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Te.offsetX+r.x*c,Te.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Oe(f,Te,n,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:De}=y;function Ie(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Pe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Pe(t,i,s,o);break;case"path":i.restore()}}function Me(t){return t.getSameCanvas(!1,!0)}function Pe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}P.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(a&&(Ie(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Me(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Me(t)),n||(n=Me(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||De(i,e)||i.__render(n||t,e);Ie(this,a,t,n,s,o)};const ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Fe=ze+"_#~&*+\\=|≮≯≈≠=…",Ue=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 Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ye=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ge=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ne=Ve(ze),je=Ve(Fe),qe=Ve("- —/~|┆·");var Xe;!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"}(Xe||(Xe={}));const{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Ke,Break:Je}=Xe;function ti(t){return Ye[t]?He:qe[t]?Je:Ge[t]?Ze:Ne[t]?$e:je[t]?Ke:Ue.test(t)?Qe:He}const ei={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ii(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:si}=ei,{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:di,Break:li}=Xe;let hi,ci,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi,Bi,ki,Ei,Ri,Si=[];function Li(t,e){yi&&!wi&&(wi=yi),hi.data.push({char:t,width:e}),ui+=e}function Ai(){fi+=ui,hi.width=ui,ci.words.push(hi),hi={data:[]},ui=0}function Oi(){Bi&&(ki.paraNumber++,ci.paraStart=!0,Bi=!1),yi&&(ci.startCharSize=wi,ci.endCharSize=yi,wi=0),ci.width=fi,Ei.width?si(ci):Ri&&Ci(),Si.push(ci),ci={words:[]},fi=0}function Ci(){fi>(ki.maxWidth||0)&&(ki.maxWidth=fi)}const{top:Ti,right:Wi,bottom:Di,left:Ii}=C;function Mi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Pi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(s=l[Ii],o-=l[Wi]+l[Ii]):e.autoSizeAlign||(s=l[Ii]),a?(n=l[Ti],a-=l[Ti]+l[Di]):e.autoSizeAlign||(n=l[Ti]));const h={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){ki=t,Si=t.rows,Ei=t.bounds,Ri=!Ei.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=i,{width:d,height:l}=Ei;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,i="break"===s.textWrap;Bi=!0,vi=null,wi=_i=yi=ui=fi=0,hi={data:[]},ci={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)gi=e[s],"\n"===gi?(ui&&Ai(),ci.paraEnd=!0,Oi(),Bi=!0):(mi=ti(gi),mi===ni&&"none"!==a&&(gi=ii(gi,a,!ui)),_i=r.measureText(gi).width,n&&(n<0&&(yi=_i),_i+=n),xi=mi===oi&&(vi===oi||vi===ni)||vi===oi&&mi!==ri,bi=!(mi!==ai&&mi!==oi||vi!==di&&vi!==ri),pi=Bi&&o?d-o:d,t&&d&&fi+ui+_i>pi&&(i?(ui&&Ai(),fi&&Oi()):(bi||(bi=mi===ni&&vi==ri),xi||bi||mi===li||mi===ai||mi===oi||ui+_i>pi?(ui&&Ai(),fi&&Oi()):fi&&Oi()))," "===gi&&!0!==Bi&&fi+ui===0||(mi===li?(" "===gi&&ui&&Ai(),Li(gi,_i),Ai()):xi||bi?(ui&&Ai(),Li(gi,_i)):Li(gi,_i)),vi=mi);ui&&Ai(),fi&&Oi(),Si.length>0&&(Si[Si.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ki.paraNumber++,fi=r.measureText(t).width,Si.push({x:o||0,text:t,width:fi,paraStart:!0}),Ri&&Ci()}))}(h,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Mi(e,"x",t[Ii]);break;case"right":Mi(e,"x",-t[Wi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Mi(e,"y",t[Ti]);break;case"bottom":Mi(e,"y",-t[Di])}}(l,h,e,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(c?c*(t.paraNumber-1):0),y=a;if(d&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let a=0,h=n;a<h;a++){if(m=i[a],m.x=f,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),d&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,d,l,h,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,h=a||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(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===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==n||i===u-1||(r+=d,t.width+=d)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,h=s+n-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char||!s){e.data.splice(s+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)}}))}}(h,e,s,o),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=D.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,e),h}};const zi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(z,Pi),Object.assign(D,zi),Object.assign(W,kt),Object.assign(T,ae),Object.assign(I,Ee),Object.assign(F,We),N();export{st as Layouter,V as LeaferCanvas,ot as Renderer,q as Watcher,N as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map