@visactor/vrender-components 0.22.6 → 0.23.0-alpha.2

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.
Files changed (46) hide show
  1. package/cjs/axis/animate/group-transition.d.ts +1 -1
  2. package/cjs/axis/animate/group-transition.js +3 -3
  3. package/cjs/axis/animate/group-transition.js.map +1 -1
  4. package/cjs/index.d.ts +1 -1
  5. package/cjs/index.js +1 -1
  6. package/cjs/index.js.map +1 -1
  7. package/cjs/label/animate/animate.js +4 -10
  8. package/cjs/label/animate/animate.js.map +1 -1
  9. package/cjs/label/base.d.ts +0 -1
  10. package/cjs/label/base.js +7 -23
  11. package/cjs/label/base.js.map +1 -1
  12. package/cjs/label/overlap/scaler.js +3 -3
  13. package/cjs/label/overlap/scaler.js.map +1 -1
  14. package/cjs/label-item/label-item.js +3 -3
  15. package/cjs/label-item/label-item.js.map +1 -1
  16. package/cjs/poptip/poptip.js +3 -3
  17. package/cjs/poptip/poptip.js.map +1 -1
  18. package/cjs/tag/tag.js +56 -60
  19. package/cjs/tag/tag.js.map +1 -1
  20. package/cjs/weather/weather-box.d.ts +2 -1
  21. package/cjs/weather/weather-box.js +5 -5
  22. package/cjs/weather/weather-box.js.map +1 -1
  23. package/dist/index.es.js +1370 -1262
  24. package/es/axis/animate/group-transition.d.ts +1 -1
  25. package/es/axis/animate/group-transition.js +1 -1
  26. package/es/axis/animate/group-transition.js.map +1 -1
  27. package/es/index.d.ts +1 -1
  28. package/es/index.js +1 -1
  29. package/es/index.js.map +1 -1
  30. package/es/label/animate/animate.js +3 -9
  31. package/es/label/animate/animate.js.map +1 -1
  32. package/es/label/base.d.ts +0 -1
  33. package/es/label/base.js +8 -24
  34. package/es/label/base.js.map +1 -1
  35. package/es/label/overlap/scaler.js +1 -1
  36. package/es/label/overlap/scaler.js.map +1 -1
  37. package/es/label-item/label-item.js +1 -1
  38. package/es/label-item/label-item.js.map +1 -1
  39. package/es/poptip/poptip.js +1 -1
  40. package/es/poptip/poptip.js.map +1 -1
  41. package/es/tag/tag.js +56 -59
  42. package/es/tag/tag.js.map +1 -1
  43. package/es/weather/weather-box.d.ts +2 -1
  44. package/es/weather/weather-box.js +1 -1
  45. package/es/weather/weather-box.js.map +1 -1
  46. package/package.json +6 -5
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, isString, pointAt, isNumber, getDecimalPlaces, isNil, Color, sqrt, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, array, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, normalizeAngle, isValidNumber, flattenArray, isRotateAABBIntersect, isLess, isGreater, cloneDeep, get, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, pointInRect, calculateAnchorOfBounds, computeQuadrant, polygonContainPoint } from '@visactor/vutils';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, Color, isNumber, cos, sin, isString, pointAt, sqrt, OBBBounds, isNil, has, normalTransform, isValidUrl, isBase64, acos, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, normalizeAngle, isValidNumber, flattenArray, array, isRotateAABBIntersect, isLess, isGreater, cloneDeep, get, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, calculateAnchorOfBounds, computeQuadrant, polygonContainPoint } from '@visactor/vutils';
2
2
  import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
3
3
 
4
4
  class Generator {
@@ -938,22 +938,22 @@ var AttributeUpdateType;
938
938
  !function (AttributeUpdateType) {
939
939
  AttributeUpdateType[AttributeUpdateType.INIT = 0] = "INIT", AttributeUpdateType[AttributeUpdateType.DEFAULT = 1] = "DEFAULT", AttributeUpdateType[AttributeUpdateType.STATE = 2] = "STATE", AttributeUpdateType[AttributeUpdateType.ANIMATE_BIND = 10] = "ANIMATE_BIND", AttributeUpdateType[AttributeUpdateType.ANIMATE_PLAY = 11] = "ANIMATE_PLAY", AttributeUpdateType[AttributeUpdateType.ANIMATE_START = 12] = "ANIMATE_START", AttributeUpdateType[AttributeUpdateType.ANIMATE_UPDATE = 13] = "ANIMATE_UPDATE", AttributeUpdateType[AttributeUpdateType.ANIMATE_END = 14] = "ANIMATE_END", AttributeUpdateType[AttributeUpdateType.TRANSLATE = 20] = "TRANSLATE", AttributeUpdateType[AttributeUpdateType.TRANSLATE_TO = 21] = "TRANSLATE_TO", AttributeUpdateType[AttributeUpdateType.SCALE = 22] = "SCALE", AttributeUpdateType[AttributeUpdateType.SCALE_TO = 23] = "SCALE_TO", AttributeUpdateType[AttributeUpdateType.ROTATE = 24] = "ROTATE", AttributeUpdateType[AttributeUpdateType.ROTATE_TO = 25] = "ROTATE_TO";
940
940
  }(AttributeUpdateType || (AttributeUpdateType = {}));
941
- var AnimateStatus;
941
+ var AnimateStatus$1;
942
942
  !function (AnimateStatus) {
943
943
  AnimateStatus[AnimateStatus.INITIAL = 0] = "INITIAL", AnimateStatus[AnimateStatus.RUNNING = 1] = "RUNNING", AnimateStatus[AnimateStatus.PAUSED = 2] = "PAUSED", AnimateStatus[AnimateStatus.END = 3] = "END";
944
- }(AnimateStatus || (AnimateStatus = {}));
945
- var AnimateMode;
944
+ }(AnimateStatus$1 || (AnimateStatus$1 = {}));
945
+ var AnimateMode$1;
946
946
  !function (AnimateMode) {
947
947
  AnimateMode[AnimateMode.NORMAL = 0] = "NORMAL", AnimateMode[AnimateMode.SET_ATTR_IMMEDIATELY = 1] = "SET_ATTR_IMMEDIATELY";
948
- }(AnimateMode || (AnimateMode = {}));
949
- var AnimateStepType;
948
+ }(AnimateMode$1 || (AnimateMode$1 = {}));
949
+ var AnimateStepType$1;
950
950
  !function (AnimateStepType) {
951
951
  AnimateStepType.wait = "wait", AnimateStepType.from = "from", AnimateStepType.to = "to", AnimateStepType.customAnimate = "customAnimate";
952
- }(AnimateStepType || (AnimateStepType = {}));
953
- var Direction$1;
952
+ }(AnimateStepType$1 || (AnimateStepType$1 = {}));
953
+ var Direction;
954
954
  !function (Direction) {
955
955
  Direction[Direction.ROW = 1] = "ROW", Direction[Direction.COLUMN = 2] = "COLUMN";
956
- }(Direction$1 || (Direction$1 = {}));
956
+ }(Direction || (Direction = {}));
957
957
  var CurveTypeEnum;
