@leafer-game/worker 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
111
111
  return rotation - oldRotation;
112
112
  },
113
113
  float(num, maxLength) {
114
- const a = maxLength ? pow$2(10, maxLength) : 1000000000000;
114
+ const a = maxLength !== undefined ? pow$2(10, maxLength) : 1000000000000;
115
115
  num = round$3(num * a) / a;
116
116
  return num === -0 ? 0 : num;
117
117
  },
@@ -4168,20 +4168,17 @@ var LeaferUI = (function (exports) {
4168
4168
  }
4169
4169
  return true;
4170
4170
  },
4171
- moveWorld(t, x, y = 0, isInnerPoint) {
4171
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4172
4172
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4173
4173
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4174
- L$1.moveLocal(t, local.x, local.y);
4174
+ L$1.moveLocal(t, local.x, local.y, transition);
4175
4175
  },
4176
- moveLocal(t, x, y = 0) {
4177
- if (typeof x === 'object') {
4178
- t.x += x.x;
4179
- t.y += x.y;
4180
- }
4181
- else {
4182
- t.x += x;
4183
- t.y += y;
4184
- }
4176
+ moveLocal(t, x, y = 0, transition) {
4177
+ if (typeof x === 'object')
4178
+ y = x.y, x = x.x;
4179
+ x += t.x;
4180
+ y += t.y;
4181
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4185
4182
  },
4186
4183
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4187
4184
  L$1.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5561,11 +5558,11 @@ var LeaferUI = (function (exports) {
5561
5558
  transform(matrix, resize) {
5562
5559
  transform(this, matrix, resize);
5563
5560
  }
5564
- move(x, y) {
5565
- moveLocal(this, x, y);
5561
+ move(x, y, transition) {
5562
+ moveLocal(this, x, y, transition);
5566
5563
  }
5567
- moveInner(x, y) {
5568
- moveWorld(this, x, y, true);
5564
+ moveInner(x, y, transition) {
5565
+ moveWorld(this, x, y, true, transition);
5569
5566
  }
5570
5567
  scaleOf(origin, scaleX, scaleY, resize) {
5571
5568
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5579,8 +5576,8 @@ var LeaferUI = (function (exports) {
5579
5576
  transformWorld(worldTransform, resize) {
5580
5577
  transformWorld(this, worldTransform, resize);
5581
5578
  }
5582
- moveWorld(x, y) {
5583
- moveWorld(this, x, y);
5579
+ moveWorld(x, y, transition) {
5580
+ moveWorld(this, x, y, false, transition);
5584
5581
  }
5585
5582
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5586
5583
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5978,7 +5975,7 @@ var LeaferUI = (function (exports) {
5978
5975
  }
5979
5976
  }
5980
5977
 
5981
- const version = "1.0.10";
5978
+ const version = "1.1.0";
5982
5979
 
5983
5980
  class LeaferCanvas extends LeaferCanvasBase {
5984
5981
  get allowBackgroundColor() { return true; }
@@ -7408,11 +7405,15 @@ var LeaferUI = (function (exports) {
7408
7405
  super(data);
7409
7406
  }
7410
7407
  reset(_data) { }
7411
- set(data, isTemp) {
7412
- if (isTemp) {
7413
- this.lockNormalStyle = true;
7414
- Object.assign(this, data);
7415
- this.lockNormalStyle = false;
7408
+ set(data, transition) {
7409
+ if (transition) {
7410
+ if (transition === 'temp') {
7411
+ this.lockNormalStyle = true;
7412
+ Object.assign(this, data);
7413
+ this.lockNormalStyle = false;
7414
+ }
7415
+ else
7416
+ this.animate(data, transition);
7416
7417
  }
7417
7418
  else
7418
7419
  Object.assign(this, data);
@@ -7722,17 +7723,17 @@ var LeaferUI = (function (exports) {
7722
7723
  if (!this.children)
7723
7724
  this.children = [];
7724
7725
  }
7725
- set(data, isTemp) {
7726
+ set(data, transition) {
7726
7727
  if (data.children) {
7727
7728
  const { children } = data;
7728
7729
  delete data.children;
7729
7730
  this.children ? this.clear() : this.__setBranch();
7730
- super.set(data, isTemp);
7731
+ super.set(data, transition);
7731
7732
  children.forEach(child => this.add(child));
7732
7733
  data.children = children;
7733
7734
  }
7734
7735
  else
7735
- super.set(data, isTemp);
7736
+ super.set(data, transition);
7736
7737
  }
7737
7738
  toJSON(options) {
7738
7739
  const data = super.toJSON(options);
@@ -7845,8 +7846,8 @@ var LeaferUI = (function (exports) {
7845
7846
  }
7846
7847
  onInit() { }
7847
7848
  initType(_type) { }
7848
- set(data) {
7849
- this.waitInit(() => { super.set(data); });
7849
+ set(data, transition) {
7850
+ this.waitInit(() => { super.set(data, transition); });
7850
7851
  }
7851
7852
  start() {
7852
7853
  clearTimeout(this.__startTimer);
@@ -8336,7 +8337,7 @@ var LeaferUI = (function (exports) {
8336
8337
  ], exports.Ellipse);
8337
8338
 
8338
8339
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8339
- const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
8340
+ const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$3, defaultPoint } = PointHelper;
8340
8341
  const { toBounds: toBounds$1 } = PathBounds;
8341
8342
  exports.Line = class Line extends exports.UI {
8342
8343
  get __tag() { return 'Line'; }
@@ -8350,7 +8351,7 @@ var LeaferUI = (function (exports) {
8350
8351
  return to;
8351
8352
  }
8352
8353
  set toPoint(value) {
8353
- this.width = getDistance$2(defaultPoint, value);
8354
+ this.width = getDistance$3(defaultPoint, value);
8354
8355
  this.rotation = getAngle$1(defaultPoint, value);
8355
8356
  if (this.height)
8356
8357
  this.height = 0;
@@ -9035,10 +9036,8 @@ var LeaferUI = (function (exports) {
9035
9036
  this.data = data;
9036
9037
  }
9037
9038
  static getValidMove(leaf, start, total) {
9038
- const { draggable, dragBounds, x, y } = leaf;
9039
- const move = leaf.getLocalPoint(total, null, true);
9040
- move.x += start.x - x;
9041
- move.y += start.y - y;
9039
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9040
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9042
9041
  if (dragBounds)
9043
9042
  this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9044
9043
  if (draggable === 'x')
@@ -9048,8 +9047,7 @@ var LeaferUI = (function (exports) {
9048
9047
  return move;
9049
9048
  }
9050
9049
  static getMoveInDragBounds(childBox, dragBounds, move, change) {
9051
- const x = childBox.x + move.x, y = childBox.y + move.y;
9052
- const right = x + childBox.width, bottom = y + childBox.height;
9050
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9053
9051
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9054
9052
  if (!change)
9055
9053
  move = Object.assign({}, move);
@@ -9101,9 +9099,7 @@ var LeaferUI = (function (exports) {
9101
9099
  return this.getLocalMove(relative, true);
9102
9100
  }
9103
9101
  getPageBounds() {
9104
- const total = this.getPageTotal();
9105
- const start = this.getPagePoint();
9106
- const bounds = {};
9102
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9107
9103
  BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9108
9104
  BoundsHelper.unsign(bounds);
9109
9105
  return bounds;
@@ -10491,6 +10487,8 @@ var LeaferUI = (function (exports) {
10491
10487
  case 'center':
10492
10488
  canvas.setStroke(stroke, __strokeWidth, options);
10493
10489
  canvas.stroke();
10490
+ if (options.__useArrow)
10491
+ strokeArrow(ui, canvas);
10494
10492
  break;
10495
10493
  case 'inside':
10496
10494
  canvas.save();
@@ -10528,6 +10526,8 @@ var LeaferUI = (function (exports) {
10528
10526
  case 'center':
10529
10527
  canvas.setStroke(undefined, __strokeWidth, options);
10530
10528
  drawStrokesStyle(strokes, false, ui, canvas);
10529
+ if (options.__useArrow)
10530
+ strokeArrow(ui, canvas);
10531
10531
  break;
10532
10532
  case 'inside':
10533
10533
  canvas.save();
@@ -10553,6 +10553,14 @@ var LeaferUI = (function (exports) {
10553
10553
  }
10554
10554
  }
10555
10555
  }
10556
+ function strokeArrow(ui, canvas) {
10557
+ if (ui.__.dashPattern) {
10558
+ canvas.beginPath();
10559
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10560
+ canvas.dashPattern = null;
10561
+ canvas.stroke();
10562
+ }
10563
+ }
10556
10564
 
10557
10565
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
10558
10566
  function shape(ui, current, options) {
@@ -11055,7 +11063,7 @@ var LeaferUI = (function (exports) {
11055
11063
  }
11056
11064
  }
11057
11065
 
11058
- const { getAngle, getDistance: getDistance$1 } = PointHelper;
11066
+ const { getAngle, getDistance: getDistance$2 } = PointHelper;
11059
11067
  const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
11060
11068
  const { toPoint: toPoint$1 } = AroundHelper;
11061
11069
  const realFrom$1 = {};
@@ -11064,7 +11072,7 @@ var LeaferUI = (function (exports) {
11064
11072
  let { from, to, type, opacity, blendMode, stretch } = paint;
11065
11073
  toPoint$1(from || 'center', box, realFrom$1);
11066
11074
  toPoint$1(to || 'bottom', box, realTo$1);
11067
- const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
11075
+ const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$2(realFrom$1, realTo$1));
11068
11076
  applyStops(style, paint.stops, opacity);
11069
11077
  const data = { type, style };
11070
11078
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
@@ -11092,7 +11100,7 @@ var LeaferUI = (function (exports) {
11092
11100
  return transform;
11093
11101
  }
11094
11102
 
11095
- const { getDistance } = PointHelper;
11103
+ const { getDistance: getDistance$1 } = PointHelper;
11096
11104
  const { toPoint } = AroundHelper;
11097
11105
  const realFrom = {};
11098
11106
  const realTo = {};
@@ -11100,7 +11108,7 @@ var LeaferUI = (function (exports) {
11100
11108
  let { from, to, type, opacity, blendMode, stretch } = paint;
11101
11109
  toPoint(from || 'center', box, realFrom);
11102
11110
  toPoint(to || 'bottom', box, realTo);
11103
- const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
11111
+ const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance$1(realFrom, realTo));
11104
11112
  applyStops(style, paint.stops, opacity);
11105
11113
  const data = { type, style };
11106
11114
  const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
@@ -12079,15 +12087,18 @@ var LeaferUI = (function (exports) {
12079
12087
  if (typeof action === 'number') {
12080
12088
  this.now = action;
12081
12089
  }
12082
- else if (action instanceof Array) {
12083
- const { length } = action;
12090
+ else if (typeof action === 'object') {
12091
+ const isArray = action instanceof Array;
12092
+ const keyframes = isArray ? action : action.keyframes;
12093
+ this.__action = isArray ? undefined : action;
12094
+ const { length } = keyframes;
12084
12095
  if (length > 1) {
12085
- const start = this.now = action[0], end = action[action.length - 1];
12096
+ const start = this.now = keyframes[0], end = keyframes[keyframes.length - 1];
12086
12097
  this.play();
12087
12098
  this.__runAction(start, end);
12088
12099
  }
12089
12100
  else if (length)
12090
- this.now = action[0];
12101
+ this.now = keyframes[0];
12091
12102
  }
12092
12103
  }
12093
12104
  __loadRobot(frame, start, end) {
@@ -12115,16 +12126,26 @@ var LeaferUI = (function (exports) {
12115
12126
  this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
12116
12127
  }
12117
12128
  __runAction(start, end) {
12129
+ let { FPS, loop, __action: a } = this;
12130
+ if (a) {
12131
+ if (a.FPS)
12132
+ FPS = a.FPS;
12133
+ if (a.loop !== undefined)
12134
+ loop = a.loop;
12135
+ }
12118
12136
  this.__timer = setTimeout(() => {
12119
12137
  if (this.running) {
12120
- if (this.now === end)
12138
+ if (this.now === end) {
12139
+ if (!loop)
12140
+ return this.stop();
12121
12141
  this.now = start;
12142
+ }
12122
12143
  else
12123
12144
  this.now++;
12124
12145
  this.__updateRobotBounds();
12125
12146
  }
12126
12147
  this.__runAction(start, end);
12127
- }, 1000 / this.FPS);
12148
+ }, 1000 / FPS);
12128
12149
  }
12129
12150
  __updateRobotBounds() {
12130
12151
  const { nowFrame } = this;
@@ -12237,7 +12258,7 @@ var LeaferUI = (function (exports) {
12237
12258
  const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
12238
12259
  leaf.killAnimate('transition');
12239
12260
  if (normalStyle)
12240
- leaf.set(normalStyle, true);
12261
+ leaf.set(normalStyle, 'temp');
12241
12262
  const statesStyle = getStyle(leaf);
12242
12263
  if (statesStyle) {
12243
12264
  const { animation } = statesStyle;
@@ -12251,14 +12272,14 @@ var LeaferUI = (function (exports) {
12251
12272
  delete statesStyle.animation;
12252
12273
  }
12253
12274
  leaf.normalStyle = filterStyle(statesStyle, leaf);
12254
- leaf.set(statesStyle, true);
12275
+ leaf.set(statesStyle, 'temp');
12255
12276
  }
12256
12277
  else {
12257
12278
  leaf.normalStyle = undefined;
12258
12279
  }
12259
12280
  if (transition) {
12260
12281
  const toStyle = filterStyle(fromStyle, leaf);
12261
- leaf.set(fromStyle, true);
12282
+ leaf.set(fromStyle, 'temp');
12262
12283
  leaf.animate([fromStyle, toStyle], transition, 'transition', true);
12263
12284
  }
12264
12285
  leaf.__layout.stateStyleChanged = false;
@@ -12956,7 +12977,7 @@ var LeaferUI = (function (exports) {
12956
12977
  this.emit(AnimateEvent.UPDATE, this);
12957
12978
  }
12958
12979
  setStyle(style) {
12959
- this.target.set(style, this.isTemp);
12980
+ this.target.set(style, this.isTemp ? 'temp' : false);
12960
12981
  }
12961
12982
  clearTimer(fn) {
12962
12983
  if (this.timer) {
@@ -13332,6 +13353,9 @@ var LeaferUI = (function (exports) {
13332
13353
  from = fourNumber(from), to = fourNumber(to);
13333
13354
  return from.map((f, i) => number(f, to[i], t));
13334
13355
  },
13356
+ text(from, to, t) {
13357
+ return (typeof from === 'number' || typeof to === 'number') ? MathHelper.float(number(from, to, t), Math.max(getDecimalLen(from), getDecimalLen(to))) : to;
13358
+ },
13335
13359
  shadow,
13336
13360
  innerShadow: shadow
13337
13361
  };
@@ -13340,6 +13364,10 @@ var LeaferUI = (function (exports) {
13340
13364
  number,
13341
13365
  color
13342
13366
  };
13367
+ function getDecimalLen(num) {
13368
+ const decimal = String(num).split('.')[1];
13369
+ return decimal ? decimal.length : 0;
13370
+ }
13343
13371
  function value(from, to, t) {
13344
13372
  return (typeof from === 'number' && typeof to === 'number') ? from + (to - from) * t : to;
13345
13373
  }
@@ -13408,23 +13436,40 @@ var LeaferUI = (function (exports) {
13408
13436
  const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
13409
13437
  const { sqrt } = Math;
13410
13438
  const HighBezierHelper = {
13411
- getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
13412
- let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
13439
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
13440
+ let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
13413
13441
  for (let i = 0; i < gaussNodes.length; i++) {
13414
- t1 = 0.5 * (1 + gaussNodes[i]);
13415
- t2 = 0.5 * (1 - gaussNodes[i]);
13442
+ t1 = half * (1 + gaussNodes[i]);
13443
+ t2 = half * (1 - gaussNodes[i]);
13416
13444
  d1X = getDerivative(t1, fromX, x1, x2, toX);
13417
13445
  d1Y = getDerivative(t1, fromY, y1, y2, toY);
13418
13446
  d2X = getDerivative(t2, fromX, x1, x2, toX);
13419
13447
  d2Y = getDerivative(t2, fromY, y1, y2, toY);
13420
13448
  distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
13421
13449
  }
13422
- return distance * 0.5;
13450
+ return distance * half;
13423
13451
  },
13424
13452
  getDerivative(t, fromV, v1, v2, toV) {
13425
13453
  const o = 1 - t;
13426
13454
  return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
13427
13455
  },
13456
+ getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
13457
+ const dx = getDerivative(t, fromX, x1, x2, toX);
13458
+ const dy = getDerivative(t, fromY, y1, y2, toY);
13459
+ return Math.atan2(dy, dx) / OneRadian;
13460
+ },
13461
+ getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
13462
+ let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
13463
+ if (middle >= 1)
13464
+ return 1;
13465
+ if (middle <= 0)
13466
+ return 0;
13467
+ while (high - low > realPrecision) {
13468
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
13469
+ middle = (low + high) / 2;
13470
+ }
13471
+ return middle;
13472
+ },
13428
13473
  cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
13429
13474
  const o = 1 - t;
13430
13475
  const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
@@ -13436,7 +13481,7 @@ var LeaferUI = (function (exports) {
13436
13481
  data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy);
13437
13482
  }
13438
13483
  };
13439
- const { getDerivative } = HighBezierHelper;
13484
+ const { getDerivative, getDistance } = HighBezierHelper;
13440
13485
 
13441
13486
  const { M, L, C, Z } = PathCommandMap;
13442
13487
  const tempPoint = {}, tempFrom = {};
@@ -13504,11 +13549,12 @@ var LeaferUI = (function (exports) {
13504
13549
  }
13505
13550
  return { total, segments, data };
13506
13551
  },
13507
- getDistancePoint(distanceData, motionDistance) {
13552
+ getDistancePoint(distanceData, motionDistance, motionPrecision) {
13508
13553
  const { segments, data } = distanceData;
13509
13554
  motionDistance = UnitConvert.number(motionDistance, distanceData.total);
13510
13555
  let total = 0, distance, to = {};
13511
13556
  let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
13557
+ let x1, y1, x2, y2, t;
13512
13558
  const len = data.length;
13513
13559
  while (i < len) {
13514
13560
  command = data[i];
@@ -13538,11 +13584,10 @@ var LeaferUI = (function (exports) {
13538
13584
  toY = data[i + 6];
13539
13585
  distance = segments[index];
13540
13586
  if (total + distance > motionDistance) {
13541
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
13542
- motionDistance -= total;
13543
- BezierHelper.getPointAndSet(motionDistance / distance, x, y, x1, y1, x2, y2, toX, toY, to);
13544
- BezierHelper.getPointAndSet(Math.max(0, motionDistance - 0.1) / distance, x, y, x1, y1, x2, y2, toX, toY, tempFrom);
13545
- to.rotation = PointHelper.getAngle(tempFrom, to);
13587
+ x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
13588
+ t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
13589
+ BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
13590
+ to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
13546
13591
  return to;
13547
13592
  }
13548
13593
  x = toX;
@@ -13559,11 +13604,12 @@ var LeaferUI = (function (exports) {
13559
13604
  }
13560
13605
  return to;
13561
13606
  },
13562
- getDistancePath(distanceData, motionDistance) {
13607
+ getDistancePath(distanceData, motionDistance, motionPrecision) {
13563
13608
  const { segments, data } = distanceData, path = [];
13564
13609
  motionDistance = UnitConvert.number(motionDistance, distanceData.total);
13565
13610
  let total = 0, distance, to = {};
13566
13611
  let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
13612
+ let x1, y1, x2, y2, t;
13567
13613
  const len = data.length;
13568
13614
  while (i < len) {
13569
13615
  command = data[i];
@@ -13590,12 +13636,13 @@ var LeaferUI = (function (exports) {
13590
13636
  path.push(command, x, y);
13591
13637
  break;
13592
13638
  case C:
13593
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
13639
+ x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
13594
13640
  toX = data[i + 5];
13595
13641
  toY = data[i + 6];
13596
13642
  distance = segments[index];
13597
13643
  if (total + distance > motionDistance) {
13598
- HighBezierHelper.cut(path, (motionDistance - total) / distance, x, y, x1, y1, x2, y2, toX, toY);
13644
+ t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
13645
+ HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
13599
13646
  return path;
13600
13647
  }
13601
13648
  x = toX;
@@ -13644,6 +13691,7 @@ var LeaferUI = (function (exports) {
13644
13691
  const { updateMatrix, updateAllMatrix } = LeafHelper;
13645
13692
  const { updateBounds } = BranchHelper;
13646
13693
  motionPathType()(ui, 'motionPath');
13694
+ motionPathType(1)(ui, 'motionPrecision');
13647
13695
  motionPathType()(ui, 'motion');
13648
13696
  motionPathType(true)(ui, 'motionRotation');
13649
13697
  ui.getMotionPathData = function () {
@@ -13654,7 +13702,7 @@ var LeaferUI = (function (exports) {
13654
13702
  const data = getMotionPathData(path);
13655
13703
  if (!data.total)
13656
13704
  return {};
13657
- const point = HighCurveHelper.getDistancePoint(data, motionDistance);
13705
+ const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
13658
13706
  MatrixHelper.toOuterPoint(path.localTransform, point);
13659
13707
  const { motionRotation } = this;
13660
13708
  if (motionRotation === false)
@@ -13694,7 +13742,7 @@ var LeaferUI = (function (exports) {
13694
13742
  if (leaf.motionPath) {
13695
13743
  const data = getMotionPathData(leaf);
13696
13744
  if (data.total)
13697
- leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
13745
+ leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
13698
13746
  }
13699
13747
  else {
13700
13748
  leaf.set(leaf.getMotionPoint(motion));
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/worker"),e=require("@leafer-in/robot"),n=require("@leafer-ui/draw"),o=require("@leafer-ui/core"),i=require("@leafer-in/animate");function r(t,e){return n.decorateLeafAttr(t,(t=>n.attr({set(o){this.__setAttr(t,o),this.waitLeafer((()=>e?n.State.setStyleName(this,e,o):n.State.set(this,o)))}})))}function a(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function s(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function l(t,e){"object"!=typeof e&&(e=void 0),f(t,e,"in")}function c(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),f(t,e,"out"))}const u={};function f(t,e,n){const{normalStyle:i}=t;e||(e=u),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==u&&o.State.canAnimate||(n=null);let r=!!n&&function(t,e,n){let i="in"===t?"transition":"transitionOut";"out"===t&&o.isNull(n[i])&&o.isNull(e[i])&&(i="transition");return o.isNull(e[i])?n[i]:e[i]}(n,e,t);const a=r?function(t,e){const n=p(e,t),o=t.animate();o&&p(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),i&&t.set(i,!0);const s=h(t);if(s){const{animation:o}=s;if(o){const i=t.animate(o,void 0,"animation",!0);Object.assign(s,i.endingStyle),"in"!==n||e.animation!==o?i.kill():r=!1,delete s.animation}t.normalStyle=d(s,t),t.set(s,!0)}else t.normalStyle=void 0;if(r){const e=d(a,t);t.set(a,!0),t.animate([a,e],r,"transition",!0)}t.__layout.stateStyleChanged=!1}function h(t){let e;const n={},{state:i}=t,r=s(t),a=i&&t.states[i];a&&o.State.isState(i,t,r)&&(e=y(n,a));const l=n.selectedStyle||t.selectedStyle;if(l&&o.State.isSelected(t,r)&&(e=y(n,l)),o.State.isDisabled(t,r)){const o=n.disabledStyle||t.disabledStyle;o&&(e=y(n,o))}else{const i=n.focusStyle||t.focusStyle;i&&o.State.isFocus(t,r)&&(e=y(n,i));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,r)&&(e=y(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,r)&&(e=y(n,s))}return e?n:void 0}function d(t,e,n,i){const r=n?t:{},a=n||t;for(let t in a)i&&o.State.animateExcludes[t]||(r[t]=e[t]);return r}function p(t,e,n){return d(t,e,n,!0)}function y(t,e){return Object.assign(t,e),!0}function S(t,e){const n=t[e];n&&l(t,n),t.button&&g(t.children,e)}function m(t,e,n){n||(n=t.states[e]),l(t,n),t.button&&g(t.children,null,e)}function g(t,e,n){if(!t)return;let i,r;for(let a=0,s=t.length;a<s;a++){if(i=t[a],e){switch(r=!0,e){case"hoverStyle":o.State.isHover(i)&&(r=!1);break;case"pressStyle":o.State.isPress(i)&&(r=!1);break;case"focusStyle":o.State.isFocus(i)&&(r=!1)}r&&S(i,e)}else n&&m(i,n);i.isBranch&&g(i.children,e,n)}}function b(t,e){const n=t[e];n&&c(t,n),t.button&&_(t.children,e)}function P(t,e,n){c(t,n),t.button&&_(t.children,null,e)}function _(t,e,n){if(!t)return;let o;for(let i=0,r=t.length;i<r;i++)o=t[i],e?b(o,e):n&&P(o,n),o.isBranch&&_(o.children,e,n)}function v(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const r=s(e,n);r&&(o=i[t](r))}return o}function x(t,e,n){let o=e[t];if(!o&&n){const i=s(e,n);i&&(o=i[t])}return o}o.State.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},o.State.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const i=s(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},o.State.isSelected=function(t,e){return x("selected",t,e)},o.State.isDisabled=function(t,e){return x("disabled",t,e)},o.State.isFocus=function(t,e){return v("isFocus",t,e)},o.State.isHover=function(t,e){return v("isHover",t,e)},o.State.isPress=function(t,e){return v("isPress",t,e)},o.State.isDrag=function(t,e){return v("isDrag",t,e)},o.State.setStyleName=function(t,e,n){n?m(t,e,t[e]):P(t,e,t[e])},o.State.set=function(t,e){const n=t.states[e];n?m(t,e,n):P(t,e,n)},o.State.getStyle=h,o.State.updateStyle=f,o.State.updateEventStyle=function(t,e){switch(e){case o.PointerEvent.ENTER:S(t,"hoverStyle");break;case o.PointerEvent.LEAVE:b(t,"hoverStyle");break;case o.PointerEvent.DOWN:S(t,"pressStyle");break;case o.PointerEvent.UP:b(t,"pressStyle")}};const M=o.UI.prototype;r(!1,"selectedStyle")(M,"selected"),r(!1,"disabledStyle")(M,"disabled"),a({})(M,"states"),r("")(M,"state"),o.dataType()(M,"normalStyle"),a()(M,"hoverStyle"),a()(M,"pressStyle"),a()(M,"focusStyle"),a()(M,"selectedStyle"),a()(M,"disabledStyle"),o.dataType(!1)(M,"button"),M.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?S(this,"focusStyle"):b(this,"focusStyle")}))},M.updateState=function(){o.State.updateStyle(this,void 0,"in")};const D=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],H=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:O}=Math,k={getDistance(t,e,n,o,i,r,a,s){let l,c,u,f,h,d,p=0;for(let y=0;y<D.length;y++)l=.5*(1+D[y]),c=.5*(1-D[y]),u=j(l,t,n,i,a),f=j(l,e,o,r,s),h=j(c,t,n,i,a),d=j(c,e,o,r,s),p+=H[y]*(O(u*u+f*f)+O(h*h+d*d));return.5*p},getDerivative(t,e,n,o,i){const r=1-t;return 3*r*r*(n-e)+6*r*t*(o-n)+3*t*t*(i-o)},cut(t,e,o,i,r,a,s,l,c,u){const f=1-e,h=f*o+e*r,d=f*i+e*a,p=f*r+e*s,y=f*a+e*l,S=f*h+e*p,m=f*d+e*y,g=f*S+e*(f*p+e*(f*s+e*c)),b=f*m+e*(f*y+e*(f*l+e*u));t.push(n.PathCommandMap.C,h,d,S,m,g,b)}},{getDerivative:j}=k,{M:A,L:C,C:E,Z:T}=n.PathCommandMap,w={},F={},N={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case A:case C:N.transformPoints(t,e,o,1),o+=3;break;case E:N.transformPoints(t,e,o,3),o+=7;break;case T:o+=1}},transformPoints(t,e,o,i){for(let r=o+1,a=r+2*i;r<a;r+=2)w.x=t[r],w.y=t[r+1],n.MatrixHelper.toOuterPoint(e,w),t[r]=w.x,t[r+1]=w.y},getMotionPathData(t){let e,o,i,r,a=0,s=[],l=0,c=0,u=0;const f=t.length;for(;l<f;){switch(r=t[l],r){case A:case C:o=t[l+1],i=t[l+2],e=r===C&&l>0?n.PointHelper.getDistanceFrom(c,u,o,i):0,c=o,u=i,l+=3;break;case E:o=t[l+5],i=t[l+6],e=k.getDistance(c,u,t[l+1],t[l+2],t[l+3],t[l+4],o,i),c=o,u=i,l+=7;break;case T:l+=1;default:e=0}s.push(e),a+=e}return{total:a,segments:s,data:t}},getDistancePoint(t,e){const{segments:o,data:i}=t;e=n.UnitConvert.number(e,t.total);let r,a,s,l,c=0,u={},f=0,h=0,d=0,p=0;const y=i.length;for(;f<y;){switch(l=i[f],l){case A:case C:if(a=i[f+1],s=i[f+2],r=o[h],c+r>e||!t.total)return f||(d=a,p=s),F.x=d,F.y=p,u.x=a,u.y=s,n.PointHelper.getDistancePoint(F,u,e-c,!0),u.rotation=n.PointHelper.getAngle(F,u),u;d=a,p=s,f+=3;break;case E:if(a=i[f+5],s=i[f+6],r=o[h],c+r>e){const t=i[f+1],o=i[f+2],l=i[f+3],h=i[f+4];return e-=c,n.BezierHelper.getPointAndSet(e/r,d,p,t,o,l,h,a,s,u),n.BezierHelper.getPointAndSet(Math.max(0,e-.1)/r,d,p,t,o,l,h,a,s,F),u.rotation=n.PointHelper.getAngle(F,u),u}d=a,p=s,f+=7;break;case T:f+=1;default:r=0}h++,c+=r}return u},getDistancePath(t,e){const{segments:o,data:i}=t,r=[];e=n.UnitConvert.number(e,t.total);let a,s,l,c,u=0,f={},h=0,d=0,p=0,y=0;const S=i.length;for(;h<S;){switch(c=i[h],c){case A:case C:if(s=i[h+1],l=i[h+2],a=o[d],u+a>e||!t.total)return h||(p=s,y=l),F.x=p,F.y=y,f.x=s,f.y=l,n.PointHelper.getDistancePoint(F,f,e-u,!0),r.push(c,f.x,f.y),r;p=s,y=l,h+=3,r.push(c,p,y);break;case E:const S=i[h+1],m=i[h+2],g=i[h+3],b=i[h+4];if(s=i[h+5],l=i[h+6],a=o[d],u+a>e)return k.cut(r,(e-u)/a,p,y,S,m,g,b,s,l),r;p=s,y=l,h+=7,r.push(c,S,m,g,b,s,l);break;case T:h+=1,r.push(c);default:a=0}d++,u+=a}return r}};function L(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!n.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}n.Transition.register("motion",(function(t,e,o,i){return t?"object"==typeof t&&(t=n.UnitConvert.number(t,i.getMotionTotal())):t=0,e?"object"==typeof e&&(e=n.UnitConvert.number(e,i.getMotionTotal())):e=0,n.Transition.number(t,e,o)})),n.Transition.register("motionRotation",(function(t,e,o){return n.Transition.number(t,e,o)}));const B=n.UI.prototype,{updateMatrix:U,updateAllMatrix:q}=n.LeafHelper,{updateBounds:R}=n.BranchHelper;function z(t){const{motion:e,leaferIsCreated:o}=t;if(!n.isNull(e)){if(o&&(t.leafer.created=!1),t.motionPath){const n=V(t);n.total&&(t.__.__pathForRender=N.getDistancePath(n,e))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(q(t),R(t,t)):U(t));o&&(t.leafer.created=!0)}}function I(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function V(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=N.getMotionPathData(t.getPath(!0,!0))}L()(B,"motionPath"),L()(B,"motion"),L(!0)(B,"motionRotation"),B.getMotionPathData=function(){return V(I(this))},B.getMotionPoint=function(t){const e=I(this),o=V(e);if(!o.total)return{};const i=N.getDistancePoint(o,t);n.MatrixHelper.toOuterPoint(e.localTransform,i);const{motionRotation:r}=this;return!1===r?delete i.rotation:"number"==typeof r&&(i.rotation+=r),i},B.getMotionTotal=function(){return this.getMotionPathData().total},B.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:o}=this;for(let i=0;i<e.length;i++)t=e[i],n.isNull(t.motion)||t.__layout.matrixChanged||(o&&t!==this&&this.leafer.layouter.addExtra(t),z(t))}else z(this)},exports.HighBezierHelper=k,exports.HighCurveHelper=N,exports.motionPathType=L,exports.stateStyleType=a,exports.stateType=r,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})}));
1
+ "use strict";var t=require("@leafer-ui/worker"),e=require("@leafer-in/robot"),n=require("@leafer-ui/draw"),o=require("@leafer-ui/core"),i=require("@leafer-in/animate");function r(t,e){return n.decorateLeafAttr(t,(t=>n.attr({set(o){this.__setAttr(t,o),this.waitLeafer((()=>e?n.State.setStyleName(this,e,o):n.State.set(this,o)))}})))}function a(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function s(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function l(t,e){"object"!=typeof e&&(e=void 0),f(t,e,"in")}function c(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),f(t,e,"out"))}const u={};function f(t,e,n){const{normalStyle:i}=t;e||(e=u),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==u&&o.State.canAnimate||(n=null);let r=!!n&&function(t,e,n){let i="in"===t?"transition":"transitionOut";"out"===t&&o.isNull(n[i])&&o.isNull(e[i])&&(i="transition");return o.isNull(e[i])?n[i]:e[i]}(n,e,t);const a=r?function(t,e){const n=p(e,t),o=t.animate();o&&p(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),i&&t.set(i,"temp");const s=h(t);if(s){const{animation:o}=s;if(o){const i=t.animate(o,void 0,"animation",!0);Object.assign(s,i.endingStyle),"in"!==n||e.animation!==o?i.kill():r=!1,delete s.animation}t.normalStyle=d(s,t),t.set(s,"temp")}else t.normalStyle=void 0;if(r){const e=d(a,t);t.set(a,"temp"),t.animate([a,e],r,"transition",!0)}t.__layout.stateStyleChanged=!1}function h(t){let e;const n={},{state:i}=t,r=s(t),a=i&&t.states[i];a&&o.State.isState(i,t,r)&&(e=y(n,a));const l=n.selectedStyle||t.selectedStyle;if(l&&o.State.isSelected(t,r)&&(e=y(n,l)),o.State.isDisabled(t,r)){const o=n.disabledStyle||t.disabledStyle;o&&(e=y(n,o))}else{const i=n.focusStyle||t.focusStyle;i&&o.State.isFocus(t,r)&&(e=y(n,i));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,r)&&(e=y(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,r)&&(e=y(n,s))}return e?n:void 0}function d(t,e,n,i){const r=n?t:{},a=n||t;for(let t in a)i&&o.State.animateExcludes[t]||(r[t]=e[t]);return r}function p(t,e,n){return d(t,e,n,!0)}function y(t,e){return Object.assign(t,e),!0}function S(t,e){const n=t[e];n&&l(t,n),t.button&&g(t.children,e)}function m(t,e,n){n||(n=t.states[e]),l(t,n),t.button&&g(t.children,null,e)}function g(t,e,n){if(!t)return;let i,r;for(let a=0,s=t.length;a<s;a++){if(i=t[a],e){switch(r=!0,e){case"hoverStyle":o.State.isHover(i)&&(r=!1);break;case"pressStyle":o.State.isPress(i)&&(r=!1);break;case"focusStyle":o.State.isFocus(i)&&(r=!1)}r&&S(i,e)}else n&&m(i,n);i.isBranch&&g(i.children,e,n)}}function b(t,e){const n=t[e];n&&c(t,n),t.button&&_(t.children,e)}function P(t,e,n){c(t,n),t.button&&_(t.children,null,e)}function _(t,e,n){if(!t)return;let o;for(let i=0,r=t.length;i<r;i++)o=t[i],e?b(o,e):n&&P(o,n),o.isBranch&&_(o.children,e,n)}function v(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const r=s(e,n);r&&(o=i[t](r))}return o}function x(t,e,n){let o=e[t];if(!o&&n){const i=s(e,n);i&&(o=i[t])}return o}o.State.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},o.State.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const i=s(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},o.State.isSelected=function(t,e){return x("selected",t,e)},o.State.isDisabled=function(t,e){return x("disabled",t,e)},o.State.isFocus=function(t,e){return v("isFocus",t,e)},o.State.isHover=function(t,e){return v("isHover",t,e)},o.State.isPress=function(t,e){return v("isPress",t,e)},o.State.isDrag=function(t,e){return v("isDrag",t,e)},o.State.setStyleName=function(t,e,n){n?m(t,e,t[e]):P(t,e,t[e])},o.State.set=function(t,e){const n=t.states[e];n?m(t,e,n):P(t,e,n)},o.State.getStyle=h,o.State.updateStyle=f,o.State.updateEventStyle=function(t,e){switch(e){case o.PointerEvent.ENTER:S(t,"hoverStyle");break;case o.PointerEvent.LEAVE:b(t,"hoverStyle");break;case o.PointerEvent.DOWN:S(t,"pressStyle");break;case o.PointerEvent.UP:b(t,"pressStyle")}};const M=o.UI.prototype;r(!1,"selectedStyle")(M,"selected"),r(!1,"disabledStyle")(M,"disabled"),a({})(M,"states"),r("")(M,"state"),o.dataType()(M,"normalStyle"),a()(M,"hoverStyle"),a()(M,"pressStyle"),a()(M,"focusStyle"),a()(M,"selectedStyle"),a()(M,"disabledStyle"),o.dataType(!1)(M,"button"),M.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?S(this,"focusStyle"):b(this,"focusStyle")}))},M.updateState=function(){o.State.updateStyle(this,void 0,"in")};const D=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],O=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:k}=Math,H={getDistance(t,e,n,o,i,r,a,s,l=1){let c,u,f,h,d,p,y=0,S=l/2;for(let l=0;l<D.length;l++)c=S*(1+D[l]),u=S*(1-D[l]),f=T(c,t,n,i,a),h=T(c,e,o,r,s),d=T(u,t,n,i,a),p=T(u,e,o,r,s),y+=O[l]*(k(f*f+h*h)+k(d*d+p*p));return y*S},getDerivative(t,e,n,o,i){const r=1-t;return 3*r*r*(n-e)+6*r*t*(o-n)+3*t*t*(i-o)},getRotation(t,e,o,i,r,a,s,l,c){const u=T(t,e,i,a,l),f=T(t,o,r,s,c);return Math.atan2(f,u)/n.OneRadian},getT(t,e,n,o,i,r,a,s,l,c,u=1){let f=0,h=1,d=t/e,p=u/e/3;if(d>=1)return 1;if(d<=0)return 0;for(;h-f>p;)j(n,o,i,r,a,s,l,c,d)<t?f=d:h=d,d=(f+h)/2;return d},cut(t,e,o,i,r,a,s,l,c,u){const f=1-e,h=f*o+e*r,d=f*i+e*a,p=f*r+e*s,y=f*a+e*l,S=f*h+e*p,m=f*d+e*y,g=f*S+e*(f*p+e*(f*s+e*c)),b=f*m+e*(f*y+e*(f*l+e*u));t.push(n.PathCommandMap.C,h,d,S,m,g,b)}},{getDerivative:T,getDistance:j}=H,{M:C,L:E,C:w,Z:A}=n.PathCommandMap,F={},N={},L={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case C:case E:L.transformPoints(t,e,o,1),o+=3;break;case w:L.transformPoints(t,e,o,3),o+=7;break;case A:o+=1}},transformPoints(t,e,o,i){for(let r=o+1,a=r+2*i;r<a;r+=2)F.x=t[r],F.y=t[r+1],n.MatrixHelper.toOuterPoint(e,F),t[r]=F.x,t[r+1]=F.y},getMotionPathData(t){let e,o,i,r,a=0,s=[],l=0,c=0,u=0;const f=t.length;for(;l<f;){switch(r=t[l],r){case C:case E:o=t[l+1],i=t[l+2],e=r===E&&l>0?n.PointHelper.getDistanceFrom(c,u,o,i):0,c=o,u=i,l+=3;break;case w:o=t[l+5],i=t[l+6],e=H.getDistance(c,u,t[l+1],t[l+2],t[l+3],t[l+4],o,i),c=o,u=i,l+=7;break;case A:l+=1;default:e=0}s.push(e),a+=e}return{total:a,segments:s,data:t}},getDistancePoint(t,e,o){const{segments:i,data:r}=t;e=n.UnitConvert.number(e,t.total);let a,s,l,c,u,f,h,d,p,y=0,S={},m=0,g=0,b=0,P=0;const _=r.length;for(;m<_;){switch(c=r[m],c){case C:case E:if(s=r[m+1],l=r[m+2],a=i[g],y+a>e||!t.total)return m||(b=s,P=l),N.x=b,N.y=P,S.x=s,S.y=l,n.PointHelper.getDistancePoint(N,S,e-y,!0),S.rotation=n.PointHelper.getAngle(N,S),S;b=s,P=l,m+=3;break;case w:if(s=r[m+5],l=r[m+6],a=i[g],y+a>e)return u=r[m+1],f=r[m+2],h=r[m+3],d=r[m+4],p=H.getT(e-y,a,b,P,u,f,h,d,s,l,o),n.BezierHelper.getPointAndSet(p,b,P,u,f,h,d,s,l,S),S.rotation=H.getRotation(p,b,P,u,f,h,d,s,l),S;b=s,P=l,m+=7;break;case A:m+=1;default:a=0}g++,y+=a}return S},getDistancePath(t,e,o){const{segments:i,data:r}=t,a=[];e=n.UnitConvert.number(e,t.total);let s,l,c,u,f,h,d,p,y,S=0,m={},g=0,b=0,P=0,_=0;const v=r.length;for(;g<v;){switch(u=r[g],u){case C:case E:if(l=r[g+1],c=r[g+2],s=i[b],S+s>e||!t.total)return g||(P=l,_=c),N.x=P,N.y=_,m.x=l,m.y=c,n.PointHelper.getDistancePoint(N,m,e-S,!0),a.push(u,m.x,m.y),a;P=l,_=c,g+=3,a.push(u,P,_);break;case w:if(f=r[g+1],h=r[g+2],d=r[g+3],p=r[g+4],l=r[g+5],c=r[g+6],s=i[b],S+s>e)return y=H.getT(e-S,s,P,_,f,h,d,p,l,c,o),H.cut(a,y,P,_,f,h,d,p,l,c),a;P=l,_=c,g+=7,a.push(u,f,h,d,p,l,c);break;case A:g+=1,a.push(u);default:s=0}b++,S+=s}return a}};function R(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!n.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}n.Transition.register("motion",(function(t,e,o,i){return t?"object"==typeof t&&(t=n.UnitConvert.number(t,i.getMotionTotal())):t=0,e?"object"==typeof e&&(e=n.UnitConvert.number(e,i.getMotionTotal())):e=0,n.Transition.number(t,e,o)})),n.Transition.register("motionRotation",(function(t,e,o){return n.Transition.number(t,e,o)}));const B=n.UI.prototype,{updateMatrix:U,updateAllMatrix:q}=n.LeafHelper,{updateBounds:I}=n.BranchHelper;function z(t){const{motion:e,leaferIsCreated:o}=t;if(!n.isNull(e)){if(o&&(t.leafer.created=!1),t.motionPath){const n=W(t);n.total&&(t.__.__pathForRender=L.getDistancePath(n,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(q(t),I(t,t)):U(t));o&&(t.leafer.created=!0)}}function V(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function W(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=L.getMotionPathData(t.getPath(!0,!0))}R()(B,"motionPath"),R(1)(B,"motionPrecision"),R()(B,"motion"),R(!0)(B,"motionRotation"),B.getMotionPathData=function(){return W(V(this))},B.getMotionPoint=function(t){const e=V(this),o=W(e);if(!o.total)return{};const i=L.getDistancePoint(o,t,e.motionPrecision);n.MatrixHelper.toOuterPoint(e.localTransform,i);const{motionRotation:r}=this;return!1===r?delete i.rotation:"number"==typeof r&&(i.rotation+=r),i},B.getMotionTotal=function(){return this.getMotionPathData().total},B.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:o}=this;for(let i=0;i<e.length;i++)t=e[i],n.isNull(t.motion)||t.__layout.matrixChanged||(o&&t!==this&&this.leafer.layouter.addExtra(t),z(t))}else z(this)},exports.HighBezierHelper=H,exports.HighCurveHelper=L,exports.motionPathType=R,exports.stateStyleType=a,exports.stateType=r,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})}));