@leafer-ui/core 1.0.0-rc.5 → 1.0.0-rc.6

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/core.cjs CHANGED
@@ -490,8 +490,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
490
490
  set(data) {
491
491
  Object.assign(this, data);
492
492
  }
493
- get() {
494
- return this.__.__getInputData();
493
+ get(options) {
494
+ return this.__.__getInputData(options);
495
+ }
496
+ getProxyData() { return undefined; }
497
+ find(condition) {
498
+ return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
499
+ }
500
+ findOne(condition) {
501
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
495
502
  }
496
503
  getPath(curve) {
497
504
  const path = this.__.path;
@@ -615,6 +622,9 @@ __decorate([
615
622
  __decorate([
616
623
  core.strokeType('path')
617
624
  ], exports.UI.prototype, "hitStroke", void 0);
625
+ __decorate([
626
+ core.hitType(false)
627
+ ], exports.UI.prototype, "hitBox", void 0);
618
628
  __decorate([
619
629
  core.hitType(true)
620
630
  ], exports.UI.prototype, "hitChildren", void 0);
@@ -923,7 +933,7 @@ exports.Ellipse = class Ellipse extends exports.UI {
923
933
  }
924
934
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
925
935
  }
926
- if (core.Platform.name === 'node')
936
+ if (core.Platform.ellipseToCurve)
927
937
  this.__.path = core.PathConvert.toCanvasData(path, true);
928
938
  }
929
939
  else {
@@ -1234,7 +1244,7 @@ exports.Canvas = __decorate([
1234
1244
  core.registerUI()
1235
1245
  ], exports.Canvas);
1236
1246
 
1237
- const { copyAndSpread, includes, spread } = core.BoundsHelper;
1247
+ const { copyAndSpread, includes, spread, setByList } = core.BoundsHelper;
1238
1248
  exports.Text = class Text extends exports.UI {
1239
1249
  get __tag() { return 'Text'; }
1240
1250
  get textDrawData() {
@@ -1268,18 +1278,19 @@ exports.Text = class Text extends exports.UI {
1268
1278
  __updateBoxBounds() {
1269
1279
  const data = this.__;
1270
1280
  const layout = this.__layout;
1271
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data;
1281
+ const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
1282
+ const width = data.__getInput('width');
1283
+ const height = data.__getInput('height');
1272
1284
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
1273
1285
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
1274
1286
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1275
1287
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1288
+ data.__clipText = textOverflow !== 'show' && (width || height);
1276
1289
  this.__updateTextDrawData();
1277
1290
  const { bounds } = data.__textDrawData;
1278
1291
  const b = layout.boxBounds;
1279
1292
  if (data.__lineHeight < fontSize)
1280
1293
  spread(bounds, fontSize / 2);
1281
- const width = data.__getInput('width');
1282
- const height = data.__getInput('height');
1283
1294
  if (width && height) {
1284
1295
  super.__updateBoxBounds();
1285
1296
  }
@@ -1294,6 +1305,10 @@ exports.Text = class Text extends exports.UI {
1294
1305
  if (contentBounds !== layout.contentBounds) {
1295
1306
  layout.contentBounds = contentBounds;
1296
1307
  layout.renderChanged = true;
1308
+ setByList(data.__textBoxBounds = {}, [b, bounds]);
1309
+ }
1310
+ else {
1311
+ data.__textBoxBounds = contentBounds;
1297
1312
  }
1298
1313
  }
1299
1314
  __updateRenderSpread() {
@@ -1303,7 +1318,7 @@ exports.Text = class Text extends exports.UI {
1303
1318
  return width;
1304
1319
  }
1305
1320
  __updateRenderBounds() {
1306
- copyAndSpread(this.__layout.renderBounds, this.__layout.contentBounds, this.__layout.renderSpread);
1321
+ copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
1307
1322
  }
1308
1323
  };
1309
1324
  __decorate([
@@ -1321,6 +1336,9 @@ __decorate([
1321
1336
  __decorate([
1322
1337
  core.affectStrokeBoundsType('outside')
1323
1338
  ], exports.Text.prototype, "strokeAlign", void 0);
1339
+ __decorate([
1340
+ core.hitType('all')
1341
+ ], exports.Text.prototype, "hitFill", void 0);
1324
1342
  __decorate([
1325
1343
  core.boundsType('')
1326
1344
  ], exports.Text.prototype, "text", void 0);
@@ -1360,6 +1378,9 @@ __decorate([
1360
1378
  __decorate([
1361
1379
  core.boundsType('top')
1362
1380
  ], exports.Text.prototype, "verticalAlign", void 0);
1381
+ __decorate([
1382
+ core.boundsType('normal')
1383
+ ], exports.Text.prototype, "textWrap", void 0);
1363
1384
  __decorate([
1364
1385
  core.boundsType('show')
1365
1386
  ], exports.Text.prototype, "textOverflow", void 0);
package/dist/core.esm.js CHANGED
@@ -489,8 +489,15 @@ let UI = UI_1 = class UI extends Leaf {
489
489
  set(data) {
490
490
  Object.assign(this, data);
491
491
  }
492
- get() {
493
- return this.__.__getInputData();
492
+ get(options) {
493
+ return this.__.__getInputData(options);
494
+ }
495
+ getProxyData() { return undefined; }
496
+ find(condition) {
497
+ return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
498
+ }
499
+ findOne(condition) {
500
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
494
501
  }
495
502
  getPath(curve) {
496
503
  const path = this.__.path;
@@ -614,6 +621,9 @@ __decorate([
614
621
  __decorate([
615
622
  strokeType('path')
616
623
  ], UI.prototype, "hitStroke", void 0);
624
+ __decorate([
625
+ hitType(false)
626
+ ], UI.prototype, "hitBox", void 0);
617
627
  __decorate([
618
628
  hitType(true)
619
629
  ], UI.prototype, "hitChildren", void 0);
@@ -922,7 +932,7 @@ let Ellipse = class Ellipse extends UI {
922
932
  }
923
933
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
924
934
  }
925
- if (Platform.name === 'node')
935
+ if (Platform.ellipseToCurve)
926
936
  this.__.path = PathConvert.toCanvasData(path, true);
927
937
  }
928
938
  else {
@@ -1233,7 +1243,7 @@ Canvas = __decorate([
1233
1243
  registerUI()
1234
1244
  ], Canvas);
1235
1245
 
1236
- const { copyAndSpread, includes, spread } = BoundsHelper;
1246
+ const { copyAndSpread, includes, spread, setByList } = BoundsHelper;
1237
1247
  let Text = class Text extends UI {
1238
1248
  get __tag() { return 'Text'; }
1239
1249
  get textDrawData() {
@@ -1267,18 +1277,19 @@ let Text = class Text extends UI {
1267
1277
  __updateBoxBounds() {
1268
1278
  const data = this.__;
1269
1279
  const layout = this.__layout;
1270
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data;
1280
+ const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
1281
+ const width = data.__getInput('width');
1282
+ const height = data.__getInput('height');
1271
1283
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
1272
1284
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
1273
1285
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1274
1286
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1287
+ data.__clipText = textOverflow !== 'show' && (width || height);
1275
1288
  this.__updateTextDrawData();
1276
1289
  const { bounds } = data.__textDrawData;
1277
1290
  const b = layout.boxBounds;
1278
1291
  if (data.__lineHeight < fontSize)
1279
1292
  spread(bounds, fontSize / 2);
1280
- const width = data.__getInput('width');
1281
- const height = data.__getInput('height');
1282
1293
  if (width && height) {
1283
1294
  super.__updateBoxBounds();
1284
1295
  }
@@ -1293,6 +1304,10 @@ let Text = class Text extends UI {
1293
1304
  if (contentBounds !== layout.contentBounds) {
1294
1305
  layout.contentBounds = contentBounds;
1295
1306
  layout.renderChanged = true;
1307
+ setByList(data.__textBoxBounds = {}, [b, bounds]);
1308
+ }
1309
+ else {
1310
+ data.__textBoxBounds = contentBounds;
1296
1311
  }
1297
1312
  }
1298
1313
  __updateRenderSpread() {
@@ -1302,7 +1317,7 @@ let Text = class Text extends UI {
1302
1317
  return width;
1303
1318
  }
1304
1319
  __updateRenderBounds() {
1305
- copyAndSpread(this.__layout.renderBounds, this.__layout.contentBounds, this.__layout.renderSpread);
1320
+ copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
1306
1321
  }
1307
1322
  };
1308
1323
  __decorate([
@@ -1320,6 +1335,9 @@ __decorate([
1320
1335
  __decorate([
1321
1336
  affectStrokeBoundsType('outside')
1322
1337
  ], Text.prototype, "strokeAlign", void 0);
1338
+ __decorate([
1339
+ hitType('all')
1340
+ ], Text.prototype, "hitFill", void 0);
1323
1341
  __decorate([
1324
1342
  boundsType('')
1325
1343
  ], Text.prototype, "text", void 0);
@@ -1359,6 +1377,9 @@ __decorate([
1359
1377
  __decorate([
1360
1378
  boundsType('top')
1361
1379
  ], Text.prototype, "verticalAlign", void 0);
1380
+ __decorate([
1381
+ boundsType('normal')
1382
+ ], Text.prototype, "textWrap", void 0);
1362
1383
  __decorate([
1363
1384
  boundsType('show')
1364
1385
  ], Text.prototype, "textOverflow", void 0);
@@ -1 +1 @@
1
- import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as r,PathConvert as o,defineLeafAttr as a,OneRadian as h,Platform as _,dataProcessor as n,dataType as d,surfaceType as l,opacityType as p,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,hitType as m,strokeType as x,cursorType as R,pathType as k,rewrite as S,Leaf as b,PathDrawer as C,useModule as A,rewriteAble as B,PathCorner as E,UICreator as P,Branch as F,registerUI as D,affectRenderBoundsType as L,BoundsHelper as T,PathCommandDataHelper as M,PathBounds as z,affectStrokeBoundsType as W,PointHelper as I,ImageEvent as O,Creator as V,Matrix as N,PathCreator as H,DataHelper as U,CanvasManager as Y,HitCanvasManager as X,PluginManager as j,LeaferEvent as G,canvasSizeAttrs as J,ResizeEvent as $,AutoBounds as q,WaitHelper as K,ImageManager as Z,Run as Q,LayoutEvent as tt,RenderEvent as et,WatchEvent as st,PropertyEvent as it}from"@leafer/core";export*from"@leafer/core";function rt(t,e,s,i){var r,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(a=(o<3?r(a):o>3?r(e,s,a):r(e,s))||a);return o>3&&a&&Object.defineProperty(e,s,a),a}function ot(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const at=i.get("LeaferTypeCreator"),ht={list:{},register(t,e){_t[t]?at.repeat(t):_t[t]=e},run(t,e){const s=ht.list[t];s?s(e):at.error("no",t)}},{list:_t}=ht;ht.register("draw",ot),ht.register("user",ot),ht.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.zoomLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:r,max:o}=i.config.zoom;let{scale:a}=t;a*Math.abs(s)<r?a=r/s:a*Math.abs(s)>o&&(a=o/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const nt={},dt={},lt={},pt={},ct={},ut={},yt={},vt=i.get("UIData");class gt extends r{setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,vt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,vt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=yt)):(this.__isFills&&(this.__removeInput("fill"),dt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=yt)):(this.__isStrokes&&(this.__removeInput("stroke"),dt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}}const ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class wt extends gt{}class mt extends wt{get __boxStroke(){return!0}}class xt extends gt{get __boxStroke(){return!0}}const{parse:Rt}=o;const kt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class St extends xt{}function bt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function Ct(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const At={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:r,strokeWidth:o}=this.__;if((s||"all"===i)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(o)-t:0,r="none"===s?0:o;t+=Math.max(i,r)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),i&&(t=Math.max(t,i));let o=t=Math.ceil(t);return s&&s.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(o=Math.max(o,r)),this.__layout.renderShapeSpread=o,t}},Bt={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this;"miniapp"===_.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:r}=this.__,o=s&&"path"===i||"all"===i,a=e.hitFill(t,r);if(o&&a)return!0;const{stroke:h,hitStroke:n,strokeWidth:d,strokeAlign:l}=this.__,p=h&&"path"===n||"all"===n,c=2*t.radiusX;let u=c;if(p)switch(l){case"inside":if(u+=2*d,!o&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!o){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Et={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=this.__;t.__useEffect=!!(e||s||i||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:r}=this.__;this.__drawRenderPath(t),s&&dt.fill(s,this,t),r&&this.__drawAfterFill(t,e),i&&dt.stroke(i,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:r}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const o=dt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&nt.shadow(this,t,o,e),s&&(this.__.__isFills?dt.fills(s,this,t):dt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),h&&nt.innerShadow(this,t,o,e),i&&(this.__.__isStrokes?dt.strokes(i,this,t,e):dt.stroke(i,this,t,e)),o.worldCanvas&&o.worldCanvas.recycle(),o.canvas.recycle()}else s&&(this.__.__isFills?dt.fills(s,this,t):dt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?dt.strokes(i,this,t,e):dt.stroke(i,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?dt.fills(s,this,t):dt.fill("#000000",this,t)),i&&(this.__.__pixelStroke?dt.strokes(i,this,t,e):dt.stroke("#000000",this,t,e))}},Pt={__drawFast(t,e){const{width:s,height:i,fill:r,stroke:o,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),o){const{strokeAlign:e,strokeWidth:r}=this.__;t.setStroke(o,r,this.__);const a=r/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-r,i-r);break;case"outside":t.strokeRect(-a,-a,s+r,i+r)}}}};var Ft;let Dt=Ft=class extends b{set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}getPath(t){const e=this.__.path;return e?t?o.toCanvasData(e,!0):e:[]}getPathString(t){return o.stringify(this.getPath(t))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&dt.compute("fill",this),e&&dt.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}export(t,e){return ut.export(this,t,e)}clone(){return Ft.one(this.toJSON())}static one(t,e,s,i,r){return P.get(t.tag||this.prototype.__tag,t,e,s,i,r)}destroy(){this.fill=this.stroke=null,super.destroy()}};rt([n(gt)],Dt.prototype,"__",void 0),rt([d("")],Dt.prototype,"id",void 0),rt([d("")],Dt.prototype,"name",void 0),rt([d("")],Dt.prototype,"className",void 0),rt([l("pass-through")],Dt.prototype,"blendMode",void 0),rt([p(1)],Dt.prototype,"opacity",void 0),rt([p(!0)],Dt.prototype,"visible",void 0),rt([c(!1)],Dt.prototype,"isMask",void 0),rt([u(!1)],Dt.prototype,"isEraser",void 0),rt([y(0)],Dt.prototype,"zIndex",void 0),rt([d()],Dt.prototype,"locked",void 0),rt([v(0)],Dt.prototype,"x",void 0),rt([v(0)],Dt.prototype,"y",void 0),rt([g(100)],Dt.prototype,"width",void 0),rt([g(100)],Dt.prototype,"height",void 0),rt([f(1)],Dt.prototype,"scaleX",void 0),rt([f(1)],Dt.prototype,"scaleY",void 0),rt([w(0)],Dt.prototype,"rotation",void 0),rt([w(0)],Dt.prototype,"skewX",void 0),rt([w(0)],Dt.prototype,"skewY",void 0),rt([v()],Dt.prototype,"around",void 0),rt([d(!1)],Dt.prototype,"draggable",void 0),rt([m(!0)],Dt.prototype,"hittable",void 0),rt([m("path")],Dt.prototype,"hitFill",void 0),rt([x("path")],Dt.prototype,"hitStroke",void 0),rt([m(!0)],Dt.prototype,"hitChildren",void 0),rt([m(!0)],Dt.prototype,"hitSelf",void 0),rt([m()],Dt.prototype,"hitRadius",void 0),rt([R("")],Dt.prototype,"cursor",void 0),rt([l()],Dt.prototype,"fill",void 0),rt([x()],Dt.prototype,"stroke",void 0),rt([x("inside")],Dt.prototype,"strokeAlign",void 0),rt([x(1)],Dt.prototype,"strokeWidth",void 0),rt([x("none")],Dt.prototype,"strokeCap",void 0),rt([x("miter")],Dt.prototype,"strokeJoin",void 0),rt([x()],Dt.prototype,"dashPattern",void 0),rt([x()],Dt.prototype,"dashOffset",void 0),rt([x(10)],Dt.prototype,"miterLimit",void 0),rt([k()],Dt.prototype,"cornerRadius",void 0),rt([k()],Dt.prototype,"cornerSmoothing",void 0),rt([bt()],Dt.prototype,"shadow",void 0),rt([bt()],Dt.prototype,"innerShadow",void 0),rt([bt()],Dt.prototype,"blur",void 0),rt([bt()],Dt.prototype,"backgroundBlur",void 0),rt([bt()],Dt.prototype,"grayscale",void 0),rt([S(b.prototype.reset)],Dt.prototype,"reset",null),rt([S(C.drawPathByData)],Dt.prototype,"__drawPathByData",null),Dt=Ft=rt([A(At),A(Bt),A(Et),B()],Dt);let Lt=class extends Dt{get __tag(){return"Group"}get resizeable(){return!1}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let s;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{s=P.get(t.tag,t),this.add(s)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}};rt([n(wt)],Lt.prototype,"__",void 0),Lt=rt([A(F),D()],Lt);let Tt=class extends Dt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i,cornerRadius:r}=this.__;r?t.roundRect(0,0,s,i,r):t.rect(0,0,s,i)}};rt([n(xt)],Tt.prototype,"__",void 0),Tt=rt([A(Pt),D()],Tt);const Mt=Tt.prototype,zt=Lt.prototype,Wt={},{copy:It,add:Ot}=T;let Vt=class extends Lt{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;It(Wt,t),super.__updateRenderBounds(),Ot(t,Wt)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};rt([n(mt)],Vt.prototype,"__",void 0),rt([L("show")],Vt.prototype,"overflow",void 0),rt([S(Mt.__updateStrokeSpread)],Vt.prototype,"__updateStrokeSpread",null),rt([S(Mt.__updateRenderSpread)],Vt.prototype,"__updateRectRenderSpread",null),rt([S(Mt.__updateBoxBounds)],Vt.prototype,"__updateBoxBounds",null),rt([S(Mt.__updateStrokeBounds)],Vt.prototype,"__updateStrokeBounds",null),rt([S(Mt.__updateRenderBounds)],Vt.prototype,"__updateRectRenderBounds",null),rt([S(Mt.__updateChange)],Vt.prototype,"__updateRectChange",null),rt([S(Mt.__drawPathByData)],Vt.prototype,"__drawPathByData",null),rt([S(Mt.__render)],Vt.prototype,"__renderRect",null),rt([S(zt.__render)],Vt.prototype,"__renderGroup",null),Vt=rt([B(),D()],Vt);let Nt=class extends Vt{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}};rt([n(class extends mt{})],Nt.prototype,"__",void 0),rt([L("hide")],Nt.prototype,"overflow",void 0),Nt=rt([D()],Nt);const{moveTo:Ht,closePath:Ut,ellipse:Yt}=M;let Xt=class extends Dt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:r}=this.__,a=t/2,h=e/2,n=this.__.path=[];s?(i||r?(s<1&&Yt(n,a,h,a*s,h*s,0,i,r,!1),Yt(n,a,h,a,h,0,r,i,!0),s<1&&Ut(n)):(s<1&&(Yt(n,a,h,a*s,h*s),Ht(n,t,h)),Yt(n,a,h,a,h,0,360,0,!0)),"node"===_.name&&(this.__.path=o.toCanvasData(n,!0))):i||r?(Ht(n,a,h),Yt(n,a,h,a,h,0,i,r,!1),Ut(n)):Yt(n,a,h,a,h)}};rt([n(class extends gt{get __boxStroke(){return!0}})],Xt.prototype,"__",void 0),rt([k(0)],Xt.prototype,"innerRadius",void 0),rt([k(0)],Xt.prototype,"startAngle",void 0),rt([k(0)],Xt.prototype,"endAngle",void 0),Xt=rt([D()],Xt);const{sin:jt,cos:Gt,PI:Jt}=Math,{moveTo:$t,lineTo:qt,closePath:Kt,drawPoints:Zt}=M,{toBounds:Qt}=z;let te=class extends Dt{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Zt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,r=e/2,o=s/2;$t(t,r,0);for(let e=1;e<i;e++)qt(t,r+r*jt(2*e*Jt/i),o-o*Gt(2*e*Jt/i))}Kt(t)}__updateRenderPath(){this.__.points&&this.__.curve?Zt(this.__.__pathForRender=[],this.__.points,this.__.curve,!0):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?(Qt(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([n(class extends gt{})],te.prototype,"__",void 0),rt([k(3)],te.prototype,"sides",void 0),rt([k()],te.prototype,"points",void 0),rt([k(0)],te.prototype,"curve",void 0),te=rt([D()],te);const{sin:ee,cos:se,PI:ie}=Math,{moveTo:re,lineTo:oe,closePath:ae}=M;let he=class extends Dt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,r=t/2,o=e/2,a=this.__.path=[];re(a,r,0);for(let t=1;t<2*s;t++)oe(a,r+(t%2==0?r:r*i)*ee(t*ie/s),o-(t%2==0?o:o*i)*se(t*ie/s));ae(a)}};rt([n(class extends gt{})],he.prototype,"__",void 0),rt([k(5)],he.prototype,"corners",void 0),rt([k(.382)],he.prototype,"innerRadius",void 0),he=rt([D()],he);const{moveTo:_e,lineTo:ne,drawPoints:de}=M,{rotate:le,getAngle:pe,getDistance:ce,defaultPoint:ue}=I,{toBounds:ye}=z;let ve=class extends Dt{get __tag(){return"Line"}get resizeable(){return!this.points}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&le(s,e),s}set toPoint(t){this.width=ce(ue,t),this.rotation=pe(ue,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?de(t,this.__.points,!1):(_e(t,0,0),ne(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?de(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(ye(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([n(class extends gt{})],ve.prototype,"__",void 0),rt([W("center")],ve.prototype,"strokeAlign",void 0),rt([g(0)],ve.prototype,"height",void 0),rt([k()],ve.prototype,"points",void 0),rt([k(0)],ve.prototype,"curve",void 0),ve=rt([D()],ve);let ge=class extends Tt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let t;const{url:e}=this,s=this.fill;s?s.url!==e&&(t=!0):e&&(t=!0),t&&(this.image&&(this.image=null),this.fill=e?{type:"image",mode:"strench",url:e}:void 0,this.once(O.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}};rt([n(St)],ge.prototype,"__",void 0),rt([g("")],ge.prototype,"url",void 0),ge=rt([D()],ge);let fe=class extends Tt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.checkUpdate();const r=new N(t.__world);r.invert();const o=new N;e&&o.translate(e.x,e.y),s&&("number"==typeof s?o.scale(s):o.scale(s.x,s.y)),i&&o.rotate(i),r.preMultiply(o),t.__render(this.canvas,{matrix:r}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:r}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};rt([n(St)],fe.prototype,"__",void 0),rt([Ct(100)],fe.prototype,"width",void 0),rt([Ct(100)],fe.prototype,"height",void 0),rt([Ct(_.devicePixelRatio)],fe.prototype,"pixelRatio",void 0),rt([Ct(!0)],fe.prototype,"smooth",void 0),rt([m("all")],fe.prototype,"hitFill",void 0),fe=rt([D()],fe);const{copyAndSpread:we,includes:me,spread:xe}=T;let Re=class extends Dt{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:r,height:o}=this.__layout.boxBounds;t.rect(s,i,r,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=pt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:r,fontSize:o,fontWeight:a,italic:h,textCase:_}=t;t.__lineHeight=ft.number(s,o),t.__letterSpacing=ft.number(i,o),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${o}px ${r}`,this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,d=e.boxBounds;t.__lineHeight<o&&xe(n,o/2);const l=t.__getInput("width"),p=t.__getInput("height");l&&p?super.__updateBoxBounds():(d.x=l?0:n.x,d.y=p?0:n.y,d.width=l||n.width,d.height=p||n.height,this.__updateNaturalSize());const c=me(d,n)?d:n;c!==e.contentBounds&&(e.contentBounds=c,e.renderChanged=!0)}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){we(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderSpread)}};rt([n(class extends gt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=kt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],Re.prototype,"__",void 0),rt([g(0)],Re.prototype,"width",void 0),rt([g(0)],Re.prototype,"height",void 0),rt([g(0)],Re.prototype,"padding",void 0),rt([W("outside")],Re.prototype,"strokeAlign",void 0),rt([g("")],Re.prototype,"text",void 0),rt([g("L")],Re.prototype,"fontFamily",void 0),rt([g(12)],Re.prototype,"fontSize",void 0),rt([g("normal")],Re.prototype,"fontWeight",void 0),rt([g(!1)],Re.prototype,"italic",void 0),rt([g("none")],Re.prototype,"textCase",void 0),rt([g("none")],Re.prototype,"textDecoration",void 0),rt([g(0)],Re.prototype,"letterSpacing",void 0),rt([g({type:"percent",value:150})],Re.prototype,"lineHeight",void 0),rt([g(0)],Re.prototype,"paraIndent",void 0),rt([g(0)],Re.prototype,"paraSpacing",void 0),rt([g("left")],Re.prototype,"textAlign",void 0),rt([g("top")],Re.prototype,"verticalAlign",void 0),rt([g("show")],Re.prototype,"textOverflow",void 0),Re=rt([D()],Re);const{toBounds:ke}=z;let Se=class extends Dt{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){ke(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}};rt([n(class extends gt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Rt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],Se.prototype,"__",void 0),rt([k()],Se.prototype,"path",void 0),rt([k()],Se.prototype,"windingRule",void 0),rt([W("center")],Se.prototype,"strokeAlign",void 0),Se=rt([D()],Se);let be=class extends Lt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Se(t);return this.pathStyle=t,this.path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,i,r,o){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,r){return this}ellipse(t,e,s,i,r,o,a,h){return this}arc(t,e,s,i,r,o){return this}arcTo(t,e,s,i,r){return this}drawEllipse(t,e,s,i,r,o,a,h){return this}drawArc(t,e,s,i,r,o){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};rt([n(class extends wt{})],be.prototype,"__",void 0),be=rt([A(H,["beginPath"]),D()],be);const Ce=i.get("Leafer");let Ae=class extends Lt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&U.assign(this.config,t);const{config:i}=this;ht.run(i.type,this),this.canvas=V.canvas(i),this.__controllers.push(this.renderer=V.renderer(this,this.canvas,i),this.watcher=V.watcher(this,i),this.layouter=V.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=V.selector(this),this.__controllers.unshift(this.interaction=V.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new Y,this.hitCanvasManager=new X,s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),j.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(G.RESTART):this.emitLeafer(G.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(G.STOP))}resize(t){const e=U.copyAttrs({},t,J);Object.keys(e).forEach((t=>this[t]=e[t]))}forceLayout(){this.__layout.checkUpdate(!0)}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=U.copyAttrs({},this.canvas,J);this.canvas.resize(t),this.__onResize(new $(t,e))}__onResize(t){this.emitEvent(t),U.copyAttrs(this.__,t,J),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new q(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(J.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&J.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=U.copyAttrs({},this.canvas,J);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(G.BEFORE_READY),this.emitLeafer(G.READY),this.emitLeafer(G.AFTER_READY),K.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(G.VIEW_READY),K.run(this.__viewReadyWait))}__onRenderEnd(t){this.viewReady||this.__onViewReady();const e=this.__checkViewCompleted();e&&this.__onViewCompleted(),this.viewCompleted=e,K.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&Z.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(G.VIEW_COMPLETED),K.run(this.__viewCompletedWait))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.viewCompleted?t():(this.__viewCompletedWait.push(t),this.running||this.start())}nextRender(t){this.watcher&&!this.watcher.changed?t():this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.checkUpdate()}emitLeafer(t){this.emitEvent(new G(t,this))}__listenEvents(){const t=Q.start("FirstCreate "+this.innerName);this.once(G.START,(()=>Q.end(t))),this.once(tt.END,(()=>this.__onReady())),this.once(et.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(st.DATA,this.__onWatchData,this),this.on_(et.END,this.__onRenderEnd,this),this.on_(tt.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new G(G.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){Ce.error(t)}}))}};rt([n(class extends wt{})],Ae.prototype,"__",void 0),rt([g()],Ae.prototype,"pixelRatio",void 0),Ae=rt([D()],Ae);let Be=class extends Ae{get __tag(){return"App"}get isApp(){return!0}__setApp(){const{canvas:t}=this,{realCanvas:e,view:s}=this.config;e||s===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(it.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new Ae(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){i.showHitView&&this.children.forEach((t=>{t.forceUpdate("surface")}))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__checkViewCompleted(){return this.children.every((t=>t.viewCompleted))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>{t.copyWorld(e.canvas)}))}__onResize(t){this.children.forEach((e=>{e.resize(t)})),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>{t.__layout.checkUpdate()}))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&U.assign(e,t),this.autoLayout&&U.copyAttrs(e,this,J),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(tt.END,(()=>this.__onReady())),t.once(et.START,(()=>this.__onCreated())),t.once(et.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(t.on_(et.END,this.__onChildRenderEnd,this))}};Be=rt([D()],Be);export{lt as Animate,Be as App,Vt as Box,fe as Canvas,ct as ColorConvert,nt as Effect,Xt as Ellipse,ut as Export,Nt as Frame,Lt as Group,ge as Image,Ae as Leafer,ht as LeaferTypeCreator,ve as Line,dt as Paint,Se as Path,be as Pen,te as Polygon,Tt as Rect,Pt as RectRender,he as Star,Re as Text,pt as TextConvert,Dt as UI,At as UIBounds,Bt as UIHit,Et as UIRender,bt as effectType,Ct as resizeType};
1
+ import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as r,PathConvert as o,defineLeafAttr as a,OneRadian as h,Platform as _,dataProcessor as n,dataType as d,surfaceType as l,opacityType as p,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,hitType as m,strokeType as x,cursorType as R,pathType as k,rewrite as S,Leaf as b,PathDrawer as C,useModule as B,rewriteAble as A,PathCorner as E,UICreator as P,Branch as F,registerUI as D,affectRenderBoundsType as L,BoundsHelper as T,PathCommandDataHelper as M,PathBounds as z,affectStrokeBoundsType as W,PointHelper as I,ImageEvent as O,Creator as V,Matrix as N,PathCreator as H,DataHelper as U,CanvasManager as Y,HitCanvasManager as X,PluginManager as j,LeaferEvent as G,canvasSizeAttrs as J,ResizeEvent as $,AutoBounds as q,WaitHelper as K,ImageManager as Z,Run as Q,LayoutEvent as tt,RenderEvent as et,WatchEvent as st,PropertyEvent as it}from"@leafer/core";export*from"@leafer/core";function rt(t,e,s,i){var r,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(a=(o<3?r(a):o>3?r(e,s,a):r(e,s))||a);return o>3&&a&&Object.defineProperty(e,s,a),a}function ot(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const at=i.get("LeaferTypeCreator"),ht={list:{},register(t,e){_t[t]?at.repeat(t):_t[t]=e},run(t,e){const s=ht.list[t];s?s(e):at.error("no",t)}},{list:_t}=ht;ht.register("draw",ot),ht.register("user",ot),ht.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.zoomLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:r,max:o}=i.config.zoom;let{scale:a}=t;a*Math.abs(s)<r?a=r/s:a*Math.abs(s)>o&&(a=o/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const nt={},dt={},lt={},pt={},ct={},ut={},yt={},vt=i.get("UIData");class gt extends r{setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,vt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,vt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=yt)):(this.__isFills&&(this.__removeInput("fill"),dt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=yt)):(this.__isStrokes&&(this.__removeInput("stroke"),dt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}}const ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class wt extends gt{}class mt extends wt{get __boxStroke(){return!0}}class xt extends gt{get __boxStroke(){return!0}}const{parse:Rt}=o;const kt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class St extends xt{}function bt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function Ct(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const Bt={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:r,strokeWidth:o}=this.__;if((s||"all"===i)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(o)-t:0,r="none"===s?0:o;t+=Math.max(i,r)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),i&&(t=Math.max(t,i));let o=t=Math.ceil(t);return s&&s.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(o=Math.max(o,r)),this.__layout.renderShapeSpread=o,t}},At={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this;"miniapp"===_.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:r}=this.__,o=s&&"path"===i||"all"===i,a=e.hitFill(t,r);if(o&&a)return!0;const{stroke:h,hitStroke:n,strokeWidth:d,strokeAlign:l}=this.__,p=h&&"path"===n||"all"===n,c=2*t.radiusX;let u=c;if(p)switch(l){case"inside":if(u+=2*d,!o&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!o){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Et={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=this.__;t.__useEffect=!!(e||s||i||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:r}=this.__;this.__drawRenderPath(t),s&&dt.fill(s,this,t),r&&this.__drawAfterFill(t,e),i&&dt.stroke(i,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:r}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const o=dt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&nt.shadow(this,t,o,e),s&&(this.__.__isFills?dt.fills(s,this,t):dt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),h&&nt.innerShadow(this,t,o,e),i&&(this.__.__isStrokes?dt.strokes(i,this,t,e):dt.stroke(i,this,t,e)),o.worldCanvas&&o.worldCanvas.recycle(),o.canvas.recycle()}else s&&(this.__.__isFills?dt.fills(s,this,t):dt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?dt.strokes(i,this,t,e):dt.stroke(i,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?dt.fills(s,this,t):dt.fill("#000000",this,t)),i&&(this.__.__pixelStroke?dt.strokes(i,this,t,e):dt.stroke("#000000",this,t,e))}},Pt={__drawFast(t,e){const{width:s,height:i,fill:r,stroke:o,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),o){const{strokeAlign:e,strokeWidth:r}=this.__;t.setStroke(o,r,this.__);const a=r/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-r,i-r);break;case"outside":t.strokeRect(-a,-a,s+r,i+r)}}}};var Ft;let Dt=Ft=class extends b{set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}reset(t){}set(t){Object.assign(this,t)}get(t){return this.__.__getInputData(t)}getProxyData(){}find(t){return this.leafer?this.leafer.selector.getBy(t,this):[]}findOne(t){return this.leafer?this.leafer.selector.getBy(t,this,!0):null}getPath(t){const e=this.__.path;return e?t?o.toCanvasData(e,!0):e:[]}getPathString(t){return o.stringify(this.getPath(t))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&dt.compute("fill",this),e&&dt.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}export(t,e){return ut.export(this,t,e)}clone(){return Ft.one(this.toJSON())}static one(t,e,s,i,r){return P.get(t.tag||this.prototype.__tag,t,e,s,i,r)}destroy(){this.fill=this.stroke=null,super.destroy()}};rt([n(gt)],Dt.prototype,"__",void 0),rt([d("")],Dt.prototype,"id",void 0),rt([d("")],Dt.prototype,"name",void 0),rt([d("")],Dt.prototype,"className",void 0),rt([l("pass-through")],Dt.prototype,"blendMode",void 0),rt([p(1)],Dt.prototype,"opacity",void 0),rt([p(!0)],Dt.prototype,"visible",void 0),rt([c(!1)],Dt.prototype,"isMask",void 0),rt([u(!1)],Dt.prototype,"isEraser",void 0),rt([y(0)],Dt.prototype,"zIndex",void 0),rt([d()],Dt.prototype,"locked",void 0),rt([v(0)],Dt.prototype,"x",void 0),rt([v(0)],Dt.prototype,"y",void 0),rt([g(100)],Dt.prototype,"width",void 0),rt([g(100)],Dt.prototype,"height",void 0),rt([f(1)],Dt.prototype,"scaleX",void 0),rt([f(1)],Dt.prototype,"scaleY",void 0),rt([w(0)],Dt.prototype,"rotation",void 0),rt([w(0)],Dt.prototype,"skewX",void 0),rt([w(0)],Dt.prototype,"skewY",void 0),rt([v()],Dt.prototype,"around",void 0),rt([d(!1)],Dt.prototype,"draggable",void 0),rt([m(!0)],Dt.prototype,"hittable",void 0),rt([m("path")],Dt.prototype,"hitFill",void 0),rt([x("path")],Dt.prototype,"hitStroke",void 0),rt([m(!1)],Dt.prototype,"hitBox",void 0),rt([m(!0)],Dt.prototype,"hitChildren",void 0),rt([m(!0)],Dt.prototype,"hitSelf",void 0),rt([m()],Dt.prototype,"hitRadius",void 0),rt([R("")],Dt.prototype,"cursor",void 0),rt([l()],Dt.prototype,"fill",void 0),rt([x()],Dt.prototype,"stroke",void 0),rt([x("inside")],Dt.prototype,"strokeAlign",void 0),rt([x(1)],Dt.prototype,"strokeWidth",void 0),rt([x("none")],Dt.prototype,"strokeCap",void 0),rt([x("miter")],Dt.prototype,"strokeJoin",void 0),rt([x()],Dt.prototype,"dashPattern",void 0),rt([x()],Dt.prototype,"dashOffset",void 0),rt([x(10)],Dt.prototype,"miterLimit",void 0),rt([k()],Dt.prototype,"cornerRadius",void 0),rt([k()],Dt.prototype,"cornerSmoothing",void 0),rt([bt()],Dt.prototype,"shadow",void 0),rt([bt()],Dt.prototype,"innerShadow",void 0),rt([bt()],Dt.prototype,"blur",void 0),rt([bt()],Dt.prototype,"backgroundBlur",void 0),rt([bt()],Dt.prototype,"grayscale",void 0),rt([S(b.prototype.reset)],Dt.prototype,"reset",null),rt([S(C.drawPathByData)],Dt.prototype,"__drawPathByData",null),Dt=Ft=rt([B(Bt),B(At),B(Et),A()],Dt);let Lt=class extends Dt{get __tag(){return"Group"}get resizeable(){return!1}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let s;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{s=P.get(t.tag,t),this.add(s)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}};rt([n(wt)],Lt.prototype,"__",void 0),Lt=rt([B(F),D()],Lt);let Tt=class extends Dt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i,cornerRadius:r}=this.__;r?t.roundRect(0,0,s,i,r):t.rect(0,0,s,i)}};rt([n(xt)],Tt.prototype,"__",void 0),Tt=rt([B(Pt),D()],Tt);const Mt=Tt.prototype,zt=Lt.prototype,Wt={},{copy:It,add:Ot}=T;let Vt=class extends Lt{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;It(Wt,t),super.__updateRenderBounds(),Ot(t,Wt)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};rt([n(mt)],Vt.prototype,"__",void 0),rt([L("show")],Vt.prototype,"overflow",void 0),rt([S(Mt.__updateStrokeSpread)],Vt.prototype,"__updateStrokeSpread",null),rt([S(Mt.__updateRenderSpread)],Vt.prototype,"__updateRectRenderSpread",null),rt([S(Mt.__updateBoxBounds)],Vt.prototype,"__updateBoxBounds",null),rt([S(Mt.__updateStrokeBounds)],Vt.prototype,"__updateStrokeBounds",null),rt([S(Mt.__updateRenderBounds)],Vt.prototype,"__updateRectRenderBounds",null),rt([S(Mt.__updateChange)],Vt.prototype,"__updateRectChange",null),rt([S(Mt.__drawPathByData)],Vt.prototype,"__drawPathByData",null),rt([S(Mt.__render)],Vt.prototype,"__renderRect",null),rt([S(zt.__render)],Vt.prototype,"__renderGroup",null),Vt=rt([A(),D()],Vt);let Nt=class extends Vt{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}};rt([n(class extends mt{})],Nt.prototype,"__",void 0),rt([L("hide")],Nt.prototype,"overflow",void 0),Nt=rt([D()],Nt);const{moveTo:Ht,closePath:Ut,ellipse:Yt}=M;let Xt=class extends Dt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:r}=this.__,a=t/2,h=e/2,n=this.__.path=[];s?(i||r?(s<1&&Yt(n,a,h,a*s,h*s,0,i,r,!1),Yt(n,a,h,a,h,0,r,i,!0),s<1&&Ut(n)):(s<1&&(Yt(n,a,h,a*s,h*s),Ht(n,t,h)),Yt(n,a,h,a,h,0,360,0,!0)),_.ellipseToCurve&&(this.__.path=o.toCanvasData(n,!0))):i||r?(Ht(n,a,h),Yt(n,a,h,a,h,0,i,r,!1),Ut(n)):Yt(n,a,h,a,h)}};rt([n(class extends gt{get __boxStroke(){return!0}})],Xt.prototype,"__",void 0),rt([k(0)],Xt.prototype,"innerRadius",void 0),rt([k(0)],Xt.prototype,"startAngle",void 0),rt([k(0)],Xt.prototype,"endAngle",void 0),Xt=rt([D()],Xt);const{sin:jt,cos:Gt,PI:Jt}=Math,{moveTo:$t,lineTo:qt,closePath:Kt,drawPoints:Zt}=M,{toBounds:Qt}=z;let te=class extends Dt{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Zt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,r=e/2,o=s/2;$t(t,r,0);for(let e=1;e<i;e++)qt(t,r+r*jt(2*e*Jt/i),o-o*Gt(2*e*Jt/i))}Kt(t)}__updateRenderPath(){this.__.points&&this.__.curve?Zt(this.__.__pathForRender=[],this.__.points,this.__.curve,!0):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?(Qt(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([n(class extends gt{})],te.prototype,"__",void 0),rt([k(3)],te.prototype,"sides",void 0),rt([k()],te.prototype,"points",void 0),rt([k(0)],te.prototype,"curve",void 0),te=rt([D()],te);const{sin:ee,cos:se,PI:ie}=Math,{moveTo:re,lineTo:oe,closePath:ae}=M;let he=class extends Dt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,r=t/2,o=e/2,a=this.__.path=[];re(a,r,0);for(let t=1;t<2*s;t++)oe(a,r+(t%2==0?r:r*i)*ee(t*ie/s),o-(t%2==0?o:o*i)*se(t*ie/s));ae(a)}};rt([n(class extends gt{})],he.prototype,"__",void 0),rt([k(5)],he.prototype,"corners",void 0),rt([k(.382)],he.prototype,"innerRadius",void 0),he=rt([D()],he);const{moveTo:_e,lineTo:ne,drawPoints:de}=M,{rotate:le,getAngle:pe,getDistance:ce,defaultPoint:ue}=I,{toBounds:ye}=z;let ve=class extends Dt{get __tag(){return"Line"}get resizeable(){return!this.points}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&le(s,e),s}set toPoint(t){this.width=ce(ue,t),this.rotation=pe(ue,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?de(t,this.__.points,!1):(_e(t,0,0),ne(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?de(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(ye(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([n(class extends gt{})],ve.prototype,"__",void 0),rt([W("center")],ve.prototype,"strokeAlign",void 0),rt([g(0)],ve.prototype,"height",void 0),rt([k()],ve.prototype,"points",void 0),rt([k(0)],ve.prototype,"curve",void 0),ve=rt([D()],ve);let ge=class extends Tt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let t;const{url:e}=this,s=this.fill;s?s.url!==e&&(t=!0):e&&(t=!0),t&&(this.image&&(this.image=null),this.fill=e?{type:"image",mode:"strench",url:e}:void 0,this.once(O.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}};rt([n(St)],ge.prototype,"__",void 0),rt([g("")],ge.prototype,"url",void 0),ge=rt([D()],ge);let fe=class extends Tt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.checkUpdate();const r=new N(t.__world);r.invert();const o=new N;e&&o.translate(e.x,e.y),s&&("number"==typeof s?o.scale(s):o.scale(s.x,s.y)),i&&o.rotate(i),r.preMultiply(o),t.__render(this.canvas,{matrix:r}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:r}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};rt([n(St)],fe.prototype,"__",void 0),rt([Ct(100)],fe.prototype,"width",void 0),rt([Ct(100)],fe.prototype,"height",void 0),rt([Ct(_.devicePixelRatio)],fe.prototype,"pixelRatio",void 0),rt([Ct(!0)],fe.prototype,"smooth",void 0),rt([m("all")],fe.prototype,"hitFill",void 0),fe=rt([D()],fe);const{copyAndSpread:we,includes:me,spread:xe,setByList:Re}=T;let ke=class extends Dt{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:r,height:o}=this.__layout.boxBounds;t.rect(s,i,r,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=pt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:r,fontSize:o,fontWeight:a,italic:h,textCase:_,textOverflow:n}=t,d=t.__getInput("width"),l=t.__getInput("height");t.__lineHeight=ft.number(s,o),t.__letterSpacing=ft.number(i,o),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${o}px ${r}`,t.__clipText="show"!==n&&(d||l),this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,c=e.boxBounds;t.__lineHeight<o&&xe(p,o/2),d&&l?super.__updateBoxBounds():(c.x=d?0:p.x,c.y=l?0:p.y,c.width=d||p.width,c.height=l||p.height,this.__updateNaturalSize());const u=me(c,p)?c:p;u!==e.contentBounds?(e.contentBounds=u,e.renderChanged=!0,Re(t.__textBoxBounds={},[c,p])):t.__textBoxBounds=u}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){we(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};rt([n(class extends gt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=kt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],ke.prototype,"__",void 0),rt([g(0)],ke.prototype,"width",void 0),rt([g(0)],ke.prototype,"height",void 0),rt([g(0)],ke.prototype,"padding",void 0),rt([W("outside")],ke.prototype,"strokeAlign",void 0),rt([m("all")],ke.prototype,"hitFill",void 0),rt([g("")],ke.prototype,"text",void 0),rt([g("L")],ke.prototype,"fontFamily",void 0),rt([g(12)],ke.prototype,"fontSize",void 0),rt([g("normal")],ke.prototype,"fontWeight",void 0),rt([g(!1)],ke.prototype,"italic",void 0),rt([g("none")],ke.prototype,"textCase",void 0),rt([g("none")],ke.prototype,"textDecoration",void 0),rt([g(0)],ke.prototype,"letterSpacing",void 0),rt([g({type:"percent",value:150})],ke.prototype,"lineHeight",void 0),rt([g(0)],ke.prototype,"paraIndent",void 0),rt([g(0)],ke.prototype,"paraSpacing",void 0),rt([g("left")],ke.prototype,"textAlign",void 0),rt([g("top")],ke.prototype,"verticalAlign",void 0),rt([g("normal")],ke.prototype,"textWrap",void 0),rt([g("show")],ke.prototype,"textOverflow",void 0),ke=rt([D()],ke);const{toBounds:Se}=z;let be=class extends Dt{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){Se(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}};rt([n(class extends gt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Rt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],be.prototype,"__",void 0),rt([k()],be.prototype,"path",void 0),rt([k()],be.prototype,"windingRule",void 0),rt([W("center")],be.prototype,"strokeAlign",void 0),be=rt([D()],be);let Ce=class extends Lt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new be(t);return this.pathStyle=t,this.path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,i,r,o){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,r){return this}ellipse(t,e,s,i,r,o,a,h){return this}arc(t,e,s,i,r,o){return this}arcTo(t,e,s,i,r){return this}drawEllipse(t,e,s,i,r,o,a,h){return this}drawArc(t,e,s,i,r,o){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};rt([n(class extends wt{})],Ce.prototype,"__",void 0),Ce=rt([B(H,["beginPath"]),D()],Ce);const Be=i.get("Leafer");let Ae=class extends Lt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&U.assign(this.config,t);const{config:i}=this;ht.run(i.type,this),this.canvas=V.canvas(i),this.__controllers.push(this.renderer=V.renderer(this,this.canvas,i),this.watcher=V.watcher(this,i),this.layouter=V.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=V.selector(this),this.__controllers.unshift(this.interaction=V.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new Y,this.hitCanvasManager=new X,s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),j.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(G.RESTART):this.emitLeafer(G.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(G.STOP))}resize(t){const e=U.copyAttrs({},t,J);Object.keys(e).forEach((t=>this[t]=e[t]))}forceLayout(){this.__layout.checkUpdate(!0)}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=U.copyAttrs({},this.canvas,J);this.canvas.resize(t),this.__onResize(new $(t,e))}__onResize(t){this.emitEvent(t),U.copyAttrs(this.__,t,J),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new q(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(J.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&J.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=U.copyAttrs({},this.canvas,J);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(G.BEFORE_READY),this.emitLeafer(G.READY),this.emitLeafer(G.AFTER_READY),K.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(G.VIEW_READY),K.run(this.__viewReadyWait))}__onRenderEnd(t){this.viewReady||this.__onViewReady();const e=this.__checkViewCompleted();e&&this.__onViewCompleted(),this.viewCompleted=e,K.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&Z.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(G.VIEW_COMPLETED),K.run(this.__viewCompletedWait))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.viewCompleted?t():(this.__viewCompletedWait.push(t),this.running||this.start())}nextRender(t){this.watcher&&!this.watcher.changed?t():this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.checkUpdate()}emitLeafer(t){this.emitEvent(new G(t,this))}__listenEvents(){const t=Q.start("FirstCreate "+this.innerName);this.once(G.START,(()=>Q.end(t))),this.once(tt.END,(()=>this.__onReady())),this.once(et.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(st.DATA,this.__onWatchData,this),this.on_(et.END,this.__onRenderEnd,this),this.on_(tt.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new G(G.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){Be.error(t)}}))}};rt([n(class extends wt{})],Ae.prototype,"__",void 0),rt([g()],Ae.prototype,"pixelRatio",void 0),Ae=rt([D()],Ae);let Ee=class extends Ae{get __tag(){return"App"}get isApp(){return!0}__setApp(){const{canvas:t}=this,{realCanvas:e,view:s}=this.config;e||s===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(it.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new Ae(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){i.showHitView&&this.children.forEach((t=>{t.forceUpdate("surface")}))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__checkViewCompleted(){return this.children.every((t=>t.viewCompleted))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>{t.copyWorld(e.canvas)}))}__onResize(t){this.children.forEach((e=>{e.resize(t)})),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>{t.__layout.checkUpdate()}))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&U.assign(e,t),this.autoLayout&&U.copyAttrs(e,this,J),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(tt.END,(()=>this.__onReady())),t.once(et.START,(()=>this.__onCreated())),t.once(et.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(t.on_(et.END,this.__onChildRenderEnd,this))}};Ee=rt([D()],Ee);export{lt as Animate,Ee as App,Vt as Box,fe as Canvas,ct as ColorConvert,nt as Effect,Xt as Ellipse,ut as Export,Nt as Frame,Lt as Group,ge as Image,Ae as Leafer,ht as LeaferTypeCreator,ve as Line,dt as Paint,be as Path,Ce as Pen,te as Polygon,Tt as Rect,Pt as RectRender,he as Star,ke as Text,pt as TextConvert,Dt as UI,Bt as UIBounds,At as UIHit,Et as UIRender,bt as effectType,Ct as resizeType};
package/dist/core.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const r=t.Debug.get("LeaferTypeCreator"),o={list:{},register(t,e){i[t]?r.repeat(t):i[t]=e},run(t,e){const s=o.list[t];s?s(e):r.error("no",t)}},{list:i}=o;o.register("draw",s),o.register("user",s),o.register("design",(function(e){e.isApp||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(s=>{t.LeafHelper.moveWorld(e.zoomLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.config.zoom;let{scale:a}=s;a*Math.abs(r)<o?a=o/r:a*Math.abs(r)>i&&(a=i/r),1!==a&&t.LeafHelper.zoomOfWorld(e.zoomLayer,s,a)})))}));const a={},n={},h={},p={},_={},d=t.Debug.get("UIData");class l extends t.LeafData{setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,d.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,d.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=_)):(this.__isFills&&(this.__removeInput("fill"),n.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=_)):(this.__isStrokes&&(this.__removeInput("stroke"),n.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}}const c={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class u extends l{}class y extends u{get __boxStroke(){return!0}}class x extends l{get __boxStroke(){return!0}}const{parse:v}=t.PathConvert;const g={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class f extends x{}function w(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function m(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const R={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},T={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(e){const{__hitCanvas:s}=this;"miniapp"===t.Platform.name&&this.__drawHitPath(s);const{fill:r,hitFill:o,windingRule:i}=this.__,a=r&&"path"===o||"all"===o,n=s.hitFill(e,i);if(a&&n)return!0;const{stroke:h,hitStroke:p,strokeWidth:_,strokeAlign:d}=this.__,l=h&&"path"===p||"all"===p,c=2*e.radiusX;let u=c;if(l)switch(d){case"inside":if(u+=2*_,!a&&n&&s.hitStroke(e,u))return!0;u=c;break;case"center":u+=_;break;case"outside":if(u+=2*_,!a){if(!n&&s.hitStroke(e,u))return!0;u=c}}return!!u&&s.hitStroke(e,u)}},C={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const i=n.shape(this,t,e),{shadow:h,innerShadow:p}=this.__;h&&a.shadow(this,t,i,e),s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t,e):n.stroke("#000000",this,t,e))}},b={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var k;exports.UI=k=class extends t.Leaf{set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}getPath(e){const s=this.__.path;return s?e?t.PathConvert.toCanvasData(s,!0):s:[]}getPathString(e){return t.PathConvert.stringify(this.getPath(e))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&n.compute("fill",this),e&&n.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:e}=this;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}export(t,e){return p.export(this,t,e)}clone(){return k.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(l)],exports.UI.prototype,"__",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.maskType(!1)],exports.UI.prototype,"isMask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"isEraser",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.dataType()],exports.UI.prototype,"locked",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.positionType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType()],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([w()],exports.UI.prototype,"shadow",void 0),e([w()],exports.UI.prototype,"innerShadow",void 0),e([w()],exports.UI.prototype,"blur",void 0),e([w()],exports.UI.prototype,"backgroundBlur",void 0),e([w()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=k=e([t.useModule(R),t.useModule(T),t.useModule(C),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get resizeable(){return!1}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}},e([t.dataProcessor(u)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:r,cornerRadius:o}=this.__;o?t.roundRect(0,0,s,r,o):t.rect(0,0,s,r)}},e([t.dataProcessor(x)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(b),t.registerUI()],exports.Rect);const P=exports.Rect.prototype,I=exports.Group.prototype,S={},{copy:B,add:E}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;B(S,t),super.__updateRenderBounds(),E(t,S)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(y)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(P.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(P.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(P.__updateBoxBounds)],exports.Box.prototype,"__updateBoxBounds",null),e([t.rewrite(P.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(P.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(P.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(P.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(P.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(I.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(class extends y{})],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:A,closePath:U,ellipse:L}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,h=this.__.path=[];r?(o||i?(r<1&&L(h,a,n,a*r,n*r,0,o,i,!1),L(h,a,n,a,n,0,i,o,!0),r<1&&U(h)):(r<1&&(L(h,a,n,a*r,n*r),A(h,e,n)),L(h,a,n,a,n,0,360,0,!0)),"node"===t.Platform.name&&(this.__.path=t.PathConvert.toCanvasData(h,!0))):o||i?(A(h,a,n),L(h,a,n,a,n,0,o,i,!1),U(h)):L(h,a,n,a,n)}},e([t.dataProcessor(class extends l{get __boxStroke(){return!0}})],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{sin:D,cos:F,PI:M}=Math,{moveTo:z,lineTo:W,closePath:H,drawPoints:O}=t.PathCommandDataHelper,{toBounds:V}=t.PathBounds;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)O(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;z(t,o,0);for(let e=1;e<r;e++)W(t,o+o*D(2*e*M/r),i-i*F(2*e*M/r))}H(t)}__updateRenderPath(){this.__.points&&this.__.curve?O(this.__.__pathForRender=[],this.__.points,this.__.curve,!0):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?(V(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),exports.Polygon=e([t.registerUI()],exports.Polygon);const{sin:N,cos:G,PI:j}=Math,{moveTo:Y,lineTo:X,closePath:J}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];Y(a,o,0);for(let t=1;t<2*s;t++)X(a,o+(t%2==0?o:o*r)*N(t*j/s),i-(t%2==0?i:i*r)*G(t*j/s));J(a)}},e([t.dataProcessor(class extends l{})],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star);const{moveTo:$,lineTo:q,drawPoints:Z}=t.PathCommandDataHelper,{rotate:K,getAngle:Q,getDistance:tt,defaultPoint:et}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get resizeable(){return!this.points}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&K(s,e),s}set toPoint(t){this.width=tt(et,t),this.rotation=Q(et,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?Z(t,this.__.points,!1):($(t,0,0),q(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?Z(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(st(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let e;const{url:s}=this,r=this.fill;r?r.url!==s&&(e=!0):s&&(e=!0),e&&(this.image&&(this.image=null),this.fill=s?{type:"image",mode:"strench",url:s}:void 0,this.once(t.ImageEvent.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(f)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.checkUpdate();const i=new t.Matrix(e.__world);i.invert();const a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.preMultiply(a),e.__render(this.canvas,{matrix:i}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(f)],exports.Canvas.prototype,"__",void 0),e([m(100)],exports.Canvas.prototype,"width",void 0),e([m(100)],exports.Canvas.prototype,"height",void 0),e([m(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([m(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:rt,includes:ot,spread:it}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=h.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:o,fontSize:i,fontWeight:a,italic:n,textCase:h}=t;t.__lineHeight=c.number(s,i),t.__letterSpacing=c.number(r,i),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*i)/2,t.__font=`${n?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${i}px ${o}`,this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,_=e.boxBounds;t.__lineHeight<i&&it(p,i/2);const d=t.__getInput("width"),l=t.__getInput("height");d&&l?super.__updateBoxBounds():(_.x=d?0:p.x,_.y=l?0:p.y,_.width=d||p.width,_.height=l||p.height,this.__updateNaturalSize());const u=ot(_,p)?_:p;u!==e.contentBounds&&(e.contentBounds=u,e.renderChanged=!0)}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){rt(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderSpread)}},e([t.dataProcessor(class extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=g[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:at}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){at(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}},e([t.dataProcessor(class extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=v(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],exports.Path.prototype,"__",void 0),e([t.pathType()],exports.Path.prototype,"path",void 0),e([t.pathType()],exports.Path.prototype,"windingRule",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}},e([t.dataProcessor(class extends u{})],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const nt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:i}=this;o.run(i.type,this),this.canvas=t.Creator.canvas(i),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,i),this.watcher=t.Creator.watcher(this,i),this.layouter=t.Creator.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.__controllers.unshift(this.interaction=t.Creator.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new t.CanvasManager,this.hitCanvasManager=new t.HitCanvasManager,r=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.PluginManager.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceLayout(){this.__layout.checkUpdate(!0)}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onRenderEnd(e){this.viewReady||this.__onViewReady();const s=this.__checkViewCompleted();s&&this.__onViewCompleted(),this.viewCompleted=s,t.WaitHelper.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&t.ImageManager.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.viewCompleted?t():(this.__viewCompletedWait.push(t),this.running||this.start())}nextRender(t){this.watcher&&!this.watcher.changed?t():this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.checkUpdate()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.END,this.__onRenderEnd,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){nt.error(t)}}))}},e([t.dataProcessor(class extends u{})],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.App=class extends exports.Leafer{get __tag(){return"App"}get isApp(){return!0}__setApp(){const{canvas:e}=this,{realCanvas:s,view:r}=this.config;s||r===this.canvas.view||!e.parentView?this.realCanvas=!0:e.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(t.PropertyEvent.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new exports.Leafer(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){t.Debug.showHitView&&this.children.forEach((t=>{t.forceUpdate("surface")}))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__checkViewCompleted(){return this.children.every((t=>t.viewCompleted))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>{t.copyWorld(e.canvas)}))}__onResize(t){this.children.forEach((e=>{e.resize(t)})),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>{t.__layout.checkUpdate()}))}__getChildConfig(e){let s=Object.assign({},this.config);return s.hittable=s.realCanvas=void 0,e&&t.DataHelper.assign(s,e),this.autoLayout&&t.DataHelper.copyAttrs(s,this,t.canvasSizeAttrs),s.view=this.realCanvas?void 0:this.view,s.fill=void 0,s}__listenChildEvents(e){e.once(t.LayoutEvent.END,(()=>this.__onReady())),e.once(t.RenderEvent.START,(()=>this.__onCreated())),e.once(t.RenderEvent.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(e.on_(t.RenderEvent.END,this.__onChildRenderEnd,this))}},exports.App=e([t.registerUI()],exports.App),exports.Animate={},exports.ColorConvert={},exports.Effect=a,exports.Export=p,exports.LeaferTypeCreator=o,exports.Paint=n,exports.RectRender=b,exports.TextConvert=h,exports.UIBounds=R,exports.UIHit=T,exports.UIRender=C,exports.effectType=w,exports.resizeType=m,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const r=t.Debug.get("LeaferTypeCreator"),o={list:{},register(t,e){i[t]?r.repeat(t):i[t]=e},run(t,e){const s=o.list[t];s?s(e):r.error("no",t)}},{list:i}=o;o.register("draw",s),o.register("user",s),o.register("design",(function(e){e.isApp||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(s=>{t.LeafHelper.moveWorld(e.zoomLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.config.zoom;let{scale:a}=s;a*Math.abs(r)<o?a=o/r:a*Math.abs(r)>i&&(a=i/r),1!==a&&t.LeafHelper.zoomOfWorld(e.zoomLayer,s,a)})))}));const a={},n={},h={},p={},_={},d=t.Debug.get("UIData");class l extends t.LeafData{setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,d.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,d.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=_)):(this.__isFills&&(this.__removeInput("fill"),n.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=_)):(this.__isStrokes&&(this.__removeInput("stroke"),n.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}}const c={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class u extends l{}class y extends u{get __boxStroke(){return!0}}class x extends l{get __boxStroke(){return!0}}const{parse:v}=t.PathConvert;const g={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class f extends x{}function w(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function m(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const T={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},R={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(e){const{__hitCanvas:s}=this;"miniapp"===t.Platform.name&&this.__drawHitPath(s);const{fill:r,hitFill:o,windingRule:i}=this.__,a=r&&"path"===o||"all"===o,n=s.hitFill(e,i);if(a&&n)return!0;const{stroke:h,hitStroke:p,strokeWidth:_,strokeAlign:d}=this.__,l=h&&"path"===p||"all"===p,c=2*e.radiusX;let u=c;if(l)switch(d){case"inside":if(u+=2*_,!a&&n&&s.hitStroke(e,u))return!0;u=c;break;case"center":u+=_;break;case"outside":if(u+=2*_,!a){if(!n&&s.hitStroke(e,u))return!0;u=c}}return!!u&&s.hitStroke(e,u)}},C={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const i=n.shape(this,t,e),{shadow:h,innerShadow:p}=this.__;h&&a.shadow(this,t,i,e),s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t,e):n.stroke("#000000",this,t,e))}},b={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var P;exports.UI=P=class extends t.Leaf{set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}reset(t){}set(t){Object.assign(this,t)}get(t){return this.__.__getInputData(t)}getProxyData(){}find(t){return this.leafer?this.leafer.selector.getBy(t,this):[]}findOne(t){return this.leafer?this.leafer.selector.getBy(t,this,!0):null}getPath(e){const s=this.__.path;return s?e?t.PathConvert.toCanvasData(s,!0):s:[]}getPathString(e){return t.PathConvert.stringify(this.getPath(e))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&n.compute("fill",this),e&&n.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:e}=this;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}export(t,e){return p.export(this,t,e)}clone(){return P.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(l)],exports.UI.prototype,"__",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.maskType(!1)],exports.UI.prototype,"isMask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"isEraser",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.dataType()],exports.UI.prototype,"locked",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.positionType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType()],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([w()],exports.UI.prototype,"shadow",void 0),e([w()],exports.UI.prototype,"innerShadow",void 0),e([w()],exports.UI.prototype,"blur",void 0),e([w()],exports.UI.prototype,"backgroundBlur",void 0),e([w()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=P=e([t.useModule(T),t.useModule(R),t.useModule(C),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get resizeable(){return!1}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}},e([t.dataProcessor(u)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:r,cornerRadius:o}=this.__;o?t.roundRect(0,0,s,r,o):t.rect(0,0,s,r)}},e([t.dataProcessor(x)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(b),t.registerUI()],exports.Rect);const k=exports.Rect.prototype,I=exports.Group.prototype,B={},{copy:S,add:E}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;S(B,t),super.__updateRenderBounds(),E(t,B)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(y)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(k.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(k.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(k.__updateBoxBounds)],exports.Box.prototype,"__updateBoxBounds",null),e([t.rewrite(k.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(k.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(k.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(k.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(k.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(I.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(class extends y{})],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:A,closePath:U,ellipse:L}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,h=this.__.path=[];r?(o||i?(r<1&&L(h,a,n,a*r,n*r,0,o,i,!1),L(h,a,n,a,n,0,i,o,!0),r<1&&U(h)):(r<1&&(L(h,a,n,a*r,n*r),A(h,e,n)),L(h,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=t.PathConvert.toCanvasData(h,!0))):o||i?(A(h,a,n),L(h,a,n,a,n,0,o,i,!1),U(h)):L(h,a,n,a,n)}},e([t.dataProcessor(class extends l{get __boxStroke(){return!0}})],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{sin:D,cos:F,PI:M}=Math,{moveTo:z,lineTo:W,closePath:H,drawPoints:O}=t.PathCommandDataHelper,{toBounds:V}=t.PathBounds;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)O(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;z(t,o,0);for(let e=1;e<r;e++)W(t,o+o*D(2*e*M/r),i-i*F(2*e*M/r))}H(t)}__updateRenderPath(){this.__.points&&this.__.curve?O(this.__.__pathForRender=[],this.__.points,this.__.curve,!0):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?(V(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),exports.Polygon=e([t.registerUI()],exports.Polygon);const{sin:N,cos:G,PI:j}=Math,{moveTo:Y,lineTo:X,closePath:J}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];Y(a,o,0);for(let t=1;t<2*s;t++)X(a,o+(t%2==0?o:o*r)*N(t*j/s),i-(t%2==0?i:i*r)*G(t*j/s));J(a)}},e([t.dataProcessor(class extends l{})],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star);const{moveTo:$,lineTo:q,drawPoints:Z}=t.PathCommandDataHelper,{rotate:K,getAngle:Q,getDistance:tt,defaultPoint:et}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get resizeable(){return!this.points}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&K(s,e),s}set toPoint(t){this.width=tt(et,t),this.rotation=Q(et,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?Z(t,this.__.points,!1):($(t,0,0),q(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?Z(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(st(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let e;const{url:s}=this,r=this.fill;r?r.url!==s&&(e=!0):s&&(e=!0),e&&(this.image&&(this.image=null),this.fill=s?{type:"image",mode:"strench",url:s}:void 0,this.once(t.ImageEvent.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(f)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.checkUpdate();const i=new t.Matrix(e.__world);i.invert();const a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.preMultiply(a),e.__render(this.canvas,{matrix:i}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(f)],exports.Canvas.prototype,"__",void 0),e([m(100)],exports.Canvas.prototype,"width",void 0),e([m(100)],exports.Canvas.prototype,"height",void 0),e([m(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([m(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:rt,includes:ot,spread:it,setByList:at}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=h.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:o,fontSize:i,fontWeight:a,italic:n,textCase:h,textOverflow:p}=t,_=t.__getInput("width"),d=t.__getInput("height");t.__lineHeight=c.number(s,i),t.__letterSpacing=c.number(r,i),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*i)/2,t.__font=`${n?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${i}px ${o}`,t.__clipText="show"!==p&&(_||d),this.__updateTextDrawData();const{bounds:l}=t.__textDrawData,u=e.boxBounds;t.__lineHeight<i&&it(l,i/2),_&&d?super.__updateBoxBounds():(u.x=_?0:l.x,u.y=d?0:l.y,u.width=_||l.width,u.height=d||l.height,this.__updateNaturalSize());const y=ot(u,l)?u:l;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,at(t.__textBoxBounds={},[u,l])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){rt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(class extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=g[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:nt}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){nt(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}},e([t.dataProcessor(class extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=v(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],exports.Path.prototype,"__",void 0),e([t.pathType()],exports.Path.prototype,"path",void 0),e([t.pathType()],exports.Path.prototype,"windingRule",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}},e([t.dataProcessor(class extends u{})],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const ht=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:i}=this;o.run(i.type,this),this.canvas=t.Creator.canvas(i),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,i),this.watcher=t.Creator.watcher(this,i),this.layouter=t.Creator.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.__controllers.unshift(this.interaction=t.Creator.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new t.CanvasManager,this.hitCanvasManager=new t.HitCanvasManager,r=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.PluginManager.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceLayout(){this.__layout.checkUpdate(!0)}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onRenderEnd(e){this.viewReady||this.__onViewReady();const s=this.__checkViewCompleted();s&&this.__onViewCompleted(),this.viewCompleted=s,t.WaitHelper.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&t.ImageManager.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.viewCompleted?t():(this.__viewCompletedWait.push(t),this.running||this.start())}nextRender(t){this.watcher&&!this.watcher.changed?t():this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.checkUpdate()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.END,this.__onRenderEnd,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){ht.error(t)}}))}},e([t.dataProcessor(class extends u{})],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.App=class extends exports.Leafer{get __tag(){return"App"}get isApp(){return!0}__setApp(){const{canvas:e}=this,{realCanvas:s,view:r}=this.config;s||r===this.canvas.view||!e.parentView?this.realCanvas=!0:e.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(t.PropertyEvent.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new exports.Leafer(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){t.Debug.showHitView&&this.children.forEach((t=>{t.forceUpdate("surface")}))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__checkViewCompleted(){return this.children.every((t=>t.viewCompleted))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>{t.copyWorld(e.canvas)}))}__onResize(t){this.children.forEach((e=>{e.resize(t)})),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>{t.__layout.checkUpdate()}))}__getChildConfig(e){let s=Object.assign({},this.config);return s.hittable=s.realCanvas=void 0,e&&t.DataHelper.assign(s,e),this.autoLayout&&t.DataHelper.copyAttrs(s,this,t.canvasSizeAttrs),s.view=this.realCanvas?void 0:this.view,s.fill=void 0,s}__listenChildEvents(e){e.once(t.LayoutEvent.END,(()=>this.__onReady())),e.once(t.RenderEvent.START,(()=>this.__onCreated())),e.once(t.RenderEvent.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(e.on_(t.RenderEvent.END,this.__onChildRenderEnd,this))}},exports.App=e([t.registerUI()],exports.App),exports.Animate={},exports.ColorConvert={},exports.Effect=a,exports.Export=p,exports.LeaferTypeCreator=o,exports.Paint=n,exports.RectRender=b,exports.TextConvert=h,exports.UIBounds=T,exports.UIHit=R,exports.UIRender=C,exports.effectType=w,exports.resizeType=m,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/core",
3
- "version": "1.0.0-rc.5",
3
+ "version": "1.0.0-rc.6",
4
4
  "description": "@leafer-ui/core",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -8,7 +8,8 @@
8
8
  "main": "dist/core.esm.js",
9
9
  "exports": {
10
10
  "import": "./dist/core.esm.js",
11
- "require": "./dist/core.cjs"
11
+ "require": "./dist/core.cjs",
12
+ "types": "./types/index.d.ts"
12
13
  },
13
14
  "types": "types/index.d.ts",
14
15
  "files": [
@@ -28,12 +29,12 @@
28
29
  "leaferjs"
29
30
  ],
30
31
  "dependencies": {
31
- "@leafer/core": "1.0.0-rc.5",
32
- "@leafer-ui/app": "1.0.0-rc.5",
33
- "@leafer-ui/display": "1.0.0-rc.5",
34
- "@leafer-ui/decorator": "1.0.0-rc.5",
35
- "@leafer-ui/display-module": "1.0.0-rc.5",
36
- "@leafer-ui/external": "1.0.0-rc.5",
37
- "@leafer-ui/type": "1.0.0-rc.5"
32
+ "@leafer/core": "1.0.0-rc.6",
33
+ "@leafer-ui/app": "1.0.0-rc.6",
34
+ "@leafer-ui/display": "1.0.0-rc.6",
35
+ "@leafer-ui/decorator": "1.0.0-rc.6",
36
+ "@leafer-ui/display-module": "1.0.0-rc.6",
37
+ "@leafer-ui/external": "1.0.0-rc.6",
38
+ "@leafer-ui/type": "1.0.0-rc.6"
38
39
  }
39
40
  }