958
958
  !function (CurveTypeEnum) {
959
959
  CurveTypeEnum[CurveTypeEnum.CubicBezierCurve = 0] = "CubicBezierCurve", CurveTypeEnum[CurveTypeEnum.QuadraticBezierCurve = 1] = "QuadraticBezierCurve", CurveTypeEnum[CurveTypeEnum.ArcCurve = 2] = "ArcCurve", CurveTypeEnum[CurveTypeEnum.LineCurve = 3] = "LineCurve", CurveTypeEnum[CurveTypeEnum.EllipseCurve = 4] = "EllipseCurve", CurveTypeEnum[CurveTypeEnum.MoveCurve = 5] = "MoveCurve";
@@ -1126,7 +1126,7 @@ class QuadraticBezierCurve extends Curve {
1126
1126
  return this._validPoint() ? quadLength(this.p0, this.p1, this.p2) : 60;
1127
1127
  }
1128
1128
  calcProjLength(direction) {
1129
- return direction === Direction$1.ROW ? abs(this.p0.x - this.p2.x) : direction === Direction$1.COLUMN ? abs(this.p0.y - this.p2.y) : 0;
1129
+ return direction === Direction.ROW ? abs(this.p0.x - this.p2.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p2.y) : 0;
1130
1130
  }
1131
1131
  getAngleAt(t) {
1132
1132
  const minT = max(t - .01, 0),
@@ -1190,7 +1190,7 @@ class CubicBezierCurve extends Curve {
1190
1190
  return this._validPoint() ? cubicLength(this.p0, this.p1, this.p2, this.p3) : 60;
1191
1191
  }
1192
1192
  calcProjLength(direction) {
1193
- return direction === Direction$1.ROW ? abs(this.p0.x - this.p3.x) : direction === Direction$1.COLUMN ? abs(this.p0.y - this.p3.y) : 0;
1193
+ return direction === Direction.ROW ? abs(this.p0.x - this.p3.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p3.y) : 0;
1194
1194
  }
1195
1195
  getAngleAt(t) {
1196
1196
  const minT = max(t - .01, 0),
@@ -1243,7 +1243,7 @@ class LineCurve extends Curve {
1243
1243
  return this._validPoint() ? PointService.distancePP(this.p0, this.p1) : 60;
1244
1244
  }
1245
1245
  calcProjLength(direction) {
1246
- return direction === Direction$1.ROW ? abs(this.p0.x - this.p1.x) : direction === Direction$1.COLUMN ? abs(this.p0.y - this.p1.y) : 0;
1246
+ return direction === Direction.ROW ? abs(this.p0.x - this.p1.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p1.y) : 0;
1247
1247
  }
1248
1248
  draw(path, x, y, sx, sy, percent) {
1249
1249
  if (path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y), percent >= 1) path.lineTo(this.p1.x * sx + x, this.p1.y * sy + y);else if (percent > 0) {
@@ -1319,14 +1319,14 @@ class SegContext {
1319
1319
  }
1320
1320
  getLength(direction) {
1321
1321
  var _a, _b;
1322
- if (direction === Direction$1.COLUMN) {
1322
+ if (direction === Direction.COLUMN) {
1323
1323
  if (!this.curves.length) return 0;
1324
1324
  const sc = this.curves[0],
1325
1325
  ec = this.curves[this.curves.length - 1],
1326
1326
  endP = null !== (_a = ec.p3) && void 0 !== _a ? _a : ec.p1;
1327
1327
  return abs(sc.p0.y - endP.y);
1328
1328
  }
1329
- if (direction === Direction$1.ROW) {
1329
+ if (direction === Direction.ROW) {
1330
1330
  if (!this.curves.length) return 0;
1331
1331
  const sc = this.curves[0],
1332
1332
  ec = this.curves[this.curves.length - 1],
@@ -1356,7 +1356,7 @@ function genCurveSegments(path, points) {
1356
1356
  for (let i = 0, n = points.length; i <= n; i++) i >= n === defined0 && ((defined0 = !defined0) ? path.lineStart() : path.lineEnd()), defined0 && path.point(points[i]);
1357
1357
  }
1358
1358
  function genSegContext(curveType, direction, points) {
1359
- const curveDirection = null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction$1.ROW : Direction$1.COLUMN;
1359
+ const curveDirection = null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN;
1360
1360
  return "monotoneY" === curveType ? new ReflectSegContext(curveType, curveDirection) : new SegContext(curveType, curveDirection);
1361
1361
  }
1362
1362
 
@@ -1618,7 +1618,7 @@ function genStepSegments(points, t) {
1618
1618
  startPoint: startPoint
1619
1619
  } = params;
1620
1620
  if (points.length < 2 - Number(!!startPoint)) return null;
1621
- const segContext = new SegContext("step", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction$1.ROW : Direction$1.COLUMN);
1621
+ const segContext = new SegContext("step", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
1622
1622
  return genStepTypeSegments(new Step$1(segContext, t, startPoint), points), segContext;
1623
1623
  }
1624
1624
  function genStepTypeSegments(path, points) {
@@ -1949,7 +1949,7 @@ class CustomPath2D extends CurvePath {
1949
1949
  } = line.attribute;
1950
1950
  if (!points) return;
1951
1951
  const cache = calcLineCache(points, curveType);
1952
- "x" === clipRangeByDimension ? this.direction = Direction$1.ROW : "y" === clipRangeByDimension ? this.direction = Direction$1.COLUMN : "auto" === clipRangeByDimension && (this.direction = cache.direction), this._curves = cache.curves;
1952
+ "x" === clipRangeByDimension ? this.direction = Direction.ROW : "y" === clipRangeByDimension ? this.direction = Direction.COLUMN : "auto" === clipRangeByDimension && (this.direction = cache.direction), this._curves = cache.curves;
1953
1953
  }
1954
1954
  fromCustomPath2D(path, x, y, sX, sY) {
1955
1955
  return this.clear(), this._runCommandList(path.commandList, x, y, sX, sY), this._updateBounds(), this;
@@ -2111,13 +2111,13 @@ class CustomPath2D extends CurvePath {
2111
2111
  this.commandList = [], this._boundsContext = null, this._ctx = null;
2112
2112
  }
2113
2113
  getLength() {
2114
- if (this.direction === Direction$1.COLUMN) {
2114
+ if (this.direction === Direction.COLUMN) {
2115
2115
  if (!this._curves.length) return 0;
2116
2116
  const sc = this._curves[0],
2117
2117
  ec = this._curves[this._curves.length - 1];
2118
2118
  return abs(sc.p0.y - ec.p1.y);
2119
2119
  }
2120
- if (this.direction === Direction$1.ROW) {
2120
+ if (this.direction === Direction.ROW) {
2121
2121
  if (!this._curves.length) return 0;
2122
2122
  const sc = this._curves[0],
2123
2123
  ec = this._curves[this._curves.length - 1];
@@ -4212,530 +4212,229 @@ const EventTarget = {
4212
4212
  }
4213
4213
  };
4214
4214
 
4215
- class Easing {
4216
- constructor() {}
4217
- static linear(t) {
4218
- return t;
4219
- }
4220
- static none() {
4221
- return this.linear;
4215
+ var ColorType;
4216
+ !function (ColorType) {
4217
+ ColorType[ColorType.Color255 = 0] = "Color255", ColorType[ColorType.Color1 = 1] = "Color1";
4218
+ }(ColorType || (ColorType = {}));
4219
+ class ColorStore {
4220
+ static Get(str) {
4221
+ let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ColorType.Color1;
4222
+ let arr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0, 1];
4223
+ if (size === ColorType.Color1) {
4224
+ const color = ColorStore.store1[str];
4225
+ if (color) return arr[0] = color[0], arr[1] = color[1], arr[2] = color[2], arr[3] = color[3], arr;
4226
+ const c = Color.parseColorString(str);
4227
+ if (c) {
4228
+ const data = [c.r / 255, c.g / 255, c.b / 255, c.opacity];
4229
+ ColorStore.store1[str] = data, ColorStore.store255[str] = [c.r, c.g, c.b, c.opacity], arr[0] = data[0], arr[1] = data[1], arr[2] = data[2], arr[3] = data[3];
4230
+ }
4231
+ return arr;
4232
+ }
4233
+ const color = ColorStore.store255[str];
4234
+ if (color) return arr[0] = color[0], arr[1] = color[1], arr[2] = color[2], arr[3] = color[3], arr;
4235
+ const c = Color.parseColorString(str);
4236
+ return c && (ColorStore.store1[str] = [c.r / 255, c.g / 255, c.b / 255, c.opacity], ColorStore.store255[str] = [c.r, c.g, c.b, c.opacity], arr[0] = c.r, arr[1] = c.g, arr[2] = c.b, arr[3] = c.opacity), arr;
4222
4237
  }
4223
- static get(amount) {
4224
- return amount < -1 ? amount = -1 : amount > 1 && (amount = 1), function (t) {
4225
- return 0 === amount ? t : amount < 0 ? t * (t * -amount + 1 + amount) : t * ((2 - t) * amount + (1 - amount));
4226
- };
4238
+ static Set(str, size, arr) {
4239
+ if (size === ColorType.Color1) {
4240
+ if (ColorStore.store1[str]) return;
4241
+ ColorStore.store1[str] = arr, ColorStore.store255[str] = [Math.floor(255 * arr[0]), Math.floor(255 * arr[1]), Math.floor(255 * arr[2]), Math.floor(255 * arr[3])];
4242
+ } else {
4243
+ if (ColorStore.store255[str]) return;
4244
+ ColorStore.store255[str] = arr, ColorStore.store1[str] = [arr[0] / 255, arr[1] / 255, arr[2] / 255, arr[3]];
4245
+ }
4227
4246
  }
4228
- static getPowIn(pow) {
4229
- return function (t) {
4230
- return Math.pow(t, pow);
4231
- };
4247
+ }
4248
+ ColorStore.store255 = {}, ColorStore.store1 = {};
4249
+
4250
+ function colorArrayToString(color) {
4251
+ let alphaChannel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
4252
+ return Array.isArray(color) && isNumber(color[0]) ? alphaChannel ? `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])},${color[3].toFixed(2)})` : `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])})` : color;
4253
+ }
4254
+ function interpolateColor(from, to, ratio, alphaChannel, cb) {
4255
+ if (Array.isArray(from) && !isNumber(from[0]) || Array.isArray(to) && !isNumber(to[0])) {
4256
+ return new Array(4).fill(0).map((_, index) => _interpolateColor(isArray(from) ? from[index] : from, isArray(to) ? to[index] : to, ratio, alphaChannel));
4232
4257
  }
4233
- static getPowOut(pow) {
4234
- return function (t) {
4235
- return 1 - Math.pow(1 - t, pow);
4236
- };
4258
+ return _interpolateColor(from, to, ratio, alphaChannel, cb);
4259
+ }
4260
+ function _interpolateColor(from, to, ratio, alphaChannel, cb) {
4261
+ if (!from || !to) return from && colorArrayToString(from) || to && colorArrayToString(to) || !1;
4262
+ let fromArray,
4263
+ toArray,
4264
+ fromGradient = !1,
4265
+ toGradient = !1;
4266
+ if (Array.isArray(from) ? fromArray = from : "string" == typeof from ? fromArray = ColorStore.Get(from, ColorType.Color255) : fromGradient = !0, Array.isArray(to) ? toArray = to : "string" == typeof to ? toArray = ColorStore.Get(to, ColorType.Color255) : toGradient = !0, fromGradient !== toGradient) {
4267
+ const gradient = fromGradient ? from : to,
4268
+ pure = fromGradient ? to : from,
4269
+ gradientFromPure = Object.assign(Object.assign({}, gradient), {
4270
+ stops: gradient.stops.map(v => Object.assign(Object.assign({}, v), {
4271
+ color: colorArrayToString(pure)
4272
+ }))
4273
+ });
4274
+ return fromGradient ? interpolateColor(gradient, gradientFromPure, ratio, alphaChannel, cb) : interpolateColor(gradientFromPure, gradient, ratio, alphaChannel, cb);
4237
4275
  }
4238
- static getPowInOut(pow) {
4239
- return function (t) {
4240
- return (t *= 2) < 1 ? .5 * Math.pow(t, pow) : 1 - .5 * Math.abs(Math.pow(2 - t, pow));
4241
- };
4276
+ if (fromGradient) {
4277
+ if (from.gradient === to.gradient) {
4278
+ const fc = from,
4279
+ tc = to,
4280
+ fromStops = fc.stops,
4281
+ toStops = tc.stops;
4282
+ if (fromStops.length !== toStops.length) return !1;
4283
+ if ("linear" === fc.gradient) return interpolateGradientLinearColor(fc, tc, ratio);
4284
+ if ("radial" === fc.gradient) return interpolateGradientRadialColor(fc, tc, ratio);
4285
+ if ("conical" === fc.gradient) return interpolateGradientConicalColor(fc, tc, ratio);
4286
+ }
4287
+ return !1;
4242
4288
  }
4243
- static getBackIn(amount) {
4244
- return function (t) {
4245
- return t * t * ((amount + 1) * t - amount);
4246
- };
4289
+ cb && cb(fromArray, toArray);
4290
+ return colorArrayToString(interpolatePureColorArray(fromArray, toArray, ratio), alphaChannel);
4291
+ }
4292
+ function interpolateGradientLinearColor(fc, tc, ratio) {
4293
+ const fStops = fc.stops,
4294
+ tStops = tc.stops;
4295
+ return {
4296
+ gradient: "linear",
4297
+ x0: fc.x0 + (tc.x0 - fc.x0) * ratio,
4298
+ x1: fc.x1 + (tc.x1 - fc.x1) * ratio,
4299
+ y0: fc.y0 + (tc.y0 - fc.y0) * ratio,
4300
+ y1: fc.y1 + (tc.y1 - fc.y1) * ratio,
4301
+ stops: new Array(fStops.length).fill(0).map((_, i) => ({
4302
+ color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),
4303
+ offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio
4304
+ }))
4305
+ };
4306
+ }
4307
+ function interpolateGradientRadialColor(fc, tc, ratio) {
4308
+ const fStops = fc.stops,
4309
+ tStops = tc.stops;
4310
+ return {
4311
+ gradient: "radial",
4312
+ x0: fc.x0 + (tc.x0 - fc.x0) * ratio,
4313
+ x1: fc.x1 + (tc.x1 - fc.x1) * ratio,
4314
+ y0: fc.y0 + (tc.y0 - fc.y0) * ratio,
4315
+ y1: fc.y1 + (tc.y1 - fc.y1) * ratio,
4316
+ r0: fc.r0 + (tc.r0 - fc.r0) * ratio,
4317
+ r1: fc.r1 + (tc.r1 - fc.r1) * ratio,
4318
+ stops: new Array(fStops.length).fill(0).map((_, i) => ({
4319
+ color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),
4320
+ offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio
4321
+ }))
4322
+ };
4323
+ }
4324
+ function interpolateGradientConicalColor(fc, tc, ratio) {
4325
+ const fStops = fc.stops,
4326
+ tStops = tc.stops;
4327
+ return {
4328
+ gradient: "conical",
4329
+ startAngle: fc.startAngle + (tc.startAngle - fc.startAngle) * ratio,
4330
+ endAngle: fc.endAngle + (tc.endAngle - fc.endAngle) * ratio,
4331
+ x: fc.x + (tc.x - fc.x) * ratio,
4332
+ y: fc.y + (tc.y - fc.y) * ratio,
4333
+ stops: new Array(fStops.length).fill(0).map((_, i) => ({
4334
+ color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),
4335
+ offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio
4336
+ }))
4337
+ };
4338
+ }
4339
+ function interpolatePureColorArray(from, to, ratio) {
4340
+ return [from[0] + (to[0] - from[0]) * ratio, from[1] + (to[1] - from[1]) * ratio, from[2] + (to[2] - from[2]) * ratio, from[3] + (to[3] - from[3]) * ratio];
4341
+ }
4342
+ function interpolatePureColorArrayToStr(from, to, ratio) {
4343
+ return `rgba(${from[0] + (to[0] - from[0]) * ratio},${from[1] + (to[1] - from[1]) * ratio},${from[2] + (to[2] - from[2]) * ratio},${from[3] + (to[3] - from[3]) * ratio})`;
4344
+ }
4345
+ const _fromColorRGB = [0, 0, 0, 0],
4346
+ _toColorRGB = [0, 0, 0, 0];
4347
+ function colorStringInterpolationToStr(fromColor, toColor, ratio) {
4348
+ return ColorStore.Get(fromColor, ColorType.Color255, _fromColorRGB), ColorStore.Get(toColor, ColorType.Color255, _toColorRGB), `rgba(${Math.round(_fromColorRGB[0] + (_toColorRGB[0] - _fromColorRGB[0]) * ratio)},${Math.round(_fromColorRGB[1] + (_toColorRGB[1] - _fromColorRGB[1]) * ratio)},${Math.round(_fromColorRGB[2] + (_toColorRGB[2] - _fromColorRGB[2]) * ratio)},${_fromColorRGB[3] + (_toColorRGB[3] - _fromColorRGB[3]) * ratio})`;
4349
+ }
4350
+
4351
+ class ResourceLoader {
4352
+ static GetImage(url, mark) {
4353
+ var _a;
4354
+ const data = ResourceLoader.cache.get(url);
4355
+ data ? "fail" === data.loadState ? application.global.getRequestAnimationFrame()(() => {
4356
+ mark.imageLoadFail(url);
4357
+ }) : "init" === data.loadState || "loading" === data.loadState ? null === (_a = data.waitingMark) || void 0 === _a || _a.push(mark) : mark && mark.imageLoadSuccess(url, data.data) : ResourceLoader.loadImage(url, mark);
4247
4358
  }
4248
- static getBackOut(amount) {
4249
- return function (t) {
4250
- return --t * t * ((amount + 1) * t + amount) + 1;
4251
- };
4359
+ static GetSvg(svgStr, mark) {
4360
+ var _a;
4361
+ let data = ResourceLoader.cache.get(svgStr);
4362
+ data ? "fail" === data.loadState ? application.global.getRequestAnimationFrame()(() => {
4363
+ mark.imageLoadFail(svgStr);
4364
+ }) : "init" === data.loadState || "loading" === data.loadState ? null === (_a = data.waitingMark) || void 0 === _a || _a.push(mark) : mark && mark.imageLoadSuccess(svgStr, data.data) : (data = {
4365
+ type: "image",
4366
+ loadState: "init"
4367
+ }, ResourceLoader.cache.set(svgStr, data), data.dataPromise = application.global.loadSvg(svgStr), data.dataPromise ? (data.waitingMark = [mark], data.dataPromise.then(res => {
4368
+ var _a;
4369
+ data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
4370
+ (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(svgStr, res.data)) : (data.loadState = "fail", mark.imageLoadFail(svgStr));
4371
+ }), data.waitingMark && (data.waitingMark = []);
4372
+ })) : (data.loadState = "fail", mark.imageLoadFail(svgStr)));
4252
4373
  }
4253
- static getBackInOut(amount) {
4254
- return amount *= 1.525, function (t) {
4255
- return (t *= 2) < 1 ? t * t * ((amount + 1) * t - amount) * .5 : .5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2);
4256
- };
4374
+ static GetFile(url, type) {
4375
+ let data = ResourceLoader.cache.get(url);
4376
+ return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
4377
+ type: type,
4378
+ loadState: "init"
4379
+ }, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
4257
4380
  }
4258
- static sineIn(t) {
4259
- return 1 - Math.cos(t * Math.PI / 2);
4381
+ static loading() {
4382
+ setTimeout(() => {
4383
+ if (!ResourceLoader.isLoading && ResourceLoader.toLoadAueue.length) {
4384
+ ResourceLoader.isLoading = !0;
4385
+ const tasks = ResourceLoader.toLoadAueue.splice(0, 10),
4386
+ promises = [];
4387
+ tasks.forEach(task => {
4388
+ const {
4389
+ url: url,
4390
+ marks: marks
4391
+ } = task,
4392
+ data = {
4393
+ type: "image",
4394
+ loadState: "init"
4395
+ };
4396
+ if (ResourceLoader.cache.set(url, data), data.dataPromise = application.global.loadImage(url), data.dataPromise) {
4397
+ data.waitingMark = marks;
4398
+ const end = data.dataPromise.then(res => {
4399
+ var _a;
4400
+ data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
4401
+ (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(url, res.data)) : (data.loadState = "fail", mark.imageLoadFail(url));
4402
+ }), data.waitingMark && (data.waitingMark = []);
4403
+ });
4404
+ promises.push(end);
4405
+ } else data.loadState = "fail", marks.forEach(mark => mark.imageLoadFail(url));
4406
+ }), Promise.all(promises).then(() => {
4407
+ ResourceLoader.isLoading = !1, this.onLoadSuccessCb.forEach(cb => cb()), ResourceLoader.loading();
4408
+ }).catch(error => {
4409
+ console.error(error), ResourceLoader.isLoading = !1, this.onLoadSuccessCb.forEach(cb => cb()), ResourceLoader.loading();
4410
+ });
4411
+ }
4412
+ }, 0);
4260
4413
  }
4261
- static sineOut(t) {
4262
- return Math.sin(t * Math.PI / 2);
4414
+ static loadImage(url, mark) {
4415
+ const index = getIndex(url, ResourceLoader.toLoadAueue);
4416
+ if (-1 !== index) return ResourceLoader.toLoadAueue[index].marks.push(mark), void ResourceLoader.loading();
4417
+ ResourceLoader.toLoadAueue.push({
4418
+ url: url,
4419
+ marks: [mark]
4420
+ }), ResourceLoader.loading();
4263
4421
  }
4264
- static sineInOut(t) {
4265
- return -(Math.cos(Math.PI * t) - 1) / 2;
4422
+ static improveImageLoading(url) {
4423
+ const index = getIndex(url, ResourceLoader.toLoadAueue);
4424
+ if (-1 !== index) {
4425
+ const elememt = ResourceLoader.toLoadAueue.splice(index, 1);
4426
+ ResourceLoader.toLoadAueue.unshift(elememt[0]);
4427
+ }
4266
4428
  }
4267
- static expoIn(t) {
4268
- return 0 === t ? 0 : Math.pow(2, 10 * t - 10);
4269
- }
4270
- static expoOut(t) {
4271
- return 1 === t ? 1 : 1 - Math.pow(2, -10 * t);
4272
- }
4273
- static expoInOut(t) {
4274
- return 0 === t ? 0 : 1 === t ? 1 : t < .5 ? Math.pow(2, 20 * t - 10) / 2 : (2 - Math.pow(2, -20 * t + 10)) / 2;
4275
- }
4276
- static circIn(t) {
4277
- return -(Math.sqrt(1 - t * t) - 1);
4278
- }
4279
- static circOut(t) {
4280
- return Math.sqrt(1 - --t * t);
4281
- }
4282
- static circInOut(t) {
4283
- return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
4284
- }
4285
- static bounceOut(t) {
4286
- return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
4287
- }
4288
- static bounceIn(t) {
4289
- return 1 - Easing.bounceOut(1 - t);
4290
- }
4291
- static bounceInOut(t) {
4292
- return t < .5 ? .5 * Easing.bounceIn(2 * t) : .5 * Easing.bounceOut(2 * t - 1) + .5;
4293
- }
4294
- static getElasticIn(amplitude, period) {
4295
- return function (t) {
4296
- if (0 === t || 1 === t) return t;
4297
- const s = period / pi2 * Math.asin(1 / amplitude);
4298
- return -amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period);
4299
- };
4300
- }
4301
- static getElasticOut(amplitude, period) {
4302
- return function (t) {
4303
- if (0 === t || 1 === t) return t;
4304
- const s = period / pi2 * Math.asin(1 / amplitude);
4305
- return amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1;
4306
- };
4307
- }
4308
- static getElasticInOut(amplitude, period) {
4309
- return function (t) {
4310
- const s = period / pi2 * Math.asin(1 / amplitude);
4311
- return (t *= 2) < 1 ? amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * -.5 : amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * .5 + 1;
4312
- };
4313
- }
4314
- static registerFunc(name, func) {
4315
- Easing[name] = func;
4316
- }
4317
- }
4318
- function flicker(t, n) {
4319
- const step = 1 / n;
4320
- let flag = 1;
4321
- for (; t > step;) t -= step, flag *= -1;
4322
- const v = flag * t / step;
4323
- return v > 0 ? v : 1 + v;
4324
- }
4325
- Easing.quadIn = Easing.getPowIn(2), Easing.quadOut = Easing.getPowOut(2), Easing.quadInOut = Easing.getPowInOut(2), Easing.cubicIn = Easing.getPowIn(3), Easing.cubicOut = Easing.getPowOut(3), Easing.cubicInOut = Easing.getPowInOut(3), Easing.quartIn = Easing.getPowIn(4), Easing.quartOut = Easing.getPowOut(4), Easing.quartInOut = Easing.getPowInOut(4), Easing.quintIn = Easing.getPowIn(5), Easing.quintOut = Easing.getPowOut(5), Easing.quintInOut = Easing.getPowInOut(5), Easing.backIn = Easing.getBackIn(1.7), Easing.backOut = Easing.getBackOut(1.7), Easing.backInOut = Easing.getBackInOut(1.7), Easing.elasticIn = Easing.getElasticIn(1, .3), Easing.elasticOut = Easing.getElasticOut(1, .3), Easing.elasticInOut = Easing.getElasticInOut(1, .3 * 1.5), Easing.easeInOutQuad = t => (t /= .5) < 1 ? .5 * Math.pow(t, 2) : -.5 * ((t -= 2) * t - 2), Easing.easeOutElastic = x => {
4326
- const c4 = 2 * Math.PI / 3;
4327
- return 0 === x ? 0 : 1 === x ? 1 : Math.pow(2, -10 * x) * Math.sin((10 * x - .75) * c4) + 1;
4328
- }, Easing.easeInOutElastic = x => {
4329
- const c5 = 2 * Math.PI / 4.5;
4330
- return 0 === x ? 0 : 1 === x ? 1 : x < .5 ? -Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
4331
- };
4332
- for (let i = 0; i < 10; i++) Easing[`flicker${i}`] = t => flicker(t, i);
4333
- for (let i = 2; i < 10; i++) Easing[`aIn${i}`] = t => i * t * t + (1 - i) * t;
4334
-
4335
- class DefaultTimeline {
4336
- constructor() {
4337
- this.id = Generator.GenAutoIncrementId(), this.animateHead = null, this.animateTail = null, this.animateCount = 0, this.paused = !1;
4338
- }
4339
- addAnimate(animate) {
4340
- this.animateTail ? (this.animateTail.nextAnimate = animate, animate.prevAnimate = this.animateTail, this.animateTail = animate, animate.nextAnimate = null) : (this.animateHead = animate, this.animateTail = animate), this.animateCount++;
4341
- }
4342
- pause() {
4343
- this.paused = !0;
4344
- }
4345
- resume() {
4346
- this.paused = !1;
4347
- }
4348
- tick(delta) {
4349
- if (this.paused) return;
4350
- let animate = this.animateHead;
4351
- for (this.animateCount = 0; animate;) animate.status === AnimateStatus.END ? this.removeAnimate(animate) : animate.status === AnimateStatus.RUNNING || animate.status === AnimateStatus.INITIAL ? (this.animateCount++, animate.advance(delta)) : animate.status === AnimateStatus.PAUSED && this.animateCount++, animate = animate.nextAnimate;
4352
- }
4353
- clear() {
4354
- let animate = this.animateHead;
4355
- for (; animate;) animate.release(), animate = animate.nextAnimate;
4356
- this.animateHead = null, this.animateTail = null, this.animateCount = 0;
4357
- }
4358
- removeAnimate(animate) {
4359
- let release = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
4360
- animate._onRemove && animate._onRemove.forEach(cb => cb()), animate === this.animateHead ? (this.animateHead = animate.nextAnimate, animate === this.animateTail ? this.animateTail = null : this.animateHead.prevAnimate = null) : animate === this.animateTail ? (this.animateTail = animate.prevAnimate, this.animateTail.nextAnimate = null) : (animate.prevAnimate.nextAnimate = animate.nextAnimate, animate.nextAnimate.prevAnimate = animate.prevAnimate), release && animate.release();
4361
- }
4362
- }
4363
- const defaultTimeline = new DefaultTimeline();
4364
-
4365
- class ACustomAnimate {
4366
- constructor(from, to, duration, easing, params) {
4367
- this.from = from, this.to = to, this.duration = duration, this.easing = easing, this.params = params, this.updateCount = 0;
4368
- }
4369
- bind(target, subAni) {
4370
- this.target = target, this.subAnimate = subAni, this.onBind();
4371
- }
4372
- onBind() {}
4373
- onFirstRun() {}
4374
- onStart() {}
4375
- onEnd() {}
4376
- getEndProps() {
4377
- return this.to;
4378
- }
4379
- getFromProps() {
4380
- return this.from;
4381
- }
4382
- getMergedEndProps() {
4383
- var _a;
4384
- const thisEndProps = this.getEndProps();
4385
- return thisEndProps ? this._endProps === thisEndProps ? this._mergedEndProps : (this._endProps = thisEndProps, void (this._mergedEndProps = Object.assign({}, null !== (_a = this.step.prev.getLastProps()) && void 0 !== _a ? _a : {}, thisEndProps))) : this.step.prev ? this.step.prev.getLastProps() : thisEndProps;
4386
- }
4387
- update(end, ratio, out) {
4388
- if (0 === this.updateCount) {
4389
- this.onFirstRun();
4390
- const props = this.step.getLastProps();
4391
- Object.keys(props).forEach(k => {
4392
- this.subAnimate.animate.validAttr(k) && (out[k] = props[k]);
4393
- });
4394
- }
4395
- this.updateCount += 1, this.onUpdate(end, ratio, out), end && this.onEnd();
4396
- }
4397
- }
4398
- class CbAnimate extends ACustomAnimate {
4399
- constructor(cb) {
4400
- super(null, null, 0, "linear"), this.cb = cb;
4401
- }
4402
- onUpdate(end, ratio, out) {}
4403
- onStart() {
4404
- this.cb();
4405
- }
4406
- }
4407
- class Animate {
4408
- constructor() {
4409
- let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Generator.GenAutoIncrementId();
4410
- let timeline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultTimeline;
4411
- let slience = arguments.length > 2 ? arguments[2] : undefined;
4412
- this.id = id, this.timeline = timeline || defaultTimeline, this.status = AnimateStatus.INITIAL, this.tailAnimate = new SubAnimate(this), this.subAnimates = [this.tailAnimate], this.timeScale = 1, this.rawPosition = -1, this._startTime = 0, this._duringTime = 0, this.timeline.addAnimate(this), this.slience = slience;
4413
- }
4414
- setTimeline(timeline) {
4415
- timeline !== this.timeline && (this.timeline.removeAnimate(this, !1), timeline.addAnimate(this));
4416
- }
4417
- getStartTime() {
4418
- return this._startTime;
4419
- }
4420
- getDuration() {
4421
- return this.subAnimates.reduce((t, subAnimate) => t + subAnimate.totalDuration, 0);
4422
- }
4423
- after(animate) {
4424
- const t = animate.getDuration();
4425
- return this._startTime = t, this;
4426
- }
4427
- afterAll(list) {
4428
- let maxT = -1 / 0;
4429
- return list.forEach(a => {
4430
- maxT = max(a.getDuration(), maxT);
4431
- }), this._startTime = maxT, this;
4432
- }
4433
- parallel(animate) {
4434
- return this._startTime = animate.getStartTime(), this;
4435
- }
4436
- static AddInterpolate(name, cb) {
4437
- Animate.interpolateMap.set(name, cb);
4438
- }
4439
- play(customAnimate) {
4440
- if (this.tailAnimate.play(customAnimate), this.target) {
4441
- const stage = this.target.stage;
4442
- stage && stage.renderNextFrame();
4443
- }
4444
- return 1 === this.subAnimates.length && this.tailAnimate.totalDuration === customAnimate.duration && this.trySetAttribute(customAnimate.getFromProps(), customAnimate.mode), this;
4445
- }
4446
- trySetAttribute(attr) {
4447
- let mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Animate.mode;
4448
- attr && mode & AnimateMode.SET_ATTR_IMMEDIATELY && this.target.setAttributes && this.target.setAttributes(attr, !1, {
4449
- type: AttributeUpdateType.ANIMATE_PLAY
4450
- });
4451
- }
4452
- runCb(cb) {
4453
- const customAnimate = new CbAnimate(() => {
4454
- cb(this, customAnimate.step.prev);
4455
- });
4456
- return this.tailAnimate.play(customAnimate), this;
4457
- }
4458
- customInterpolate(key, ratio, from, to, target, ret) {
4459
- const func = Animate.interpolateMap.get(key) || Animate.interpolateMap.get("");
4460
- return !!func && func(key, ratio, from, to, target, ret);
4461
- }
4462
- pause() {
4463
- this.status === AnimateStatus.RUNNING && (this.status = AnimateStatus.PAUSED);
4464
- }
4465
- resume() {
4466
- this.status === AnimateStatus.PAUSED && (this.status = AnimateStatus.RUNNING);
4467
- }
4468
- to(props, duration, easing, params) {
4469
- if (this.tailAnimate.to(props, duration, easing, params), this.target) {
4470
- const stage = this.target.stage;
4471
- stage && stage.renderNextFrame();
4472
- }
4473
- return this;
4474
- }
4475
- from(props, duration, easing, params) {
4476
- if (this.tailAnimate.from(props, duration, easing, params), this.target) {
4477
- const stage = this.target.stage;
4478
- stage && stage.renderNextFrame();
4479
- }
4480
- return this;
4481
- }
4482
- wait(duration) {
4483
- if (this.tailAnimate.wait(duration), this.target) {
4484
- const stage = this.target.stage;
4485
- stage && stage.renderNextFrame();
4486
- }
4487
- return this;
4488
- }
4489
- startAt(t) {
4490
- if (this.tailAnimate.startAt(t), this.target) {
4491
- const stage = this.target.stage;
4492
- stage && stage.renderNextFrame();
4493
- }
4494
- return this;
4495
- }
4496
- loop(l) {
4497
- if (this.tailAnimate.loop = l, this.target) {
4498
- const stage = this.target.stage;
4499
- stage && stage.renderNextFrame();
4500
- }
4501
- return this;
4502
- }
4503
- reversed(r) {
4504
- if (this.tailAnimate.reversed = r, this.target) {
4505
- const stage = this.target.stage;
4506
- stage && stage.renderNextFrame();
4507
- }
4508
- return this;
4509
- }
4510
- bounce(b) {
4511
- if (this.tailAnimate.bounce = b, this.target) {
4512
- const stage = this.target.stage;
4513
- stage && stage.renderNextFrame();
4514
- }
4515
- return this;
4516
- }
4517
- subAnimate() {
4518
- const sa = new SubAnimate(this, this.tailAnimate);
4519
- return this.tailAnimate = sa, this.subAnimates.push(sa), sa.bind(this.target), this;
4520
- }
4521
- getStartProps() {
4522
- return this.subAnimates[0].getStartProps();
4523
- }
4524
- getEndProps() {
4525
- return this.tailAnimate.getEndProps();
4526
- }
4527
- depreventAttr(key) {
4528
- this._preventAttrs && this._preventAttrs.delete(key);
4529
- }
4530
- preventAttr(key) {
4531
- this._preventAttrs || (this._preventAttrs = new Set()), this._preventAttrs.add(key);
4532
- }
4533
- preventAttrs(keys) {
4534
- keys.forEach(key => this.preventAttr(key));
4535
- }
4536
- validAttr(key) {
4537
- return !this._preventAttrs || !this._preventAttrs.has(key);
4538
- }
4539
- bind(target) {
4540
- return this.target = target, this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this), this.subAnimates.forEach(sa => {
4541
- sa.bind(target);
4542
- }), this;
4543
- }
4544
- advance(delta) {
4545
- if (this._duringTime < this._startTime) {
4546
- if (this._duringTime + delta * this.timeScale < this._startTime) return void (this._duringTime += delta * this.timeScale);
4547
- delta = this._duringTime + delta * this.timeScale - this._startTime, this._duringTime = this._startTime;
4548
- }
4549
- this.status === AnimateStatus.INITIAL && (this.status = AnimateStatus.RUNNING, this._onStart && this._onStart.forEach(cb => cb()));
4550
- this.setPosition(Math.max(this.rawPosition, 0) + delta * this.timeScale) && this.status === AnimateStatus.RUNNING && (this.status = AnimateStatus.END, this._onEnd && this._onEnd.forEach(cb => cb()));
4551
- }
4552
- setPosition(rawPosition) {
4553
- let sa,
4554
- d = 0;
4555
- const prevRawPos = this.rawPosition,
4556
- maxRawPos = this.subAnimates.reduce((a, b) => a + b.totalDuration, 0);
4557
- rawPosition < 0 && (rawPosition = 0);
4558
- const end = rawPosition >= maxRawPos;
4559
- if (end && (rawPosition = maxRawPos), rawPosition === prevRawPos) return end;
4560
- for (let i = 0; i < this.subAnimates.length && (sa = this.subAnimates[i], !(d + sa.totalDuration >= rawPosition)); i++) d += sa.totalDuration, sa = void 0;
4561
- return this.rawPosition = rawPosition, sa.setPosition(rawPosition - d), end;
4562
- }
4563
- onStart(cb) {
4564
- this._onStart || (this._onStart = []), this._onStart.push(cb);
4565
- }
4566
- onEnd(cb) {
4567
- this._onEnd || (this._onEnd = []), this._onEnd.push(cb);
4568
- }
4569
- onRemove(cb) {
4570
- this._onRemove || (this._onRemove = []), this._onRemove.push(cb);
4571
- }
4572
- onFrame(cb) {
4573
- this._onFrame || (this._onFrame = []), this._onFrame.push(cb);
4574
- }
4575
- release() {
4576
- this.status = AnimateStatus.END;
4577
- }
4578
- stop(nextVal) {
4579
- nextVal || this.target.onStop(), "start" === nextVal ? this.target.onStop(this.getStartProps()) : "end" === nextVal ? this.target.onStop(this.getEndProps()) : this.target.onStop(nextVal), this.release();
4580
- }
4581
- }
4582
- Animate.mode = AnimateMode.NORMAL, Animate.interpolateMap = new Map();
4583
- class SubAnimate {
4584
- get totalDuration() {
4585
- return this.calcAttr(), this._totalDuration + this._startAt;
4586
- }
4587
- constructor(animate, lastSubAnimate) {
4588
- this.rawPosition = -1, this.position = 0, this.loop = 0, this.duration = 0, this.animate = animate, this.stepHead = new Step(0, 0, lastSubAnimate ? Object.assign({}, lastSubAnimate.stepTail.props) : {}), this.stepTail = this.stepHead, this.dirty = !0, this._startAt = 0;
4589
- }
4590
- calcAttr() {
4591
- this.dirty && (this._totalDuration = this.duration * (this.loop + 1));
4592
- }
4593
- bind(target) {
4594
- return this.target = target, this;
4595
- }
4596
- play(customAnimate) {
4597
- let duration = customAnimate.duration;
4598
- (null == duration || duration < 0) && (duration = 0);
4599
- const easing = customAnimate.easing,
4600
- easingFunc = "string" == typeof easing ? Easing[easing] : easing,
4601
- step = this._addStep(duration, null, easingFunc);
4602
- return step.type = AnimateStepType.customAnimate, this._appendProps(customAnimate.getEndProps(), step, !1), this._appendCustomAnimate(customAnimate, step), this;
4603
- }
4604
- to(props, duration, easing, params) {
4605
- (null == duration || duration < 0) && (duration = 0);
4606
- const easingFunc = "string" == typeof easing ? Easing[easing] : easing,
4607
- step = this._addStep(duration, null, easingFunc);
4608
- return step.type = AnimateStepType.to, this._appendProps(props, step, !!params && params.tempProps), step.propKeys || (step.propKeys = Object.keys(step.props)), params && params.noPreventAttrs || this.target.animates && this.target.animates.forEach(a => {
4609
- a.id !== this.animate.id && a.preventAttrs(step.propKeys);
4610
- }), this;
4611
- }
4612
- from(props, duration, easing, params) {
4613
- this.to(props, 0, easing, params);
4614
- const toProps = {};
4615
- this.stepTail.propKeys || (this.stepTail.propKeys = Object.keys(this.stepTail.props)), this.stepTail.propKeys.forEach(k => {
4616
- toProps[k] = this.getLastPropByName(k, this.stepTail);
4617
- }), this.to(toProps, duration, easing, params), this.stepTail.type = AnimateStepType.from;
4618
- }
4619
- startAt(t) {
4620
- return t < 0 && (t = 0), this._startAt = t, this;
4621
- }
4622
- getStartProps() {
4623
- var _a;
4624
- return null === (_a = this.stepHead) || void 0 === _a ? void 0 : _a.props;
4625
- }
4626
- getEndProps() {
4627
- return this.stepTail.props;
4628
- }
4629
- getLastStep() {
4630
- return this._lastStep;
4631
- }
4632
- wait(duration) {
4633
- if (duration > 0) {
4634
- const step = this._addStep(+duration, null);
4635
- step.type = AnimateStepType.wait, step.prev.customAnimate ? step.props = step.prev.customAnimate.getEndProps() : step.props = step.prev.props, this.target.onAddStep && this.target.onAddStep(step);
4636
- }
4637
- return this;
4638
- }
4639
- _addStep(duration, props, easingFunc) {
4640
- const step = new Step(this.duration, duration, props, easingFunc);
4641
- return this.duration += duration, this.stepTail.append(step), this.stepTail = step, step;
4642
- }
4643
- _appendProps(props, step, tempProps) {
4644
- step.props = tempProps ? props : Object.assign({}, props);
4645
- let lastStep = step.prev;
4646
- const _props = step.props;
4647
- for (step.propKeys || (step.propKeys = Object.keys(step.props)), step.propKeys.forEach(k => {
4648
- void 0 === step.props[k] && (step.props[k] = this.target.getDefaultAttribute(k));
4649
- }); lastStep.prev;) lastStep.props && (lastStep.propKeys || (lastStep.propKeys = Object.keys(lastStep.props)), lastStep.propKeys.forEach(key => {
4650
- void 0 === _props[key] && (_props[key] = lastStep.props[key]);
4651
- })), step.propKeys = Object.keys(step.props), lastStep = lastStep.prev;
4652
- const initProps = this.stepHead.props;
4653
- step.propKeys || (step.propKeys = Object.keys(_props)), step.propKeys.forEach(key => {
4654
- if (void 0 === initProps[key]) {
4655
- const parentAnimateInitProps = this.animate.getStartProps();
4656
- initProps[key] = parentAnimateInitProps[key] = this.target.getComputedAttribute(key);
4657
- }
4658
- }), this.target.onAddStep && this.target.onAddStep(step);
4659
- }
4660
- _appendCustomAnimate(customAnimate, step) {
4661
- step.customAnimate = customAnimate, customAnimate.step = step, customAnimate.bind(this.target, this);
4662
- }
4663
- setPosition(rawPosition) {
4664
- var _a;
4665
- const d = this.duration,
4666
- loopCount = this.loop,
4667
- prevRawPos = this.rawPosition;
4668
- let loop,
4669
- position,
4670
- end = !1;
4671
- const startAt = null !== (_a = this._startAt) && void 0 !== _a ? _a : 0;
4672
- if (rawPosition < 0 && (rawPosition = 0), rawPosition < startAt) return this.rawPosition = rawPosition, !1;
4673
- if (rawPosition -= startAt, d <= 0 && (end = !0, d < 0)) return end;
4674
- if (loop = Math.floor(rawPosition / d), position = rawPosition - loop * d, end = rawPosition >= loopCount * d + d, end && (position = d, loop = loopCount, rawPosition = position * loop + d), rawPosition === prevRawPos) return end;
4675
- const rev = !this.reversed != !(this.bounce && loop % 2);
4676
- return rev && (position = d - position), this._deltaPosition = position - this.position, this.position = position, this.rawPosition = rawPosition + startAt, this.updatePosition(end, rev), end;
4677
- }
4678
- updatePosition(end, rev) {
4679
- if (!this.stepHead) return;
4680
- let step = this.stepHead.next;
4681
- const position = this.position,
4682
- duration = this.duration;
4683
- if (this.target && step) {
4684
- let stepNext = step.next;
4685
- for (; stepNext && stepNext.position <= position;) step = stepNext, stepNext = step.next;
4686
- let ratio = end ? 0 === duration ? 1 : position / duration : (position - step.position) / step.duration;
4687
- step.easing && (ratio = step.easing(ratio)), this.tryCallCustomAnimateLifeCycle(step, this._lastStep || (rev ? this.stepTail : this.stepHead), rev), this.updateTarget(step, ratio, end), this._lastStep = step, this.animate._onFrame && this.animate._onFrame.forEach(cb => cb(step, ratio));
4688
- }
4689
- }
4690
- tryCallCustomAnimateLifeCycle(step, lastStep, rev) {
4691
- if (step !== lastStep) if (rev) {
4692
- let _step = lastStep.prev;
4693
- for (; _step && _step !== step;) _step.customAnimate && (_step.customAnimate.onStart && _step.customAnimate.onStart(), _step.customAnimate.onEnd && _step.customAnimate.onEnd()), _step = step.prev;
4694
- lastStep && lastStep.customAnimate && lastStep.customAnimate.onEnd && lastStep.customAnimate.onEnd(), step && step.customAnimate && step.customAnimate.onStart && step.customAnimate.onStart();
4695
- } else {
4696
- let _step = lastStep.next;
4697
- for (; _step && _step !== step;) _step.customAnimate && (_step.customAnimate.onStart && _step.customAnimate.onStart(), _step.customAnimate.onEnd && _step.customAnimate.onEnd()), _step = _step.next;
4698
- lastStep && lastStep.customAnimate && lastStep.customAnimate.onEnd && lastStep.customAnimate.onEnd(), step && step.customAnimate && step.customAnimate.onStart && step.customAnimate.onStart();
4699
- }
4700
- }
4701
- getLastPropByName(name, step) {
4702
- let lastStep = step.prev;
4703
- for (; lastStep;) {
4704
- if (lastStep.props && void 0 !== lastStep.props[name]) return lastStep.props[name];
4705
- if (lastStep.customAnimate) {
4706
- const val = lastStep.customAnimate.getEndProps()[name];
4707
- if (void 0 !== val) return val;
4708
- }
4709
- lastStep = lastStep.prev;
4710
- }
4711
- return Logger.getInstance().warn("未知错误,step中找不到属性"), step.props[name];
4712
- }
4713
- updateTarget(step, ratio, end) {
4714
- null == step.props && null == step.customAnimate || this.target.onStep(this, this.animate, step, ratio, end);
4429
+ static onLoadSuccess(cb) {
4430
+ this.onLoadSuccessCb.push(cb);
4715
4431
  }
4716
4432
  }
4717
- class Step {
4718
- constructor(position, duration, props, easing) {
4719
- this.duration = duration, this.position = position, this.props = props, this.easing = easing;
4720
- }
4721
- append(step) {
4722
- step.prev = this, step.next = this.next, this.next = step;
4723
- }
4724
- getLastProps() {
4725
- let step = this.prev;
4726
- for (; step;) {
4727
- if (step.props) return step.props;
4728
- if (step.customAnimate) return step.customAnimate.getMergedEndProps();
4729
- step = step.prev;
4730
- }
4731
- return null;
4732
- }
4433
+ function getIndex(url, arr) {
4434
+ for (let i = 0; i < arr.length; i++) if (arr[i].url === url) return i;
4435
+ return -1;
4733
4436
  }
4734
-
4735
- const DefaultStateAnimateConfig = {
4736
- duration: 200,
4737
- easing: "cubicOut"
4738
- };
4437
+ ResourceLoader.cache = new Map(), ResourceLoader.isLoading = !1, ResourceLoader.toLoadAueue = [], ResourceLoader.onLoadSuccessCb = [];
4739
4438
 
4740
4439
  var Edge;
4741
4440
  !function (Edge) {
@@ -4842,424 +4541,129 @@ const calculateLineHeight = (lineHeight, fontSize) => {
4842
4541
  return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
4843
4542
  };
4844
4543
 
4845
- class IncreaseCount extends ACustomAnimate {
4846
- constructor(from, to, duration, easing, params) {
4847
- super(from, to, duration, easing, params);
4848
- }
4849
- getEndProps() {
4850
- return !1 === this.valid ? {} : {
4851
- text: this.to
4852
- };
4853
- }
4854
- onBind() {
4855
- var _a, _b, _c, _d, _e, _f, _g, _h;
4856
- this.fromNumber = isNumber(null === (_a = this.from) || void 0 === _a ? void 0 : _a.text) ? null === (_b = this.from) || void 0 === _b ? void 0 : _b.text : Number.parseFloat(null === (_c = this.from) || void 0 === _c ? void 0 : _c.text), this.toNumber = isNumber(null === (_d = this.to) || void 0 === _d ? void 0 : _d.text) ? null === (_e = this.to) || void 0 === _e ? void 0 : _e.text : Number.parseFloat(null === (_f = this.to) || void 0 === _f ? void 0 : _f.text), Number.isFinite(this.toNumber) || (this.fromNumber = 0), Number.isFinite(this.toNumber) || (this.valid = !1), !1 !== this.valid && (this.decimalLength = null !== (_h = null === (_g = this.params) || void 0 === _g ? void 0 : _g.fixed) && void 0 !== _h ? _h : Math.max(getDecimalPlaces(this.fromNumber), getDecimalPlaces(this.toNumber)));
4544
+ class BaseSymbol {
4545
+ bounds(size, bounds) {
4546
+ if (isNumber(size)) {
4547
+ const halfS = size / 2;
4548
+ bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
4549
+ } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
4857
4550
  }
4858
- onEnd() {}
4859
- onUpdate(end, ratio, out) {
4860
- var _a;
4861
- !1 !== this.valid && (out.text = end ? null === (_a = this.to) || void 0 === _a ? void 0 : _a.text : (this.fromNumber + (this.toNumber - this.fromNumber) * ratio).toFixed(this.decimalLength));
4551
+ parseSize(size) {
4552
+ return isNumber(size) ? size : Math.min(size[0], size[1]);
4862
4553
  }
4863
4554
  }
4864
- var Direction;
4865
- !function (Direction) {
4866
- Direction[Direction.LEFT_TO_RIGHT = 0] = "LEFT_TO_RIGHT", Direction[Direction.RIGHT_TO_LEFT = 1] = "RIGHT_TO_LEFT", Direction[Direction.TOP_TO_BOTTOM = 2] = "TOP_TO_BOTTOM", Direction[Direction.BOTTOM_TO_TOP = 3] = "BOTTOM_TO_TOP", Direction[Direction.STROKE = 4] = "STROKE";
4867
- }(Direction || (Direction = {}));
4868
- class InputText extends ACustomAnimate {
4555
+
4556
+ function circle(ctx, r, x, y, z) {
4557
+ return z ? ctx.arc(x, y, r, 0, tau, !1, z) : ctx.arc(x, y, r, 0, tau), !1;
4558
+ }
4559
+ class CircleSymbol extends BaseSymbol {
4869
4560
  constructor() {
4870
- super(...arguments), this.fromText = "", this.toText = "";
4871
- }
4872
- getEndProps() {
4873
- return !1 === this.valid ? {} : {
4874
- text: this.to
4875
- };
4561
+ super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
4876
4562
  }
4877
- onBind() {
4878
- var _a, _b, _c;
4879
- this.fromText = null !== (_b = null === (_a = this.from) || void 0 === _a ? void 0 : _a.text) && void 0 !== _b ? _b : "", this.toText = (null === (_c = this.to) || void 0 === _c ? void 0 : _c.text) || "", (!this.toText || isArray(this.toText) && 0 === this.toText.length) && (this.valid = !1), isArray(this.toText) && (this.toText = this.toText.map(item => (item || "").toString()));
4563
+ draw(ctx, size, x, y, z) {
4564
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
4880
4565
  }
4881
- onEnd() {
4882
- this.target.detachShadow();
4566
+ drawOffset(ctx, size, x, y, offset, z) {
4567
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
4883
4568
  }
4884
- onUpdate(end, ratio, out) {
4885
- if (!1 === this.valid) return;
4886
- const fromCount = this.fromText.length,
4887
- toTextIsArray = isArray(this.toText),
4888
- toCount = toTextIsArray ? this.toText.reduce((c, t) => c + (t || "").length, 0) : this.toText.length,
4889
- count = Math.ceil(fromCount + (toCount - fromCount) * ratio);
4890
- if (toTextIsArray) {
4891
- out.text = [];
4892
- let len = 0;
4893
- this.toText.forEach(t => {
4894
- len + t.length > count ? (out.text.push(t.substr(0, count - len)), len = count) : (out.text.push(t), len += t.length);
4895
- });
4896
- } else out.text = this.toText.substr(0, count);
4569
+ drawToSvgPath(size, x, y, z) {
4570
+ const r = this.parseSize(size) / 2;
4571
+ return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
4897
4572
  }
4898
4573
  }
4574
+ var circle$1 = new CircleSymbol();
4899
4575
 
4900
- const normalizeRectAttributes = attribute => {
4901
- if (!attribute) return {
4902
- x: 0,
4903
- y: 0,
4904
- width: 0,
4905
- height: 0
4906
- };
4907
- let width = isNil(attribute.width) ? attribute.x1 - attribute.x : attribute.width,
4908
- height = isNil(attribute.height) ? attribute.y1 - attribute.y : attribute.height,
4909
- x = 0,
4910
- y = 0;
4911
- return width < 0 ? (x = width, width = -width) : Number.isNaN(width) && (width = 0), height < 0 ? (y = height, height = -height) : Number.isNaN(height) && (height = 0), {
4912
- x: x,
4913
- y: y,
4914
- width: width,
4915
- height: height
4916
- };
4917
- };
4918
-
4919
- var ColorType;
4920
- !function (ColorType) {
4921
- ColorType[ColorType.Color255 = 0] = "Color255", ColorType[ColorType.Color1 = 1] = "Color1";
4922
- }(ColorType || (ColorType = {}));
4923
- class ColorStore {
4924
- static Get(str) {
4925
- let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ColorType.Color1;
4926
- let arr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0, 1];
4927
- if (size === ColorType.Color1) {
4928
- const color = ColorStore.store1[str];
4929
- if (color) return arr[0] = color[0], arr[1] = color[1], arr[2] = color[2], arr[3] = color[3], arr;
4930
- const c = Color.parseColorString(str);
4931
- if (c) {
4932
- const data = [c.r / 255, c.g / 255, c.b / 255, c.opacity];
4933
- ColorStore.store1[str] = data, ColorStore.store255[str] = [c.r, c.g, c.b, c.opacity], arr[0] = data[0], arr[1] = data[1], arr[2] = data[2], arr[3] = data[3];
4934
- }
4935
- return arr;
4936
- }
4937
- const color = ColorStore.store255[str];
4938
- if (color) return arr[0] = color[0], arr[1] = color[1], arr[2] = color[2], arr[3] = color[3], arr;
4939
- const c = Color.parseColorString(str);
4940
- return c && (ColorStore.store1[str] = [c.r / 255, c.g / 255, c.b / 255, c.opacity], ColorStore.store255[str] = [c.r, c.g, c.b, c.opacity], arr[0] = c.r, arr[1] = c.g, arr[2] = c.b, arr[3] = c.opacity), arr;
4576
+ function cross(ctx, r, x, y, z) {
4577
+ return ctx.moveTo(-3 * r + x, -r + y, z), ctx.lineTo(-r + x, -r + y, z), ctx.lineTo(-r + x, -3 * r + y, z), ctx.lineTo(r + x, -3 * r + y, z), ctx.lineTo(r + x, -r + y, z), ctx.lineTo(3 * r + x, -r + y, z), ctx.lineTo(3 * r + x, r + y, z), ctx.lineTo(r + x, r + y, z), ctx.lineTo(r + x, 3 * r + y, z), ctx.lineTo(-r + x, 3 * r + y, z), ctx.lineTo(-r + x, r + y, z), ctx.lineTo(-3 * r + x, r + y, z), ctx.closePath(), !0;
4578
+ }
4579
+ function crossOffset(ctx, r, x, y, offset, z) {
4580
+ return ctx.moveTo(-3 * r + x - offset, -r + y - offset, z), ctx.lineTo(-r + x - offset, -r + y - offset, z), ctx.lineTo(-r + x - offset, -3 * r + y - offset, z), ctx.lineTo(r + x + offset, -3 * r + y - offset, z), ctx.lineTo(r + x + offset, -r + y - offset, z), ctx.lineTo(3 * r + x + offset, -r + y - offset, z), ctx.lineTo(3 * r + x + offset, r + y + offset, z), ctx.lineTo(r + x + offset, r + y + offset, z), ctx.lineTo(r + x + offset, 3 * r + y + offset, z), ctx.lineTo(-r + x - offset, 3 * r + y + offset, z), ctx.lineTo(-r + x - offset, r + y + offset, z), ctx.lineTo(-3 * r + x - offset, r + y + offset, z), ctx.closePath(), !0;
4581
+ }
4582
+ class CrossSymbol extends BaseSymbol {
4583
+ constructor() {
4584
+ super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
4941
4585
  }
4942
- static Set(str, size, arr) {
4943
- if (size === ColorType.Color1) {
4944
- if (ColorStore.store1[str]) return;
4945
- ColorStore.store1[str] = arr, ColorStore.store255[str] = [Math.floor(255 * arr[0]), Math.floor(255 * arr[1]), Math.floor(255 * arr[2]), Math.floor(255 * arr[3])];
4946
- } else {
4947
- if (ColorStore.store255[str]) return;
4948
- ColorStore.store255[str] = arr, ColorStore.store1[str] = [arr[0] / 255, arr[1] / 255, arr[2] / 255, arr[3]];
4949
- }
4586
+ draw(ctx, size, x, y, z) {
4587
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
4588
+ }
4589
+ drawOffset(ctx, size, x, y, offset, z) {
4590
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
4950
4591
  }
4951
4592
  }
4952
- ColorStore.store255 = {}, ColorStore.store1 = {};
4593
+ var cross$1 = new CrossSymbol();
4953
4594
 
4954
- function colorArrayToString(color) {
4955
- let alphaChannel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
4956
- return Array.isArray(color) && isNumber(color[0]) ? alphaChannel ? `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])},${color[3].toFixed(2)})` : `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])})` : color;
4595
+ function diamond(ctx, r, x, y, z) {
4596
+ return ctx.moveTo(x, y - r, z), ctx.lineTo(r + x, y, z), ctx.lineTo(x, y + r, z), ctx.lineTo(x - r, y, z), ctx.closePath(), !0;
4957
4597
  }
4958
- function interpolateColor(from, to, ratio, alphaChannel, cb) {
4959
- if (Array.isArray(from) && !isNumber(from[0]) || Array.isArray(to) && !isNumber(to[0])) {
4960
- return new Array(4).fill(0).map((_, index) => _interpolateColor(isArray(from) ? from[index] : from, isArray(to) ? to[index] : to, ratio, alphaChannel));
4598
+ class DiamondSymbol extends BaseSymbol {
4599
+ constructor() {
4600
+ super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
4961
4601
  }
4962
- return _interpolateColor(from, to, ratio, alphaChannel, cb);
4963
- }
4964
- function _interpolateColor(from, to, ratio, alphaChannel, cb) {
4965
- if (!from || !to) return from && colorArrayToString(from) || to && colorArrayToString(to) || !1;
4966
- let fromArray,
4967
- toArray,
4968
- fromGradient = !1,
4969
- toGradient = !1;
4970
- if (Array.isArray(from) ? fromArray = from : "string" == typeof from ? fromArray = ColorStore.Get(from, ColorType.Color255) : fromGradient = !0, Array.isArray(to) ? toArray = to : "string" == typeof to ? toArray = ColorStore.Get(to, ColorType.Color255) : toGradient = !0, fromGradient !== toGradient) {
4971
- const gradient = fromGradient ? from : to,
4972
- pure = fromGradient ? to : from,
4973
- gradientFromPure = Object.assign(Object.assign({}, gradient), {
4974
- stops: gradient.stops.map(v => Object.assign(Object.assign({}, v), {
4975
- color: colorArrayToString(pure)
4976
- }))
4977
- });
4978
- return fromGradient ? interpolateColor(gradient, gradientFromPure, ratio, alphaChannel, cb) : interpolateColor(gradientFromPure, gradient, ratio, alphaChannel, cb);
4602
+ draw(ctx, size, x, y, z) {
4603
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
4979
4604
  }
4980
- if (fromGradient) {
4981
- if (from.gradient === to.gradient) {
4982
- const fc = from,
4983
- tc = to,
4984
- fromStops = fc.stops,
4985
- toStops = tc.stops;
4986
- if (fromStops.length !== toStops.length) return !1;
4987
- if ("linear" === fc.gradient) return interpolateGradientLinearColor(fc, tc, ratio);
4988
- if ("radial" === fc.gradient) return interpolateGradientRadialColor(fc, tc, ratio);
4989
- if ("conical" === fc.gradient) return interpolateGradientConicalColor(fc, tc, ratio);
4990
- }
4991
- return !1;
4605
+ drawFitDir(ctx, size, x, y, z) {
4606
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
4607
+ }
4608
+ drawOffset(ctx, size, x, y, offset, z) {
4609
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
4992
4610
  }
4993
- cb && cb(fromArray, toArray);
4994
- return colorArrayToString(interpolatePureColorArray(fromArray, toArray, ratio), alphaChannel);
4995
4611
  }
4996
- function interpolateGradientLinearColor(fc, tc, ratio) {
4997
- const fStops = fc.stops,
4998
- tStops = tc.stops;
4999
- return {
5000
- gradient: "linear",
5001
- x0: fc.x0 + (tc.x0 - fc.x0) * ratio,
5002
- x1: fc.x1 + (tc.x1 - fc.x1) * ratio,
5003
- y0: fc.y0 + (tc.y0 - fc.y0) * ratio,
5004
- y1: fc.y1 + (tc.y1 - fc.y1) * ratio,
5005
- stops: new Array(fStops.length).fill(0).map((_, i) => ({
5006
- color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),
5007
- offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio
5008
- }))
5009
- };
4612
+ var diamond$1 = new DiamondSymbol();
4613
+
4614
+ function square(ctx, r, x, y) {
4615
+ const wh = 2 * r;
4616
+ return ctx.rect(x - r, y - r, wh, wh), !1;
5010
4617
  }
5011
- function interpolateGradientRadialColor(fc, tc, ratio) {
5012
- const fStops = fc.stops,
5013
- tStops = tc.stops;
5014
- return {
5015
- gradient: "radial",
5016
- x0: fc.x0 + (tc.x0 - fc.x0) * ratio,
5017
- x1: fc.x1 + (tc.x1 - fc.x1) * ratio,
5018
- y0: fc.y0 + (tc.y0 - fc.y0) * ratio,
5019
- y1: fc.y1 + (tc.y1 - fc.y1) * ratio,
5020
- r0: fc.r0 + (tc.r0 - fc.r0) * ratio,
5021
- r1: fc.r1 + (tc.r1 - fc.r1) * ratio,
5022
- stops: new Array(fStops.length).fill(0).map((_, i) => ({
5023
- color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),
5024
- offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio
5025
- }))
5026
- };
4618
+ class SquareSymbol extends BaseSymbol {
4619
+ constructor() {
4620
+ super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
4621
+ }
4622
+ draw(ctx, size, x, y) {
4623
+ return square(ctx, this.parseSize(size) / 2, x, y);
4624
+ }
4625
+ drawOffset(ctx, size, x, y, offset) {
4626
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
4627
+ }
5027
4628
  }
5028
- function interpolateGradientConicalColor(fc, tc, ratio) {
5029
- const fStops = fc.stops,
5030
- tStops = tc.stops;
5031
- return {
5032
- gradient: "conical",
5033
- startAngle: fc.startAngle + (tc.startAngle - fc.startAngle) * ratio,
5034
- endAngle: fc.endAngle + (tc.endAngle - fc.endAngle) * ratio,
5035
- x: fc.x + (tc.x - fc.x) * ratio,
5036
- y: fc.y + (tc.y - fc.y) * ratio,
5037
- stops: new Array(fStops.length).fill(0).map((_, i) => ({
5038
- color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),
5039
- offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio
5040
- }))
5041
- };
4629
+ var square$1 = new SquareSymbol();
4630
+
4631
+ function trianglUpOffset(ctx, r, x, y) {
4632
+ let offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
4633
+ return ctx.moveTo(x + r + 2 * offset, r + y + offset), ctx.lineTo(x - r - 2 * offset, r + y + offset), ctx.lineTo(x, y - r - 2 * offset), ctx.closePath(), !0;
5042
4634
  }
5043
- function interpolatePureColorArray(from, to, ratio) {
5044
- return [from[0] + (to[0] - from[0]) * ratio, from[1] + (to[1] - from[1]) * ratio, from[2] + (to[2] - from[2]) * ratio, from[3] + (to[3] - from[3]) * ratio];
4635
+ class TriangleUpSymbol extends BaseSymbol {
4636
+ constructor() {
4637
+ super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
4638
+ }
4639
+ draw(ctx, size, x, y) {
4640
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
4641
+ }
4642
+ drawOffset(ctx, size, x, y, offset) {
4643
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
4644
+ }
5045
4645
  }
5046
- const _fromColorRGB = [0, 0, 0, 0],
5047
- _toColorRGB = [0, 0, 0, 0];
5048
- function colorStringInterpolationToStr(fromColor, toColor, ratio) {
5049
- return ColorStore.Get(fromColor, ColorType.Color255, _fromColorRGB), ColorStore.Get(toColor, ColorType.Color255, _toColorRGB), `rgba(${Math.round(_fromColorRGB[0] + (_toColorRGB[0] - _fromColorRGB[0]) * ratio)},${Math.round(_fromColorRGB[1] + (_toColorRGB[1] - _fromColorRGB[1]) * ratio)},${Math.round(_fromColorRGB[2] + (_toColorRGB[2] - _fromColorRGB[2]) * ratio)},${_fromColorRGB[3] + (_toColorRGB[3] - _fromColorRGB[3]) * ratio})`;
4646
+ var triangleUp = new TriangleUpSymbol();
4647
+
4648
+ class TriangleSymbol extends TriangleUpSymbol {
4649
+ constructor() {
4650
+ super(...arguments), this.type = "triangle";
4651
+ }
5050
4652
  }
4653
+ var triangle = new TriangleSymbol();
5051
4654
 
5052
- class ResourceLoader {
5053
- static GetImage(url, mark) {
5054
- var _a;
5055
- const data = ResourceLoader.cache.get(url);
5056
- data ? "fail" === data.loadState ? application.global.getRequestAnimationFrame()(() => {
5057
- mark.imageLoadFail(url);
5058
- }) : "init" === data.loadState || "loading" === data.loadState ? null === (_a = data.waitingMark) || void 0 === _a || _a.push(mark) : mark && mark.imageLoadSuccess(url, data.data) : ResourceLoader.loadImage(url, mark);
5059
- }
5060
- static GetSvg(svgStr, mark) {
5061
- var _a;
5062
- let data = ResourceLoader.cache.get(svgStr);
5063
- data ? "fail" === data.loadState ? application.global.getRequestAnimationFrame()(() => {
5064
- mark.imageLoadFail(svgStr);
5065
- }) : "init" === data.loadState || "loading" === data.loadState ? null === (_a = data.waitingMark) || void 0 === _a || _a.push(mark) : mark && mark.imageLoadSuccess(svgStr, data.data) : (data = {
5066
- type: "image",
5067
- loadState: "init"
5068
- }, ResourceLoader.cache.set(svgStr, data), data.dataPromise = application.global.loadSvg(svgStr), data.dataPromise ? (data.waitingMark = [mark], data.dataPromise.then(res => {
5069
- var _a;
5070
- data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
5071
- (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(svgStr, res.data)) : (data.loadState = "fail", mark.imageLoadFail(svgStr));
5072
- }), data.waitingMark && (data.waitingMark = []);
5073
- })) : (data.loadState = "fail", mark.imageLoadFail(svgStr)));
5074
- }
5075
- static GetFile(url, type) {
5076
- let data = ResourceLoader.cache.get(url);
5077
- return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
5078
- type: type,
5079
- loadState: "init"
5080
- }, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
5081
- }
5082
- static loading() {
5083
- setTimeout(() => {
5084
- if (!ResourceLoader.isLoading && ResourceLoader.toLoadAueue.length) {
5085
- ResourceLoader.isLoading = !0;
5086
- const tasks = ResourceLoader.toLoadAueue.splice(0, 10),
5087
- promises = [];
5088
- tasks.forEach(task => {
5089
- const {
5090
- url: url,
5091
- marks: marks
5092
- } = task,
5093
- data = {
5094
- type: "image",
5095
- loadState: "init"
5096
- };
5097
- if (ResourceLoader.cache.set(url, data), data.dataPromise = application.global.loadImage(url), data.dataPromise) {
5098
- data.waitingMark = marks;
5099
- const end = data.dataPromise.then(res => {
5100
- var _a;
5101
- data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
5102
- (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(url, res.data)) : (data.loadState = "fail", mark.imageLoadFail(url));
5103
- }), data.waitingMark && (data.waitingMark = []);
5104
- });
5105
- promises.push(end);
5106
- } else data.loadState = "fail", marks.forEach(mark => mark.imageLoadFail(url));
5107
- }), Promise.all(promises).then(() => {
5108
- ResourceLoader.isLoading = !1, this.onLoadSuccessCb.forEach(cb => cb()), ResourceLoader.loading();
5109
- }).catch(error => {
5110
- console.error(error), ResourceLoader.isLoading = !1, this.onLoadSuccessCb.forEach(cb => cb()), ResourceLoader.loading();
5111
- });
5112
- }
5113
- }, 0);
5114
- }
5115
- static loadImage(url, mark) {
5116
- const index = getIndex(url, ResourceLoader.toLoadAueue);
5117
- if (-1 !== index) return ResourceLoader.toLoadAueue[index].marks.push(mark), void ResourceLoader.loading();
5118
- ResourceLoader.toLoadAueue.push({
5119
- url: url,
5120
- marks: [mark]
5121
- }), ResourceLoader.loading();
5122
- }
5123
- static improveImageLoading(url) {
5124
- const index = getIndex(url, ResourceLoader.toLoadAueue);
5125
- if (-1 !== index) {
5126
- const elememt = ResourceLoader.toLoadAueue.splice(index, 1);
5127
- ResourceLoader.toLoadAueue.unshift(elememt[0]);
5128
- }
5129
- }
5130
- static onLoadSuccess(cb) {
5131
- this.onLoadSuccessCb.push(cb);
5132
- }
5133
- }
5134
- function getIndex(url, arr) {
5135
- for (let i = 0; i < arr.length; i++) if (arr[i].url === url) return i;
5136
- return -1;
5137
- }
5138
- ResourceLoader.cache = new Map(), ResourceLoader.isLoading = !1, ResourceLoader.toLoadAueue = [], ResourceLoader.onLoadSuccessCb = [];
5139
-
5140
- class BaseSymbol {
5141
- bounds(size, bounds) {
5142
- if (isNumber(size)) {
5143
- const halfS = size / 2;
5144
- bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
5145
- } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
5146
- }
5147
- parseSize(size) {
5148
- return isNumber(size) ? size : Math.min(size[0], size[1]);
5149
- }
5150
- }
5151
-
5152
- function circle(ctx, r, x, y, z) {
5153
- return z ? ctx.arc(x, y, r, 0, tau, !1, z) : ctx.arc(x, y, r, 0, tau), !1;
5154
- }
5155
- class CircleSymbol extends BaseSymbol {
5156
- constructor() {
5157
- super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
5158
- }
5159
- draw(ctx, size, x, y, z) {
5160
- return circle(ctx, this.parseSize(size) / 2, x, y, z);
5161
- }
5162
- drawOffset(ctx, size, x, y, offset, z) {
5163
- return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
5164
- }
5165
- drawToSvgPath(size, x, y, z) {
5166
- const r = this.parseSize(size) / 2;
5167
- return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
5168
- }
5169
- }
5170
- var circle$1 = new CircleSymbol();
5171
-
5172
- function cross(ctx, r, x, y, z) {
5173
- return ctx.moveTo(-3 * r + x, -r + y, z), ctx.lineTo(-r + x, -r + y, z), ctx.lineTo(-r + x, -3 * r + y, z), ctx.lineTo(r + x, -3 * r + y, z), ctx.lineTo(r + x, -r + y, z), ctx.lineTo(3 * r + x, -r + y, z), ctx.lineTo(3 * r + x, r + y, z), ctx.lineTo(r + x, r + y, z), ctx.lineTo(r + x, 3 * r + y, z), ctx.lineTo(-r + x, 3 * r + y, z), ctx.lineTo(-r + x, r + y, z), ctx.lineTo(-3 * r + x, r + y, z), ctx.closePath(), !0;
5174
- }
5175
- function crossOffset(ctx, r, x, y, offset, z) {
5176
- return ctx.moveTo(-3 * r + x - offset, -r + y - offset, z), ctx.lineTo(-r + x - offset, -r + y - offset, z), ctx.lineTo(-r + x - offset, -3 * r + y - offset, z), ctx.lineTo(r + x + offset, -3 * r + y - offset, z), ctx.lineTo(r + x + offset, -r + y - offset, z), ctx.lineTo(3 * r + x + offset, -r + y - offset, z), ctx.lineTo(3 * r + x + offset, r + y + offset, z), ctx.lineTo(r + x + offset, r + y + offset, z), ctx.lineTo(r + x + offset, 3 * r + y + offset, z), ctx.lineTo(-r + x - offset, 3 * r + y + offset, z), ctx.lineTo(-r + x - offset, r + y + offset, z), ctx.lineTo(-3 * r + x - offset, r + y + offset, z), ctx.closePath(), !0;
5177
- }
5178
- class CrossSymbol extends BaseSymbol {
5179
- constructor() {
5180
- super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
5181
- }
5182
- draw(ctx, size, x, y, z) {
5183
- return cross(ctx, this.parseSize(size) / 6, x, y, z);
5184
- }
5185
- drawOffset(ctx, size, x, y, offset, z) {
5186
- return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
5187
- }
5188
- }
5189
- var cross$1 = new CrossSymbol();
5190
-
5191
- function diamond(ctx, r, x, y, z) {
5192
- return ctx.moveTo(x, y - r, z), ctx.lineTo(r + x, y, z), ctx.lineTo(x, y + r, z), ctx.lineTo(x - r, y, z), ctx.closePath(), !0;
5193
- }
5194
- class DiamondSymbol extends BaseSymbol {
5195
- constructor() {
5196
- super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
5197
- }
5198
- draw(ctx, size, x, y, z) {
5199
- return diamond(ctx, this.parseSize(size) / 2, x, y, z);
5200
- }
5201
- drawFitDir(ctx, size, x, y, z) {
5202
- return diamond(ctx, this.parseSize(size) / 2, x, y, z);
5203
- }
5204
- drawOffset(ctx, size, x, y, offset, z) {
5205
- return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
5206
- }
5207
- }
5208
- var diamond$1 = new DiamondSymbol();
5209
-
5210
- function square(ctx, r, x, y) {
5211
- const wh = 2 * r;
5212
- return ctx.rect(x - r, y - r, wh, wh), !1;
5213
- }
5214
- class SquareSymbol extends BaseSymbol {
5215
- constructor() {
5216
- super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
5217
- }
5218
- draw(ctx, size, x, y) {
5219
- return square(ctx, this.parseSize(size) / 2, x, y);
5220
- }
5221
- drawOffset(ctx, size, x, y, offset) {
5222
- return square(ctx, this.parseSize(size) / 2 + offset, x, y);
5223
- }
5224
- }
5225
- var square$1 = new SquareSymbol();
5226
-
5227
- function trianglUpOffset(ctx, r, x, y) {
5228
- let offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
5229
- return ctx.moveTo(x + r + 2 * offset, r + y + offset), ctx.lineTo(x - r - 2 * offset, r + y + offset), ctx.lineTo(x, y - r - 2 * offset), ctx.closePath(), !0;
5230
- }
5231
- class TriangleUpSymbol extends BaseSymbol {
5232
- constructor() {
5233
- super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
5234
- }
5235
- draw(ctx, size, x, y) {
5236
- return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
5237
- }
5238
- drawOffset(ctx, size, x, y, offset) {
5239
- return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
5240
- }
5241
- }
5242
- var triangleUp = new TriangleUpSymbol();
5243
-
5244
- class TriangleSymbol extends TriangleUpSymbol {
5245
- constructor() {
5246
- super(...arguments), this.type = "triangle";
5247
- }
5248
- }
5249
- var triangle = new TriangleSymbol();
5250
-
5251
- const kr = Math.sin(Math.PI / 10) / Math.sin(7 * Math.PI / 10),
5252
- kx = Math.sin(tau / 10) * kr,
5253
- ky = -Math.cos(tau / 10) * kr;
5254
- function star(ctx, r, transX, transY) {
5255
- const x = kx * r,
5256
- y = ky * r;
5257
- ctx.moveTo(transX, -r + transY), ctx.lineTo(x + transX, y + transY);
5258
- for (let i = 1; i < 5; ++i) {
5259
- const a = tau * i / 5,
5260
- c = Math.cos(a),
5261
- s = Math.sin(a);
5262
- ctx.lineTo(s * r + transX, -c * r + transY), ctx.lineTo(c * x - s * y + transX, s * x + c * y + transY);
4655
+ const kr = Math.sin(Math.PI / 10) / Math.sin(7 * Math.PI / 10),
4656
+ kx = Math.sin(tau / 10) * kr,
4657
+ ky = -Math.cos(tau / 10) * kr;
4658
+ function star(ctx, r, transX, transY) {
4659
+ const x = kx * r,
4660
+ y = ky * r;
4661
+ ctx.moveTo(transX, -r + transY), ctx.lineTo(x + transX, y + transY);
4662
+ for (let i = 1; i < 5; ++i) {
4663
+ const a = tau * i / 5,
4664
+ c = Math.cos(a),
4665
+ s = Math.sin(a);
4666
+ ctx.lineTo(s * r + transX, -c * r + transY), ctx.lineTo(c * x - s * y + transX, s * x + c * y + transY);
5263
4667
  }
5264
4668
  return ctx.closePath(), !0;
5265
4669
  }
@@ -5945,6 +5349,11 @@ const SVG_PARSE_ATTRIBUTE_MAP = {
5945
5349
  };
5946
5350
  const SVG_PARSE_ATTRIBUTE_MAP_KEYS = Object.keys(SVG_PARSE_ATTRIBUTE_MAP);
5947
5351
 
5352
+ const DefaultStateAnimateConfig = {
5353
+ duration: 200,
5354
+ easing: "cubicOut"
5355
+ };
5356
+
5948
5357
  const _tempBounds = new AABBBounds(),
5949
5358
  tempMatrix = new Matrix(),
5950
5359
  tempBounds = new AABBBounds();
@@ -6011,6 +5420,9 @@ class Graphic extends Node {
6011
5420
  var _a;
6012
5421
  super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
6013
5422
  }
5423
+ getAttributes() {
5424
+ return this.attribute;
5425
+ }
6014
5426
  setMode(mode) {
6015
5427
  "3d" === mode ? this.set3dMode() : this.set2dMode();
6016
5428
  }
@@ -6317,23 +5729,6 @@ class Graphic extends Node {
6317
5729
  skewTo(b, c) {
6318
5730
  return this;
6319
5731
  }
6320
- animate(params) {
6321
- var _a;
6322
- this.animates || (this.animates = new Map());
6323
- const animate = new Animate(null == params ? void 0 : params.id, null !== (_a = null == params ? void 0 : params.timeline) && void 0 !== _a ? _a : this.stage && this.stage.getTimeline(), null == params ? void 0 : params.slience);
6324
- if (animate.bind(this), params) {
6325
- const {
6326
- onStart: onStart,
6327
- onFrame: onFrame,
6328
- onEnd: onEnd,
6329
- onRemove: onRemove
6330
- } = params;
6331
- null != onStart && animate.onStart(onStart), null != onFrame && animate.onFrame(onFrame), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove), animate.interpolateFunc = params.interpolate;
6332
- }
6333
- return this.animates.set(animate.id, animate), animate.onRemove(() => {
6334
- animate.stop(), this.animates.delete(animate.id);
6335
- }), animate;
6336
- }
6337
5732
  onAttributeUpdate(context) {
6338
5733
  context && context.skipUpdateCallback || (application.graphicService.onAttributeUpdate(this), this._emitCustomEvent("afterAttributeUpdate", context));
6339
5734
  }
@@ -6348,7 +5743,7 @@ class Graphic extends Node {
6348
5743
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
6349
5744
  }
6350
5745
  applyStateAttrs(attrs, stateNames, hasAnimation, isClear) {
6351
- var _a, _b, _c, _d;
5746
+ var _a, _b;
6352
5747
  if (hasAnimation) {
6353
5748
  const keys = Object.keys(attrs),
6354
5749
  noWorkAttrs = this.getNoWorkAnimateAttr(),
@@ -6357,10 +5752,16 @@ class Graphic extends Node {
6357
5752
  keys.forEach(key => {
6358
5753
  noWorkAttrs[key] ? (noAnimateAttrs || (noAnimateAttrs = {}), noAnimateAttrs[key] = attrs[key]) : animateAttrs[key] = isClear && void 0 === attrs[key] ? this.getDefaultAttribute(key) : attrs[key];
6359
5754
  });
6360
- const animate = this.animate({
6361
- slience: !0
6362
- });
6363
- animate.stateNames = stateNames, animate.to(animateAttrs, null !== (_b = null === (_a = this.stateAnimateConfig) || void 0 === _a ? void 0 : _a.duration) && void 0 !== _b ? _b : DefaultStateAnimateConfig.duration, null !== (_d = null === (_c = this.stateAnimateConfig) || void 0 === _c ? void 0 : _c.easing) && void 0 !== _d ? _d : DefaultStateAnimateConfig.easing), noAnimateAttrs && this.setAttributes(noAnimateAttrs, !1, {
5755
+ const stateAnimateConfig = null !== (_b = null !== (_a = this.context.stateAnimateConfig) && void 0 !== _a ? _a : this.stateAnimateConfig) && void 0 !== _b ? _b : DefaultStateAnimateConfig;
5756
+ this.applyAnimationState(["state"], [{
5757
+ name: "state",
5758
+ animation: {
5759
+ type: "state",
5760
+ to: animateAttrs,
5761
+ duration: stateAnimateConfig.duration,
5762
+ easing: stateAnimateConfig.easing
5763
+ }
5764
+ }]), noAnimateAttrs && this.setAttributes(noAnimateAttrs, !1, {
6364
5765
  type: AttributeUpdateType.STATE
6365
5766
  });
6366
5767
  } else this.stopStateAnimates(), this.setAttributes(attrs, !1, {
@@ -6536,7 +5937,7 @@ class Graphic extends Node {
6536
5937
  if (this.stage = stage, this.layer = layer, this.setStageToShadowRoot(stage, layer), this.animates && this.animates.size) {
6537
5938
  const timeline = stage.getTimeline();
6538
5939
  this.animates.forEach(a => {
6539
- a.timeline === defaultTimeline && a.setTimeline(timeline);
5940
+ a.timeline.isGlobal && (a.setTimeline(timeline), timeline.addAnimate(a));
6540
5941
  });
6541
5942
  }
6542
5943
  this._onSetStage && this._onSetStage(this, stage, layer), application.graphicService.onSetStage(this, stage);
@@ -8606,6 +8007,25 @@ function createLine(attributes) {
8606
8007
  return new Line$1(attributes);
8607
8008
  }
8608
8009
 
8010
+ const normalizeRectAttributes = attribute => {
8011
+ if (!attribute) return {
8012
+ x: 0,
8013
+ y: 0,
8014
+ width: 0,
8015
+ height: 0
8016
+ };
8017
+ let width = isNil(attribute.width) ? attribute.x1 - attribute.x : attribute.width,
8018
+ height = isNil(attribute.height) ? attribute.y1 - attribute.y : attribute.height,
8019
+ x = 0,
8020
+ y = 0;
8021
+ return width < 0 ? (x = width, width = -width) : Number.isNaN(width) && (width = 0), height < 0 ? (y = height, height = -height) : Number.isNaN(height) && (height = 0), {
8022
+ x: x,
8023
+ y: y,
8024
+ width: width,
8025
+ height: height
8026
+ };
8027
+ };
8028
+
8609
8029
  const RECT_UPDATE_TAG_KEY = ["width", "x1", "y1", "height", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
8610
8030
  class Rect extends Graphic {
8611
8031
  constructor(params) {
@@ -11266,7 +10686,7 @@ function drawSegments(path, segPath, percent, clipRangeByDimension, params) {
11266
10686
  }
11267
10687
  if (percent <= 0) return;
11268
10688
  let direction;
11269
- "x" === clipRangeByDimension ? direction = Direction$1.ROW : "y" === clipRangeByDimension ? direction = Direction$1.COLUMN : "auto" === clipRangeByDimension && (direction = segPath.direction);
10689
+ "x" === clipRangeByDimension ? direction = Direction.ROW : "y" === clipRangeByDimension ? direction = Direction.COLUMN : "auto" === clipRangeByDimension && (direction = segPath.direction);
11270
10690
  const totalDrawLength = percent * segPath.tryUpdateLength(direction);
11271
10691
  let drawedLengthUntilLast = 0,
11272
10692
  defined0 = !0,
@@ -11499,8 +10919,8 @@ function drawAreaSegments(path, segPath, percent, params) {
11499
10919
  endP = null !== (_a = topCurves[topCurves.length - 1].p3) && void 0 !== _a ? _a : topCurves[topCurves.length - 1].p1,
11500
10920
  xTotalLength = abs(endP.x - topCurves[0].p0.x),
11501
10921
  yTotalLength = abs(endP.y - topCurves[0].p0.y);
11502
- direction = null != direction ? direction : xTotalLength > yTotalLength ? Direction$1.ROW : Direction$1.COLUMN, Number.isFinite(xTotalLength) || (direction = Direction$1.COLUMN), Number.isFinite(yTotalLength) || (direction = Direction$1.ROW);
11503
- const totalDrawLength = percent * (direction === Direction$1.ROW ? xTotalLength : yTotalLength);
10922
+ direction = null != direction ? direction : xTotalLength > yTotalLength ? Direction.ROW : Direction.COLUMN, Number.isFinite(xTotalLength) || (direction = Direction.COLUMN), Number.isFinite(yTotalLength) || (direction = Direction.ROW);
10923
+ const totalDrawLength = percent * (direction === Direction.ROW ? xTotalLength : yTotalLength);
11504
10924
  let drawedLengthUntilLast = 0,
11505
10925
  lastDefined = !0;
11506
10926
  const topList = [],
@@ -11741,14 +11161,14 @@ let DefaultCanvasAreaRender = class extends BaseRender {
11741
11161
  } = area.attribute;
11742
11162
  let endP,
11743
11163
  startP,
11744
- direction = Direction$1.ROW;
11164
+ direction = Direction.ROW;
11745
11165
  if (segments) {
11746
11166
  const endSeg = segments[segments.length - 1];
11747
11167
  startP = segments[0].points[0], endP = endSeg.points[endSeg.points.length - 1];
11748
11168
  } else startP = points[0], endP = points[points.length - 1];
11749
11169
  const xTotalLength = abs(endP.x - startP.x),
11750
11170
  yTotalLength = abs(endP.y - startP.y);
11751
- direction = null == endP.x1 ? Direction$1.ROW : null == endP.y1 ? Direction$1.COLUMN : Number.isFinite(xTotalLength + yTotalLength) ? xTotalLength > yTotalLength ? Direction$1.ROW : Direction$1.COLUMN : Direction$1.ROW, drawAreaSegments(context.camera ? context : context.nativeContext, cache, clipRange, {
11171
+ direction = null == endP.x1 ? Direction.ROW : null == endP.y1 ? Direction.COLUMN : Number.isFinite(xTotalLength + yTotalLength) ? xTotalLength > yTotalLength ? Direction.ROW : Direction.COLUMN : Direction.ROW, drawAreaSegments(context.camera ? context : context.nativeContext, cache, clipRange, {
11752
11172
  offsetX: offsetX,
11753
11173
  offsetY: offsetY,
11754
11174
  offsetZ: offsetZ,
@@ -11767,7 +11187,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
11767
11187
  const {
11768
11188
  stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
11769
11189
  } = attribute;
11770
- isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
11190
+ isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction.ROW ? "x" : "y", {
11771
11191
  offsetX: offsetX,
11772
11192
  offsetY: offsetY,
11773
11193
  offsetZ: offsetZ
@@ -15889,284 +15309,1001 @@ function limitShapeInBounds(shape, bounds) {
15889
15309
  }
15890
15310
  }
15891
15311
 
15892
- function loadTagComponent() {
15893
- registerGroup();
15894
- registerRect();
15895
- registerSymbol();
15896
- registerRichtext();
15897
- registerText();
15312
+ function loadTagComponent() {
15313
+ registerGroup();
15314
+ registerRect();
15315
+ registerSymbol();
15316
+ registerRichtext();
15317
+ registerText();
15318
+ }
15319
+
15320
+ loadTagComponent();
15321
+ class Tag extends AbstractComponent {
15322
+ getBgRect() {
15323
+ return this._bgRect;
15324
+ }
15325
+ getTextShape() {
15326
+ return this._textShape;
15327
+ }
15328
+ constructor(attributes, options) {
15329
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, Tag.defaultAttributes, attributes));
15330
+ this.name = 'tag';
15331
+ this._tagStates = [];
15332
+ this._rectStates = [];
15333
+ this._symbolStates = [];
15334
+ this._textStates = [];
15335
+ }
15336
+ render() {
15337
+ var _a, _b, _c;
15338
+ this.cacheStates();
15339
+ const { text = '', textStyle = {}, shape = {}, panel = {}, space = 4, minWidth, maxWidth, padding = 4, visible, state, type, textAlwaysCenter, containerTextAlign } = this.attribute;
15340
+ const parsedPadding = normalizePadding(padding);
15341
+ const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group');
15342
+ let symbol;
15343
+ let tagX = -parsedPadding[3];
15344
+ let tagY = -parsedPadding[0];
15345
+ let tagWidth = parsedPadding[1] + parsedPadding[3];
15346
+ let tagHeight = parsedPadding[0] + parsedPadding[2];
15347
+ let textX = 0;
15348
+ let symbolPlaceWidth = 0;
15349
+ const { visible: shapeVisible } = shape, shapeStyle = __rest(shape, ["visible"]);
15350
+ if (isBoolean(shapeVisible)) {
15351
+ const size = (shapeStyle === null || shapeStyle === void 0 ? void 0 : shapeStyle.size) || 10;
15352
+ const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
15353
+ symbol = group.createOrUpdateChild('tag-shape', Object.assign(Object.assign({ symbolType: 'circle', size, strokeBoundsBuffer: 0 }, shapeStyle), { visible: shapeVisible, x: maxSize / 2, y: maxSize / 2 }), 'symbol');
15354
+ if (!isEmpty(state === null || state === void 0 ? void 0 : state.shape)) {
15355
+ symbol.states = state.shape;
15356
+ }
15357
+ if (shapeVisible) {
15358
+ symbolPlaceWidth = maxSize + space;
15359
+ }
15360
+ }
15361
+ tagWidth += symbolPlaceWidth;
15362
+ textX += symbolPlaceWidth;
15363
+ let textShape;
15364
+ const isRich = isRichText({ text }) || type === 'rich';
15365
+ if (isRich) {
15366
+ const richTextAttrs = Object.assign(Object.assign(Object.assign({}, richTextAttributeTransform(Object.assign({ type, text }, textStyle))), textStyle), { visible: isValid(text) && visible !== false, x: textX, y: 0 });
15367
+ textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext');
15368
+ tagWidth += textShape.AABBBounds.width();
15369
+ tagHeight += textShape.AABBBounds.height();
15370
+ tagX += textShape.AABBBounds.x1;
15371
+ tagY += textShape.AABBBounds.y1;
15372
+ }
15373
+ else {
15374
+ const textAttrs = Object.assign(Object.assign({ text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text, visible: isValid(text) && visible !== false, lineHeight: textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize }, textStyle), { x: textX, y: 0 });
15375
+ if (isNil(textAttrs.lineHeight)) {
15376
+ textAttrs.lineHeight = textStyle.fontSize;
15377
+ }
15378
+ textShape = group.createOrUpdateChild('tag-text', textAttrs, 'text');
15379
+ if (!isEmpty(state === null || state === void 0 ? void 0 : state.text)) {
15380
+ textShape.states = state.text;
15381
+ }
15382
+ const textBounds = measureTextSize(textAttrs.text, textStyle, (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.getTheme()) === null || _b === void 0 ? void 0 : _b.text);
15383
+ const textWidth = textBounds.width;
15384
+ const textHeight = textBounds.height;
15385
+ tagWidth += textWidth;
15386
+ const size = (_c = shape.size) !== null && _c !== void 0 ? _c : 10;
15387
+ const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
15388
+ tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);
15389
+ const { textAlign, textBaseline } = textStyle;
15390
+ if (isValid(minWidth) || isValid(maxWidth)) {
15391
+ if (isValid(minWidth) && tagWidth < minWidth) {
15392
+ tagWidth = minWidth;
15393
+ }
15394
+ if (isValid(maxWidth) && tagWidth > maxWidth) {
15395
+ tagWidth = maxWidth;
15396
+ textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);
15397
+ }
15398
+ }
15399
+ tagX = 0;
15400
+ tagY = 0;
15401
+ let flag = 0;
15402
+ if (textAlign === 'left' || textAlign === 'start') {
15403
+ flag = 1;
15404
+ }
15405
+ else if (textAlign === 'right' || textAlign === 'end') {
15406
+ flag = -1;
15407
+ }
15408
+ else if (textAlign === 'center') {
15409
+ flag = 0;
15410
+ }
15411
+ if (!flag) {
15412
+ tagX -= tagWidth / 2;
15413
+ if (symbol) {
15414
+ symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);
15415
+ }
15416
+ group.setAttribute('x', -symbolPlaceWidth / 2);
15417
+ }
15418
+ else if (flag < 0) {
15419
+ tagX -= tagWidth;
15420
+ if (symbol) {
15421
+ symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);
15422
+ }
15423
+ group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);
15424
+ }
15425
+ else if (flag > 0) {
15426
+ group.setAttribute('x', parsedPadding[3]);
15427
+ }
15428
+ const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;
15429
+ const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';
15430
+ const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';
15431
+ if (shouldCenter && flag) {
15432
+ const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
15433
+ const tsWidth = textWidth + symbolPlaceWidth;
15434
+ const textX = flag === 1
15435
+ ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
15436
+ : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
15437
+ textShape.setAttributes({
15438
+ x: textX,
15439
+ textAlign: 'center'
15440
+ });
15441
+ if (symbol) {
15442
+ const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
15443
+ symbol.setAttributes({
15444
+ x: symbolX
15445
+ });
15446
+ }
15447
+ }
15448
+ if (shouldLeft && flag !== 1) {
15449
+ const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
15450
+ const offset = flag === 0
15451
+ ? -containerWidth / 2 + symbolPlaceWidth / 2
15452
+ : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;
15453
+ const textX = offset + symbolPlaceWidth;
15454
+ textShape.setAttributes({
15455
+ x: textX,
15456
+ textAlign: 'left'
15457
+ });
15458
+ if (symbol) {
15459
+ const symbolX = offset + maxSize / 2;
15460
+ symbol.setAttributes({
15461
+ x: symbolX
15462
+ });
15463
+ }
15464
+ }
15465
+ if (shouldRight && flag !== -1) {
15466
+ const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
15467
+ const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;
15468
+ textShape.setAttributes({
15469
+ x: textX,
15470
+ textAlign: 'right'
15471
+ });
15472
+ if (symbol) {
15473
+ const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;
15474
+ symbol.setAttributes({
15475
+ x: symbolX
15476
+ });
15477
+ }
15478
+ }
15479
+ if (textBaseline === 'middle') {
15480
+ tagY -= tagHeight / 2;
15481
+ if (symbol) {
15482
+ symbol.setAttribute('y', 0);
15483
+ }
15484
+ }
15485
+ else if (textBaseline === 'bottom') {
15486
+ tagY -= tagHeight;
15487
+ if (symbol) {
15488
+ symbol.setAttribute('y', -textHeight / 2);
15489
+ }
15490
+ group.setAttribute('y', -parsedPadding[2]);
15491
+ }
15492
+ else if (textBaseline === 'top') {
15493
+ group.setAttribute('y', parsedPadding[0]);
15494
+ if (symbol) {
15495
+ symbol.setAttribute('y', textHeight / 2);
15496
+ }
15497
+ }
15498
+ }
15499
+ const { visible: bgVisible } = panel, backgroundStyle = __rest(panel, ["visible"]);
15500
+ if (visible && isBoolean(bgVisible)) {
15501
+ const bgRect = this.createOrUpdateChild('tag-panel', Object.assign(Object.assign({}, backgroundStyle), { visible: bgVisible && !!text, width: tagWidth, height: tagHeight, x: tagX, y: tagY }), 'rect');
15502
+ if (!isEmpty(state === null || state === void 0 ? void 0 : state.panel)) {
15503
+ bgRect.states = state.panel;
15504
+ }
15505
+ if (backgroundStyle.customShape) {
15506
+ const customShape = backgroundStyle.customShape;
15507
+ bgRect.pathProxy = (attrs) => {
15508
+ return customShape(this, attrs, new CustomPath2D());
15509
+ };
15510
+ }
15511
+ this._bgRect = bgRect;
15512
+ }
15513
+ this._textShape = textShape;
15514
+ this._symbol = symbol;
15515
+ this.resetStates();
15516
+ }
15517
+ initAttributes(params, options) {
15518
+ params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, Tag.defaultAttributes, params);
15519
+ super.initAttributes(params);
15520
+ this.render();
15521
+ }
15522
+ addState(stateName, keepCurrentStates, hasAnimation) {
15523
+ super.addState(stateName, keepCurrentStates, hasAnimation);
15524
+ if (this._textShape) {
15525
+ this._textShape.addState(stateName, keepCurrentStates, hasAnimation);
15526
+ }
15527
+ if (this._bgRect) {
15528
+ this._bgRect.addState(stateName, keepCurrentStates, hasAnimation);
15529
+ }
15530
+ if (this._symbol) {
15531
+ this._symbol.addState(stateName, keepCurrentStates, hasAnimation);
15532
+ }
15533
+ }
15534
+ removeState(stateName, hasAnimation) {
15535
+ super.removeState(stateName, hasAnimation);
15536
+ if (this._textShape) {
15537
+ this._textShape.removeState(stateName, hasAnimation);
15538
+ }
15539
+ if (this._bgRect) {
15540
+ this._bgRect.removeState(stateName, hasAnimation);
15541
+ }
15542
+ if (this._symbol) {
15543
+ this._symbol.removeState(stateName, hasAnimation);
15544
+ }
15545
+ }
15546
+ cacheStates() {
15547
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
15548
+ this._tagStates = (_b = (_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
15549
+ this._rectStates = (_e = (_d = (_c = this._bgRect) === null || _c === void 0 ? void 0 : _c.currentStates) === null || _d === void 0 ? void 0 : _d.slice()) !== null && _e !== void 0 ? _e : [];
15550
+ this._symbolStates = (_h = (_g = (_f = this._symbol) === null || _f === void 0 ? void 0 : _f.currentStates) === null || _g === void 0 ? void 0 : _g.slice()) !== null && _h !== void 0 ? _h : [];
15551
+ this._textStates = (_l = (_k = (_j = this._textShape) === null || _j === void 0 ? void 0 : _j.currentStates) === null || _k === void 0 ? void 0 : _k.slice()) !== null && _l !== void 0 ? _l : [];
15552
+ this.clearStates();
15553
+ (_m = this._bgRect) === null || _m === void 0 ? void 0 : _m.clearStates();
15554
+ (_o = this._symbol) === null || _o === void 0 ? void 0 : _o.clearStates();
15555
+ (_p = this._textShape) === null || _p === void 0 ? void 0 : _p.clearStates();
15556
+ }
15557
+ resetStates() {
15558
+ var _a, _b, _c;
15559
+ this._tagStates.length && this.useStates(this._tagStates);
15560
+ this._rectStates.length && ((_a = this._bgRect) === null || _a === void 0 ? void 0 : _a.useStates(this._rectStates));
15561
+ this._symbolStates.length && ((_b = this._symbol) === null || _b === void 0 ? void 0 : _b.useStates(this._symbolStates));
15562
+ this._textStates.length && ((_c = this._textShape) === null || _c === void 0 ? void 0 : _c.useStates(this._textStates));
15563
+ }
15564
+ }
15565
+ Tag.defaultAttributes = {
15566
+ visible: true,
15567
+ textStyle: {
15568
+ fontSize: 12,
15569
+ fill: '#000',
15570
+ textAlign: 'left',
15571
+ textBaseline: 'top'
15572
+ },
15573
+ space: 4,
15574
+ padding: 4,
15575
+ shape: {
15576
+ fill: '#000'
15577
+ }
15578
+ };
15579
+
15580
+ var AnimateMode;
15581
+ !function (AnimateMode) {
15582
+ AnimateMode[AnimateMode.NORMAL = 0] = "NORMAL", AnimateMode[AnimateMode.SET_ATTR_IMMEDIATELY = 1] = "SET_ATTR_IMMEDIATELY";
15583
+ }(AnimateMode || (AnimateMode = {}));
15584
+
15585
+ var AnimateStepType;
15586
+ !function (AnimateStepType) {
15587
+ AnimateStepType.wait = "wait", AnimateStepType.from = "from", AnimateStepType.to = "to", AnimateStepType.customAnimate = "customAnimate";
15588
+ }(AnimateStepType || (AnimateStepType = {}));
15589
+ var AnimateStatus;
15590
+ !function (AnimateStatus) {
15591
+ AnimateStatus[AnimateStatus.INITIAL = 0] = "INITIAL", AnimateStatus[AnimateStatus.RUNNING = 1] = "RUNNING", AnimateStatus[AnimateStatus.PAUSED = 2] = "PAUSED", AnimateStatus[AnimateStatus.END = 3] = "END";
15592
+ }(AnimateStatus || (AnimateStatus = {}));
15593
+
15594
+ class Easing {
15595
+ constructor() {}
15596
+ static linear(t) {
15597
+ return t;
15598
+ }
15599
+ static none() {
15600
+ return this.linear;
15601
+ }
15602
+ static get(amount) {
15603
+ return amount < -1 ? amount = -1 : amount > 1 && (amount = 1), function (t) {
15604
+ return 0 === amount ? t : amount < 0 ? t * (t * -amount + 1 + amount) : t * ((2 - t) * amount + (1 - amount));
15605
+ };
15606
+ }
15607
+ static getPowIn(pow) {
15608
+ return function (t) {
15609
+ return Math.pow(t, pow);
15610
+ };
15611
+ }
15612
+ static getPowOut(pow) {
15613
+ return function (t) {
15614
+ return 1 - Math.pow(1 - t, pow);
15615
+ };
15616
+ }
15617
+ static getPowInOut(pow) {
15618
+ return function (t) {
15619
+ return (t *= 2) < 1 ? .5 * Math.pow(t, pow) : 1 - .5 * Math.abs(Math.pow(2 - t, pow));
15620
+ };
15621
+ }
15622
+ static getBackIn(amount) {
15623
+ return function (t) {
15624
+ return t * t * ((amount + 1) * t - amount);
15625
+ };
15626
+ }
15627
+ static getBackOut(amount) {
15628
+ return function (t) {
15629
+ return --t * t * ((amount + 1) * t + amount) + 1;
15630
+ };
15631
+ }
15632
+ static getBackInOut(amount) {
15633
+ return amount *= 1.525, function (t) {
15634
+ return (t *= 2) < 1 ? t * t * ((amount + 1) * t - amount) * .5 : .5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2);
15635
+ };
15636
+ }
15637
+ static sineIn(t) {
15638
+ return 1 - Math.cos(t * Math.PI / 2);
15639
+ }
15640
+ static sineOut(t) {
15641
+ return Math.sin(t * Math.PI / 2);
15642
+ }
15643
+ static sineInOut(t) {
15644
+ return -(Math.cos(Math.PI * t) - 1) / 2;
15645
+ }
15646
+ static expoIn(t) {
15647
+ return 0 === t ? 0 : Math.pow(2, 10 * t - 10);
15648
+ }
15649
+ static expoOut(t) {
15650
+ return 1 === t ? 1 : 1 - Math.pow(2, -10 * t);
15651
+ }
15652
+ static expoInOut(t) {
15653
+ return 0 === t ? 0 : 1 === t ? 1 : t < .5 ? Math.pow(2, 20 * t - 10) / 2 : (2 - Math.pow(2, -20 * t + 10)) / 2;
15654
+ }
15655
+ static circIn(t) {
15656
+ return -(Math.sqrt(1 - t * t) - 1);
15657
+ }
15658
+ static circOut(t) {
15659
+ return Math.sqrt(1 - --t * t);
15660
+ }
15661
+ static circInOut(t) {
15662
+ return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
15663
+ }
15664
+ static bounceOut(t) {
15665
+ return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
15666
+ }
15667
+ static bounceIn(t) {
15668
+ return 1 - Easing.bounceOut(1 - t);
15669
+ }
15670
+ static bounceInOut(t) {
15671
+ return t < .5 ? .5 * Easing.bounceIn(2 * t) : .5 * Easing.bounceOut(2 * t - 1) + .5;
15672
+ }
15673
+ static getElasticIn(amplitude, period) {
15674
+ return function (t) {
15675
+ if (0 === t || 1 === t) return t;
15676
+ const s = period / pi2 * Math.asin(1 / amplitude);
15677
+ return -amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period);
15678
+ };
15679
+ }
15680
+ static getElasticOut(amplitude, period) {
15681
+ return function (t) {
15682
+ if (0 === t || 1 === t) return t;
15683
+ const s = period / pi2 * Math.asin(1 / amplitude);
15684
+ return amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1;
15685
+ };
15686
+ }
15687
+ static getElasticInOut(amplitude, period) {
15688
+ return function (t) {
15689
+ const s = period / pi2 * Math.asin(1 / amplitude);
15690
+ return (t *= 2) < 1 ? amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * -.5 : amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * .5 + 1;
15691
+ };
15692
+ }
15693
+ static registerFunc(name, func) {
15694
+ Easing[name] = func;
15695
+ }
15696
+ }
15697
+ function flicker(t, n) {
15698
+ const step = 1 / n;
15699
+ let flag = 1;
15700
+ for (; t > step;) t -= step, flag *= -1;
15701
+ const v = flag * t / step;
15702
+ return v > 0 ? v : 1 + v;
15703
+ }
15704
+ Easing.quadIn = Easing.getPowIn(2), Easing.quadOut = Easing.getPowOut(2), Easing.quadInOut = Easing.getPowInOut(2), Easing.cubicIn = Easing.getPowIn(3), Easing.cubicOut = Easing.getPowOut(3), Easing.cubicInOut = Easing.getPowInOut(3), Easing.quartIn = Easing.getPowIn(4), Easing.quartOut = Easing.getPowOut(4), Easing.quartInOut = Easing.getPowInOut(4), Easing.quintIn = Easing.getPowIn(5), Easing.quintOut = Easing.getPowOut(5), Easing.quintInOut = Easing.getPowInOut(5), Easing.backIn = Easing.getBackIn(1.7), Easing.backOut = Easing.getBackOut(1.7), Easing.backInOut = Easing.getBackInOut(1.7), Easing.elasticIn = Easing.getElasticIn(1, .3), Easing.elasticOut = Easing.getElasticOut(1, .3), Easing.elasticInOut = Easing.getElasticInOut(1, .3 * 1.5), Easing.easeInOutQuad = t => (t /= .5) < 1 ? .5 * Math.pow(t, 2) : -.5 * ((t -= 2) * t - 2), Easing.easeOutElastic = x => {
15705
+ const c4 = 2 * Math.PI / 3;
15706
+ return 0 === x ? 0 : 1 === x ? 1 : Math.pow(2, -10 * x) * Math.sin((10 * x - .75) * c4) + 1;
15707
+ }, Easing.easeInOutElastic = x => {
15708
+ const c5 = 2 * Math.PI / 4.5;
15709
+ return 0 === x ? 0 : 1 === x ? 1 : x < .5 ? -Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
15710
+ };
15711
+ for (let i = 0; i < 10; i++) Easing[`flicker${i}`] = t => flicker(t, i);
15712
+ for (let i = 2; i < 10; i++) Easing[`aIn${i}`] = t => i * t * t + (1 - i) * t;
15713
+
15714
+ function interpolateNumber(from, to, ratio) {
15715
+ return from + (to - from) * ratio;
15716
+ }
15717
+
15718
+ class InterpolateUpdateStore {
15719
+ constructor() {
15720
+ this.opacity = (key, from, to, ratio, step, target) => {
15721
+ target.attribute.opacity = interpolateNumber(from, to, ratio);
15722
+ }, this.fillOpacity = (key, from, to, ratio, step, target) => {
15723
+ target.attribute.fillOpacity = interpolateNumber(from, to, ratio);
15724
+ }, this.strokeOpacity = (key, from, to, ratio, step, target) => {
15725
+ target.attribute.strokeOpacity = interpolateNumber(from, to, ratio);
15726
+ }, this.zIndex = (key, from, to, ratio, step, target) => {
15727
+ target.attribute.zIndex = interpolateNumber(from, to, ratio);
15728
+ }, this.backgroundOpacity = (key, from, to, ratio, step, target) => {
15729
+ target.attribute.backgroundOpacity = interpolateNumber(from, to, ratio);
15730
+ }, this.shadowOffsetX = (key, from, to, ratio, step, target) => {
15731
+ target.attribute.shadowOffsetX = interpolateNumber(from, to, ratio);
15732
+ }, this.shadowOffsetY = (key, from, to, ratio, step, target) => {
15733
+ target.attribute.shadowOffsetY = interpolateNumber(from, to, ratio);
15734
+ }, this.shadowBlur = (key, from, to, ratio, step, target) => {
15735
+ target.attribute.shadowBlur = interpolateNumber(from, to, ratio);
15736
+ }, this.fill = (key, from, to, ratio, step, target) => {
15737
+ target.attribute.fill = interpolateColor(from, to, ratio, !1);
15738
+ }, this.fillPure = (key, from, to, ratio, step, target) => {
15739
+ target.attribute.fill = interpolatePureColorArrayToStr(step.fromParsedProps.fill, step.toParsedProps.fill, ratio);
15740
+ }, this.stroke = (key, from, to, ratio, step, target) => {
15741
+ target.attribute.stroke = interpolateColor(from, to, ratio, !1);
15742
+ }, this.strokePure = (key, from, to, ratio, step, target) => {
15743
+ target.attribute.stroke = interpolatePureColorArrayToStr(step.fromParsedProps.stroke, step.toParsedProps.stroke, ratio);
15744
+ }, this.width = (key, from, to, ratio, step, target) => {
15745
+ target.attribute.width = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15746
+ }, this.height = (key, from, to, ratio, step, target) => {
15747
+ target.attribute.height = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15748
+ }, this.x = (key, from, to, ratio, step, target) => {
15749
+ target.attribute.x = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(), target.addUpdatePositionTag();
15750
+ }, this.y = (key, from, to, ratio, step, target) => {
15751
+ target.attribute.y = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(), target.addUpdatePositionTag();
15752
+ }, this.angle = (key, from, to, ratio, step, target) => {
15753
+ target.attribute.angle = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(), target.addUpdatePositionTag();
15754
+ }, this.scaleX = (key, from, to, ratio, step, target) => {
15755
+ target.attribute.scaleX = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(), target.addUpdatePositionTag();
15756
+ }, this.scaleY = (key, from, to, ratio, step, target) => {
15757
+ target.attribute.scaleY = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(), target.addUpdatePositionTag();
15758
+ }, this.lineWidth = (key, from, to, ratio, step, target) => {
15759
+ target.attribute.lineWidth = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15760
+ }, this.startAngle = (key, from, to, ratio, step, target) => {
15761
+ target.attribute.startAngle = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15762
+ }, this.endAngle = (key, from, to, ratio, step, target) => {
15763
+ target.attribute.endAngle = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15764
+ }, this.radius = (key, from, to, ratio, step, target) => {
15765
+ target.attribute.radius = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15766
+ }, this.outerRadius = (key, from, to, ratio, step, target) => {
15767
+ target.attribute.outerRadius = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15768
+ }, this.innerRadius = (key, from, to, ratio, step, target) => {
15769
+ target.attribute.innerRadius = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15770
+ }, this.size = (key, from, to, ratio, step, target) => {
15771
+ target.attribute.size = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
15772
+ };
15773
+ }
15774
+ }
15775
+ const interpolateUpdateStore = new InterpolateUpdateStore();
15776
+ function commonInterpolateUpdate(key, from, to, ratio, step, target) {
15777
+ if (Number.isFinite(to) && Number.isFinite(from)) return target.attribute[key] = from + (to - from) * ratio, !0;
15778
+ if (Array.isArray(to) && Array.isArray(from) && to.length === from.length) {
15779
+ const nextList = [];
15780
+ let valid = !0;
15781
+ for (let i = 0; i < to.length; i++) {
15782
+ const v = from[i],
15783
+ val = v + (to[i] - v) * ratio;
15784
+ if (!Number.isFinite(val)) {
15785
+ valid = !1;
15786
+ break;
15787
+ }
15788
+ nextList.push(val);
15789
+ }
15790
+ return valid && (target.attribute[key] = nextList), !0;
15791
+ }
15792
+ return !1;
15793
+ }
15794
+
15795
+ function noop() {}
15796
+ class Step {
15797
+ constructor(type, props, duration, easing) {
15798
+ this._startTime = 0, this._hasFirstRun = !1, this.type = type, this.props = props, this.duration = duration, this.easing = easing ? "function" == typeof easing ? easing : Easing[easing] : Easing.linear, "wait" === type && (this.onUpdate = noop);
15799
+ }
15800
+ bind(target, animate) {
15801
+ this.target = target, this.animate = animate, this.onBind();
15802
+ }
15803
+ append(step) {
15804
+ this.next = step, step.prev = this, step.setStartTime(this.getStartTime() + this.duration, !1);
15805
+ }
15806
+ updateDownstreamStartTimes() {
15807
+ let currentStep = this.next,
15808
+ currentStartTime = this._startTime + this.duration;
15809
+ for (; currentStep;) currentStep.setStartTime(currentStartTime, !1), currentStartTime += currentStep.duration, currentStep = currentStep.next;
15810
+ this.animate.updateDuration();
15811
+ }
15812
+ getLastProps() {
15813
+ return this.prev ? this.prev.props || {} : this.animate.getStartProps();
15814
+ }
15815
+ setDuration(duration) {
15816
+ let updateDownstream = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
15817
+ this.duration = duration, updateDownstream && this.updateDownstreamStartTimes();
15818
+ }
15819
+ getDuration() {
15820
+ return this.duration;
15821
+ }
15822
+ determineInterpolateUpdateFunction() {
15823
+ if (!this.props) return;
15824
+ const funcs = [];
15825
+ this.propKeys.forEach(key => {
15826
+ if ("fill" === key || "stroke" === key) {
15827
+ const from = this.getLastProps()[key],
15828
+ to = this.props[key];
15829
+ if (isString(from) && isString(to)) {
15830
+ const fromArray = ColorStore.Get(from, ColorType.Color255),
15831
+ toArray = ColorStore.Get(to, ColorType.Color255);
15832
+ this.fromParsedProps || (this.fromParsedProps = {}), this.toParsedProps || (this.toParsedProps = {}), this.fromParsedProps[key] = fromArray, this.toParsedProps[key] = toArray;
15833
+ }
15834
+ funcs.push(interpolateUpdateStore["fill" === key ? "fillPure" : "strokePure"]);
15835
+ } else interpolateUpdateStore[key] ? funcs.push(interpolateUpdateStore[key]) : funcs.push(commonInterpolateUpdate);
15836
+ }), this.interpolateUpdateFunctions = funcs;
15837
+ }
15838
+ setStartTime(time) {
15839
+ let updateDownstream = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
15840
+ this._startTime = time, updateDownstream && this.updateDownstreamStartTimes();
15841
+ }
15842
+ getStartTime() {
15843
+ return this._startTime;
15844
+ }
15845
+ onBind() {}
15846
+ onFirstRun() {}
15847
+ onStart() {
15848
+ this._hasFirstRun || (this._hasFirstRun = !0, this.fromProps = this.getLastProps(), this.determineInterpolateUpdateFunction(), this.tryPreventConflict(), this.trySyncStartProps(), this.onFirstRun());
15849
+ }
15850
+ tryPreventConflict() {
15851
+ const animate = this.animate;
15852
+ this.target.animates.forEach(a => {
15853
+ if (a === animate || a.priority > animate.priority) return;
15854
+ const fromProps = a.getStartProps();
15855
+ this.propKeys.forEach(key => {
15856
+ null != fromProps[key] && a.preventAttr(key);
15857
+ });
15858
+ });
15859
+ }
15860
+ deleteSelfAttr(key) {
15861
+ var _a;
15862
+ delete this.props[key], this.fromProps && delete this.fromProps[key];
15863
+ const index = this.propKeys.indexOf(key);
15864
+ -1 !== index && (this.propKeys.splice(index, 1), null === (_a = this.interpolateUpdateFunctions) || void 0 === _a || _a.splice(index, 1));
15865
+ }
15866
+ trySyncStartProps() {
15867
+ this.propKeys.forEach(key => {
15868
+ this.fromProps[key] = this.animate.target.getComputedAttribute(key);
15869
+ });
15870
+ }
15871
+ update(end, ratio, out) {
15872
+ if (this.onStart(), !this.props || !this.propKeys) return;
15873
+ const easedRatio = this.easing(ratio);
15874
+ this.animate.interpolateUpdateFunction ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target) : this.interpolateUpdateFunctions.forEach((func, index) => {
15875
+ if (!this.animate.validAttr(this.propKeys[index])) return;
15876
+ const key = this.propKeys[index];
15877
+ func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
15878
+ }), this.onUpdate(end, easedRatio, out);
15879
+ }
15880
+ onUpdate(end, ratio, out) {}
15881
+ onEnd(cb) {
15882
+ cb ? this._endCb = cb : this._endCb && (this.target.setAttributes(this.props), this._endCb(this.animate, this));
15883
+ }
15884
+ getEndProps() {
15885
+ return this.props;
15886
+ }
15887
+ getFromProps() {
15888
+ return this.fromProps;
15889
+ }
15890
+ getMergedEndProps() {
15891
+ return this.getEndProps();
15892
+ }
15893
+ }
15894
+ class WaitStep extends Step {
15895
+ constructor(type, props, duration, easing) {
15896
+ super(type, props, duration, easing);
15897
+ }
15898
+ update(end, ratio, out) {
15899
+ this.onStart();
15900
+ }
15901
+ determineInterpolateUpdateFunction() {}
15902
+ }
15903
+
15904
+ class DefaultTimeline {
15905
+ get animateCount() {
15906
+ return this.animates.length;
15907
+ }
15908
+ constructor() {
15909
+ this.animates = [], this._playSpeed = 1, this._totalDuration = 0, this._startTime = 0, this._currentTime = 0, this._endAnimatePtr = -1, this.id = Generator.GenAutoIncrementId(), this.animates = [], this.paused = !1;
15910
+ }
15911
+ isRunning() {
15912
+ return !this.paused && this._endAnimatePtr >= 0;
15913
+ }
15914
+ forEachAccessAnimate(cb) {
15915
+ for (let i = 0; i <= this._endAnimatePtr; i++) cb(this.animates[i], i);
15916
+ }
15917
+ addAnimate(animate) {
15918
+ this.animates.push(animate), this._endAnimatePtr++, this.animates[this.animates.length - 1] = this.animates[this._endAnimatePtr], this.animates[this._endAnimatePtr] = animate, this._totalDuration = Math.max(this._totalDuration, animate.getStartTime() + animate.getDuration());
15919
+ }
15920
+ pause() {
15921
+ this.paused = !0;
15922
+ }
15923
+ resume() {
15924
+ this.paused = !1;
15925
+ }
15926
+ tick(delta) {
15927
+ if (this.paused) return;
15928
+ const scaledDelta = delta * this._playSpeed;
15929
+ this._currentTime += scaledDelta, this.forEachAccessAnimate((animate, i) => {
15930
+ animate.status === AnimateStatus$1.END ? this.removeAnimate(animate, !0, i) : animate.status !== AnimateStatus$1.RUNNING && animate.status !== AnimateStatus$1.INITIAL || animate.advance(scaledDelta);
15931
+ });
15932
+ }
15933
+ clear() {
15934
+ this.forEachAccessAnimate(animate => {
15935
+ animate.release();
15936
+ }), this.animates = [], this._totalDuration = 0;
15937
+ }
15938
+ removeAnimate(animate) {
15939
+ let release = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
15940
+ let index = arguments.length > 2 ? arguments[2] : undefined;
15941
+ this._endAnimatePtr < 0 || (release && (animate._onRemove && animate._onRemove.forEach(cb => cb()), animate.release()), index = null != index ? index : this.animates.indexOf(animate), this.animates[index] = this.animates[this._endAnimatePtr], this._endAnimatePtr--);
15942
+ }
15943
+ recalculateTotalDuration() {
15944
+ this._totalDuration = 0, this.animates.forEach(animate => {
15945
+ this._totalDuration = Math.max(this._totalDuration, animate.getStartTime() + animate.getDuration());
15946
+ });
15947
+ }
15948
+ getTotalDuration() {
15949
+ return this._totalDuration;
15950
+ }
15951
+ getPlaySpeed() {
15952
+ return this._playSpeed;
15953
+ }
15954
+ setPlaySpeed(speed) {
15955
+ this._playSpeed = speed;
15956
+ }
15957
+ getPlayState() {
15958
+ return this.paused ? "paused" : 0 === this.animateCount ? "stopped" : "playing";
15959
+ }
15960
+ setStartTime(time) {
15961
+ this._startTime = time;
15962
+ }
15963
+ getStartTime() {
15964
+ return this._startTime;
15965
+ }
15966
+ getCurrentTime() {
15967
+ return this._currentTime;
15968
+ }
15969
+ setCurrentTime(time) {
15970
+ this._currentTime = time;
15971
+ }
15972
+ }
15973
+ const defaultTimeline = new DefaultTimeline();
15974
+ defaultTimeline.isGlobal = !0;
15975
+
15976
+ class Animate {
15977
+ constructor() {
15978
+ let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Generator.GenAutoIncrementId();
15979
+ let timeline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultTimeline;
15980
+ let slience = arguments.length > 2 ? arguments[2] : undefined;
15981
+ this.id = id, this.status = AnimateStatus.INITIAL, this._timeline = timeline, timeline.addAnimate(this), this.slience = slience, this._startTime = 0, this._duration = 0, this._totalDuration = 0, this._loopCount = 0, this._currentLoop = 0, this._bounce = !1, this._firstStep = null, this._lastStep = null, this._startProps = {}, this._endProps = {}, this._preventAttrs = new Set(), this.currentTime = 0, this.interpolateUpdateFunction = null, this.priority = 0;
15982
+ }
15983
+ getStartProps() {
15984
+ return this._startProps;
15985
+ }
15986
+ getEndProps() {
15987
+ return this._endProps;
15988
+ }
15989
+ setTimeline(timeline) {
15990
+ this._timeline = timeline;
15991
+ }
15992
+ getTimeline() {
15993
+ return this._timeline;
15994
+ }
15995
+ get timeline() {
15996
+ return this._timeline;
15997
+ }
15998
+ bind(target) {
15999
+ return this.target = target, this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this), this.target.animationAttribute || (this.target.animationAttribute = {}), this;
16000
+ }
16001
+ to(props) {
16002
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
16003
+ let easing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "linear";
16004
+ const step = new Step(AnimateStepType.to, props, duration, easing);
16005
+ return this.updateStepAfterAppend(step), step.bind(this.target, this), this;
16006
+ }
16007
+ wait(delay) {
16008
+ const step = new WaitStep(AnimateStepType.wait, {}, delay, "linear");
16009
+ return this.updateStepAfterAppend(step), step.bind(this.target, this), this;
16010
+ }
16011
+ updateStepAfterAppend(step) {
16012
+ this._firstStep ? (this._lastStep.append(step), this._lastStep = step) : (this._firstStep = step, this._lastStep = step), this.parseStepProps(step), this.updateDuration();
16013
+ }
16014
+ parseStepProps(step) {
16015
+ this._lastStep && (step.propKeys = step.propKeys || Object.keys(step.props), Object.keys(this._endProps).forEach(key => {
16016
+ var _a;
16017
+ step.props[key] = null !== (_a = step.props[key]) && void 0 !== _a ? _a : this._endProps[key];
16018
+ }), step.propKeys.forEach(key => {
16019
+ this._endProps[key] = step.props[key];
16020
+ }));
16021
+ }
16022
+ reSyncProps() {
16023
+ if (!this._lastStep) return;
16024
+ this._endProps = {};
16025
+ let currentStep = this._firstStep;
16026
+ for (; currentStep;) Object.keys(this._endProps).forEach(key => {
16027
+ var _a;
16028
+ currentStep.props[key] = null !== (_a = currentStep.props[key]) && void 0 !== _a ? _a : this._endProps[key];
16029
+ }), currentStep.propKeys.forEach(key => {
16030
+ this._endProps[key] = currentStep.props[key];
16031
+ }), currentStep = currentStep.next;
16032
+ }
16033
+ from(props) {
16034
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
16035
+ let easing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "linear";
16036
+ const step = new Step(AnimateStepType.from, props, duration, easing);
16037
+ return this._firstStep ? (this._lastStep.append(step), this._lastStep = step) : (this._firstStep = step, this._lastStep = step), this.updateDuration(), this;
16038
+ }
16039
+ play(customAnimate) {
16040
+ return this.updateStepAfterAppend(customAnimate), customAnimate.bind(this.target, this), this;
16041
+ }
16042
+ pause() {
16043
+ this.status === AnimateStatus.RUNNING && (this.status = AnimateStatus.PAUSED);
16044
+ }
16045
+ resume() {
16046
+ this.status === AnimateStatus.PAUSED && (this.status = AnimateStatus.RUNNING);
16047
+ }
16048
+ onStart(cb) {
16049
+ var _a;
16050
+ cb ? (this._onStart || (this._onStart = []), this._onStart.push(cb)) : (null === (_a = this._onStart) || void 0 === _a || _a.forEach(cb => cb()), Object.keys(this._endProps).forEach(key => {
16051
+ this._startProps[key] = this.target.getComputedAttribute(key);
16052
+ }));
16053
+ }
16054
+ onEnd(cb) {
16055
+ var _a;
16056
+ cb ? (this._onEnd || (this._onEnd = []), this._onEnd.push(cb)) : null === (_a = this._onEnd) || void 0 === _a || _a.forEach(cb => cb());
16057
+ }
16058
+ onFrame(cb) {
16059
+ cb && (this._onFrame || (this._onFrame = []), this._onFrame.push(cb));
16060
+ }
16061
+ onRemove(cb) {
16062
+ var _a;
16063
+ cb ? (this._onRemove || (this._onRemove = []), this._onRemove.push(cb)) : null === (_a = this._onRemove) || void 0 === _a || _a.forEach(cb => cb());
16064
+ }
16065
+ preventAttr(key) {
16066
+ this._preventAttrs.add(key), delete this._startProps[key], delete this._endProps[key];
16067
+ let step = this._firstStep;
16068
+ for (; step;) step.deleteSelfAttr(key), step = step.next;
16069
+ }
16070
+ preventAttrs(keys) {
16071
+ keys.forEach(key => this._preventAttrs.add(key));
16072
+ }
16073
+ validAttr(key) {
16074
+ return !this._preventAttrs.has(key);
16075
+ }
16076
+ runCb(cb) {
16077
+ var _a;
16078
+ return null === (_a = this._lastStep) || void 0 === _a || _a.onEnd(cb), this;
16079
+ }
16080
+ startAt(t) {
16081
+ return this._startTime = t, this;
16082
+ }
16083
+ customInterpolate(key, ratio, from, to, target, ret) {
16084
+ return !1;
16085
+ }
16086
+ getFromValue() {
16087
+ return this._startProps;
16088
+ }
16089
+ getToValue() {
16090
+ return this._endProps;
16091
+ }
16092
+ stop(type) {
16093
+ this.status = AnimateStatus.END, this.onEnd(), this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
16094
+ }
16095
+ release() {
16096
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
16097
+ }
16098
+ getDuration() {
16099
+ return this._duration;
16100
+ }
16101
+ getStartTime() {
16102
+ return this._startTime;
16103
+ }
16104
+ afterAll(list) {
16105
+ if (!list || 0 === list.length) return this;
16106
+ let maxEndTime = 0;
16107
+ return list.forEach(animate => {
16108
+ const endTime = animate.getStartTime() + animate.getTotalDuration();
16109
+ maxEndTime = Math.max(maxEndTime, endTime);
16110
+ }), this.startAt(maxEndTime);
16111
+ }
16112
+ after(animate) {
16113
+ if (!animate) return this;
16114
+ const endTime = animate.getStartTime() + animate.getTotalDuration();
16115
+ return this.startAt(endTime);
16116
+ }
16117
+ parallel(animate) {
16118
+ return animate ? (this.startAt(animate.getStartTime()), this) : this;
16119
+ }
16120
+ loop(n) {
16121
+ return !0 === n ? n = 1 / 0 : !1 === n && (n = 0), this._loopCount = n, this.updateDuration(), this;
16122
+ }
16123
+ bounce(b) {
16124
+ return this._bounce = b, this;
16125
+ }
16126
+ advance(delta) {
16127
+ var _a;
16128
+ if (this.status === AnimateStatus.END) return void console.warn("aaa 动画已经结束,不能推进");
16129
+ const nextTime = this.currentTime + delta;
16130
+ if (nextTime < this._startTime) return void (this.currentTime = nextTime);
16131
+ if (nextTime >= this._startTime + this._totalDuration) return null === (_a = this._lastStep) || void 0 === _a || _a.onEnd(), this.onEnd(), void (this.status = AnimateStatus.END);
16132
+ this.status = AnimateStatus.RUNNING, this.currentTime <= this._startTime && this.onStart(), this.currentTime = nextTime;
16133
+ let cycleTime = nextTime - this._startTime,
16134
+ newLoop = !1,
16135
+ bounceTime = !1;
16136
+ if (this._loopCount > 0) {
16137
+ cycleTime = (nextTime - this._startTime) % this._duration;
16138
+ const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);
16139
+ newLoop = currentLoop > this._currentLoop, this._currentLoop = currentLoop, bounceTime = this._bounce && currentLoop % 2 == 1, bounceTime && (cycleTime = this._duration - cycleTime);
16140
+ }
16141
+ newLoop && !bounceTime && this.target.setAttributes(this._startProps);
16142
+ let targetStep = null;
16143
+ if (this._lastStep === this._firstStep) targetStep = this._firstStep;else {
16144
+ let currentStep = this._firstStep;
16145
+ for (; currentStep;) {
16146
+ const stepStartTime = currentStep.getStartTime(),
16147
+ stepDuration = currentStep.getDuration();
16148
+ if (cycleTime >= stepStartTime && cycleTime <= stepStartTime + stepDuration) {
16149
+ targetStep = currentStep;
16150
+ break;
16151
+ }
16152
+ currentStep = currentStep.next;
16153
+ }
16154
+ }
16155
+ if (!targetStep) return;
16156
+ const ratio = (cycleTime - targetStep.getStartTime()) / targetStep.getDuration(),
16157
+ isEnd = ratio >= 1;
16158
+ targetStep.update(isEnd, ratio, {}), isEnd && targetStep.onEnd();
16159
+ }
16160
+ updateDuration() {
16161
+ this._lastStep ? (this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration(), this._totalDuration = this._duration * (this._loopCount + 1)) : this._duration = 0;
16162
+ }
16163
+ getTotalDuration() {
16164
+ return this._totalDuration;
16165
+ }
16166
+ getLoop() {
16167
+ return this._loopCount;
16168
+ }
16169
+ }
16170
+
16171
+ class ACustomAnimate extends Step {
16172
+ constructor(customFrom, customTo, duration, easing, params) {
16173
+ super("customAnimate", customTo, duration, easing), this.type = "customAnimate", this.customFrom = customFrom, this.params = params;
16174
+ }
16175
+ update(end, ratio, out) {
16176
+ if (this.onStart(), !this.props || !this.propKeys) return;
16177
+ const easedRatio = this.easing(ratio);
16178
+ this.onUpdate(end, easedRatio, out);
16179
+ }
16180
+ setProps(props) {
16181
+ this.props = props, this.propKeys = Object.keys(props), this.animate.reSyncProps();
16182
+ }
15898
16183
  }
15899
16184
 
15900
- loadTagComponent();
15901
- class Tag extends AbstractComponent {
15902
- getBgRect() {
15903
- return this._bgRect;
15904
- }
15905
- getTextShape() {
15906
- return this._textShape;
15907
- }
15908
- constructor(attributes, options) {
15909
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, Tag.defaultAttributes, attributes));
15910
- this.name = 'tag';
15911
- this._tagStates = [];
15912
- this._rectStates = [];
15913
- this._symbolStates = [];
15914
- this._textStates = [];
15915
- }
15916
- render() {
15917
- var _a, _b, _c;
15918
- this.cacheStates();
15919
- const { text = '', textStyle = {}, shape = {}, panel = {}, space = 4, minWidth, maxWidth, padding = 4, visible, state, type, textAlwaysCenter, containerTextAlign } = this.attribute;
15920
- const parsedPadding = normalizePadding(padding);
15921
- const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group');
15922
- let symbol;
15923
- let tagX = -parsedPadding[3];
15924
- let tagY = -parsedPadding[0];
15925
- let tagWidth = parsedPadding[1] + parsedPadding[3];
15926
- let tagHeight = parsedPadding[0] + parsedPadding[2];
15927
- let textX = 0;
15928
- let symbolPlaceWidth = 0;
15929
- const { visible: shapeVisible } = shape, shapeStyle = __rest(shape, ["visible"]);
15930
- if (isBoolean(shapeVisible)) {
15931
- const size = (shapeStyle === null || shapeStyle === void 0 ? void 0 : shapeStyle.size) || 10;
15932
- const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
15933
- symbol = group.createOrUpdateChild('tag-shape', Object.assign(Object.assign({ symbolType: 'circle', size, strokeBoundsBuffer: 0 }, shapeStyle), { visible: shapeVisible, x: maxSize / 2, y: maxSize / 2 }), 'symbol');
15934
- if (!isEmpty(state === null || state === void 0 ? void 0 : state.shape)) {
15935
- symbol.states = state.shape;
15936
- }
15937
- if (shapeVisible) {
15938
- symbolPlaceWidth = maxSize + space;
15939
- }
15940
- }
15941
- tagWidth += symbolPlaceWidth;
15942
- textX += symbolPlaceWidth;
15943
- let textShape;
15944
- let textWidth;
15945
- let textHeight;
15946
- const isRich = isRichText({ text }) || type === 'rich';
15947
- if (isRich) {
15948
- const richTextAttrs = Object.assign(Object.assign(Object.assign({}, richTextAttributeTransform(Object.assign({ type, text }, textStyle))), textStyle), { visible: isValid(text) && visible !== false, x: textX, y: 0 });
15949
- if (isNil(richTextAttrs.lineHeight)) {
15950
- richTextAttrs.lineHeight = textStyle.fontSize;
15951
- }
15952
- textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext');
15953
- textWidth = textShape.AABBBounds.width();
15954
- textHeight = textShape.AABBBounds.height();
15955
- }
15956
- else {
15957
- const textAttrs = Object.assign(Object.assign({ text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text, visible: isValid(text) && visible !== false, lineHeight: textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize }, textStyle), { x: textX, y: 0 });
15958
- if (isNil(textAttrs.lineHeight)) {
15959
- textAttrs.lineHeight = textStyle.fontSize;
15960
- }
15961
- textShape = group.createOrUpdateChild('tag-text', textAttrs, 'text');
15962
- const textBounds = measureTextSize(textAttrs.text, textStyle, (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.getTheme()) === null || _b === void 0 ? void 0 : _b.text);
15963
- textWidth = textBounds.width;
15964
- textHeight = textBounds.height;
15965
- }
15966
- tagWidth += textWidth;
15967
- const size = (_c = shape.size) !== null && _c !== void 0 ? _c : 10;
15968
- const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
15969
- tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);
15970
- const { textAlign, textBaseline } = textStyle;
15971
- if (isValid(minWidth) || isValid(maxWidth)) {
15972
- if (isValid(minWidth) && tagWidth < minWidth) {
15973
- tagWidth = minWidth;
15974
- }
15975
- if (isValid(maxWidth) && tagWidth > maxWidth) {
15976
- tagWidth = maxWidth;
15977
- textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);
15978
- }
15979
- }
15980
- tagX = 0;
15981
- tagY = 0;
15982
- let flag = 0;
15983
- if (textAlign === 'left' || textAlign === 'start') {
15984
- flag = 1;
15985
- }
15986
- else if (textAlign === 'right' || textAlign === 'end') {
15987
- flag = -1;
15988
- }
15989
- else if (textAlign === 'center') {
15990
- flag = 0;
15991
- }
15992
- if (!flag) {
15993
- tagX -= tagWidth / 2;
15994
- if (symbol) {
15995
- symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);
15996
- }
15997
- group.setAttribute('x', -symbolPlaceWidth / 2);
15998
- }
15999
- else if (flag < 0) {
16000
- tagX -= tagWidth;
16001
- if (symbol) {
16002
- symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);
16003
- }
16004
- group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);
16005
- }
16006
- else if (flag > 0) {
16007
- group.setAttribute('x', parsedPadding[3]);
16008
- }
16009
- const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;
16010
- const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';
16011
- const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';
16012
- const updateTextAttrs = (textX, textAlign) => {
16013
- if (textShape.type === 'richtext') {
16014
- textShape.setAttributes({
16015
- x: textX,
16016
- textAlign,
16017
- textConfig: array(textShape.attribute.textConfig).map(t => {
16018
- return Object.assign(Object.assign({}, t), { textAlign });
16019
- })
16020
- });
16021
- }
16022
- else {
16023
- textShape.setAttributes({
16024
- x: textX,
16025
- textAlign
16026
- });
16027
- }
16028
- };
16029
- if (shouldCenter && flag) {
16030
- const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16031
- const tsWidth = textWidth + symbolPlaceWidth;
16032
- const textX = flag === 1
16033
- ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
16034
- : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
16035
- updateTextAttrs(textX, 'center');
16036
- if (symbol) {
16037
- const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
16038
- symbol.setAttributes({
16039
- x: symbolX
16040
- });
16041
- }
16042
- }
16043
- if (shouldLeft && flag !== 1) {
16044
- const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16045
- const offset = flag === 0
16046
- ? -containerWidth / 2 + symbolPlaceWidth / 2
16047
- : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;
16048
- const textX = offset + symbolPlaceWidth;
16049
- updateTextAttrs(textX, 'left');
16050
- if (symbol) {
16051
- const symbolX = offset + maxSize / 2;
16052
- symbol.setAttributes({
16053
- x: symbolX
16054
- });
16055
- }
16056
- }
16057
- if (shouldRight && flag !== -1) {
16058
- const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16059
- const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;
16060
- updateTextAttrs(textX, 'right');
16061
- if (symbol) {
16062
- const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;
16063
- symbol.setAttributes({
16064
- x: symbolX
16065
- });
16066
- }
16067
- }
16068
- if (textBaseline === 'middle') {
16069
- tagY -= tagHeight / 2;
16070
- if (symbol) {
16071
- symbol.setAttribute('y', 0);
16072
- }
16073
- }
16074
- else if (textBaseline === 'bottom') {
16075
- tagY -= tagHeight;
16076
- if (symbol) {
16077
- symbol.setAttribute('y', -textHeight / 2);
16078
- }
16079
- group.setAttribute('y', -parsedPadding[2]);
16080
- }
16081
- else if (textBaseline === 'top') {
16082
- group.setAttribute('y', parsedPadding[0]);
16083
- if (symbol) {
16084
- symbol.setAttribute('y', textHeight / 2);
16085
- }
16086
- }
16087
- if (!isEmpty(state === null || state === void 0 ? void 0 : state.text)) {
16088
- textShape.states = state.text;
16089
- }
16090
- const { visible: bgVisible } = panel, backgroundStyle = __rest(panel, ["visible"]);
16091
- if (visible && isBoolean(bgVisible)) {
16092
- const bgRect = this.createOrUpdateChild('tag-panel', Object.assign(Object.assign({}, backgroundStyle), { visible: bgVisible && !!text, width: tagWidth, height: tagHeight, x: tagX, y: tagY }), 'rect');
16093
- if (!isEmpty(state === null || state === void 0 ? void 0 : state.panel)) {
16094
- bgRect.states = state.panel;
16095
- }
16096
- if (backgroundStyle.customShape) {
16097
- const customShape = backgroundStyle.customShape;
16098
- bgRect.pathProxy = (attrs) => {
16099
- return customShape(this, attrs, new CustomPath2D());
16100
- };
16101
- }
16102
- this._bgRect = bgRect;
16103
- }
16104
- this._textShape = textShape;
16105
- this._symbol = symbol;
16106
- this.resetStates();
16107
- }
16108
- initAttributes(params, options) {
16109
- params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, Tag.defaultAttributes, params);
16110
- super.initAttributes(params);
16111
- this.render();
16112
- }
16113
- addState(stateName, keepCurrentStates, hasAnimation) {
16114
- super.addState(stateName, keepCurrentStates, hasAnimation);
16115
- if (this._textShape) {
16116
- this._textShape.addState(stateName, keepCurrentStates, hasAnimation);
16117
- }
16118
- if (this._bgRect) {
16119
- this._bgRect.addState(stateName, keepCurrentStates, hasAnimation);
16120
- }
16121
- if (this._symbol) {
16122
- this._symbol.addState(stateName, keepCurrentStates, hasAnimation);
16123
- }
16124
- }
16125
- removeState(stateName, hasAnimation) {
16126
- super.removeState(stateName, hasAnimation);
16127
- if (this._textShape) {
16128
- this._textShape.removeState(stateName, hasAnimation);
16129
- }
16130
- if (this._bgRect) {
16131
- this._bgRect.removeState(stateName, hasAnimation);
16132
- }
16133
- if (this._symbol) {
16134
- this._symbol.removeState(stateName, hasAnimation);
16135
- }
16136
- }
16137
- cacheStates() {
16138
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
16139
- this._tagStates = (_b = (_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
16140
- this._rectStates = (_e = (_d = (_c = this._bgRect) === null || _c === void 0 ? void 0 : _c.currentStates) === null || _d === void 0 ? void 0 : _d.slice()) !== null && _e !== void 0 ? _e : [];
16141
- this._symbolStates = (_h = (_g = (_f = this._symbol) === null || _f === void 0 ? void 0 : _f.currentStates) === null || _g === void 0 ? void 0 : _g.slice()) !== null && _h !== void 0 ? _h : [];
16142
- this._textStates = (_l = (_k = (_j = this._textShape) === null || _j === void 0 ? void 0 : _j.currentStates) === null || _k === void 0 ? void 0 : _k.slice()) !== null && _l !== void 0 ? _l : [];
16143
- this.clearStates();
16144
- (_m = this._bgRect) === null || _m === void 0 ? void 0 : _m.clearStates();
16145
- (_o = this._symbol) === null || _o === void 0 ? void 0 : _o.clearStates();
16146
- (_p = this._textShape) === null || _p === void 0 ? void 0 : _p.clearStates();
16185
+ class IncreaseCount extends ACustomAnimate {
16186
+ constructor(from, to, duration, easing, params) {
16187
+ super(from, to, duration, easing, params), this.formatTemplate = null, this.decimalLength = null == params ? void 0 : params.decimalLength, (null == params ? void 0 : params.formatTemplate) && params.formatTemplate.includes("{{var}}") && (this.formatTemplate = params.formatTemplate);
16188
+ }
16189
+ onFirstRun() {
16190
+ var _a, _b, _c;
16191
+ const fromProps = this.getLastProps(),
16192
+ toProps = this.getEndProps(),
16193
+ fromText = null !== (_a = fromProps.text) && void 0 !== _a ? _a : 0,
16194
+ toText = null !== (_b = toProps.text) && void 0 !== _b ? _b : 0;
16195
+ this.valid = !0;
16196
+ let fromNum = 0,
16197
+ toNum = 0,
16198
+ fromFormat = "",
16199
+ toFormat = "",
16200
+ maxDecimalLength = 0;
16201
+ if ("number" == typeof fromText) {
16202
+ fromNum = fromText;
16203
+ const decimalPart = fromText.toString().split(".")[1] || "";
16204
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
16205
+ } else {
16206
+ if ("string" != typeof fromText) return void (this.valid = !1);
16207
+ if (fromText.endsWith("%")) {
16208
+ fromFormat = "%";
16209
+ const cleanNumStr = fromText.substring(0, fromText.length - 1).replace(/,/g, "");
16210
+ if (fromNum = parseFloat(cleanNumStr) / 100, isNaN(fromNum)) return void (this.valid = !1);
16211
+ const decimalPart = cleanNumStr.split(".")[1] || "";
16212
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2);
16213
+ } else {
16214
+ const cleanNumStr = fromText.replace(/,/g, "");
16215
+ if (fromNum = parseFloat(cleanNumStr), isNaN(fromNum)) return void (this.valid = !1);
16216
+ fromText.includes(",") && (fromFormat = ",");
16217
+ const decimalPart = cleanNumStr.split(".")[1] || "";
16218
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
16219
+ }
16147
16220
  }
16148
- resetStates() {
16149
- var _a, _b, _c;
16150
- this._tagStates.length && this.useStates(this._tagStates);
16151
- this._rectStates.length && ((_a = this._bgRect) === null || _a === void 0 ? void 0 : _a.useStates(this._rectStates));
16152
- this._symbolStates.length && ((_b = this._symbol) === null || _b === void 0 ? void 0 : _b.useStates(this._symbolStates));
16153
- this._textStates.length && ((_c = this._textShape) === null || _c === void 0 ? void 0 : _c.useStates(this._textStates));
16221
+ if ("number" == typeof toText) {
16222
+ toNum = toText;
16223
+ const decimalPart = toText.toString().split(".")[1] || "";
16224
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
16225
+ } else {
16226
+ if ("string" != typeof toText) return void (this.valid = !1);
16227
+ if (toText.endsWith("%")) {
16228
+ toFormat = "%";
16229
+ const cleanNumStr = toText.substring(0, toText.length - 1).replace(/,/g, "");
16230
+ if (toNum = parseFloat(cleanNumStr) / 100, isNaN(toNum)) return void (this.valid = !1);
16231
+ const decimalPart = cleanNumStr.split(".")[1] || "";
16232
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2);
16233
+ } else {
16234
+ const cleanNumStr = toText.replace(/,/g, "");
16235
+ if (toNum = parseFloat(cleanNumStr), isNaN(toNum)) return void (this.valid = !1);
16236
+ toText.includes(",") && (toFormat = ",");
16237
+ const decimalPart = cleanNumStr.split(".")[1] || "";
16238
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
16239
+ }
16154
16240
  }
16241
+ if (null === (_c = this.params) || void 0 === _c ? void 0 : _c.format) {
16242
+ switch (this.params.format) {
16243
+ case "percent":
16244
+ this.format = "%";
16245
+ break;
16246
+ case "thousandth":
16247
+ this.format = ",";
16248
+ break;
16249
+ case "none":
16250
+ this.format = "";
16251
+ break;
16252
+ default:
16253
+ this.format = toFormat || fromFormat;
16254
+ }
16255
+ "%" === this.format && "%" !== toFormat && "%" !== fromFormat && void 0 === this.decimalLength && (this.decimalLength = 2), "%" === this.format || "%" !== toFormat && "%" !== fromFormat || (fromNum *= 100, toNum *= 100);
16256
+ } else this.format = toFormat || fromFormat;
16257
+ this.fromNumber = fromNum, this.toNumber = toNum, void 0 === this.decimalLength && (this.decimalLength = maxDecimalLength);
16258
+ }
16259
+ onEnd(cb) {
16260
+ super.onEnd(cb), cb || this.props && this.target.setAttributes(this.props);
16261
+ }
16262
+ onUpdate(end, ratio, out) {
16263
+ if (!this.valid) return;
16264
+ const currentNumber = this.fromNumber + (this.toNumber - this.fromNumber) * ratio;
16265
+ let formattedText = "";
16266
+ const format = this.format,
16267
+ numberWithDecimals = ("%" === format ? 100 * currentNumber : currentNumber).toFixed(this.decimalLength);
16268
+ let formattedWithBasicFormat,
16269
+ formattedNumber = numberWithDecimals;
16270
+ if (parseFloat(numberWithDecimals) === Math.floor(parseFloat(numberWithDecimals)) && (formattedNumber = Math.floor(parseFloat(numberWithDecimals))), "%" === format) formattedWithBasicFormat = `${formattedNumber}%`;else if ("," === format) {
16271
+ const parts = formattedNumber.toString().split(".");
16272
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), formattedWithBasicFormat = parts.join(".");
16273
+ } else formattedWithBasicFormat = formattedNumber;
16274
+ formattedText = this.formatTemplate ? this.formatTemplate.replace("{{var}}", formattedWithBasicFormat.toString()) : formattedWithBasicFormat, this.target.setAttribute("text", formattedText);
16275
+ }
16276
+ }
16277
+
16278
+ class InputText extends ACustomAnimate {
16279
+ constructor(from, to, duration, easing, params) {
16280
+ super(from, to, duration, easing, params), this.fromText = "", this.toText = "", this.showCursor = !1, this.cursorChar = "|", this.blinkCursor = !0, this.beforeText = "", this.afterText = "", void 0 !== (null == params ? void 0 : params.showCursor) && (this.showCursor = params.showCursor), void 0 !== (null == params ? void 0 : params.cursorChar) && (this.cursorChar = params.cursorChar), void 0 !== (null == params ? void 0 : params.blinkCursor) && (this.blinkCursor = params.blinkCursor), void 0 !== (null == params ? void 0 : params.beforeText) && (this.beforeText = params.beforeText), void 0 !== (null == params ? void 0 : params.afterText) && (this.afterText = params.afterText);
16281
+ }
16282
+ onFirstRun() {
16283
+ var _a, _b;
16284
+ const fromProps = this.getLastProps(),
16285
+ toProps = this.getEndProps(),
16286
+ fromText = null !== (_a = fromProps.text) && void 0 !== _a ? _a : "",
16287
+ toText = null !== (_b = toProps.text) && void 0 !== _b ? _b : "";
16288
+ this.valid = !0, this.fromText = fromText.toString(), this.toText = toText.toString(), this.toText || "" === this.toText || (this.valid = !1);
16289
+ }
16290
+ onEnd(cb) {
16291
+ super.onEnd(cb), cb || (this.showCursor && !this.blinkCursor ? this.target.setAttribute("text", this.beforeText + this.toText + this.cursorChar + this.afterText) : this.target.setAttribute("text", this.beforeText + this.toText + this.afterText));
16292
+ }
16293
+ onUpdate(end, ratio, out) {
16294
+ if (!this.valid) return;
16295
+ const totalChars = this.toText.length,
16296
+ fromChars = this.fromText.length;
16297
+ let currentLength, currentText;
16298
+ fromChars > totalChars ? (currentLength = Math.round(fromChars - (fromChars - totalChars) * ratio), currentText = this.fromText.substring(0, currentLength)) : (currentLength = Math.round(fromChars + (totalChars - fromChars) * ratio), currentText = this.toText.startsWith(this.fromText) ? this.toText.substring(0, currentLength) : currentLength <= fromChars ? this.fromText.substring(0, currentLength) : this.toText.substring(0, currentLength - fromChars + Math.min(fromChars, currentLength)));
16299
+ let displayText = this.beforeText + currentText + this.afterText;
16300
+ if (this.showCursor) if (this.blinkCursor) {
16301
+ const blinkRate = .1;
16302
+ Math.floor(ratio / blinkRate) % 2 == 0 && (displayText = this.beforeText + currentText + this.cursorChar + this.afterText);
16303
+ } else displayText = this.beforeText + currentText + this.cursorChar + this.afterText;
16304
+ this.target.setAttribute("text", displayText);
16305
+ }
16155
16306
  }
16156
- Tag.defaultAttributes = {
16157
- visible: true,
16158
- textStyle: {
16159
- fontSize: 12,
16160
- fill: '#000',
16161
- textAlign: 'left',
16162
- textBaseline: 'top'
16163
- },
16164
- space: 4,
16165
- padding: 4,
16166
- shape: {
16167
- fill: '#000'
16168
- }
16169
- };
16170
16307
 
16171
16308
  const DEFAULT_THEME = {
16172
16309
  visible: true,
@@ -20023,11 +20160,10 @@ function bitmapTool(width, height, padding = { top: 0, left: 0, right: 0, bottom
20023
20160
  }
20024
20161
  function clampRangeByBitmap($, range) {
20025
20162
  const { x1, x2, y1, y2 } = range;
20026
- const { top = 0, left = 0, right = 0, bottom = 0 } = $.padding;
20027
- const _x1 = clamp(x1, -left, $.width + right);
20028
- const _x2 = clamp(x2, -left, $.width + right);
20029
- const _y1 = clamp(y1, -top, $.height + bottom);
20030
- const _y2 = clamp(y2, -top, $.height + bottom);
20163
+ const _x1 = clamp(x1, 0, $.width);
20164
+ const _x2 = clamp(x2, 0, $.width);
20165
+ const _y1 = clamp(y1, 0, $.height);
20166
+ const _y2 = clamp(y2, 0, $.height);
20031
20167
  return {
20032
20168
  x1: $.x(_x1),
20033
20169
  x2: $.x(_x2),
@@ -20198,18 +20334,9 @@ function getAnimationAttributes(textAttribute, type) {
20198
20334
  return (_b = (_a = animationEffects[type]) === null || _a === void 0 ? void 0 : _a.call(animationEffects, textAttribute)) !== null && _b !== void 0 ? _b : { from: {}, to: {} };
20199
20335
  }
20200
20336
  function updateAnimation(prev, next, animationConfig) {
20201
- const changeAttributes = (prev, next) => {
20202
- const changed = {};
20203
- for (const key in next.attribute) {
20204
- if (prev.attribute[key] !== next.attribute[key]) {
20205
- changed[key] = next.attribute[key];
20206
- }
20207
- }
20208
- return changed;
20209
- };
20210
20337
  if (!isArray(animationConfig)) {
20211
20338
  const { duration, easing, increaseEffect = true } = animationConfig;
20212
- prev.animate().to(changeAttributes(prev, next), duration, easing);
20339
+ prev.animate().to(next.attribute, duration, easing);
20213
20340
  if (increaseEffect && prev.type === 'text' && next.type === 'text') {
20214
20341
  playIncreaseCount(prev, next, duration, easing);
20215
20342
  }
@@ -20219,7 +20346,7 @@ function updateAnimation(prev, next, animationConfig) {
20219
20346
  const { duration, easing, increaseEffect = true, channel } = cfg;
20220
20347
  const { to } = update(prev, next, channel, cfg.options);
20221
20348
  if (!isEmpty(to)) {
20222
- prev.animate().to(changeAttributes(prev, next), duration, easing);
20349
+ prev.animate().to(to, duration, easing);
20223
20350
  }
20224
20351
  if (increaseEffect && prev.type === 'text' && next.type === 'text') {
20225
20352
  playIncreaseCount(prev, next, duration, easing);
@@ -20978,9 +21105,7 @@ class LabelBase extends AbstractComponent {
20978
21105
  return this._overlapByStrategy(labels, option, bmpTool, bitmap);
20979
21106
  }
20980
21107
  _overlapGlobal(labels, option, bmpTool, bitmap) {
20981
- let result = labels.filter(label => label.attribute.visible &&
20982
- label.attribute.opacity !== 0 &&
20983
- this.isMarkInsideRect(this.getRelatedGraphic(label.attribute), bmpTool));
21108
+ let result = labels.filter(label => label.attribute.visible && label.attribute.opacity !== 0);
20984
21109
  const { clampForce = true, hideOnHit = true, overlapPadding, strategy } = option;
20985
21110
  if (clampForce) {
20986
21111
  for (let i = 0; i < result.length; i++) {
@@ -21072,7 +21197,7 @@ class LabelBase extends AbstractComponent {
21072
21197
  const text = labels[i];
21073
21198
  const baseMark = this.getRelatedGraphic(text.attribute);
21074
21199
  text.update();
21075
- if (!this.isMarkInsideRect(baseMark, bmpTool)) {
21200
+ if (!isRectIntersect(baseMark.AABBBounds, { x1: 0, x2: bmpTool.width, y1: 0, y2: bmpTool.height }, true)) {
21076
21201
  continue;
21077
21202
  }
21078
21203
  if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
@@ -21112,23 +21237,6 @@ class LabelBase extends AbstractComponent {
21112
21237
  }
21113
21238
  return result;
21114
21239
  }
21115
- isMarkInsideRect(baseMark, bmpTool) {
21116
- const { left, right, top, bottom } = bmpTool.padding;
21117
- const rect = { x1: -left, x2: bmpTool.width + right, y1: -top, y2: bmpTool.height + bottom };
21118
- const bounds = baseMark.AABBBounds;
21119
- if (bounds.width() !== 0 && bounds.height() !== 0) {
21120
- return isRectIntersect(baseMark.AABBBounds, rect, true);
21121
- }
21122
- const { attribute } = baseMark;
21123
- if (baseMark.type === 'rect') {
21124
- const { x, x1, y, y1 } = attribute;
21125
- return pointInRect({ x: x !== null && x !== void 0 ? x : x1, y: y !== null && y !== void 0 ? y : y1 }, rect, true);
21126
- }
21127
- else if ('x' in attribute && 'y' in attribute) {
21128
- return pointInRect({ x: attribute.x, y: attribute.y }, rect, true);
21129
- }
21130
- return false;
21131
- }
21132
21240
  getBaseMarkGroup() {
21133
21241
  const { baseMarkGroupName } = this.attribute;
21134
21242
  if (!baseMarkGroupName) {
@@ -31500,6 +31608,6 @@ StoryLabelItem.defaultAttributes = {
31500
31608
  theme: 'default'
31501
31609
  };
31502
31610
 
31503
- const version = "0.22.6";
31611
+ const version = "0.23.0-alpha.2";
31504
31612
 
31505
31613
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };