@antv/g 5.3.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/components/Transform.d.ts +5 -1
  2. package/dist/components/Transform.d.ts.map +1 -1
  3. package/dist/css/StyleValueRegistry.d.ts.map +1 -1
  4. package/dist/css/interfaces.d.ts +1 -1
  5. package/dist/css/interfaces.d.ts.map +1 -1
  6. package/dist/css/parser/color.d.ts +4 -1
  7. package/dist/css/parser/color.d.ts.map +1 -1
  8. package/dist/css/parser/gradient.d.ts +4 -3
  9. package/dist/css/parser/gradient.d.ts.map +1 -1
  10. package/dist/css/parser/path.d.ts +2 -2
  11. package/dist/css/parser/path.d.ts.map +1 -1
  12. package/dist/css/parser/transform.d.ts +1 -0
  13. package/dist/css/parser/transform.d.ts.map +1 -1
  14. package/dist/css/properties/CSSPropertyColor.d.ts +4 -1
  15. package/dist/css/properties/CSSPropertyColor.d.ts.map +1 -1
  16. package/dist/css/properties/CSSPropertyPath.d.ts +2 -12
  17. package/dist/css/properties/CSSPropertyPath.d.ts.map +1 -1
  18. package/dist/css/properties/CSSPropertyTransform.d.ts.map +1 -1
  19. package/dist/display-objects/Circle.d.ts.map +1 -1
  20. package/dist/display-objects/DisplayObject.d.ts +2 -0
  21. package/dist/display-objects/DisplayObject.d.ts.map +1 -1
  22. package/dist/display-objects/Ellipse.d.ts.map +1 -1
  23. package/dist/dom/interfaces.d.ts +0 -1
  24. package/dist/dom/interfaces.d.ts.map +1 -1
  25. package/dist/index.esm.js +565 -170
  26. package/dist/index.js +530 -132
  27. package/dist/index.umd.js +1679 -1494
  28. package/dist/index.umd.min.js +2 -2
  29. package/dist/services/SceneGraphService.d.ts +6 -2
  30. package/dist/services/SceneGraphService.d.ts.map +1 -1
  31. package/dist/types.d.ts +0 -5
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/utils/index.d.ts +1 -0
  34. package/dist/utils/index.d.ts.map +1 -1
  35. package/dist/utils/interpolation.d.ts.map +1 -1
  36. package/dist/utils/memoize.d.ts +11 -0
  37. package/dist/utils/memoize.d.ts.map +1 -0
  38. package/dist/utils/string.d.ts +4 -1
  39. package/dist/utils/string.d.ts.map +1 -1
  40. package/package.json +6 -7
package/dist/index.umd.js CHANGED
@@ -4723,6 +4723,17 @@
4723
4723
  PERFORMANCE OF THIS SOFTWARE.
4724
4724
  ***************************************************************************** */
4725
4725
 
4726
+ var __assign = function() {
4727
+ __assign = Object.assign || function __assign(t) {
4728
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4729
+ s = arguments[i];
4730
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
4731
+ }
4732
+ return t;
4733
+ };
4734
+ return __assign.apply(this, arguments);
4735
+ };
4736
+
4726
4737
  function __decorate(decorators, target, key, desc) {
4727
4738
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4728
4739
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4736,6 +4747,16 @@
4736
4747
 
4737
4748
  function __metadata(metadataKey, metadataValue) {
4738
4749
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
4750
+ }
4751
+
4752
+ function __spreadArray(to, from, pack) {
4753
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4754
+ if (ar || !(i in from)) {
4755
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4756
+ ar[i] = from[i];
4757
+ }
4758
+ }
4759
+ return to.concat(ar || Array.prototype.slice.call(from));
4739
4760
  }
4740
4761
 
4741
4762
  function _regeneratorRuntime() {
@@ -7567,6 +7588,33 @@
7567
7588
 
7568
7589
  return out;
7569
7590
  }
7591
+ /**
7592
+ * Creates a new vec2 initialized with the given values
7593
+ *
7594
+ * @param {Number} x X component
7595
+ * @param {Number} y Y component
7596
+ * @returns {vec2} a new 2D vector
7597
+ */
7598
+
7599
+ function fromValues$4(x, y) {
7600
+ var out = new ARRAY_TYPE(2);
7601
+ out[0] = x;
7602
+ out[1] = y;
7603
+ return out;
7604
+ }
7605
+ /**
7606
+ * Copy the values from one vec2 to another
7607
+ *
7608
+ * @param {vec2} out the receiving vector
7609
+ * @param {ReadonlyVec2} a the source vector
7610
+ * @returns {vec2} out
7611
+ */
7612
+
7613
+ function copy$4(out, a) {
7614
+ out[0] = a[0];
7615
+ out[1] = a[1];
7616
+ return out;
7617
+ }
7570
7618
  /**
7571
7619
  * Normalize a vec2
7572
7620
  *
@@ -7897,7 +7945,7 @@
7897
7945
  return "-" + letter.toLowerCase();
7898
7946
  }); // Remove first dash
7899
7947
 
7900
- return str.charAt(0) === '-' ? str.substr(1) : str;
7948
+ return str.charAt(0) === '-' ? str.substring(1) : str;
7901
7949
  };
7902
7950
  /**
7903
7951
  Easing Functions from anime.js, they are tried and true, so, its better to use them instead of other alternatives
@@ -8990,20 +9038,45 @@
8990
9038
  return timing.easingFunction(directedProgress);
8991
9039
  }
8992
9040
 
8993
- var cache = {};
8994
- function camelCase(str) {
8995
- if (str === void 0) {
8996
- str = '';
9041
+ /**
9042
+ * @see https://github.com/lodash/lodash/blob/master/memoize.js
9043
+ */
9044
+ function memoize(func, resolver) {
9045
+ if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
9046
+ throw new TypeError('Expected a function');
8997
9047
  }
8998
9048
 
8999
- if (!cache[str]) {
9000
- cache[str] = str.replace(/-([a-z])/g, function (g) {
9001
- return g[1].toUpperCase();
9002
- });
9003
- }
9049
+ var memoized = function memoized() {
9050
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9051
+ args[_key] = arguments[_key];
9052
+ }
9053
+
9054
+ var key = resolver ? resolver.apply(this, args) : args[0];
9055
+ var cache = memoized.cache;
9056
+
9057
+ if (cache.has(key)) {
9058
+ return cache.get(key);
9059
+ }
9060
+
9061
+ var result = func.apply(this, args);
9062
+ memoized.cache = cache.set(key, result) || cache;
9063
+ return result;
9064
+ };
9004
9065
 
9005
- return cache[str];
9066
+ memoized.cache = new (memoize.Cache || Map)();
9067
+ return memoized;
9006
9068
  }
9069
+ memoize.Cache = Map;
9070
+
9071
+ var camelCase = memoize(function (str) {
9072
+ if (str === void 0) {
9073
+ str = '';
9074
+ }
9075
+
9076
+ return str.replace(/-([a-z])/g, function (g) {
9077
+ return g[1].toUpperCase();
9078
+ });
9079
+ });
9007
9080
  function isString(str) {
9008
9081
  if (!isNil(str) && typeof str === 'string') {
9009
9082
  return true;
@@ -9209,15 +9282,33 @@
9209
9282
  alias: 'img'
9210
9283
  }
9211
9284
  };
9212
- function formatAttribute(name, value) {
9213
- var _map$values;
9214
-
9285
+ var formatAttributeName = memoize(function (name) {
9215
9286
  var attributeName = camelCase(name);
9216
9287
  var map = FORMAT_ATTR_MAP[attributeName];
9217
9288
  attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
9218
- var attributeValue = (map === null || map === void 0 ? void 0 : (_map$values = map.values) === null || _map$values === void 0 ? void 0 : _map$values[value]) || value;
9289
+ return [attributeName, map];
9290
+ });
9291
+ function formatAttribute(name, value) {
9292
+ var _map$values;
9293
+
9294
+ var _formatAttributeName = formatAttributeName(name),
9295
+ attributeName = _formatAttributeName[0],
9296
+ map = _formatAttributeName[1];
9297
+
9298
+ var attributeValue = isString(value) && (map === null || map === void 0 ? void 0 : (_map$values = map.values) === null || _map$values === void 0 ? void 0 : _map$values[value]) || value;
9219
9299
  return [attributeName, attributeValue];
9220
- }
9300
+ } // export const formatAttribute = memoize(
9301
+ // (name: string, value: any): [string, any] => {
9302
+ // let attributeName = camelCase(name);
9303
+ // const map = FORMAT_ATTR_MAP[attributeName];
9304
+ // attributeName = map?.alias || attributeName;
9305
+ // const attributeValue = map?.values?.[value] || value;
9306
+ // return [attributeName, attributeValue];
9307
+ // },
9308
+ // (name: string, value: any) => {
9309
+ // return `${name}${value}`;
9310
+ // },
9311
+ // );
9221
9312
 
9222
9313
  (function (Shape) {
9223
9314
  Shape["GROUP"] = "g";
@@ -14382,947 +14473,173 @@
14382
14473
  : m1) * 255;
14383
14474
  }
14384
14475
 
14385
- /** Detect free variable `global` from Node.js. */
14386
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
14476
+ var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
14477
+ var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
14478
+ var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
14479
+ var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
14387
14480
 
14388
- /** Detect free variable `self`. */
14389
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
14481
+ function spaceColorStops(colorStops) {
14482
+ var _colorStops$length;
14390
14483
 
14391
- /** Used as a reference to the global object. */
14392
- var root = freeGlobal || freeSelf || Function('return this')();
14484
+ var length = colorStops.length;
14485
+ colorStops[length - 1].length = (_colorStops$length = colorStops[length - 1].length) !== null && _colorStops$length !== void 0 ? _colorStops$length : {
14486
+ type: '%',
14487
+ value: '100'
14488
+ };
14393
14489
 
14394
- /** Built-in value references. */
14395
- var Symbol$1 = root.Symbol;
14490
+ if (length > 1) {
14491
+ var _colorStops$0$length;
14396
14492
 
14397
- /** Used for built-in method references. */
14398
- var objectProto = Object.prototype;
14493
+ colorStops[0].length = (_colorStops$0$length = colorStops[0].length) !== null && _colorStops$0$length !== void 0 ? _colorStops$0$length : {
14494
+ type: '%',
14495
+ value: '0'
14496
+ };
14497
+ }
14399
14498
 
14400
- /** Used to check objects for own properties. */
14401
- var hasOwnProperty = objectProto.hasOwnProperty;
14499
+ var previousIndex = 0;
14500
+ var previousOffset = Number(colorStops[0].length.value);
14402
14501
 
14403
- /**
14404
- * Used to resolve the
14405
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
14406
- * of values.
14407
- */
14408
- var nativeObjectToString = objectProto.toString;
14502
+ for (var i = 1; i < length; i++) {
14503
+ var _colorStops$i$length;
14409
14504
 
14410
- /** Built-in value references. */
14411
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
14505
+ var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
14412
14506
 
14413
- /**
14414
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
14415
- *
14416
- * @private
14417
- * @param {*} value The value to query.
14418
- * @returns {string} Returns the raw `toStringTag`.
14419
- */
14420
- function getRawTag(value) {
14421
- var isOwn = hasOwnProperty.call(value, symToStringTag),
14422
- tag = value[symToStringTag];
14507
+ if (!isNil(offset) && !isNil(previousOffset)) {
14508
+ for (var j = 1; j < i - previousIndex; j++) {
14509
+ colorStops[previousIndex + j].length = {
14510
+ type: '%',
14511
+ value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
14512
+ };
14513
+ }
14423
14514
 
14424
- try {
14425
- value[symToStringTag] = undefined;
14426
- var unmasked = true;
14427
- } catch (e) {}
14428
-
14429
- var result = nativeObjectToString.call(value);
14430
- if (unmasked) {
14431
- if (isOwn) {
14432
- value[symToStringTag] = tag;
14433
- } else {
14434
- delete value[symToStringTag];
14515
+ previousIndex = i;
14516
+ previousOffset = Number(offset);
14435
14517
  }
14436
14518
  }
14437
- return result;
14438
- }
14519
+ } // The position of the gradient line's starting point.
14520
+ // different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
14439
14521
 
14440
- /** Used for built-in method references. */
14441
- var objectProto$1 = Object.prototype;
14442
14522
 
14443
- /**
14444
- * Used to resolve the
14445
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
14446
- * of values.
14447
- */
14448
- var nativeObjectToString$1 = objectProto$1.toString;
14523
+ var SideOrCornerToDegMap = {
14524
+ left: 270 - 90,
14525
+ top: 0 - 90,
14526
+ bottom: 180 - 90,
14527
+ right: 90 - 90,
14528
+ 'left top': 315 - 90,
14529
+ 'top left': 315 - 90,
14530
+ 'left bottom': 225 - 90,
14531
+ 'bottom left': 225 - 90,
14532
+ 'right top': 45 - 90,
14533
+ 'top right': 45 - 90,
14534
+ 'right bottom': 135 - 90,
14535
+ 'bottom right': 135 - 90
14536
+ };
14537
+ var angleToDeg = memoize(function (orientation) {
14538
+ var angle;
14449
14539
 
14450
- /**
14451
- * Converts `value` to a string using `Object.prototype.toString`.
14452
- *
14453
- * @private
14454
- * @param {*} value The value to convert.
14455
- * @returns {string} Returns the converted string.
14456
- */
14457
- function objectToString(value) {
14458
- return nativeObjectToString$1.call(value);
14459
- }
14540
+ if (orientation.type === 'angular') {
14541
+ angle = Number(orientation.value);
14542
+ } else {
14543
+ angle = SideOrCornerToDegMap[orientation.value] || 0;
14544
+ }
14460
14545
 
14461
- /** `Object#toString` result references. */
14462
- var nullTag = '[object Null]',
14463
- undefinedTag = '[object Undefined]';
14546
+ return angle;
14547
+ });
14548
+ var positonToPercentage = memoize(function (position) {
14549
+ var cx = 0.5;
14550
+ var cy = 0.5;
14464
14551
 
14465
- /** Built-in value references. */
14466
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
14552
+ if ((position === null || position === void 0 ? void 0 : position.type) === 'position') {
14553
+ var _position$value = position.value,
14554
+ x = _position$value.x,
14555
+ y = _position$value.y;
14467
14556
 
14468
- /**
14469
- * The base implementation of `getTag` without fallbacks for buggy environments.
14470
- *
14471
- * @private
14472
- * @param {*} value The value to query.
14473
- * @returns {string} Returns the `toStringTag`.
14474
- */
14475
- function baseGetTag(value) {
14476
- if (value == null) {
14477
- return value === undefined ? undefinedTag : nullTag;
14478
- }
14479
- return (symToStringTag$1 && symToStringTag$1 in Object(value))
14480
- ? getRawTag(value)
14481
- : objectToString(value);
14482
- }
14557
+ if ((x === null || x === void 0 ? void 0 : x.type) === 'position-keyword') {
14558
+ if (x.value === 'left') {
14559
+ cx = 0;
14560
+ } else if (x.value === 'center') {
14561
+ cx = 0.5;
14562
+ } else if (x.value === 'right') {
14563
+ cx = 1;
14564
+ } else if (x.value === 'top') {
14565
+ cy = 0;
14566
+ } else if (x.value === 'bottom') {
14567
+ cy = 1;
14568
+ }
14569
+ }
14483
14570
 
14484
- /**
14485
- * Checks if `value` is the
14486
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
14487
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
14488
- *
14489
- * @static
14490
- * @memberOf _
14491
- * @since 0.1.0
14492
- * @category Lang
14493
- * @param {*} value The value to check.
14494
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
14495
- * @example
14496
- *
14497
- * _.isObject({});
14498
- * // => true
14499
- *
14500
- * _.isObject([1, 2, 3]);
14501
- * // => true
14502
- *
14503
- * _.isObject(_.noop);
14504
- * // => true
14505
- *
14506
- * _.isObject(null);
14507
- * // => false
14508
- */
14509
- function isObject$1(value) {
14510
- var type = typeof value;
14511
- return value != null && (type == 'object' || type == 'function');
14512
- }
14571
+ if ((y === null || y === void 0 ? void 0 : y.type) === 'position-keyword') {
14572
+ if (y.value === 'left') {
14573
+ cx = 0;
14574
+ } else if (y.value === 'center') {
14575
+ cy = 0.5;
14576
+ } else if (y.value === 'right') {
14577
+ cx = 1;
14578
+ } else if (y.value === 'top') {
14579
+ cy = 0;
14580
+ } else if (y.value === 'bottom') {
14581
+ cy = 1;
14582
+ }
14583
+ }
14513
14584
 
14514
- /** `Object#toString` result references. */
14515
- var asyncTag = '[object AsyncFunction]',
14516
- funcTag = '[object Function]',
14517
- genTag = '[object GeneratorFunction]',
14518
- proxyTag = '[object Proxy]';
14585
+ if ((x === null || x === void 0 ? void 0 : x.type) === '%') {
14586
+ cx = Number(x.value) / 100;
14587
+ }
14519
14588
 
14520
- /**
14521
- * Checks if `value` is classified as a `Function` object.
14522
- *
14523
- * @static
14524
- * @memberOf _
14525
- * @since 0.1.0
14526
- * @category Lang
14527
- * @param {*} value The value to check.
14528
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
14529
- * @example
14530
- *
14531
- * _.isFunction(_);
14532
- * // => true
14533
- *
14534
- * _.isFunction(/abc/);
14535
- * // => false
14536
- */
14537
- function isFunction$1(value) {
14538
- if (!isObject$1(value)) {
14539
- return false;
14589
+ if ((y === null || y === void 0 ? void 0 : y.type) === '%') {
14590
+ cy = Number(x.value) / 100;
14591
+ }
14540
14592
  }
14541
- // The use of `Object#toString` avoids issues with the `typeof` operator
14542
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
14543
- var tag = baseGetTag(value);
14544
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
14545
- }
14546
14593
 
14547
- /** Used to detect overreaching core-js shims. */
14548
- var coreJsData = root['__core-js_shared__'];
14594
+ return {
14595
+ cx: cx,
14596
+ cy: cy
14597
+ };
14598
+ });
14599
+ var parseGradient$1 = memoize(function (colorStr) {
14600
+ if (colorStr.indexOf('linear') > -1 || colorStr.indexOf('radial') > -1) {
14601
+ var ast = parseGradient(colorStr);
14602
+ return ast.map(function (_ref) {
14603
+ var type = _ref.type,
14604
+ orientation = _ref.orientation,
14605
+ colorStops = _ref.colorStops;
14606
+ spaceColorStops(colorStops);
14607
+ var steps = colorStops.map(function (colorStop) {
14608
+ // TODO: only support % for now, should calc percentage of axis length when using px/em
14609
+ return [Number(colorStop.length.value) / 100, colorStopToString(colorStop)];
14610
+ });
14549
14611
 
14550
- /** Used to detect methods masquerading as native. */
14551
- var maskSrcKey = (function() {
14552
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
14553
- return uid ? ('Symbol(src)_1.' + uid) : '';
14554
- }());
14612
+ if (type === 'linear-gradient') {
14613
+ return new CSSGradientValue(exports.GradientType.LinearGradient, {
14614
+ angle: orientation ? angleToDeg(orientation) : 0,
14615
+ steps: steps,
14616
+ hash: colorStr
14617
+ });
14618
+ } else if (type === 'radial-gradient') {
14619
+ if (!orientation) {
14620
+ orientation = [{
14621
+ type: 'shape',
14622
+ value: 'circle'
14623
+ }];
14624
+ }
14555
14625
 
14556
- /**
14557
- * Checks if `func` has its source masked.
14558
- *
14559
- * @private
14560
- * @param {Function} func The function to check.
14561
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
14562
- */
14563
- function isMasked(func) {
14564
- return !!maskSrcKey && (maskSrcKey in func);
14565
- }
14626
+ if (orientation[0].type === 'shape' && orientation[0].value === 'circle') {
14627
+ var _positonToPercentage = positonToPercentage(orientation[0].at),
14628
+ cx = _positonToPercentage.cx,
14629
+ cy = _positonToPercentage.cy;
14566
14630
 
14567
- /** Used for built-in method references. */
14568
- var funcProto = Function.prototype;
14631
+ return new CSSGradientValue(exports.GradientType.RadialGradient, {
14632
+ cx: cx,
14633
+ cy: cy,
14634
+ steps: steps,
14635
+ hash: colorStr
14636
+ });
14637
+ } // } else if (type === 'repeating-linear-gradient') {
14638
+ // } else if (type === 'repeating-radial-gradient') {
14569
14639
 
14570
- /** Used to resolve the decompiled source of functions. */
14571
- var funcToString = funcProto.toString;
14572
-
14573
- /**
14574
- * Converts `func` to its source code.
14575
- *
14576
- * @private
14577
- * @param {Function} func The function to convert.
14578
- * @returns {string} Returns the source code.
14579
- */
14580
- function toSource(func) {
14581
- if (func != null) {
14582
- try {
14583
- return funcToString.call(func);
14584
- } catch (e) {}
14585
- try {
14586
- return (func + '');
14587
- } catch (e) {}
14588
- }
14589
- return '';
14590
- }
14591
-
14592
- /**
14593
- * Used to match `RegExp`
14594
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
14595
- */
14596
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
14597
-
14598
- /** Used to detect host constructors (Safari). */
14599
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
14600
-
14601
- /** Used for built-in method references. */
14602
- var funcProto$1 = Function.prototype,
14603
- objectProto$2 = Object.prototype;
14604
-
14605
- /** Used to resolve the decompiled source of functions. */
14606
- var funcToString$1 = funcProto$1.toString;
14607
-
14608
- /** Used to check objects for own properties. */
14609
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
14610
-
14611
- /** Used to detect if a method is native. */
14612
- var reIsNative = RegExp('^' +
14613
- funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
14614
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
14615
- );
14616
-
14617
- /**
14618
- * The base implementation of `_.isNative` without bad shim checks.
14619
- *
14620
- * @private
14621
- * @param {*} value The value to check.
14622
- * @returns {boolean} Returns `true` if `value` is a native function,
14623
- * else `false`.
14624
- */
14625
- function baseIsNative(value) {
14626
- if (!isObject$1(value) || isMasked(value)) {
14627
- return false;
14628
- }
14629
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
14630
- return pattern.test(toSource(value));
14631
- }
14632
-
14633
- /**
14634
- * Gets the value at `key` of `object`.
14635
- *
14636
- * @private
14637
- * @param {Object} [object] The object to query.
14638
- * @param {string} key The key of the property to get.
14639
- * @returns {*} Returns the property value.
14640
- */
14641
- function getValue(object, key) {
14642
- return object == null ? undefined : object[key];
14643
- }
14644
-
14645
- /**
14646
- * Gets the native function at `key` of `object`.
14647
- *
14648
- * @private
14649
- * @param {Object} object The object to query.
14650
- * @param {string} key The key of the method to get.
14651
- * @returns {*} Returns the function if it's native, else `undefined`.
14652
- */
14653
- function getNative(object, key) {
14654
- var value = getValue(object, key);
14655
- return baseIsNative(value) ? value : undefined;
14656
- }
14657
-
14658
- /**
14659
- * Performs a
14660
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
14661
- * comparison between two values to determine if they are equivalent.
14662
- *
14663
- * @static
14664
- * @memberOf _
14665
- * @since 4.0.0
14666
- * @category Lang
14667
- * @param {*} value The value to compare.
14668
- * @param {*} other The other value to compare.
14669
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
14670
- * @example
14671
- *
14672
- * var object = { 'a': 1 };
14673
- * var other = { 'a': 1 };
14674
- *
14675
- * _.eq(object, object);
14676
- * // => true
14677
- *
14678
- * _.eq(object, other);
14679
- * // => false
14680
- *
14681
- * _.eq('a', 'a');
14682
- * // => true
14683
- *
14684
- * _.eq('a', Object('a'));
14685
- * // => false
14686
- *
14687
- * _.eq(NaN, NaN);
14688
- * // => true
14689
- */
14690
- function eq(value, other) {
14691
- return value === other || (value !== value && other !== other);
14692
- }
14693
-
14694
- /* Built-in method references that are verified to be native. */
14695
- var nativeCreate = getNative(Object, 'create');
14696
-
14697
- /**
14698
- * Removes all key-value entries from the hash.
14699
- *
14700
- * @private
14701
- * @name clear
14702
- * @memberOf Hash
14703
- */
14704
- function hashClear() {
14705
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
14706
- this.size = 0;
14707
- }
14708
-
14709
- /**
14710
- * Removes `key` and its value from the hash.
14711
- *
14712
- * @private
14713
- * @name delete
14714
- * @memberOf Hash
14715
- * @param {Object} hash The hash to modify.
14716
- * @param {string} key The key of the value to remove.
14717
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
14718
- */
14719
- function hashDelete(key) {
14720
- var result = this.has(key) && delete this.__data__[key];
14721
- this.size -= result ? 1 : 0;
14722
- return result;
14723
- }
14724
-
14725
- /** Used to stand-in for `undefined` hash values. */
14726
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
14727
-
14728
- /** Used for built-in method references. */
14729
- var objectProto$3 = Object.prototype;
14730
-
14731
- /** Used to check objects for own properties. */
14732
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
14733
-
14734
- /**
14735
- * Gets the hash value for `key`.
14736
- *
14737
- * @private
14738
- * @name get
14739
- * @memberOf Hash
14740
- * @param {string} key The key of the value to get.
14741
- * @returns {*} Returns the entry value.
14742
- */
14743
- function hashGet(key) {
14744
- var data = this.__data__;
14745
- if (nativeCreate) {
14746
- var result = data[key];
14747
- return result === HASH_UNDEFINED ? undefined : result;
14748
- }
14749
- return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
14750
- }
14751
-
14752
- /** Used for built-in method references. */
14753
- var objectProto$4 = Object.prototype;
14754
-
14755
- /** Used to check objects for own properties. */
14756
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
14757
-
14758
- /**
14759
- * Checks if a hash value for `key` exists.
14760
- *
14761
- * @private
14762
- * @name has
14763
- * @memberOf Hash
14764
- * @param {string} key The key of the entry to check.
14765
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
14766
- */
14767
- function hashHas(key) {
14768
- var data = this.__data__;
14769
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
14770
- }
14771
-
14772
- /** Used to stand-in for `undefined` hash values. */
14773
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
14774
-
14775
- /**
14776
- * Sets the hash `key` to `value`.
14777
- *
14778
- * @private
14779
- * @name set
14780
- * @memberOf Hash
14781
- * @param {string} key The key of the value to set.
14782
- * @param {*} value The value to set.
14783
- * @returns {Object} Returns the hash instance.
14784
- */
14785
- function hashSet(key, value) {
14786
- var data = this.__data__;
14787
- this.size += this.has(key) ? 0 : 1;
14788
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
14789
- return this;
14790
- }
14791
-
14792
- /**
14793
- * Creates a hash object.
14794
- *
14795
- * @private
14796
- * @constructor
14797
- * @param {Array} [entries] The key-value pairs to cache.
14798
- */
14799
- function Hash(entries) {
14800
- var index = -1,
14801
- length = entries == null ? 0 : entries.length;
14802
-
14803
- this.clear();
14804
- while (++index < length) {
14805
- var entry = entries[index];
14806
- this.set(entry[0], entry[1]);
14807
- }
14808
- }
14809
-
14810
- // Add methods to `Hash`.
14811
- Hash.prototype.clear = hashClear;
14812
- Hash.prototype['delete'] = hashDelete;
14813
- Hash.prototype.get = hashGet;
14814
- Hash.prototype.has = hashHas;
14815
- Hash.prototype.set = hashSet;
14816
-
14817
- /**
14818
- * Removes all key-value entries from the list cache.
14819
- *
14820
- * @private
14821
- * @name clear
14822
- * @memberOf ListCache
14823
- */
14824
- function listCacheClear() {
14825
- this.__data__ = [];
14826
- this.size = 0;
14827
- }
14828
-
14829
- /**
14830
- * Gets the index at which the `key` is found in `array` of key-value pairs.
14831
- *
14832
- * @private
14833
- * @param {Array} array The array to inspect.
14834
- * @param {*} key The key to search for.
14835
- * @returns {number} Returns the index of the matched value, else `-1`.
14836
- */
14837
- function assocIndexOf(array, key) {
14838
- var length = array.length;
14839
- while (length--) {
14840
- if (eq(array[length][0], key)) {
14841
- return length;
14842
- }
14843
- }
14844
- return -1;
14845
- }
14846
-
14847
- /** Used for built-in method references. */
14848
- var arrayProto = Array.prototype;
14849
-
14850
- /** Built-in value references. */
14851
- var splice = arrayProto.splice;
14852
-
14853
- /**
14854
- * Removes `key` and its value from the list cache.
14855
- *
14856
- * @private
14857
- * @name delete
14858
- * @memberOf ListCache
14859
- * @param {string} key The key of the value to remove.
14860
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
14861
- */
14862
- function listCacheDelete(key) {
14863
- var data = this.__data__,
14864
- index = assocIndexOf(data, key);
14865
-
14866
- if (index < 0) {
14867
- return false;
14868
- }
14869
- var lastIndex = data.length - 1;
14870
- if (index == lastIndex) {
14871
- data.pop();
14872
- } else {
14873
- splice.call(data, index, 1);
14874
- }
14875
- --this.size;
14876
- return true;
14877
- }
14878
-
14879
- /**
14880
- * Gets the list cache value for `key`.
14881
- *
14882
- * @private
14883
- * @name get
14884
- * @memberOf ListCache
14885
- * @param {string} key The key of the value to get.
14886
- * @returns {*} Returns the entry value.
14887
- */
14888
- function listCacheGet(key) {
14889
- var data = this.__data__,
14890
- index = assocIndexOf(data, key);
14891
-
14892
- return index < 0 ? undefined : data[index][1];
14893
- }
14894
-
14895
- /**
14896
- * Checks if a list cache value for `key` exists.
14897
- *
14898
- * @private
14899
- * @name has
14900
- * @memberOf ListCache
14901
- * @param {string} key The key of the entry to check.
14902
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
14903
- */
14904
- function listCacheHas(key) {
14905
- return assocIndexOf(this.__data__, key) > -1;
14906
- }
14907
-
14908
- /**
14909
- * Sets the list cache `key` to `value`.
14910
- *
14911
- * @private
14912
- * @name set
14913
- * @memberOf ListCache
14914
- * @param {string} key The key of the value to set.
14915
- * @param {*} value The value to set.
14916
- * @returns {Object} Returns the list cache instance.
14917
- */
14918
- function listCacheSet(key, value) {
14919
- var data = this.__data__,
14920
- index = assocIndexOf(data, key);
14921
-
14922
- if (index < 0) {
14923
- ++this.size;
14924
- data.push([key, value]);
14925
- } else {
14926
- data[index][1] = value;
14927
- }
14928
- return this;
14929
- }
14930
-
14931
- /**
14932
- * Creates an list cache object.
14933
- *
14934
- * @private
14935
- * @constructor
14936
- * @param {Array} [entries] The key-value pairs to cache.
14937
- */
14938
- function ListCache(entries) {
14939
- var index = -1,
14940
- length = entries == null ? 0 : entries.length;
14941
-
14942
- this.clear();
14943
- while (++index < length) {
14944
- var entry = entries[index];
14945
- this.set(entry[0], entry[1]);
14946
- }
14947
- }
14948
-
14949
- // Add methods to `ListCache`.
14950
- ListCache.prototype.clear = listCacheClear;
14951
- ListCache.prototype['delete'] = listCacheDelete;
14952
- ListCache.prototype.get = listCacheGet;
14953
- ListCache.prototype.has = listCacheHas;
14954
- ListCache.prototype.set = listCacheSet;
14955
-
14956
- /* Built-in method references that are verified to be native. */
14957
- var Map$1 = getNative(root, 'Map');
14958
-
14959
- /**
14960
- * Removes all key-value entries from the map.
14961
- *
14962
- * @private
14963
- * @name clear
14964
- * @memberOf MapCache
14965
- */
14966
- function mapCacheClear() {
14967
- this.size = 0;
14968
- this.__data__ = {
14969
- 'hash': new Hash,
14970
- 'map': new (Map$1 || ListCache),
14971
- 'string': new Hash
14972
- };
14973
- }
14974
-
14975
- /**
14976
- * Checks if `value` is suitable for use as unique object key.
14977
- *
14978
- * @private
14979
- * @param {*} value The value to check.
14980
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
14981
- */
14982
- function isKeyable(value) {
14983
- var type = typeof value;
14984
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
14985
- ? (value !== '__proto__')
14986
- : (value === null);
14987
- }
14988
-
14989
- /**
14990
- * Gets the data for `map`.
14991
- *
14992
- * @private
14993
- * @param {Object} map The map to query.
14994
- * @param {string} key The reference key.
14995
- * @returns {*} Returns the map data.
14996
- */
14997
- function getMapData(map, key) {
14998
- var data = map.__data__;
14999
- return isKeyable(key)
15000
- ? data[typeof key == 'string' ? 'string' : 'hash']
15001
- : data.map;
15002
- }
15003
-
15004
- /**
15005
- * Removes `key` and its value from the map.
15006
- *
15007
- * @private
15008
- * @name delete
15009
- * @memberOf MapCache
15010
- * @param {string} key The key of the value to remove.
15011
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
15012
- */
15013
- function mapCacheDelete(key) {
15014
- var result = getMapData(this, key)['delete'](key);
15015
- this.size -= result ? 1 : 0;
15016
- return result;
15017
- }
15018
-
15019
- /**
15020
- * Gets the map value for `key`.
15021
- *
15022
- * @private
15023
- * @name get
15024
- * @memberOf MapCache
15025
- * @param {string} key The key of the value to get.
15026
- * @returns {*} Returns the entry value.
15027
- */
15028
- function mapCacheGet(key) {
15029
- return getMapData(this, key).get(key);
15030
- }
15031
-
15032
- /**
15033
- * Checks if a map value for `key` exists.
15034
- *
15035
- * @private
15036
- * @name has
15037
- * @memberOf MapCache
15038
- * @param {string} key The key of the entry to check.
15039
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
15040
- */
15041
- function mapCacheHas(key) {
15042
- return getMapData(this, key).has(key);
15043
- }
15044
-
15045
- /**
15046
- * Sets the map `key` to `value`.
15047
- *
15048
- * @private
15049
- * @name set
15050
- * @memberOf MapCache
15051
- * @param {string} key The key of the value to set.
15052
- * @param {*} value The value to set.
15053
- * @returns {Object} Returns the map cache instance.
15054
- */
15055
- function mapCacheSet(key, value) {
15056
- var data = getMapData(this, key),
15057
- size = data.size;
15058
-
15059
- data.set(key, value);
15060
- this.size += data.size == size ? 0 : 1;
15061
- return this;
15062
- }
15063
-
15064
- /**
15065
- * Creates a map cache object to store key-value pairs.
15066
- *
15067
- * @private
15068
- * @constructor
15069
- * @param {Array} [entries] The key-value pairs to cache.
15070
- */
15071
- function MapCache(entries) {
15072
- var index = -1,
15073
- length = entries == null ? 0 : entries.length;
15074
-
15075
- this.clear();
15076
- while (++index < length) {
15077
- var entry = entries[index];
15078
- this.set(entry[0], entry[1]);
15079
- }
15080
- }
15081
-
15082
- // Add methods to `MapCache`.
15083
- MapCache.prototype.clear = mapCacheClear;
15084
- MapCache.prototype['delete'] = mapCacheDelete;
15085
- MapCache.prototype.get = mapCacheGet;
15086
- MapCache.prototype.has = mapCacheHas;
15087
- MapCache.prototype.set = mapCacheSet;
15088
-
15089
- /** Error message constants. */
15090
- var FUNC_ERROR_TEXT = 'Expected a function';
15091
-
15092
- /**
15093
- * Creates a function that memoizes the result of `func`. If `resolver` is
15094
- * provided, it determines the cache key for storing the result based on the
15095
- * arguments provided to the memoized function. By default, the first argument
15096
- * provided to the memoized function is used as the map cache key. The `func`
15097
- * is invoked with the `this` binding of the memoized function.
15098
- *
15099
- * **Note:** The cache is exposed as the `cache` property on the memoized
15100
- * function. Its creation may be customized by replacing the `_.memoize.Cache`
15101
- * constructor with one whose instances implement the
15102
- * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
15103
- * method interface of `clear`, `delete`, `get`, `has`, and `set`.
15104
- *
15105
- * @static
15106
- * @memberOf _
15107
- * @since 0.1.0
15108
- * @category Function
15109
- * @param {Function} func The function to have its output memoized.
15110
- * @param {Function} [resolver] The function to resolve the cache key.
15111
- * @returns {Function} Returns the new memoized function.
15112
- * @example
15113
- *
15114
- * var object = { 'a': 1, 'b': 2 };
15115
- * var other = { 'c': 3, 'd': 4 };
15116
- *
15117
- * var values = _.memoize(_.values);
15118
- * values(object);
15119
- * // => [1, 2]
15120
- *
15121
- * values(other);
15122
- * // => [3, 4]
15123
- *
15124
- * object.a = 2;
15125
- * values(object);
15126
- * // => [1, 2]
15127
- *
15128
- * // Modify the result cache.
15129
- * values.cache.set(object, ['a', 'b']);
15130
- * values(object);
15131
- * // => ['a', 'b']
15132
- *
15133
- * // Replace `_.memoize.Cache`.
15134
- * _.memoize.Cache = WeakMap;
15135
- */
15136
- function memoize(func, resolver) {
15137
- if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
15138
- throw new TypeError(FUNC_ERROR_TEXT);
15139
- }
15140
- var memoized = function() {
15141
- var args = arguments,
15142
- key = resolver ? resolver.apply(this, args) : args[0],
15143
- cache = memoized.cache;
15144
-
15145
- if (cache.has(key)) {
15146
- return cache.get(key);
15147
- }
15148
- var result = func.apply(this, args);
15149
- memoized.cache = cache.set(key, result) || cache;
15150
- return result;
15151
- };
15152
- memoized.cache = new (memoize.Cache || MapCache);
15153
- return memoized;
15154
- }
15155
-
15156
- // Expose `MapCache`.
15157
- memoize.Cache = MapCache;
15158
-
15159
- var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
15160
- var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
15161
- var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
15162
- var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
15163
-
15164
- function spaceColorStops(colorStops) {
15165
- var _colorStops$length;
15166
-
15167
- var length = colorStops.length;
15168
- colorStops[length - 1].length = (_colorStops$length = colorStops[length - 1].length) !== null && _colorStops$length !== void 0 ? _colorStops$length : {
15169
- type: '%',
15170
- value: '100'
15171
- };
15172
-
15173
- if (length > 1) {
15174
- var _colorStops$0$length;
15175
-
15176
- colorStops[0].length = (_colorStops$0$length = colorStops[0].length) !== null && _colorStops$0$length !== void 0 ? _colorStops$0$length : {
15177
- type: '%',
15178
- value: '0'
15179
- };
15180
- }
15181
-
15182
- var previousIndex = 0;
15183
- var previousOffset = Number(colorStops[0].length.value);
15184
-
15185
- for (var i = 1; i < length; i++) {
15186
- var _colorStops$i$length;
15187
-
15188
- var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
15189
-
15190
- if (!isNil(offset) && !isNil(previousOffset)) {
15191
- for (var j = 1; j < i - previousIndex; j++) {
15192
- colorStops[previousIndex + j].length = {
15193
- type: '%',
15194
- value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
15195
- };
15196
- }
15197
-
15198
- previousIndex = i;
15199
- previousOffset = Number(offset);
15200
- }
15201
- }
15202
- } // The position of the gradient line's starting point.
15203
- // different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
15204
-
15205
-
15206
- var SideOrCornerToDegMap = {
15207
- left: 270 - 90,
15208
- top: 0 - 90,
15209
- bottom: 180 - 90,
15210
- right: 90 - 90,
15211
- 'left top': 315 - 90,
15212
- 'top left': 315 - 90,
15213
- 'left bottom': 225 - 90,
15214
- 'bottom left': 225 - 90,
15215
- 'right top': 45 - 90,
15216
- 'top right': 45 - 90,
15217
- 'right bottom': 135 - 90,
15218
- 'bottom right': 135 - 90
15219
- };
15220
- var angleToDeg = memoize(function (orientation) {
15221
- var angle;
15222
-
15223
- if (orientation.type === 'angular') {
15224
- angle = Number(orientation.value);
15225
- } else {
15226
- angle = SideOrCornerToDegMap[orientation.value] || 0;
15227
- }
15228
-
15229
- return angle;
15230
- });
15231
- var positonToPercentage = memoize(function (position) {
15232
- var cx = 0.5;
15233
- var cy = 0.5;
15234
-
15235
- if ((position === null || position === void 0 ? void 0 : position.type) === 'position') {
15236
- var _position$value = position.value,
15237
- x = _position$value.x,
15238
- y = _position$value.y;
15239
-
15240
- if ((x === null || x === void 0 ? void 0 : x.type) === 'position-keyword') {
15241
- if (x.value === 'left') {
15242
- cx = 0;
15243
- } else if (x.value === 'center') {
15244
- cx = 0.5;
15245
- } else if (x.value === 'right') {
15246
- cx = 1;
15247
- } else if (x.value === 'top') {
15248
- cy = 0;
15249
- } else if (x.value === 'bottom') {
15250
- cy = 1;
15251
- }
15252
- }
15253
-
15254
- if ((y === null || y === void 0 ? void 0 : y.type) === 'position-keyword') {
15255
- if (y.value === 'left') {
15256
- cx = 0;
15257
- } else if (y.value === 'center') {
15258
- cy = 0.5;
15259
- } else if (y.value === 'right') {
15260
- cx = 1;
15261
- } else if (y.value === 'top') {
15262
- cy = 0;
15263
- } else if (y.value === 'bottom') {
15264
- cy = 1;
15265
- }
15266
- }
15267
-
15268
- if ((x === null || x === void 0 ? void 0 : x.type) === '%') {
15269
- cx = Number(x.value) / 100;
15270
- }
15271
-
15272
- if ((y === null || y === void 0 ? void 0 : y.type) === '%') {
15273
- cy = Number(x.value) / 100;
15274
- }
15275
- }
15276
-
15277
- return {
15278
- cx: cx,
15279
- cy: cy
15280
- };
15281
- });
15282
- var parseGradient$1 = memoize(function (colorStr) {
15283
- if (colorStr.indexOf('linear') > -1 || colorStr.indexOf('radial') > -1) {
15284
- var ast = parseGradient(colorStr);
15285
- return ast.map(function (_ref) {
15286
- var type = _ref.type,
15287
- orientation = _ref.orientation,
15288
- colorStops = _ref.colorStops;
15289
- spaceColorStops(colorStops);
15290
- var steps = colorStops.map(function (colorStop) {
15291
- // TODO: only support % for now, should calc percentage of axis length when using px/em
15292
- return [Number(colorStop.length.value) / 100, colorStopToString(colorStop)];
15293
- });
15294
-
15295
- if (type === 'linear-gradient') {
15296
- return new CSSGradientValue(exports.GradientType.LinearGradient, {
15297
- angle: orientation ? angleToDeg(orientation) : 0,
15298
- steps: steps,
15299
- hash: colorStr
15300
- });
15301
- } else if (type === 'radial-gradient') {
15302
- if (!orientation) {
15303
- orientation = [{
15304
- type: 'shape',
15305
- value: 'circle'
15306
- }];
15307
- }
15308
-
15309
- if (orientation[0].type === 'shape' && orientation[0].value === 'circle') {
15310
- var _positonToPercentage = positonToPercentage(orientation[0].at),
15311
- cx = _positonToPercentage.cx,
15312
- cy = _positonToPercentage.cy;
15313
-
15314
- return new CSSGradientValue(exports.GradientType.RadialGradient, {
15315
- cx: cx,
15316
- cy: cy,
15317
- steps: steps,
15318
- hash: colorStr
15319
- });
15320
- } // } else if (type === 'repeating-linear-gradient') {
15321
- // } else if (type === 'repeating-radial-gradient') {
15322
-
15323
- }
15324
- });
15325
- } // legacy format, should be deprecated later
14640
+ }
14641
+ });
14642
+ } // legacy format, should be deprecated later
15326
14643
 
15327
14644
 
15328
14645
  var type = colorStr[0];
@@ -16287,10 +15604,40 @@
16287
15604
  }
16288
15605
 
16289
15606
  function clonePath(path) {
16290
- return path.map((x) => (Array.isArray(x) ? [...x] : x));
15607
+ return path.map(function (x) { return (Array.isArray(x) ? __spreadArray([], x, true) : x); });
15608
+ }
15609
+
15610
+ /**
15611
+ * Rounds the values of a `PathArray` instance to
15612
+ * a specified amount of decimals and returns it.
15613
+ */
15614
+ function roundPath(path, round) {
15615
+ if (round === 'off')
15616
+ return clonePath(path);
15617
+ // to round values to the power
15618
+ // the `round` value must be integer
15619
+ var pow = typeof round === 'number' && round >= 1 ? Math.pow(10, round) : 1;
15620
+ return path.map(function (pi) {
15621
+ var values = pi
15622
+ .slice(1)
15623
+ .map(Number)
15624
+ .map(function (n) { return (round ? Math.round(n * pow) / pow : Math.round(n)); });
15625
+ return __spreadArray([pi[0]], values, true);
15626
+ });
15627
+ }
15628
+
15629
+ /**
15630
+ * Returns a valid `d` attribute string value created
15631
+ * by rounding values and concatenating the `pathArray` segments.
15632
+ */
15633
+ function path2String(path, round) {
15634
+ if (round === void 0) { round = 'off'; }
15635
+ return roundPath(path, round)
15636
+ .map(function (x) { return x[0] + x.slice(1).join(' '); })
15637
+ .join('');
16291
15638
  }
16292
15639
 
16293
- const paramsParser = {
15640
+ var paramsParser = {
16294
15641
  x1: 0,
16295
15642
  y1: 0,
16296
15643
  x2: 0,
@@ -16304,9 +15651,9 @@
16304
15651
  function fixArc(pathArray, allPathCommands, i) {
16305
15652
  if (pathArray[i].length > 7) {
16306
15653
  pathArray[i].shift();
16307
- const pi = pathArray[i];
15654
+ var pi = pathArray[i];
16308
15655
  // const ni = i + 1;
16309
- let ni = i;
15656
+ var ni = i;
16310
15657
  while (pi.length) {
16311
15658
  // if created multiple C:s, their original seg is saved
16312
15659
  allPathCommands[i] = 'A';
@@ -16317,7 +15664,7 @@
16317
15664
  }
16318
15665
  }
16319
15666
 
16320
- const paramsCount = {
15667
+ var paramsCount = {
16321
15668
  a: 7,
16322
15669
  c: 6,
16323
15670
  h: 1,
@@ -16336,8 +15683,8 @@
16336
15683
  */
16337
15684
  function isPathArray(path) {
16338
15685
  return (Array.isArray(path) &&
16339
- path.every((seg) => {
16340
- const lk = seg[0].toLowerCase();
15686
+ path.every(function (seg) {
15687
+ var lk = seg[0].toLowerCase();
16341
15688
  return paramsCount[lk] === seg.length - 1 && 'achlmqstvz'.includes(lk);
16342
15689
  }));
16343
15690
  }
@@ -16349,7 +15696,10 @@
16349
15696
  function isAbsoluteArray(path) {
16350
15697
  return (isPathArray(path) &&
16351
15698
  // @ts-ignore -- `isPathArray` also checks if it's `Array`
16352
- path.every(([x]) => x === x.toUpperCase()));
15699
+ path.every(function (_a) {
15700
+ var x = _a[0];
15701
+ return x === x.toUpperCase();
15702
+ }));
16353
15703
  }
16354
15704
 
16355
15705
  /**
@@ -16358,28 +15708,31 @@
16358
15708
  * with absolute values.
16359
15709
  */
16360
15710
  function isNormalizedArray(path) {
16361
- return isAbsoluteArray(path) && path.every(([pc]) => 'ACLMQZ'.includes(pc));
15711
+ return isAbsoluteArray(path) && path.every(function (_a) {
15712
+ var pc = _a[0];
15713
+ return 'ACLMQZ'.includes(pc);
15714
+ });
16362
15715
  }
16363
15716
 
16364
15717
  /**
16365
15718
  * Breaks the parsing of a pathString once a segment is finalized.
16366
15719
  */
16367
15720
  function finalizeSegment(path) {
16368
- let pathCommand = path.pathValue[path.segmentStart];
16369
- let LK = pathCommand.toLowerCase();
16370
- const { data } = path;
15721
+ var pathCommand = path.pathValue[path.segmentStart];
15722
+ var LK = pathCommand.toLowerCase();
15723
+ var data = path.data;
16371
15724
  while (data.length >= paramsCount[LK]) {
16372
15725
  // overloaded `moveTo`
16373
15726
  // https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts
16374
15727
  if (LK === 'm' && data.length > 2) {
16375
15728
  // @ts-ignore
16376
- path.segments.push([pathCommand, ...data.splice(0, 2)]);
15729
+ path.segments.push(__spreadArray([pathCommand], data.splice(0, 2), true));
16377
15730
  LK = 'l';
16378
15731
  pathCommand = pathCommand === 'm' ? 'l' : 'L';
16379
15732
  }
16380
15733
  else {
16381
15734
  // @ts-ignore
16382
- path.segments.push([pathCommand, ...data.splice(0, paramsCount[LK])]);
15735
+ path.segments.push(__spreadArray([pathCommand], data.splice(0, paramsCount[LK]), true));
16383
15736
  }
16384
15737
  if (!paramsCount[LK]) {
16385
15738
  break;
@@ -16392,8 +15745,8 @@
16392
15745
  * Usually a `large-arc-flag` or `sweep-flag`.
16393
15746
  */
16394
15747
  function scanFlag(path) {
16395
- const { index, pathValue } = path;
16396
- const code = pathValue.charCodeAt(index);
15748
+ var index = path.index, pathValue = path.pathValue;
15749
+ var code = pathValue.charCodeAt(index);
16397
15750
  if (code === 0x30 /* 0 */) {
16398
15751
  path.param = 0;
16399
15752
  path.index += 1;
@@ -16404,7 +15757,7 @@
16404
15757
  path.index += 1;
16405
15758
  return;
16406
15759
  }
16407
- path.err = `[path-util]: invalid Arc flag "${pathValue[index]}", expecting 0 or 1 at index ${index}`;
15760
+ path.err = "[path-util]: invalid Arc flag \"" + pathValue[index] + "\", expecting 0 or 1 at index " + index;
16408
15761
  }
16409
15762
 
16410
15763
  /**
@@ -16423,16 +15776,16 @@
16423
15776
  * every path command, negative numbers or floating point numbers.
16424
15777
  */
16425
15778
  function scanParam(path) {
16426
- const { max, pathValue, index: start } = path;
16427
- let index = start;
16428
- let zeroFirst = false;
16429
- let hasCeiling = false;
16430
- let hasDecimal = false;
16431
- let hasDot = false;
16432
- let ch;
15779
+ var max = path.max, pathValue = path.pathValue, start = path.index;
15780
+ var index = start;
15781
+ var zeroFirst = false;
15782
+ var hasCeiling = false;
15783
+ var hasDecimal = false;
15784
+ var hasDot = false;
15785
+ var ch;
16433
15786
  if (index >= max) {
16434
15787
  // path.err = 'SvgPath: missed param (at pos ' + index + ')';
16435
- path.err = `[path-util]: Invalid path value at index ${index}, "pathValue" is missing param`;
15788
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"pathValue\" is missing param";
16436
15789
  return;
16437
15790
  }
16438
15791
  ch = pathValue.charCodeAt(index);
@@ -16445,7 +15798,7 @@
16445
15798
  // https://github.com/ariya/esprimas
16446
15799
  if (!isDigit(ch) && ch !== 0x2e /* . */) {
16447
15800
  // path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
16448
- path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" is not a number`;
15801
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" is not a number";
16449
15802
  return;
16450
15803
  }
16451
15804
  if (ch !== 0x2e /* . */) {
@@ -16457,7 +15810,7 @@
16457
15810
  if (ch && isDigit(ch)) {
16458
15811
  // path.err = 'SvgPath: numbers started with `0` such as `09`
16459
15812
  // are illegal (at pos ' + start + ')';
16460
- path.err = `[path-util]: Invalid path value at index ${start}, "${pathValue[start]}" illegal number`;
15813
+ path.err = "[path-util]: Invalid path value at index " + start + ", \"" + pathValue[start] + "\" illegal number";
16461
15814
  return;
16462
15815
  }
16463
15816
  }
@@ -16478,7 +15831,7 @@
16478
15831
  }
16479
15832
  if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {
16480
15833
  if (hasDot && !hasCeiling && !hasDecimal) {
16481
- path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" invalid float exponent`;
15834
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" invalid float exponent";
16482
15835
  return;
16483
15836
  }
16484
15837
  index += 1;
@@ -16492,7 +15845,7 @@
16492
15845
  }
16493
15846
  }
16494
15847
  else {
16495
- path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" invalid integer exponent`;
15848
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" invalid integer exponent";
16496
15849
  return;
16497
15850
  }
16498
15851
  }
@@ -16504,7 +15857,7 @@
16504
15857
  * Checks if the character is a space.
16505
15858
  */
16506
15859
  function isSpace(ch) {
16507
- const specialSpaces = [
15860
+ var specialSpaces = [
16508
15861
  0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f,
16509
15862
  0x205f, 0x3000, 0xfeff,
16510
15863
  ];
@@ -16528,7 +15881,7 @@
16528
15881
  * space character.
16529
15882
  */
16530
15883
  function skipSpaces(path) {
16531
- const { pathValue, max } = path;
15884
+ var pathValue = path.pathValue, max = path.max;
16532
15885
  while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {
16533
15886
  path.index += 1;
16534
15887
  }
@@ -16569,12 +15922,12 @@
16569
15922
  * where a segment starts and where it ends.
16570
15923
  */
16571
15924
  function scanSegment(path) {
16572
- const { max, pathValue, index } = path;
16573
- const cmdCode = pathValue.charCodeAt(index);
16574
- const reqParams = paramsCount[pathValue[index].toLowerCase()];
15925
+ var max = path.max, pathValue = path.pathValue, index = path.index;
15926
+ var cmdCode = pathValue.charCodeAt(index);
15927
+ var reqParams = paramsCount[pathValue[index].toLowerCase()];
16575
15928
  path.segmentStart = index;
16576
15929
  if (!isPathCommand(cmdCode)) {
16577
- path.err = `[path-util]: Invalid path value "${pathValue[index]}" is not a path command`;
15930
+ path.err = "[path-util]: Invalid path value \"" + pathValue[index] + "\" is not a path command";
16578
15931
  return;
16579
15932
  }
16580
15933
  path.index += 1;
@@ -16586,7 +15939,7 @@
16586
15939
  return;
16587
15940
  }
16588
15941
  for (;;) {
16589
- for (let i = reqParams; i > 0; i -= 1) {
15942
+ for (var i = reqParams; i > 0; i -= 1) {
16590
15943
  if (isArcCommand(cmdCode) && (i === 3 || i === 4))
16591
15944
  scanFlag(path);
16592
15945
  else
@@ -16617,8 +15970,8 @@
16617
15970
  * The `PathParser` is used by the `parsePathString` static method
16618
15971
  * to generate a `pathArray`.
16619
15972
  */
16620
- class PathParser {
16621
- constructor(pathString) {
15973
+ var PathParser = /** @class */ (function () {
15974
+ function PathParser(pathString) {
16622
15975
  this.pathValue = pathString;
16623
15976
  // @ts-ignore
16624
15977
  this.segments = [];
@@ -16629,7 +15982,8 @@
16629
15982
  this.data = [];
16630
15983
  this.err = '';
16631
15984
  }
16632
- }
15985
+ return PathParser;
15986
+ }());
16633
15987
 
16634
15988
  /**
16635
15989
  * Parses a path string value and returns an array
@@ -16639,7 +15993,7 @@
16639
15993
  if (isPathArray(pathInput)) {
16640
15994
  return clonePath(pathInput);
16641
15995
  }
16642
- const path = new PathParser(pathInput);
15996
+ var path = new PathParser(pathInput);
16643
15997
  skipSpaces(path);
16644
15998
  while (path.index < path.max && !path.err.length) {
16645
15999
  scanSegment(path);
@@ -16651,26 +16005,26 @@
16651
16005
  if (isAbsoluteArray(pathInput)) {
16652
16006
  return clonePath(pathInput);
16653
16007
  }
16654
- const path = parsePathString(pathInput);
16008
+ var path = parsePathString(pathInput);
16655
16009
  // if (!path || !path.length) {
16656
16010
  // return [['M', 0, 0]];
16657
16011
  // }
16658
- let x = 0;
16659
- let y = 0;
16660
- let mx = 0;
16661
- let my = 0;
16012
+ var x = 0;
16013
+ var y = 0;
16014
+ var mx = 0;
16015
+ var my = 0;
16662
16016
  // @ts-ignore
16663
- return path.map((segment) => {
16664
- const values = segment.slice(1).map(Number);
16665
- const [pathCommand] = segment;
16666
- const absCommand = pathCommand.toUpperCase();
16017
+ return path.map(function (segment) {
16018
+ var values = segment.slice(1).map(Number);
16019
+ var pathCommand = segment[0];
16020
+ var absCommand = pathCommand.toUpperCase();
16667
16021
  if (pathCommand === 'M') {
16668
- [x, y] = values;
16022
+ x = values[0], y = values[1];
16669
16023
  mx = x;
16670
16024
  my = y;
16671
16025
  return ['M', x, y];
16672
16026
  }
16673
- let absoluteSegment;
16027
+ var absoluteSegment;
16674
16028
  if (pathCommand !== absCommand) {
16675
16029
  switch (absCommand) {
16676
16030
  case 'A':
@@ -16694,26 +16048,26 @@
16694
16048
  default: {
16695
16049
  // use brakets for `eslint: no-case-declaration`
16696
16050
  // https://stackoverflow.com/a/50753272/803358
16697
- const absValues = values.map((n, j) => n + (j % 2 ? y : x));
16051
+ var absValues = values.map(function (n, j) { return n + (j % 2 ? y : x); });
16698
16052
  // for n, l, c, s, q, t
16699
- absoluteSegment = [absCommand, ...absValues];
16053
+ absoluteSegment = __spreadArray([absCommand], absValues, true);
16700
16054
  }
16701
16055
  }
16702
16056
  }
16703
16057
  else {
16704
- absoluteSegment = [absCommand, ...values];
16058
+ absoluteSegment = __spreadArray([absCommand], values, true);
16705
16059
  }
16706
- const segLength = absoluteSegment.length;
16060
+ var segLength = absoluteSegment.length;
16707
16061
  switch (absCommand) {
16708
16062
  case 'Z':
16709
16063
  x = mx;
16710
16064
  y = my;
16711
16065
  break;
16712
16066
  case 'H':
16713
- [, x] = absoluteSegment;
16067
+ x = absoluteSegment[1];
16714
16068
  break;
16715
16069
  case 'V':
16716
- [, y] = absoluteSegment;
16070
+ y = absoluteSegment[1];
16717
16071
  break;
16718
16072
  default:
16719
16073
  x = absoluteSegment[segLength - 2];
@@ -16732,10 +16086,10 @@
16732
16086
  * eg. H/V -> L, T -> Q
16733
16087
  */
16734
16088
  function normalizeSegment(segment, params) {
16735
- const [pathCommand] = segment;
16736
- const { x1: px1, y1: py1, x2: px2, y2: py2 } = params;
16737
- const values = segment.slice(1).map(Number);
16738
- let result = segment;
16089
+ var pathCommand = segment[0];
16090
+ var px1 = params.x1, py1 = params.y1, px2 = params.x2, py2 = params.y2;
16091
+ var values = segment.slice(1).map(Number);
16092
+ var result = segment;
16739
16093
  if (!'TQ'.includes(pathCommand)) {
16740
16094
  // optional but good to be cautious
16741
16095
  params.qx = null;
@@ -16748,21 +16102,21 @@
16748
16102
  result = ['L', px1, segment[1]];
16749
16103
  }
16750
16104
  else if (pathCommand === 'S') {
16751
- const x1 = px1 * 2 - px2;
16752
- const y1 = py1 * 2 - py2;
16105
+ var x1 = px1 * 2 - px2;
16106
+ var y1 = py1 * 2 - py2;
16753
16107
  params.x1 = x1;
16754
16108
  params.y1 = y1;
16755
- result = ['C', x1, y1, ...values];
16109
+ result = __spreadArray(['C', x1, y1], values, true);
16756
16110
  }
16757
16111
  else if (pathCommand === 'T') {
16758
- const qx = px1 * 2 - params.qx;
16759
- const qy = py1 * 2 - params.qy;
16112
+ var qx = px1 * 2 - params.qx;
16113
+ var qy = py1 * 2 - params.qy;
16760
16114
  params.qx = qx;
16761
16115
  params.qy = qy;
16762
- result = ['Q', qx, qy, ...values];
16116
+ result = __spreadArray(['Q', qx, qy], values, true);
16763
16117
  }
16764
16118
  else if (pathCommand === 'Q') {
16765
- const [nqx, nqy] = values;
16119
+ var nqx = values[0], nqy = values[1];
16766
16120
  params.qx = nqx;
16767
16121
  params.qy = nqy;
16768
16122
  }
@@ -16779,18 +16133,18 @@
16779
16133
  if (isNormalizedArray(pathInput)) {
16780
16134
  return clonePath(pathInput);
16781
16135
  }
16782
- const path = path2Absolute(pathInput);
16783
- const params = Object.assign({}, paramsParser);
16784
- const allPathCommands = [];
16785
- const ii = path.length;
16786
- let pathCommand = '';
16787
- for (let i = 0; i < ii; i += 1) {
16788
- [pathCommand] = path[i];
16136
+ var path = path2Absolute(pathInput);
16137
+ var params = __assign({}, paramsParser);
16138
+ var allPathCommands = [];
16139
+ var ii = path.length;
16140
+ var pathCommand = '';
16141
+ for (var i = 0; i < ii; i += 1) {
16142
+ pathCommand = path[i][0];
16789
16143
  // Save current path command
16790
16144
  allPathCommands[i] = pathCommand;
16791
16145
  path[i] = normalizeSegment(path[i], params);
16792
- const segment = path[i];
16793
- const seglen = segment.length;
16146
+ var segment = path[i];
16147
+ var seglen = segment.length;
16794
16148
  params.x1 = +segment[seglen - 2];
16795
16149
  params.y1 = +segment[seglen - 1];
16796
16150
  params.x2 = +segment[seglen - 4] || params.x1;
@@ -16807,12 +16161,15 @@
16807
16161
  * @returns {boolean} iteration result
16808
16162
  */
16809
16163
  function isCurveArray(path) {
16810
- return isNormalizedArray(path) && path.every(([pc]) => 'MC'.includes(pc));
16164
+ return isNormalizedArray(path) && path.every(function (_a) {
16165
+ var pc = _a[0];
16166
+ return 'MC'.includes(pc);
16167
+ });
16811
16168
  }
16812
16169
 
16813
16170
  function rotateVector(x, y, rad) {
16814
- const X = x * Math.cos(rad) - y * Math.sin(rad);
16815
- const Y = x * Math.sin(rad) + y * Math.cos(rad);
16171
+ var X = x * Math.cos(rad) - y * Math.sin(rad);
16172
+ var Y = x * Math.sin(rad) + y * Math.cos(rad);
16816
16173
  return { x: X, y: Y };
16817
16174
  }
16818
16175
 
@@ -16823,23 +16180,23 @@
16823
16180
  * http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
16824
16181
  */
16825
16182
  function arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, recursive) {
16826
- let x1 = X1;
16827
- let y1 = Y1;
16828
- let rx = RX;
16829
- let ry = RY;
16830
- let x2 = X2;
16831
- let y2 = Y2;
16183
+ var x1 = X1;
16184
+ var y1 = Y1;
16185
+ var rx = RX;
16186
+ var ry = RY;
16187
+ var x2 = X2;
16188
+ var y2 = Y2;
16832
16189
  // for more information of where this Math came from visit:
16833
16190
  // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
16834
- const d120 = (Math.PI * 120) / 180;
16835
- const rad = (Math.PI / 180) * (+angle || 0);
16191
+ var d120 = (Math.PI * 120) / 180;
16192
+ var rad = (Math.PI / 180) * (+angle || 0);
16836
16193
  /** @type {number[]} */
16837
- let res = [];
16838
- let xy;
16839
- let f1;
16840
- let f2;
16841
- let cx;
16842
- let cy;
16194
+ var res = [];
16195
+ var xy;
16196
+ var f1;
16197
+ var f2;
16198
+ var cx;
16199
+ var cy;
16843
16200
  if (!recursive) {
16844
16201
  xy = rotateVector(x1, y1, -rad);
16845
16202
  x1 = xy.x;
@@ -16847,17 +16204,17 @@
16847
16204
  xy = rotateVector(x2, y2, -rad);
16848
16205
  x2 = xy.x;
16849
16206
  y2 = xy.y;
16850
- const x = (x1 - x2) / 2;
16851
- const y = (y1 - y2) / 2;
16852
- let h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
16207
+ var x = (x1 - x2) / 2;
16208
+ var y = (y1 - y2) / 2;
16209
+ var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
16853
16210
  if (h > 1) {
16854
16211
  h = Math.sqrt(h);
16855
16212
  rx *= h;
16856
16213
  ry *= h;
16857
16214
  }
16858
- const rx2 = rx * rx;
16859
- const ry2 = ry * ry;
16860
- const k = (LAF === SF ? -1 : 1) *
16215
+ var rx2 = rx * rx;
16216
+ var ry2 = ry * ry;
16217
+ var k = (LAF === SF ? -1 : 1) *
16861
16218
  Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
16862
16219
  cx = (k * rx * y) / ry + (x1 + x2) / 2;
16863
16220
  cy = (k * -ry * x) / rx + (y1 + y2) / 2;
@@ -16879,38 +16236,38 @@
16879
16236
  }
16880
16237
  }
16881
16238
  else {
16882
- [f1, f2, cx, cy] = recursive;
16239
+ f1 = recursive[0], f2 = recursive[1], cx = recursive[2], cy = recursive[3];
16883
16240
  }
16884
- let df = f2 - f1;
16241
+ var df = f2 - f1;
16885
16242
  if (Math.abs(df) > d120) {
16886
- const f2old = f2;
16887
- const x2old = x2;
16888
- const y2old = y2;
16243
+ var f2old = f2;
16244
+ var x2old = x2;
16245
+ var y2old = y2;
16889
16246
  f2 = f1 + d120 * (SF && f2 > f1 ? 1 : -1);
16890
16247
  x2 = cx + rx * Math.cos(f2);
16891
16248
  y2 = cy + ry * Math.sin(f2);
16892
16249
  res = arcToCubic(x2, y2, rx, ry, angle, 0, SF, x2old, y2old, [f2, f2old, cx, cy]);
16893
16250
  }
16894
16251
  df = f2 - f1;
16895
- const c1 = Math.cos(f1);
16896
- const s1 = Math.sin(f1);
16897
- const c2 = Math.cos(f2);
16898
- const s2 = Math.sin(f2);
16899
- const t = Math.tan(df / 4);
16900
- const hx = (4 / 3) * rx * t;
16901
- const hy = (4 / 3) * ry * t;
16902
- const m1 = [x1, y1];
16903
- const m2 = [x1 + hx * s1, y1 - hy * c1];
16904
- const m3 = [x2 + hx * s2, y2 - hy * c2];
16905
- const m4 = [x2, y2];
16252
+ var c1 = Math.cos(f1);
16253
+ var s1 = Math.sin(f1);
16254
+ var c2 = Math.cos(f2);
16255
+ var s2 = Math.sin(f2);
16256
+ var t = Math.tan(df / 4);
16257
+ var hx = (4 / 3) * rx * t;
16258
+ var hy = (4 / 3) * ry * t;
16259
+ var m1 = [x1, y1];
16260
+ var m2 = [x1 + hx * s1, y1 - hy * c1];
16261
+ var m3 = [x2 + hx * s2, y2 - hy * c2];
16262
+ var m4 = [x2, y2];
16906
16263
  m2[0] = 2 * m1[0] - m2[0];
16907
16264
  m2[1] = 2 * m1[1] - m2[1];
16908
16265
  if (recursive) {
16909
- return [...m2, ...m3, ...m4, ...res];
16266
+ return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], m2, true), m3, true), m4, true), res, true);
16910
16267
  }
16911
- res = [...m2, ...m3, ...m4, ...res];
16912
- const newres = [];
16913
- for (let i = 0, ii = res.length; i < ii; i += 1) {
16268
+ res = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], m2, true), m3, true), m4, true), res, true);
16269
+ var newres = [];
16270
+ for (var i = 0, ii = res.length; i < ii; i += 1) {
16914
16271
  newres[i] = i % 2 ? rotateVector(res[i - 1], res[i], rad).y : rotateVector(res[i], res[i + 1], rad).x;
16915
16272
  }
16916
16273
  return newres;
@@ -17099,8 +16456,8 @@
17099
16456
  // }
17100
16457
 
17101
16458
  function quadToCubic(x1, y1, qx, qy, x2, y2) {
17102
- const r13 = 1 / 3;
17103
- const r23 = 2 / 3;
16459
+ var r13 = 1 / 3;
16460
+ var r23 = 2 / 3;
17104
16461
  return [
17105
16462
  r13 * x1 + r23 * qx,
17106
16463
  r13 * y1 + r23 * qy,
@@ -17112,10 +16469,10 @@
17112
16469
  }
17113
16470
 
17114
16471
  function midPoint(a, b, t) {
17115
- const ax = a[0];
17116
- const ay = a[1];
17117
- const bx = b[0];
17118
- const by = b[1];
16472
+ var ax = a[0];
16473
+ var ay = a[1];
16474
+ var bx = b[0];
16475
+ var by = b[1];
17119
16476
  return [ax + (bx - ax) * t, ay + (by - ay) * t];
17120
16477
  }
17121
16478
 
@@ -17128,8 +16485,8 @@
17128
16485
  * the minimum and maximum {x,y} coordinates of a line (L,V,H,Z) segment.
17129
16486
  */
17130
16487
  function segmentLineFactory(x1, y1, x2, y2, distance) {
17131
- const length = distanceSquareRoot([x1, y1], [x2, y2]);
17132
- let point = { x: 0, y: 0 };
16488
+ var length = distanceSquareRoot([x1, y1], [x2, y2]);
16489
+ var point = { x: 0, y: 0 };
17133
16490
  if (typeof distance === 'number') {
17134
16491
  if (distance <= 0) {
17135
16492
  point = { x: x1, y: y1 };
@@ -17138,13 +16495,13 @@
17138
16495
  point = { x: x2, y: y2 };
17139
16496
  }
17140
16497
  else {
17141
- const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);
17142
- point = { x, y };
16498
+ var _a = midPoint([x1, y1], [x2, y2], distance / length), x = _a[0], y = _a[1];
16499
+ point = { x: x, y: y };
17143
16500
  }
17144
16501
  }
17145
16502
  return {
17146
- length,
17147
- point,
16503
+ length: length,
16504
+ point: point,
17148
16505
  min: {
17149
16506
  x: Math.min(x1, x2),
17150
16507
  y: Math.min(y1, y2),
@@ -17157,29 +16514,29 @@
17157
16514
  }
17158
16515
 
17159
16516
  function lineToCubic(x1, y1, x2, y2) {
17160
- const t = 0.5;
17161
- const p0 = [x1, y1];
17162
- const p1 = [x2, y2];
17163
- const p2 = midPoint(p0, p1, t);
17164
- const p3 = midPoint(p1, p2, t);
17165
- const p4 = midPoint(p2, p3, t);
17166
- const p5 = midPoint(p3, p4, t);
17167
- const p6 = midPoint(p4, p5, t);
17168
- const seg1 = [...p0, ...p2, ...p4, ...p6, t];
16517
+ var t = 0.5;
16518
+ var p0 = [x1, y1];
16519
+ var p1 = [x2, y2];
16520
+ var p2 = midPoint(p0, p1, t);
16521
+ var p3 = midPoint(p1, p2, t);
16522
+ var p4 = midPoint(p2, p3, t);
16523
+ var p5 = midPoint(p3, p4, t);
16524
+ var p6 = midPoint(p4, p5, t);
16525
+ var seg1 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], p0, true), p2, true), p4, true), p6, true), [t], false);
17169
16526
  // @ts-ignore
17170
- const cp1 = segmentLineFactory(...seg1).point;
17171
- const seg2 = [...p6, ...p5, ...p3, ...p1, 0];
16527
+ var cp1 = segmentLineFactory.apply(void 0, seg1).point;
16528
+ var seg2 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], p6, true), p5, true), p3, true), p1, true), [0], false);
17172
16529
  // @ts-ignore
17173
- const cp2 = segmentLineFactory(...seg2).point;
16530
+ var cp2 = segmentLineFactory.apply(void 0, seg2).point;
17174
16531
  return [cp1.x, cp1.y, cp2.x, cp2.y, x2, y2];
17175
16532
  }
17176
16533
 
17177
16534
  function segmentToCubic(segment, params) {
17178
- const [pathCommand] = segment;
17179
- const values = segment.slice(1).map(Number);
17180
- const [x, y] = values;
17181
- let args;
17182
- const { x1: px1, y1: py1, x: px, y: py } = params;
16535
+ var pathCommand = segment[0];
16536
+ var values = segment.slice(1).map(Number);
16537
+ var x = values[0], y = values[1];
16538
+ var args;
16539
+ var px1 = params.x1, py1 = params.y1, px = params.x, py = params.y;
17183
16540
  if (!'TQ'.includes(pathCommand)) {
17184
16541
  params.qx = null;
17185
16542
  params.qy = null;
@@ -17190,31 +16547,32 @@
17190
16547
  params.y = y;
17191
16548
  return segment;
17192
16549
  case 'A':
17193
- args = [px1, py1, ...values];
16550
+ args = __spreadArray([px1, py1], values, true);
17194
16551
  // @ts-ignore
17195
- return ['C', ...arcToCubic(...args)];
16552
+ return __spreadArray(['C'], arcToCubic.apply(void 0, args), true);
17196
16553
  case 'Q':
17197
16554
  params.qx = x;
17198
16555
  params.qy = y;
17199
- args = [px1, py1, ...values];
16556
+ args = __spreadArray([px1, py1], values, true);
17200
16557
  // @ts-ignore
17201
- return ['C', ...quadToCubic(...args)];
16558
+ return __spreadArray(['C'], quadToCubic.apply(void 0, args), true);
17202
16559
  case 'L':
17203
- return ['C', ...lineToCubic(px1, py1, x, y)];
16560
+ return __spreadArray(['C'], lineToCubic(px1, py1, x, y), true);
17204
16561
  case 'Z':
17205
16562
  // prevent NaN from divide 0
17206
16563
  if (px1 === px && py1 === py) {
17207
16564
  return ['C', px1, py1, px, py, px, py];
17208
16565
  }
17209
- return ['C', ...lineToCubic(px1, py1, px, py)];
16566
+ return __spreadArray(['C'], lineToCubic(px1, py1, px, py), true);
17210
16567
  }
17211
16568
  return segment;
17212
16569
  }
17213
16570
 
17214
16571
  // import { fixPath } from '../process/fix-path';
17215
- function path2Curve(pathInput, needZCommandIndexes = false) {
16572
+ function path2Curve(pathInput, needZCommandIndexes) {
16573
+ if (needZCommandIndexes === void 0) { needZCommandIndexes = false; }
17216
16574
  if (isCurveArray(pathInput)) {
17217
- const cloned = clonePath(pathInput);
16575
+ var cloned = clonePath(pathInput);
17218
16576
  if (needZCommandIndexes) {
17219
16577
  return [cloned, []];
17220
16578
  }
@@ -17224,19 +16582,19 @@
17224
16582
  }
17225
16583
  // fixPath will remove 'Z' command
17226
16584
  // const path = fixPath(normalizePath(pathInput));
17227
- const path = normalizePath(pathInput);
17228
- const params = Object.assign({}, paramsParser);
17229
- const allPathCommands = [];
17230
- let pathCommand = '';
17231
- let ii = path.length;
17232
- let segment;
17233
- let seglen;
17234
- const zCommandIndexes = [];
17235
- for (let i = 0; i < ii; i += 1) {
16585
+ var path = normalizePath(pathInput);
16586
+ var params = __assign({}, paramsParser);
16587
+ var allPathCommands = [];
16588
+ var pathCommand = '';
16589
+ var ii = path.length;
16590
+ var segment;
16591
+ var seglen;
16592
+ var zCommandIndexes = [];
16593
+ for (var i = 0; i < ii; i += 1) {
17236
16594
  if (path[i])
17237
- [pathCommand] = path[i];
16595
+ pathCommand = path[i][0];
17238
16596
  allPathCommands[i] = pathCommand;
17239
- const curveSegment = segmentToCubic(path[i], params);
16597
+ var curveSegment = segmentToCubic(path[i], params);
17240
16598
  path[i] = curveSegment;
17241
16599
  fixArc(path, allPathCommands, i);
17242
16600
  ii = path.length; // solves curveArrays ending in Z
@@ -17263,24 +16621,25 @@
17263
16621
 
17264
16622
  // reverse CURVE based pathArray segments only
17265
16623
  function reverseCurve(pathArray) {
17266
- const rotatedCurve = pathArray
16624
+ var rotatedCurve = pathArray
17267
16625
  .slice(1)
17268
- .map((x, i, curveOnly) =>
17269
- // @ts-ignore
17270
- !i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1)))
16626
+ .map(function (x, i, curveOnly) {
17271
16627
  // @ts-ignore
17272
- .map((x) => x.map((y, i) => x[x.length - i - 2 * (1 - (i % 2))]))
16628
+ return !i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1));
16629
+ })
16630
+ // @ts-ignore
16631
+ .map(function (x) { return x.map(function (y, i) { return x[x.length - i - 2 * (1 - (i % 2))]; }); })
17273
16632
  .reverse();
17274
- return [['M'].concat(rotatedCurve[0].slice(0, 2))].concat(rotatedCurve.map((x) => ['C'].concat(x.slice(2))));
16633
+ return [['M'].concat(rotatedCurve[0].slice(0, 2))].concat(rotatedCurve.map(function (x) { return ['C'].concat(x.slice(2)); }));
17275
16634
  }
17276
16635
 
17277
16636
  function angleBetween(v0, v1) {
17278
- const { x: v0x, y: v0y } = v0;
17279
- const { x: v1x, y: v1y } = v1;
17280
- const p = v0x * v1x + v0y * v1y;
17281
- const n = Math.sqrt((Math.pow(v0x, 2) + Math.pow(v0y, 2)) * (Math.pow(v1x, 2) + Math.pow(v1y, 2)));
17282
- const sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;
17283
- const angle = sign * Math.acos(p / n);
16637
+ var v0x = v0.x, v0y = v0.y;
16638
+ var v1x = v1.x, v1y = v1.y;
16639
+ var p = v0x * v1x + v0y * v1y;
16640
+ var n = Math.sqrt((Math.pow(v0x, 2) + Math.pow(v0y, 2)) * (Math.pow(v1x, 2) + Math.pow(v1y, 2)));
16641
+ var sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;
16642
+ var angle = sign * Math.acos(p / n);
17284
16643
  return angle;
17285
16644
  }
17286
16645
  /**
@@ -17289,51 +16648,51 @@
17289
16648
  * @see https://github.com/MadLittleMods/svg-curve-lib/blob/master/src/js/svg-curve-lib.js
17290
16649
  */
17291
16650
  function getPointAtArcSegmentLength(x1, y1, RX, RY, angle, LAF, SF, x, y, t) {
17292
- const { abs, sin, cos, sqrt, PI } = Math;
17293
- let rx = abs(RX);
17294
- let ry = abs(RY);
17295
- const xRot = ((angle % 360) + 360) % 360;
17296
- const xRotRad = xRot * (PI / 180);
16651
+ var abs = Math.abs, sin = Math.sin, cos = Math.cos, sqrt = Math.sqrt, PI = Math.PI;
16652
+ var rx = abs(RX);
16653
+ var ry = abs(RY);
16654
+ var xRot = ((angle % 360) + 360) % 360;
16655
+ var xRotRad = xRot * (PI / 180);
17297
16656
  if (x1 === x && y1 === y) {
17298
16657
  return { x: x1, y: y1 };
17299
16658
  }
17300
16659
  if (rx === 0 || ry === 0) {
17301
16660
  return segmentLineFactory(x1, y1, x, y, t).point;
17302
16661
  }
17303
- const dx = (x1 - x) / 2;
17304
- const dy = (y1 - y) / 2;
17305
- const transformedPoint = {
16662
+ var dx = (x1 - x) / 2;
16663
+ var dy = (y1 - y) / 2;
16664
+ var transformedPoint = {
17306
16665
  x: cos(xRotRad) * dx + sin(xRotRad) * dy,
17307
16666
  y: -sin(xRotRad) * dx + cos(xRotRad) * dy,
17308
16667
  };
17309
- const radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
16668
+ var radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
17310
16669
  if (radiiCheck > 1) {
17311
16670
  rx *= sqrt(radiiCheck);
17312
16671
  ry *= sqrt(radiiCheck);
17313
16672
  }
17314
- const cSquareNumerator = Math.pow(rx, 2) * Math.pow(ry, 2) - Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) - Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
17315
- const cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
17316
- let cRadicand = cSquareNumerator / cSquareRootDenom;
16673
+ var cSquareNumerator = Math.pow(rx, 2) * Math.pow(ry, 2) - Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) - Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
16674
+ var cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
16675
+ var cRadicand = cSquareNumerator / cSquareRootDenom;
17317
16676
  cRadicand = cRadicand < 0 ? 0 : cRadicand;
17318
- const cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);
17319
- const transformedCenter = {
16677
+ var cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);
16678
+ var transformedCenter = {
17320
16679
  x: cCoef * ((rx * transformedPoint.y) / ry),
17321
16680
  y: cCoef * (-(ry * transformedPoint.x) / rx),
17322
16681
  };
17323
- const center = {
16682
+ var center = {
17324
16683
  x: cos(xRotRad) * transformedCenter.x - sin(xRotRad) * transformedCenter.y + (x1 + x) / 2,
17325
16684
  y: sin(xRotRad) * transformedCenter.x + cos(xRotRad) * transformedCenter.y + (y1 + y) / 2,
17326
16685
  };
17327
- const startVector = {
16686
+ var startVector = {
17328
16687
  x: (transformedPoint.x - transformedCenter.x) / rx,
17329
16688
  y: (transformedPoint.y - transformedCenter.y) / ry,
17330
16689
  };
17331
- const startAngle = angleBetween({ x: 1, y: 0 }, startVector);
17332
- const endVector = {
16690
+ var startAngle = angleBetween({ x: 1, y: 0 }, startVector);
16691
+ var endVector = {
17333
16692
  x: (-transformedPoint.x - transformedCenter.x) / rx,
17334
16693
  y: (-transformedPoint.y - transformedCenter.y) / ry,
17335
16694
  };
17336
- let sweepAngle = angleBetween(startVector, endVector);
16695
+ var sweepAngle = angleBetween(startVector, endVector);
17337
16696
  if (!SF && sweepAngle > 0) {
17338
16697
  sweepAngle -= 2 * PI;
17339
16698
  }
@@ -17341,10 +16700,10 @@
17341
16700
  sweepAngle += 2 * PI;
17342
16701
  }
17343
16702
  sweepAngle %= 2 * PI;
17344
- const alpha = startAngle + sweepAngle * t;
17345
- const ellipseComponentX = rx * cos(alpha);
17346
- const ellipseComponentY = ry * sin(alpha);
17347
- const point = {
16703
+ var alpha = startAngle + sweepAngle * t;
16704
+ var ellipseComponentX = rx * cos(alpha);
16705
+ var ellipseComponentY = ry * sin(alpha);
16706
+ var point = {
17348
16707
  x: cos(xRotRad) * ellipseComponentX - sin(xRotRad) * ellipseComponentY + center.x,
17349
16708
  y: sin(xRotRad) * ellipseComponentX + cos(xRotRad) * ellipseComponentY + center.y,
17350
16709
  };
@@ -17362,27 +16721,28 @@
17362
16721
  * the shape minimum and maximum {x,y} coordinates of an A (arc-to) segment.
17363
16722
  */
17364
16723
  function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
17365
- const distanceIsNumber = typeof distance === 'number';
17366
- let x = X1;
17367
- let y = Y1;
17368
- let LENGTH = 0;
17369
- let prev = [x, y, LENGTH];
17370
- let cur = [x, y];
17371
- let t = 0;
17372
- let POINT = { x: 0, y: 0 };
17373
- let POINTS = [{ x, y }];
16724
+ var _a;
16725
+ var distanceIsNumber = typeof distance === 'number';
16726
+ var x = X1;
16727
+ var y = Y1;
16728
+ var LENGTH = 0;
16729
+ var prev = [x, y, LENGTH];
16730
+ var cur = [x, y];
16731
+ var t = 0;
16732
+ var POINT = { x: 0, y: 0 };
16733
+ var POINTS = [{ x: x, y: y }];
17374
16734
  if (distanceIsNumber && distance <= 0) {
17375
- POINT = { x, y };
16735
+ POINT = { x: x, y: y };
17376
16736
  }
17377
- const sampleSize = 300;
17378
- for (let j = 0; j <= sampleSize; j += 1) {
16737
+ var sampleSize = 300;
16738
+ for (var j = 0; j <= sampleSize; j += 1) {
17379
16739
  t = j / sampleSize;
17380
- ({ x, y } = getPointAtArcSegmentLength(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, t));
17381
- POINTS = [...POINTS, { x, y }];
16740
+ (_a = getPointAtArcSegmentLength(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, t), x = _a.x, y = _a.y);
16741
+ POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
17382
16742
  LENGTH += distanceSquareRoot(cur, [x, y]);
17383
16743
  cur = [x, y];
17384
16744
  if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
17385
- const dv = (LENGTH - distance) / (LENGTH - prev[2]);
16745
+ var dv = (LENGTH - distance) / (LENGTH - prev[2]);
17386
16746
  POINT = {
17387
16747
  x: cur[0] * (1 - dv) + prev[0] * dv,
17388
16748
  y: cur[1] * (1 - dv) + prev[1] * dv,
@@ -17397,12 +16757,12 @@
17397
16757
  length: LENGTH,
17398
16758
  point: POINT,
17399
16759
  min: {
17400
- x: Math.min(...POINTS.map((n) => n.x)),
17401
- y: Math.min(...POINTS.map((n) => n.y)),
16760
+ x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
16761
+ y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
17402
16762
  },
17403
16763
  max: {
17404
- x: Math.max(...POINTS.map((n) => n.x)),
17405
- y: Math.max(...POINTS.map((n) => n.y)),
16764
+ x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
16765
+ y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
17406
16766
  },
17407
16767
  };
17408
16768
  }
@@ -17412,7 +16772,7 @@
17412
16772
  * the minimum and maximum {x,y} coordinates of a C (cubic-bezier) segment.
17413
16773
  */
17414
16774
  function getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t) {
17415
- const t1 = 1 - t;
16775
+ var t1 = 1 - t;
17416
16776
  return {
17417
16777
  x: Math.pow(t1, 3) * x1 + 3 * Math.pow(t1, 2) * t * c1x + 3 * t1 * Math.pow(t, 2) * c2x + Math.pow(t, 3) * x2,
17418
16778
  y: Math.pow(t1, 3) * y1 + 3 * Math.pow(t1, 2) * t * c1y + 3 * t1 * Math.pow(t, 2) * c2y + Math.pow(t, 3) * y2,
@@ -17423,28 +16783,29 @@
17423
16783
  * or an {x,y} point at a given length.
17424
16784
  */
17425
16785
  function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
17426
- const distanceIsNumber = typeof distance === 'number';
17427
- let x = x1;
17428
- let y = y1;
17429
- let LENGTH = 0;
17430
- let prev = [x, y, LENGTH];
17431
- let cur = [x, y];
17432
- let t = 0;
17433
- let POINT = { x: 0, y: 0 };
17434
- let POINTS = [{ x, y }];
16786
+ var _a;
16787
+ var distanceIsNumber = typeof distance === 'number';
16788
+ var x = x1;
16789
+ var y = y1;
16790
+ var LENGTH = 0;
16791
+ var prev = [x, y, LENGTH];
16792
+ var cur = [x, y];
16793
+ var t = 0;
16794
+ var POINT = { x: 0, y: 0 };
16795
+ var POINTS = [{ x: x, y: y }];
17435
16796
  if (distanceIsNumber && distance <= 0) {
17436
- POINT = { x, y };
16797
+ POINT = { x: x, y: y };
17437
16798
  }
17438
16799
  // bad perf when size = 300
17439
- const sampleSize = 20;
17440
- for (let j = 0; j <= sampleSize; j += 1) {
16800
+ var sampleSize = 20;
16801
+ for (var j = 0; j <= sampleSize; j += 1) {
17441
16802
  t = j / sampleSize;
17442
- ({ x, y } = getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t));
17443
- POINTS = [...POINTS, { x, y }];
16803
+ (_a = getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t), x = _a.x, y = _a.y);
16804
+ POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
17444
16805
  LENGTH += distanceSquareRoot(cur, [x, y]);
17445
16806
  cur = [x, y];
17446
16807
  if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
17447
- const dv = (LENGTH - distance) / (LENGTH - prev[2]);
16808
+ var dv = (LENGTH - distance) / (LENGTH - prev[2]);
17448
16809
  POINT = {
17449
16810
  x: cur[0] * (1 - dv) + prev[0] * dv,
17450
16811
  y: cur[1] * (1 - dv) + prev[1] * dv,
@@ -17459,12 +16820,12 @@
17459
16820
  length: LENGTH,
17460
16821
  point: POINT,
17461
16822
  min: {
17462
- x: Math.min(...POINTS.map((n) => n.x)),
17463
- y: Math.min(...POINTS.map((n) => n.y)),
16823
+ x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
16824
+ y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
17464
16825
  },
17465
16826
  max: {
17466
- x: Math.max(...POINTS.map((n) => n.x)),
17467
- y: Math.max(...POINTS.map((n) => n.y)),
16827
+ x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
16828
+ y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
17468
16829
  },
17469
16830
  };
17470
16831
  }
@@ -17476,7 +16837,7 @@
17476
16837
  * @see https://github.com/substack/point-at-length
17477
16838
  */
17478
16839
  function getPointAtQuadSegmentLength(x1, y1, cx, cy, x2, y2, t) {
17479
- const t1 = 1 - t;
16840
+ var t1 = 1 - t;
17480
16841
  return {
17481
16842
  x: Math.pow(t1, 2) * x1 + 2 * t1 * t * cx + Math.pow(t, 2) * x2,
17482
16843
  y: Math.pow(t1, 2) * y1 + 2 * t1 * t * cy + Math.pow(t, 2) * y2,
@@ -17487,27 +16848,28 @@
17487
16848
  * the minimum and maximum {x,y} coordinates of a Q (quadratic-bezier) segment.
17488
16849
  */
17489
16850
  function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
17490
- const distanceIsNumber = typeof distance === 'number';
17491
- let x = x1;
17492
- let y = y1;
17493
- let LENGTH = 0;
17494
- let prev = [x, y, LENGTH];
17495
- let cur = [x, y];
17496
- let t = 0;
17497
- let POINT = { x: 0, y: 0 };
17498
- let POINTS = [{ x, y }];
16851
+ var _a;
16852
+ var distanceIsNumber = typeof distance === 'number';
16853
+ var x = x1;
16854
+ var y = y1;
16855
+ var LENGTH = 0;
16856
+ var prev = [x, y, LENGTH];
16857
+ var cur = [x, y];
16858
+ var t = 0;
16859
+ var POINT = { x: 0, y: 0 };
16860
+ var POINTS = [{ x: x, y: y }];
17499
16861
  if (distanceIsNumber && distance <= 0) {
17500
- POINT = { x, y };
16862
+ POINT = { x: x, y: y };
17501
16863
  }
17502
- const sampleSize = 300;
17503
- for (let j = 0; j <= sampleSize; j += 1) {
16864
+ var sampleSize = 300;
16865
+ for (var j = 0; j <= sampleSize; j += 1) {
17504
16866
  t = j / sampleSize;
17505
- ({ x, y } = getPointAtQuadSegmentLength(x1, y1, qx, qy, x2, y2, t));
17506
- POINTS = [...POINTS, { x, y }];
16867
+ (_a = getPointAtQuadSegmentLength(x1, y1, qx, qy, x2, y2, t), x = _a.x, y = _a.y);
16868
+ POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
17507
16869
  LENGTH += distanceSquareRoot(cur, [x, y]);
17508
16870
  cur = [x, y];
17509
16871
  if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
17510
- const dv = (LENGTH - distance) / (LENGTH - prev[2]);
16872
+ var dv = (LENGTH - distance) / (LENGTH - prev[2]);
17511
16873
  POINT = {
17512
16874
  x: cur[0] * (1 - dv) + prev[0] * dv,
17513
16875
  y: cur[1] * (1 - dv) + prev[1] * dv,
@@ -17523,12 +16885,12 @@
17523
16885
  length: LENGTH,
17524
16886
  point: POINT,
17525
16887
  min: {
17526
- x: Math.min(...POINTS.map((n) => n.x)),
17527
- y: Math.min(...POINTS.map((n) => n.y)),
16888
+ x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
16889
+ y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
17528
16890
  },
17529
16891
  max: {
17530
- x: Math.max(...POINTS.map((n) => n.x)),
17531
- y: Math.max(...POINTS.map((n) => n.y)),
16892
+ x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
16893
+ y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
17532
16894
  },
17533
16895
  };
17534
16896
  }
@@ -17539,34 +16901,35 @@
17539
16901
  * the shape minimum and maximum {x,y} coordinates.
17540
16902
  */
17541
16903
  function pathLengthFactory(pathInput, distance) {
17542
- const path = normalizePath(pathInput);
17543
- const distanceIsNumber = typeof distance === 'number';
17544
- let isM;
17545
- let data = [];
17546
- let pathCommand;
17547
- let x = 0;
17548
- let y = 0;
17549
- let mx = 0;
17550
- let my = 0;
17551
- let seg;
17552
- let MIN = [];
17553
- let MAX = [];
17554
- let length = 0;
17555
- let min = { x: 0, y: 0 };
17556
- let max = min;
17557
- let point = min;
17558
- let POINT = min;
17559
- let LENGTH = 0;
17560
- for (let i = 0, ll = path.length; i < ll; i += 1) {
16904
+ var _a, _b, _c, _d, _e, _f;
16905
+ var path = normalizePath(pathInput);
16906
+ var distanceIsNumber = typeof distance === 'number';
16907
+ var isM;
16908
+ var data = [];
16909
+ var pathCommand;
16910
+ var x = 0;
16911
+ var y = 0;
16912
+ var mx = 0;
16913
+ var my = 0;
16914
+ var seg;
16915
+ var MIN = [];
16916
+ var MAX = [];
16917
+ var length = 0;
16918
+ var min = { x: 0, y: 0 };
16919
+ var max = min;
16920
+ var point = min;
16921
+ var POINT = min;
16922
+ var LENGTH = 0;
16923
+ for (var i = 0, ll = path.length; i < ll; i += 1) {
17561
16924
  seg = path[i];
17562
- [pathCommand] = seg;
16925
+ pathCommand = seg[0];
17563
16926
  isM = pathCommand === 'M';
17564
- data = !isM ? [x, y, ...seg.slice(1)] : data;
16927
+ data = !isM ? __spreadArray([x, y], seg.slice(1), true) : data;
17565
16928
  // this segment is always ZERO
17566
16929
  /* istanbul ignore else */
17567
16930
  if (isM) {
17568
16931
  // remember mx, my for Z
17569
- [, mx, my] = seg;
16932
+ mx = seg[1], my = seg[2];
17570
16933
  min = { x: mx, y: my };
17571
16934
  max = min;
17572
16935
  length = 0;
@@ -17576,48 +16939,48 @@
17576
16939
  }
17577
16940
  else if (pathCommand === 'L') {
17578
16941
  // @ts-ignore
17579
- ({ length, min, max, point } = segmentLineFactory(...data, (distance || 0) - LENGTH));
16942
+ (_a = segmentLineFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _a.length, min = _a.min, max = _a.max, point = _a.point);
17580
16943
  }
17581
16944
  else if (pathCommand === 'A') {
17582
16945
  // @ts-ignore
17583
- ({ length, min, max, point } = segmentArcFactory(...data, (distance || 0) - LENGTH));
16946
+ (_b = segmentArcFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _b.length, min = _b.min, max = _b.max, point = _b.point);
17584
16947
  }
17585
16948
  else if (pathCommand === 'C') {
17586
16949
  // @ts-ignore
17587
- ({ length, min, max, point } = segmentCubicFactory(...data, (distance || 0) - LENGTH));
16950
+ (_c = segmentCubicFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _c.length, min = _c.min, max = _c.max, point = _c.point);
17588
16951
  }
17589
16952
  else if (pathCommand === 'Q') {
17590
16953
  // @ts-ignore
17591
- ({ length, min, max, point } = segmentQuadFactory(...data, (distance || 0) - LENGTH));
16954
+ (_d = segmentQuadFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _d.length, min = _d.min, max = _d.max, point = _d.point);
17592
16955
  }
17593
16956
  else if (pathCommand === 'Z') {
17594
16957
  data = [x, y, mx, my];
17595
16958
  // @ts-ignore
17596
- ({ length, min, max, point } = segmentLineFactory(...data, (distance || 0) - LENGTH));
16959
+ (_e = segmentLineFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _e.length, min = _e.min, max = _e.max, point = _e.point);
17597
16960
  }
17598
16961
  if (distanceIsNumber && LENGTH < distance && LENGTH + length >= distance) {
17599
16962
  POINT = point;
17600
16963
  }
17601
- MAX = [...MAX, max];
17602
- MIN = [...MIN, min];
16964
+ MAX = __spreadArray(__spreadArray([], MAX, true), [max], false);
16965
+ MIN = __spreadArray(__spreadArray([], MIN, true), [min], false);
17603
16966
  LENGTH += length;
17604
- [x, y] = pathCommand !== 'Z' ? seg.slice(-2) : [mx, my];
16967
+ _f = pathCommand !== 'Z' ? seg.slice(-2) : [mx, my], x = _f[0], y = _f[1];
17605
16968
  }
17606
16969
  // native `getPointAtLength` behavior when the given distance
17607
16970
  // is higher than total length
17608
16971
  if (distanceIsNumber && distance >= LENGTH) {
17609
- POINT = { x, y };
16972
+ POINT = { x: x, y: y };
17610
16973
  }
17611
16974
  return {
17612
16975
  length: LENGTH,
17613
16976
  point: POINT,
17614
16977
  min: {
17615
- x: Math.min(...MIN.map((n) => n.x)),
17616
- y: Math.min(...MIN.map((n) => n.y)),
16978
+ x: Math.min.apply(Math, MIN.map(function (n) { return n.x; })),
16979
+ y: Math.min.apply(Math, MIN.map(function (n) { return n.y; })),
17617
16980
  },
17618
16981
  max: {
17619
- x: Math.max(...MAX.map((n) => n.x)),
17620
- y: Math.max(...MAX.map((n) => n.y)),
16982
+ x: Math.max.apply(Math, MAX.map(function (n) { return n.x; })),
16983
+ y: Math.max.apply(Math, MAX.map(function (n) { return n.y; })),
17621
16984
  },
17622
16985
  };
17623
16986
  }
@@ -17640,13 +17003,13 @@
17640
17003
  cz: 0,
17641
17004
  };
17642
17005
  }
17643
- const { length, min: { x: xMin, y: yMin }, max: { x: xMax, y: yMax }, } = pathLengthFactory(path);
17644
- const width = xMax - xMin;
17645
- const height = yMax - yMin;
17006
+ var _a = pathLengthFactory(path), length = _a.length, _b = _a.min, xMin = _b.x, yMin = _b.y, _c = _a.max, xMax = _c.x, yMax = _c.y;
17007
+ var width = xMax - xMin;
17008
+ var height = yMax - yMin;
17646
17009
  return {
17647
- length,
17648
- width,
17649
- height,
17010
+ length: length,
17011
+ width: width,
17012
+ height: height,
17650
17013
  x: xMin,
17651
17014
  y: yMin,
17652
17015
  x2: xMax,
@@ -17659,28 +17022,30 @@
17659
17022
  }
17660
17023
 
17661
17024
  function getRotations(a) {
17662
- const segCount = a.length;
17663
- const pointCount = segCount - 1;
17664
- return a.map((f, idx) => a.map((p, i) => {
17665
- let oldSegIdx = idx + i;
17666
- let seg;
17667
- if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === 'M')) {
17668
- seg = a[oldSegIdx];
17669
- return ['M'].concat(seg.slice(-2));
17670
- }
17671
- if (oldSegIdx >= segCount)
17672
- oldSegIdx -= pointCount;
17673
- return a[oldSegIdx];
17674
- }));
17025
+ var segCount = a.length;
17026
+ var pointCount = segCount - 1;
17027
+ return a.map(function (f, idx) {
17028
+ return a.map(function (p, i) {
17029
+ var oldSegIdx = idx + i;
17030
+ var seg;
17031
+ if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === 'M')) {
17032
+ seg = a[oldSegIdx];
17033
+ return ['M'].concat(seg.slice(-2));
17034
+ }
17035
+ if (oldSegIdx >= segCount)
17036
+ oldSegIdx -= pointCount;
17037
+ return a[oldSegIdx];
17038
+ });
17039
+ });
17675
17040
  }
17676
17041
  function getRotatedCurve(a, b) {
17677
- const segCount = a.length - 1;
17678
- const lineLengths = [];
17679
- let computedIndex = 0;
17680
- let sumLensSqrd = 0;
17681
- const rotations = getRotations(a);
17682
- rotations.forEach((r, i) => {
17683
- a.slice(1).forEach((s, j) => {
17042
+ var segCount = a.length - 1;
17043
+ var lineLengths = [];
17044
+ var computedIndex = 0;
17045
+ var sumLensSqrd = 0;
17046
+ var rotations = getRotations(a);
17047
+ rotations.forEach(function (r, i) {
17048
+ a.slice(1).forEach(function (s, j) {
17684
17049
  // @ts-ignore
17685
17050
  sumLensSqrd += distanceSquareRoot(a[(i + j) % segCount].slice(-2), b[j % segCount].slice(-2));
17686
17051
  });
@@ -17714,23 +17079,24 @@
17714
17079
  * @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
17715
17080
  */
17716
17081
  function getPathArea(path) {
17717
- let x = 0;
17718
- let y = 0;
17719
- let len = 0;
17082
+ var x = 0;
17083
+ var y = 0;
17084
+ var len = 0;
17720
17085
  return path2Curve(path)
17721
- .map((seg) => {
17086
+ .map(function (seg) {
17087
+ var _a;
17722
17088
  switch (seg[0]) {
17723
17089
  case 'M':
17724
- [, x, y] = seg;
17090
+ x = seg[1], y = seg[2];
17725
17091
  return 0;
17726
17092
  default:
17727
17093
  // @ts-ignore
17728
- len = getCubicSegArea(x, y, ...seg.slice(1));
17729
- [x, y] = seg.slice(-2);
17094
+ len = getCubicSegArea.apply(void 0, __spreadArray([x, y], seg.slice(1), false));
17095
+ _a = seg.slice(-2), x = _a[0], y = _a[1];
17730
17096
  return len;
17731
17097
  }
17732
17098
  })
17733
- .reduce((a, b) => a + b, 0);
17099
+ .reduce(function (a, b) { return a + b; }, 0);
17734
17100
  }
17735
17101
  // export function getPathArea(pathArray: AbsoluteArray) {
17736
17102
  // let x = 0;
@@ -17769,17 +17135,18 @@
17769
17135
  return pathLengthFactory(pathInput, distance).point;
17770
17136
  }
17771
17137
 
17772
- function splitCubic(pts, t = 0.5) {
17773
- const p0 = pts.slice(0, 2);
17774
- const p1 = pts.slice(2, 4);
17775
- const p2 = pts.slice(4, 6);
17776
- const p3 = pts.slice(6, 8);
17777
- const p4 = midPoint(p0, p1, t);
17778
- const p5 = midPoint(p1, p2, t);
17779
- const p6 = midPoint(p2, p3, t);
17780
- const p7 = midPoint(p4, p5, t);
17781
- const p8 = midPoint(p5, p6, t);
17782
- const p9 = midPoint(p7, p8, t);
17138
+ function splitCubic(pts, t) {
17139
+ if (t === void 0) { t = 0.5; }
17140
+ var p0 = pts.slice(0, 2);
17141
+ var p1 = pts.slice(2, 4);
17142
+ var p2 = pts.slice(4, 6);
17143
+ var p3 = pts.slice(6, 8);
17144
+ var p4 = midPoint(p0, p1, t);
17145
+ var p5 = midPoint(p1, p2, t);
17146
+ var p6 = midPoint(p2, p3, t);
17147
+ var p7 = midPoint(p4, p5, t);
17148
+ var p8 = midPoint(p5, p6, t);
17149
+ var p9 = midPoint(p7, p8, t);
17783
17150
  return [
17784
17151
  // @ts-ignore
17785
17152
  ['C'].concat(p4, p7, p9),
@@ -17788,12 +17155,12 @@
17788
17155
  ];
17789
17156
  }
17790
17157
  function getCurveArray(segments) {
17791
- return segments.map((segment, i, pathArray) => {
17158
+ return segments.map(function (segment, i, pathArray) {
17792
17159
  // @ts-ignore
17793
- const segmentData = i && pathArray[i - 1].slice(-2).concat(segment.slice(1));
17160
+ var segmentData = i && pathArray[i - 1].slice(-2).concat(segment.slice(1));
17794
17161
  // @ts-ignore
17795
- const curveLength = i ? segmentCubicFactory(...segmentData).length : 0;
17796
- let subsegs;
17162
+ var curveLength = i ? segmentCubicFactory.apply(void 0, segmentData).length : 0;
17163
+ var subsegs;
17797
17164
  if (i) {
17798
17165
  // must be [segment,segment]
17799
17166
  subsegs = curveLength ? splitCubic(segmentData) : [segment, segment];
@@ -17809,33 +17176,40 @@
17809
17176
  });
17810
17177
  }
17811
17178
  function equalizeSegments(path1, path2, TL) {
17812
- const c1 = getCurveArray(path1);
17813
- const c2 = getCurveArray(path2);
17814
- const L1 = c1.length;
17815
- const L2 = c2.length;
17816
- const l1 = c1.filter((x) => x.l).length;
17817
- const l2 = c2.filter((x) => x.l).length;
17818
- const m1 = c1.filter((x) => x.l).reduce((a, { l }) => a + l, 0) / l1 || 0;
17819
- const m2 = c2.filter((x) => x.l).reduce((a, { l }) => a + l, 0) / l2 || 0;
17820
- const tl = TL || Math.max(L1, L2);
17821
- const mm = [m1, m2];
17822
- const dif = [tl - L1, tl - L2];
17823
- let canSplit = 0;
17824
- const result = [c1, c2].map((x, i) =>
17825
- // @ts-ignore
17826
- x.l === tl
17827
- ? x.map((y) => y.s)
17828
- : x
17829
- .map((y, j) => {
17830
- canSplit = j && dif[i] && y.l >= mm[i];
17831
- dif[i] -= canSplit ? 1 : 0;
17832
- return canSplit ? y.ss : [y.s];
17833
- })
17834
- .flat());
17179
+ var c1 = getCurveArray(path1);
17180
+ var c2 = getCurveArray(path2);
17181
+ var L1 = c1.length;
17182
+ var L2 = c2.length;
17183
+ var l1 = c1.filter(function (x) { return x.l; }).length;
17184
+ var l2 = c2.filter(function (x) { return x.l; }).length;
17185
+ var m1 = c1.filter(function (x) { return x.l; }).reduce(function (a, _a) {
17186
+ var l = _a.l;
17187
+ return a + l;
17188
+ }, 0) / l1 || 0;
17189
+ var m2 = c2.filter(function (x) { return x.l; }).reduce(function (a, _a) {
17190
+ var l = _a.l;
17191
+ return a + l;
17192
+ }, 0) / l2 || 0;
17193
+ var tl = TL || Math.max(L1, L2);
17194
+ var mm = [m1, m2];
17195
+ var dif = [tl - L1, tl - L2];
17196
+ var canSplit = 0;
17197
+ var result = [c1, c2].map(function (x, i) {
17198
+ // @ts-ignore
17199
+ return x.l === tl
17200
+ ? x.map(function (y) { return y.s; })
17201
+ : x
17202
+ .map(function (y, j) {
17203
+ canSplit = j && dif[i] && y.l >= mm[i];
17204
+ dif[i] -= canSplit ? 1 : 0;
17205
+ return canSplit ? y.ss : [y.s];
17206
+ })
17207
+ .flat();
17208
+ });
17835
17209
  return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
17836
17210
  }
17837
17211
 
17838
- var parsePath = memoize(function (path, object) {
17212
+ var memoizedParsePath = memoize(function (path) {
17839
17213
  var absolutePath;
17840
17214
 
17841
17215
  try {
@@ -17867,11 +17241,6 @@
17867
17241
  height = _getPathBBoxTotalLeng.height,
17868
17242
  length = _getPathBBoxTotalLeng.length;
17869
17243
 
17870
- if (object) {
17871
- object.parsedStyle.defX = x;
17872
- object.parsedStyle.defY = y;
17873
- }
17874
-
17875
17244
  return {
17876
17245
  absolutePath: absolutePath,
17877
17246
  hasArc: hasArc,
@@ -17883,7 +17252,19 @@
17883
17252
  zCommandIndexes: zCommandIndexes,
17884
17253
  rect: new Rectangle(x, y, width, height)
17885
17254
  };
17255
+ }, function (path) {
17256
+ return isString(path) ? path : path2String(path);
17886
17257
  });
17258
+ function parsePath(path, object) {
17259
+ var result = memoizedParsePath(path);
17260
+
17261
+ if (object) {
17262
+ object.parsedStyle.defX = result.rect.x;
17263
+ object.parsedStyle.defY = result.rect.y;
17264
+ }
17265
+
17266
+ return result;
17267
+ }
17887
17268
  function mergePaths(left, right, object) {
17888
17269
  var curve1 = left.curve;
17889
17270
  var curve2 = right.curve;
@@ -18233,104 +17614,561 @@
18233
17614
  }
18234
17615
  };
18235
17616
 
18236
- /**
18237
- * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
18238
- *
18239
- * @example
18240
- * points="100,10 250,150 200,110"
17617
+ /**
17618
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
17619
+ *
17620
+ * @example
17621
+ * points="100,10 250,150 200,110"
17622
+ */
17623
+
17624
+ function parsePoints(pointsOrStr, object) {
17625
+ var points;
17626
+
17627
+ if (isString(pointsOrStr)) {
17628
+ points = pointsOrStr.split(' ').map(function (pointStr) {
17629
+ var _pointStr$split = pointStr.split(','),
17630
+ x = _pointStr$split[0],
17631
+ y = _pointStr$split[1];
17632
+
17633
+ return [Number(x), Number(y)];
17634
+ });
17635
+ } else {
17636
+ points = pointsOrStr;
17637
+ }
17638
+
17639
+ var segments = [];
17640
+ var tempLength = 0;
17641
+ var segmentT;
17642
+ var segmentL;
17643
+ var totalLength = polyline.length(points);
17644
+ points.forEach(function (p, i) {
17645
+ if (points[i + 1]) {
17646
+ segmentT = [0, 0];
17647
+ segmentT[0] = tempLength / totalLength;
17648
+ segmentL = line.length(p[0], p[1], points[i + 1][0], points[i + 1][1]);
17649
+ tempLength += segmentL;
17650
+ segmentT[1] = tempLength / totalLength;
17651
+ segments.push(segmentT);
17652
+ }
17653
+ });
17654
+ var minX = Math.min.apply(Math, points.map(function (point) {
17655
+ return point[0];
17656
+ }));
17657
+ var minY = Math.min.apply(Math, points.map(function (point) {
17658
+ return point[1];
17659
+ }));
17660
+
17661
+ if (object) {
17662
+ object.parsedStyle.defX = minX;
17663
+ object.parsedStyle.defY = minY;
17664
+ }
17665
+
17666
+ return {
17667
+ points: points,
17668
+ totalLength: totalLength,
17669
+ segments: segments
17670
+ };
17671
+ }
17672
+
17673
+ var parseParam = function parseParam(css) {
17674
+ return parseDimension(/deg|rad|grad|turn|px|%/g, css);
17675
+ };
17676
+ var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
17677
+ function parseFilter(filterStr) {
17678
+ if (filterStr === void 0) {
17679
+ filterStr = '';
17680
+ }
17681
+
17682
+ filterStr = filterStr.toLowerCase().trim();
17683
+
17684
+ if (filterStr === 'none') {
17685
+ return [];
17686
+ }
17687
+
17688
+ var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
17689
+ var result = [];
17690
+ var match;
17691
+ var prevLastIndex = 0;
17692
+
17693
+ while (match = filterRegExp.exec(filterStr)) {
17694
+ if (match.index !== prevLastIndex) {
17695
+ return [];
17696
+ }
17697
+
17698
+ prevLastIndex = match.index + match[0].length;
17699
+
17700
+ if (supportedFilters.indexOf(match[1]) > -1) {
17701
+ result.push({
17702
+ name: match[1],
17703
+ params: match[2].split(' ').map(function (p) {
17704
+ return parseParam(p) || parseColor(p);
17705
+ })
17706
+ });
17707
+ }
17708
+
17709
+ if (filterRegExp.lastIndex === filterStr.length) {
17710
+ return result;
17711
+ }
17712
+ }
17713
+
17714
+ return [];
17715
+ }
17716
+
17717
+ var normalize$4 = function normalize(out, mat) {
17718
+ var m44 = mat[15];
17719
+ // Cannot normalize.
17720
+ if (m44 === 0)
17721
+ return false
17722
+ var scale = 1 / m44;
17723
+ for (var i=0; i<16; i++)
17724
+ out[i] = mat[i] * scale;
17725
+ return true
17726
+ };
17727
+
17728
+ var create_1 = create$6;
17729
+
17730
+ /**
17731
+ * Creates a new identity mat4
17732
+ *
17733
+ * @returns {mat4} a new 4x4 matrix
17734
+ */
17735
+ function create$6() {
17736
+ var out = new Float32Array(16);
17737
+ out[0] = 1;
17738
+ out[1] = 0;
17739
+ out[2] = 0;
17740
+ out[3] = 0;
17741
+ out[4] = 0;
17742
+ out[5] = 1;
17743
+ out[6] = 0;
17744
+ out[7] = 0;
17745
+ out[8] = 0;
17746
+ out[9] = 0;
17747
+ out[10] = 1;
17748
+ out[11] = 0;
17749
+ out[12] = 0;
17750
+ out[13] = 0;
17751
+ out[14] = 0;
17752
+ out[15] = 1;
17753
+ return out;
17754
+ }
17755
+
17756
+ var clone_1 = clone$2;
17757
+
17758
+ /**
17759
+ * Creates a new mat4 initialized with values from an existing matrix
17760
+ *
17761
+ * @param {mat4} a matrix to clone
17762
+ * @returns {mat4} a new 4x4 matrix
17763
+ */
17764
+ function clone$2(a) {
17765
+ var out = new Float32Array(16);
17766
+ out[0] = a[0];
17767
+ out[1] = a[1];
17768
+ out[2] = a[2];
17769
+ out[3] = a[3];
17770
+ out[4] = a[4];
17771
+ out[5] = a[5];
17772
+ out[6] = a[6];
17773
+ out[7] = a[7];
17774
+ out[8] = a[8];
17775
+ out[9] = a[9];
17776
+ out[10] = a[10];
17777
+ out[11] = a[11];
17778
+ out[12] = a[12];
17779
+ out[13] = a[13];
17780
+ out[14] = a[14];
17781
+ out[15] = a[15];
17782
+ return out;
17783
+ }
17784
+
17785
+ var determinant_1 = determinant;
17786
+
17787
+ /**
17788
+ * Calculates the determinant of a mat4
17789
+ *
17790
+ * @param {mat4} a the source matrix
17791
+ * @returns {Number} determinant of a
17792
+ */
17793
+ function determinant(a) {
17794
+ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
17795
+ a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
17796
+ a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
17797
+ a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
17798
+
17799
+ b00 = a00 * a11 - a01 * a10,
17800
+ b01 = a00 * a12 - a02 * a10,
17801
+ b02 = a00 * a13 - a03 * a10,
17802
+ b03 = a01 * a12 - a02 * a11,
17803
+ b04 = a01 * a13 - a03 * a11,
17804
+ b05 = a02 * a13 - a03 * a12,
17805
+ b06 = a20 * a31 - a21 * a30,
17806
+ b07 = a20 * a32 - a22 * a30,
17807
+ b08 = a20 * a33 - a23 * a30,
17808
+ b09 = a21 * a32 - a22 * a31,
17809
+ b10 = a21 * a33 - a23 * a31,
17810
+ b11 = a22 * a33 - a23 * a32;
17811
+
17812
+ // Calculate the determinant
17813
+ return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
17814
+ }
17815
+
17816
+ var invert_1 = invert$2;
17817
+
17818
+ /**
17819
+ * Inverts a mat4
17820
+ *
17821
+ * @param {mat4} out the receiving matrix
17822
+ * @param {mat4} a the source matrix
17823
+ * @returns {mat4} out
17824
+ */
17825
+ function invert$2(out, a) {
17826
+ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
17827
+ a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
17828
+ a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
17829
+ a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
17830
+
17831
+ b00 = a00 * a11 - a01 * a10,
17832
+ b01 = a00 * a12 - a02 * a10,
17833
+ b02 = a00 * a13 - a03 * a10,
17834
+ b03 = a01 * a12 - a02 * a11,
17835
+ b04 = a01 * a13 - a03 * a11,
17836
+ b05 = a02 * a13 - a03 * a12,
17837
+ b06 = a20 * a31 - a21 * a30,
17838
+ b07 = a20 * a32 - a22 * a30,
17839
+ b08 = a20 * a33 - a23 * a30,
17840
+ b09 = a21 * a32 - a22 * a31,
17841
+ b10 = a21 * a33 - a23 * a31,
17842
+ b11 = a22 * a33 - a23 * a32,
17843
+
17844
+ // Calculate the determinant
17845
+ det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
17846
+
17847
+ if (!det) {
17848
+ return null;
17849
+ }
17850
+ det = 1.0 / det;
17851
+
17852
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
17853
+ out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
17854
+ out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
17855
+ out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
17856
+ out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
17857
+ out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
17858
+ out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
17859
+ out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
17860
+ out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
17861
+ out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
17862
+ out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
17863
+ out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
17864
+ out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
17865
+ out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
17866
+ out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
17867
+ out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
17868
+
17869
+ return out;
17870
+ }
17871
+
17872
+ var transpose_1 = transpose;
17873
+
17874
+ /**
17875
+ * Transpose the values of a mat4
17876
+ *
17877
+ * @param {mat4} out the receiving matrix
17878
+ * @param {mat4} a the source matrix
17879
+ * @returns {mat4} out
17880
+ */
17881
+ function transpose(out, a) {
17882
+ // If we are transposing ourselves we can skip a few steps but have to cache some values
17883
+ if (out === a) {
17884
+ var a01 = a[1], a02 = a[2], a03 = a[3],
17885
+ a12 = a[6], a13 = a[7],
17886
+ a23 = a[11];
17887
+
17888
+ out[1] = a[4];
17889
+ out[2] = a[8];
17890
+ out[3] = a[12];
17891
+ out[4] = a01;
17892
+ out[6] = a[9];
17893
+ out[7] = a[13];
17894
+ out[8] = a02;
17895
+ out[9] = a12;
17896
+ out[11] = a[14];
17897
+ out[12] = a03;
17898
+ out[13] = a13;
17899
+ out[14] = a23;
17900
+ } else {
17901
+ out[0] = a[0];
17902
+ out[1] = a[4];
17903
+ out[2] = a[8];
17904
+ out[3] = a[12];
17905
+ out[4] = a[1];
17906
+ out[5] = a[5];
17907
+ out[6] = a[9];
17908
+ out[7] = a[13];
17909
+ out[8] = a[2];
17910
+ out[9] = a[6];
17911
+ out[10] = a[10];
17912
+ out[11] = a[14];
17913
+ out[12] = a[3];
17914
+ out[13] = a[7];
17915
+ out[14] = a[11];
17916
+ out[15] = a[15];
17917
+ }
17918
+
17919
+ return out;
17920
+ }
17921
+
17922
+ var length_1 = length$1;
17923
+
17924
+ /**
17925
+ * Calculates the length of a vec3
17926
+ *
17927
+ * @param {vec3} a vector to calculate length of
17928
+ * @returns {Number} length of a
17929
+ */
17930
+ function length$1(a) {
17931
+ var x = a[0],
17932
+ y = a[1],
17933
+ z = a[2];
17934
+ return Math.sqrt(x*x + y*y + z*z)
17935
+ }
17936
+
17937
+ var normalize_1 = normalize$5;
17938
+
17939
+ /**
17940
+ * Normalize a vec3
17941
+ *
17942
+ * @param {vec3} out the receiving vector
17943
+ * @param {vec3} a vector to normalize
17944
+ * @returns {vec3} out
17945
+ */
17946
+ function normalize$5(out, a) {
17947
+ var x = a[0],
17948
+ y = a[1],
17949
+ z = a[2];
17950
+ var len = x*x + y*y + z*z;
17951
+ if (len > 0) {
17952
+ //TODO: evaluate use of glm_invsqrt here?
17953
+ len = 1 / Math.sqrt(len);
17954
+ out[0] = a[0] * len;
17955
+ out[1] = a[1] * len;
17956
+ out[2] = a[2] * len;
17957
+ }
17958
+ return out
17959
+ }
17960
+
17961
+ var dot_1 = dot$2;
17962
+
17963
+ /**
17964
+ * Calculates the dot product of two vec3's
17965
+ *
17966
+ * @param {vec3} a the first operand
17967
+ * @param {vec3} b the second operand
17968
+ * @returns {Number} dot product of a and b
18241
17969
  */
17970
+ function dot$2(a, b) {
17971
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
17972
+ }
18242
17973
 
18243
- function parsePoints(pointsOrStr, object) {
18244
- var points;
17974
+ var cross_1 = cross$1;
18245
17975
 
18246
- if (isString(pointsOrStr)) {
18247
- points = pointsOrStr.split(' ').map(function (pointStr) {
18248
- var _pointStr$split = pointStr.split(','),
18249
- x = _pointStr$split[0],
18250
- y = _pointStr$split[1];
17976
+ /**
17977
+ * Computes the cross product of two vec3's
17978
+ *
17979
+ * @param {vec3} out the receiving vector
17980
+ * @param {vec3} a the first operand
17981
+ * @param {vec3} b the second operand
17982
+ * @returns {vec3} out
17983
+ */
17984
+ function cross$1(out, a, b) {
17985
+ var ax = a[0], ay = a[1], az = a[2],
17986
+ bx = b[0], by = b[1], bz = b[2];
17987
+
17988
+ out[0] = ay * bz - az * by;
17989
+ out[1] = az * bx - ax * bz;
17990
+ out[2] = ax * by - ay * bx;
17991
+ return out
17992
+ }
17993
+
17994
+ /*jshint unused:true*/
17995
+ /*
17996
+ Input: matrix ; a 4x4 matrix
17997
+ Output: translation ; a 3 component vector
17998
+ scale ; a 3 component vector
17999
+ skew ; skew factors XY,XZ,YZ represented as a 3 component vector
18000
+ perspective ; a 4 component vector
18001
+ quaternion ; a 4 component vector
18002
+ Returns false if the matrix cannot be decomposed, true if it can
18003
+
18004
+
18005
+ References:
18006
+ https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
18007
+ https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
18008
+ http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
18009
+ */
18251
18010
 
18252
- return [Number(x), Number(y)];
18253
- });
18254
- } else {
18255
- points = pointsOrStr;
18256
- }
18257
18011
 
18258
- var segments = [];
18259
- var tempLength = 0;
18260
- var segmentT;
18261
- var segmentL;
18262
- var totalLength = polyline.length(points);
18263
- points.forEach(function (p, i) {
18264
- if (points[i + 1]) {
18265
- segmentT = [0, 0];
18266
- segmentT[0] = tempLength / totalLength;
18267
- segmentL = line.length(p[0], p[1], points[i + 1][0], points[i + 1][1]);
18268
- tempLength += segmentL;
18269
- segmentT[1] = tempLength / totalLength;
18270
- segments.push(segmentT);
18271
- }
18272
- });
18273
- var minX = Math.min.apply(Math, points.map(function (point) {
18274
- return point[0];
18275
- }));
18276
- var minY = Math.min.apply(Math, points.map(function (point) {
18277
- return point[1];
18278
- }));
18279
18012
 
18280
- if (object) {
18281
- object.parsedStyle.defX = minX;
18282
- object.parsedStyle.defY = minY;
18283
- }
18284
18013
 
18285
- return {
18286
- points: points,
18287
- totalLength: totalLength,
18288
- segments: segments
18289
- };
18290
- }
18291
18014
 
18292
- var parseParam = function parseParam(css) {
18293
- return parseDimension(/deg|rad|grad|turn|px|%/g, css);
18294
- };
18295
- var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
18296
- function parseFilter(filterStr) {
18297
- if (filterStr === void 0) {
18298
- filterStr = '';
18299
- }
18300
18015
 
18301
- filterStr = filterStr.toLowerCase().trim();
18302
18016
 
18303
- if (filterStr === 'none') {
18304
- return [];
18305
- }
18306
18017
 
18307
- var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
18308
- var result = [];
18309
- var match;
18310
- var prevLastIndex = 0;
18018
+ var vec3 = {
18019
+ length: length_1,
18020
+ normalize: normalize_1,
18021
+ dot: dot_1,
18022
+ cross: cross_1
18023
+ };
18311
18024
 
18312
- while (match = filterRegExp.exec(filterStr)) {
18313
- if (match.index !== prevLastIndex) {
18314
- return [];
18315
- }
18025
+ var tmp = create_1();
18026
+ var perspectiveMatrix = create_1();
18027
+ var tmpVec4 = [0, 0, 0, 0];
18028
+ var row = [ [0,0,0], [0,0,0], [0,0,0] ];
18029
+ var pdum3 = [0,0,0];
18030
+
18031
+ var mat4Decompose = function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
18032
+ if (!translation) translation = [0,0,0];
18033
+ if (!scale) scale = [0,0,0];
18034
+ if (!skew) skew = [0,0,0];
18035
+ if (!perspective) perspective = [0,0,0,1];
18036
+ if (!quaternion) quaternion = [0,0,0,1];
18037
+
18038
+ //normalize, if not possible then bail out early
18039
+ if (!normalize$4(tmp, matrix))
18040
+ return false
18041
+
18042
+ // perspectiveMatrix is used to solve for perspective, but it also provides
18043
+ // an easy way to test for singularity of the upper 3x3 component.
18044
+ clone_1(perspectiveMatrix);
18045
+
18046
+ perspectiveMatrix[3] = 0;
18047
+ perspectiveMatrix[7] = 0;
18048
+ perspectiveMatrix[11] = 0;
18049
+ perspectiveMatrix[15] = 1;
18050
+
18051
+ // If the perspectiveMatrix is not invertible, we are also unable to
18052
+ // decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
18053
+ if (Math.abs(determinant_1(perspectiveMatrix) < 1e-8))
18054
+ return false
18055
+
18056
+ var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11],
18057
+ a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
18058
+
18059
+ // First, isolate perspective.
18060
+ if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
18061
+ tmpVec4[0] = a03;
18062
+ tmpVec4[1] = a13;
18063
+ tmpVec4[2] = a23;
18064
+ tmpVec4[3] = a33;
18065
+
18066
+ // Solve the equation by inverting perspectiveMatrix and multiplying
18067
+ // rightHandSide by the inverse.
18068
+ // resuing the perspectiveMatrix here since it's no longer needed
18069
+ var ret = invert_1(perspectiveMatrix, perspectiveMatrix);
18070
+ if (!ret) return false
18071
+ transpose_1(perspectiveMatrix, perspectiveMatrix);
18072
+
18073
+ //multiply by transposed inverse perspective matrix, into perspective vec4
18074
+ vec4multMat4(perspective, tmpVec4, perspectiveMatrix);
18075
+ } else {
18076
+ //no perspective
18077
+ perspective[0] = perspective[1] = perspective[2] = 0;
18078
+ perspective[3] = 1;
18079
+ }
18080
+
18081
+ // Next take care of translation
18082
+ translation[0] = a30;
18083
+ translation[1] = a31;
18084
+ translation[2] = a32;
18085
+
18086
+ // Now get scale and shear. 'row' is a 3 element array of 3 component vectors
18087
+ mat3from4(row, tmp);
18088
+
18089
+ // Compute X scale factor and normalize first row.
18090
+ scale[0] = vec3.length(row[0]);
18091
+ vec3.normalize(row[0], row[0]);
18092
+
18093
+ // Compute XY shear factor and make 2nd row orthogonal to 1st.
18094
+ skew[0] = vec3.dot(row[0], row[1]);
18095
+ combine(row[1], row[1], row[0], 1.0, -skew[0]);
18096
+
18097
+ // Now, compute Y scale and normalize 2nd row.
18098
+ scale[1] = vec3.length(row[1]);
18099
+ vec3.normalize(row[1], row[1]);
18100
+ skew[0] /= scale[1];
18101
+
18102
+ // Compute XZ and YZ shears, orthogonalize 3rd row
18103
+ skew[1] = vec3.dot(row[0], row[2]);
18104
+ combine(row[2], row[2], row[0], 1.0, -skew[1]);
18105
+ skew[2] = vec3.dot(row[1], row[2]);
18106
+ combine(row[2], row[2], row[1], 1.0, -skew[2]);
18107
+
18108
+ // Next, get Z scale and normalize 3rd row.
18109
+ scale[2] = vec3.length(row[2]);
18110
+ vec3.normalize(row[2], row[2]);
18111
+ skew[1] /= scale[2];
18112
+ skew[2] /= scale[2];
18113
+
18114
+
18115
+ // At this point, the matrix (in rows) is orthonormal.
18116
+ // Check for a coordinate system flip. If the determinant
18117
+ // is -1, then negate the matrix and the scaling factors.
18118
+ vec3.cross(pdum3, row[1], row[2]);
18119
+ if (vec3.dot(row[0], pdum3) < 0) {
18120
+ for (var i = 0; i < 3; i++) {
18121
+ scale[i] *= -1;
18122
+ row[i][0] *= -1;
18123
+ row[i][1] *= -1;
18124
+ row[i][2] *= -1;
18125
+ }
18126
+ }
18127
+
18128
+ // Now, get the rotations out
18129
+ quaternion[0] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
18130
+ quaternion[1] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
18131
+ quaternion[2] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
18132
+ quaternion[3] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
18133
+
18134
+ if (row[2][1] > row[1][2])
18135
+ quaternion[0] = -quaternion[0];
18136
+ if (row[0][2] > row[2][0])
18137
+ quaternion[1] = -quaternion[1];
18138
+ if (row[1][0] > row[0][1])
18139
+ quaternion[2] = -quaternion[2];
18140
+ return true
18141
+ };
18316
18142
 
18317
- prevLastIndex = match.index + match[0].length;
18143
+ //will be replaced by gl-vec4 eventually
18144
+ function vec4multMat4(out, a, m) {
18145
+ var x = a[0], y = a[1], z = a[2], w = a[3];
18146
+ out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
18147
+ out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
18148
+ out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
18149
+ out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
18150
+ return out;
18151
+ }
18318
18152
 
18319
- if (supportedFilters.indexOf(match[1]) > -1) {
18320
- result.push({
18321
- name: match[1],
18322
- params: match[2].split(' ').map(function (p) {
18323
- return parseParam(p) || parseColor(p);
18324
- })
18325
- });
18326
- }
18153
+ //gets upper-left of a 4x4 matrix into a 3x3 of vectors
18154
+ function mat3from4(out, mat4x4) {
18155
+ out[0][0] = mat4x4[0];
18156
+ out[0][1] = mat4x4[1];
18157
+ out[0][2] = mat4x4[2];
18158
+
18159
+ out[1][0] = mat4x4[4];
18160
+ out[1][1] = mat4x4[5];
18161
+ out[1][2] = mat4x4[6];
18327
18162
 
18328
- if (filterRegExp.lastIndex === filterStr.length) {
18329
- return result;
18330
- }
18331
- }
18163
+ out[2][0] = mat4x4[8];
18164
+ out[2][1] = mat4x4[9];
18165
+ out[2][2] = mat4x4[10];
18166
+ }
18332
18167
 
18333
- return [];
18168
+ function combine(out, a, b, scale1, scale2) {
18169
+ out[0] = a[0] * scale1 + b[0] * scale2;
18170
+ out[1] = a[1] * scale1 + b[1] * scale2;
18171
+ out[2] = a[2] * scale1 + b[2] * scale2;
18334
18172
  }
18335
18173
 
18336
18174
  /**
@@ -18472,22 +18310,23 @@
18472
18310
 
18473
18311
 
18474
18312
  var transformFunctions = {
18475
- // matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
18476
- // matrix3d: ['NNNNNNNNNNNNNNNN', id],
18313
+ // @ts-ignore
18314
+ matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id$1],
18315
+ matrix3d: ['NNNNNNNNNNNNNNNN', id$1],
18477
18316
  rotate: ['A'],
18478
18317
  rotatex: ['A'],
18479
18318
  rotatey: ['A'],
18480
18319
  rotatez: ['A'],
18481
18320
  rotate3d: ['NNNA'],
18482
- // perspective: ['L'],
18321
+ perspective: ['L'],
18483
18322
  scale: ['Nn', cast([_, _, CSS.number(1)]), id$1],
18484
18323
  scalex: ['N', cast([_, CSS.number(1), CSS.number(1)]), cast([_, CSS.number(1)])],
18485
18324
  scaley: ['N', cast([CSS.number(1), _, CSS.number(1)]), cast([CSS.number(1), _])],
18486
18325
  scalez: ['N', cast([CSS.number(1), CSS.number(1), _])],
18487
18326
  scale3d: ['NNN', id$1],
18488
- // skew: ['Aa', null, id],
18489
- // skewx: ['A', null, cast([_, Odeg])],
18490
- // skewy: ['A', null, cast([Odeg, _])],
18327
+ skew: ['Aa', null, id$1],
18328
+ skewx: ['A', null, cast([_, Odeg])],
18329
+ skewy: ['A', null, cast([Odeg, _])],
18491
18330
  translate: ['Tt', cast([_, _, Opx]), id$1],
18492
18331
  translatex: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
18493
18332
  translatey: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
@@ -18580,33 +18419,289 @@
18580
18419
  }
18581
18420
 
18582
18421
  return [];
18583
- } // function mergeMatrices(left: number[][], right: number[][]): [
18584
- // number[][], number[][], () => string,
18585
- // ] {
18586
- // if (left.decompositionPair !== right) {
18587
- // left.decompositionPair = right;
18588
- // var leftArgs = makeMatrixDecomposition(left);
18589
- // }
18590
- // if (right.decompositionPair !== left) {
18591
- // right.decompositionPair = left;
18592
- // var rightArgs = makeMatrixDecomposition(right);
18593
- // }
18594
- // if (leftArgs[0] === null || rightArgs[0] === null)
18595
- // return [[false], [true], (x) => { return x ? right[0].d : left[0].d; }];
18596
- // leftArgs[0].push(0);
18597
- // rightArgs[0].push(1);
18598
- // return [
18599
- // leftArgs,
18600
- // rightArgs,
18601
- // (list) => {
18602
- // const q = quat(leftArgs[0][3], rightArgs[0][3], list[5]);
18603
- // const mat = composeMatrix(list[0], list[1], list[2], q, list[4]);
18604
- // const stringifiedArgs = mat.map(numberToLongString).join(',');
18605
- // return stringifiedArgs;
18606
- // }
18607
- // ];
18608
- // }
18609
- // scalex/y/z -> scale
18422
+ }
18423
+ function convertItemToMatrix(item) {
18424
+ var x;
18425
+ var y;
18426
+ var z;
18427
+ var angle;
18428
+
18429
+ switch (item.t) {
18430
+ case 'rotatex':
18431
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18432
+ return [1, 0, 0, 0, 0, Math.cos(angle), Math.sin(angle), 0, 0, -Math.sin(angle), Math.cos(angle), 0, 0, 0, 0, 1];
18433
+
18434
+ case 'rotatey':
18435
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18436
+ return [Math.cos(angle), 0, -Math.sin(angle), 0, 0, 1, 0, 0, Math.sin(angle), 0, Math.cos(angle), 0, 0, 0, 0, 1];
18437
+
18438
+ case 'rotate':
18439
+ case 'rotatez':
18440
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18441
+ return [Math.cos(angle), Math.sin(angle), 0, 0, -Math.sin(angle), Math.cos(angle), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18442
+
18443
+ case 'rotate3d':
18444
+ x = item.d[0].value;
18445
+ y = item.d[1].value;
18446
+ z = item.d[2].value;
18447
+ angle = deg2rad(convertAngleUnit(item.d[3]));
18448
+ var sqrLength = x * x + y * y + z * z;
18449
+
18450
+ if (sqrLength === 0) {
18451
+ x = 1;
18452
+ y = 0;
18453
+ z = 0;
18454
+ } else if (sqrLength !== 1) {
18455
+ var length = Math.sqrt(sqrLength);
18456
+ x /= length;
18457
+ y /= length;
18458
+ z /= length;
18459
+ }
18460
+
18461
+ var s = Math.sin(angle / 2);
18462
+ var sc = s * Math.cos(angle / 2);
18463
+ var sq = s * s;
18464
+ return [1 - 2 * (y * y + z * z) * sq, 2 * (x * y * sq + z * sc), 2 * (x * z * sq - y * sc), 0, 2 * (x * y * sq - z * sc), 1 - 2 * (x * x + z * z) * sq, 2 * (y * z * sq + x * sc), 0, 2 * (x * z * sq + y * sc), 2 * (y * z * sq - x * sc), 1 - 2 * (x * x + y * y) * sq, 0, 0, 0, 0, 1];
18465
+
18466
+ case 'scale':
18467
+ return [item.d[0].value, 0, 0, 0, 0, item.d[1].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18468
+
18469
+ case 'scalex':
18470
+ return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18471
+
18472
+ case 'scaley':
18473
+ return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18474
+
18475
+ case 'scalez':
18476
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
18477
+
18478
+ case 'scale3d':
18479
+ return [item.d[0].value, 0, 0, 0, 0, item.d[1].value, 0, 0, 0, 0, item.d[2].value, 0, 0, 0, 0, 1];
18480
+
18481
+ case 'skew':
18482
+ var xAngle = deg2rad(convertAngleUnit(item.d[0]));
18483
+ var yAngle = deg2rad(convertAngleUnit(item.d[1]));
18484
+ return [1, Math.tan(yAngle), 0, 0, Math.tan(xAngle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18485
+
18486
+ case 'skewx':
18487
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18488
+ return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18489
+
18490
+ case 'skewy':
18491
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18492
+ return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18493
+
18494
+ case 'translate':
18495
+ // TODO: pass target
18496
+ x = convertPercentUnit(item.d[0], 0, null) || 0;
18497
+ y = convertPercentUnit(item.d[1], 0, null) || 0;
18498
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
18499
+
18500
+ case 'translatex':
18501
+ x = convertPercentUnit(item.d[0], 0, null) || 0;
18502
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
18503
+
18504
+ case 'translatey':
18505
+ y = convertPercentUnit(item.d[0], 0, null) || 0;
18506
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
18507
+
18508
+ case 'translatez':
18509
+ z = convertPercentUnit(item.d[0], 0, null) || 0;
18510
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
18511
+
18512
+ case 'translate3d':
18513
+ x = convertPercentUnit(item.d[0], 0, null) || 0;
18514
+ y = convertPercentUnit(item.d[1], 0, null) || 0;
18515
+ z = convertPercentUnit(item.d[2], 0, null) || 0;
18516
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1];
18517
+
18518
+ case 'perspective':
18519
+ var t = convertPercentUnit(item.d[0], 0, null) || 0;
18520
+ var p = t ? -1 / t : 0;
18521
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, p, 0, 0, 0, 1];
18522
+
18523
+ case 'matrix':
18524
+ return [item.d[0].value, item.d[1].value, 0, 0, item.d[2].value, item.d[3].value, 0, 0, 0, 0, 1, 0, item.d[4].value, item.d[5].value, 0, 1];
18525
+
18526
+ case 'matrix3d':
18527
+ return item.d.map(function (d) {
18528
+ return d.value;
18529
+ });
18530
+ }
18531
+ }
18532
+
18533
+ function multiplyMatrices(a, b) {
18534
+ return [a[0] * b[0] + a[4] * b[1] + a[8] * b[2] + a[12] * b[3], a[1] * b[0] + a[5] * b[1] + a[9] * b[2] + a[13] * b[3], a[2] * b[0] + a[6] * b[1] + a[10] * b[2] + a[14] * b[3], a[3] * b[0] + a[7] * b[1] + a[11] * b[2] + a[15] * b[3], a[0] * b[4] + a[4] * b[5] + a[8] * b[6] + a[12] * b[7], a[1] * b[4] + a[5] * b[5] + a[9] * b[6] + a[13] * b[7], a[2] * b[4] + a[6] * b[5] + a[10] * b[6] + a[14] * b[7], a[3] * b[4] + a[7] * b[5] + a[11] * b[6] + a[15] * b[7], a[0] * b[8] + a[4] * b[9] + a[8] * b[10] + a[12] * b[11], a[1] * b[8] + a[5] * b[9] + a[9] * b[10] + a[13] * b[11], a[2] * b[8] + a[6] * b[9] + a[10] * b[10] + a[14] * b[11], a[3] * b[8] + a[7] * b[9] + a[11] * b[10] + a[15] * b[11], a[0] * b[12] + a[4] * b[13] + a[8] * b[14] + a[12] * b[15], a[1] * b[12] + a[5] * b[13] + a[9] * b[14] + a[13] * b[15], a[2] * b[12] + a[6] * b[13] + a[10] * b[14] + a[14] * b[15], a[3] * b[12] + a[7] * b[13] + a[11] * b[14] + a[15] * b[15]];
18535
+ }
18536
+
18537
+ function convertToMatrix(transformList) {
18538
+ if (transformList.length === 0) {
18539
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18540
+ }
18541
+
18542
+ return transformList.map(convertItemToMatrix).reduce(multiplyMatrices);
18543
+ }
18544
+
18545
+ function makeMatrixDecomposition(transformList) {
18546
+ var translate = [0, 0, 0];
18547
+ var scale = [0, 0, 0];
18548
+ var skew = [0, 0, 0];
18549
+ var perspective = [0, 0, 0, 1];
18550
+ var quaternion = [0, 0, 0, 1];
18551
+ mat4Decompose(convertToMatrix(transformList), translate, scale, skew, perspective, quaternion);
18552
+ return [translate, scale, skew, quaternion, perspective];
18553
+ }
18554
+
18555
+ var composeMatrix = function () {
18556
+ function multiply(a, b) {
18557
+ var result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
18558
+
18559
+ for (var i = 0; i < 4; i++) {
18560
+ for (var j = 0; j < 4; j++) {
18561
+ for (var k = 0; k < 4; k++) {
18562
+ result[i][j] += b[i][k] * a[k][j];
18563
+ }
18564
+ }
18565
+ }
18566
+
18567
+ return result;
18568
+ }
18569
+
18570
+ function is2D(m) {
18571
+ return m[0][2] == 0 && m[0][3] == 0 && m[1][2] == 0 && m[1][3] == 0 && m[2][0] == 0 && m[2][1] == 0 && m[2][2] == 1 && m[2][3] == 0 && m[3][2] == 0 && m[3][3] == 1;
18572
+ }
18573
+
18574
+ function composeMatrix(translate, scale, skew, quat, perspective) {
18575
+ var matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
18576
+
18577
+ for (var i = 0; i < 4; i++) {
18578
+ matrix[i][3] = perspective[i];
18579
+ }
18580
+
18581
+ for (var _i = 0; _i < 3; _i++) {
18582
+ for (var j = 0; j < 3; j++) {
18583
+ matrix[3][_i] += translate[j] * matrix[j][_i];
18584
+ }
18585
+ }
18586
+
18587
+ var x = quat[0],
18588
+ y = quat[1],
18589
+ z = quat[2],
18590
+ w = quat[3];
18591
+ var rotMatrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
18592
+ rotMatrix[0][0] = 1 - 2 * (y * y + z * z);
18593
+ rotMatrix[0][1] = 2 * (x * y - z * w);
18594
+ rotMatrix[0][2] = 2 * (x * z + y * w);
18595
+ rotMatrix[1][0] = 2 * (x * y + z * w);
18596
+ rotMatrix[1][1] = 1 - 2 * (x * x + z * z);
18597
+ rotMatrix[1][2] = 2 * (y * z - x * w);
18598
+ rotMatrix[2][0] = 2 * (x * z - y * w);
18599
+ rotMatrix[2][1] = 2 * (y * z + x * w);
18600
+ rotMatrix[2][2] = 1 - 2 * (x * x + y * y);
18601
+ matrix = multiply(matrix, rotMatrix);
18602
+ var temp = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
18603
+
18604
+ if (skew[2]) {
18605
+ temp[2][1] = skew[2];
18606
+ matrix = multiply(matrix, temp);
18607
+ }
18608
+
18609
+ if (skew[1]) {
18610
+ temp[2][1] = 0;
18611
+ temp[2][0] = skew[0];
18612
+ matrix = multiply(matrix, temp);
18613
+ }
18614
+
18615
+ if (skew[0]) {
18616
+ temp[2][0] = 0;
18617
+ temp[1][0] = skew[0];
18618
+ matrix = multiply(matrix, temp);
18619
+ }
18620
+
18621
+ for (var _i2 = 0; _i2 < 3; _i2++) {
18622
+ for (var _j = 0; _j < 3; _j++) {
18623
+ matrix[_i2][_j] *= scale[_i2];
18624
+ }
18625
+ }
18626
+
18627
+ if (is2D(matrix)) {
18628
+ return [matrix[0][0], matrix[0][1], matrix[1][0], matrix[1][1], matrix[3][0], matrix[3][1]];
18629
+ }
18630
+
18631
+ return matrix[0].concat(matrix[1], matrix[2], matrix[3]);
18632
+ }
18633
+
18634
+ return composeMatrix;
18635
+ }();
18636
+
18637
+ function numberToLongString(x) {
18638
+ return x.toFixed(6).replace('.000000', '');
18639
+ }
18640
+
18641
+ function mergeMatrices(left, right) {
18642
+ var leftArgs;
18643
+ var rightArgs; // @ts-ignore
18644
+
18645
+ if (left.decompositionPair !== right) {
18646
+ // @ts-ignore
18647
+ left.decompositionPair = right;
18648
+ leftArgs = makeMatrixDecomposition(left);
18649
+ } // @ts-ignore
18650
+
18651
+
18652
+ if (right.decompositionPair !== left) {
18653
+ // @ts-ignore
18654
+ right.decompositionPair = left;
18655
+ rightArgs = makeMatrixDecomposition(right);
18656
+ }
18657
+
18658
+ if (leftArgs[0] === null || rightArgs[0] === null) return [// @ts-ignore
18659
+ [false], // @ts-ignore
18660
+ [true], // @ts-ignore
18661
+ function (x) {
18662
+ return x ? right[0].d : left[0].d;
18663
+ }];
18664
+ leftArgs[0].push(0);
18665
+ rightArgs[0].push(1);
18666
+ return [leftArgs, rightArgs, // @ts-ignore
18667
+ function (list) {
18668
+ // @ts-ignore
18669
+ var q = quat(leftArgs[0][3], rightArgs[0][3], list[5]);
18670
+ var mat = composeMatrix(list[0], list[1], list[2], q, list[4]);
18671
+ var stringifiedArgs = mat.map(numberToLongString).join(',');
18672
+ return stringifiedArgs;
18673
+ }];
18674
+ }
18675
+
18676
+ function dot$3(v1, v2) {
18677
+ var result = 0;
18678
+
18679
+ for (var i = 0; i < v1.length; i++) {
18680
+ result += v1[i] * v2[i];
18681
+ }
18682
+
18683
+ return result;
18684
+ }
18685
+
18686
+ function quat(fromQ, toQ, f) {
18687
+ var product = dot$3(fromQ, toQ);
18688
+ product = clamp(product, -1.0, 1.0);
18689
+ var quat = [];
18690
+
18691
+ if (product === 1.0) {
18692
+ quat = fromQ;
18693
+ } else {
18694
+ var theta = Math.acos(product);
18695
+ var w = Math.sin(f * theta) * 1 / Math.sqrt(1 - product * product);
18696
+
18697
+ for (var i = 0; i < 4; i++) {
18698
+ quat.push(fromQ[i] * (Math.cos(f * theta) - product * w) + toQ[i] * w);
18699
+ }
18700
+ }
18701
+
18702
+ return quat;
18703
+ } // scalex/y/z -> scale
18704
+
18610
18705
 
18611
18706
  function typeTo2D(type) {
18612
18707
  return type.replace(/[xy]/, '');
@@ -18636,7 +18731,7 @@
18636
18731
  type = _left$i.t,
18637
18732
  args = _left$i.d; // none -> scale(1)/translateX(0)
18638
18733
 
18639
- var defaultValue = type.substr(0, 5) === 'scale' ? 1 : 0;
18734
+ var defaultValue = type.substring(0, 5) === 'scale' ? 1 : 0;
18640
18735
  right.push({
18641
18736
  t: type,
18642
18737
  d: args.map(function (arg) {
@@ -18661,21 +18756,31 @@
18661
18756
  var rightResult = [];
18662
18757
  var types = []; // merge matrix() with matrix3d()
18663
18758
 
18664
- if (left.length !== right.length) ; else {
18665
- for (var _i = 0; _i < left.length; _i++) {
18666
- var leftType = left[_i].t;
18667
- var rightType = right[_i].t;
18668
- var leftArgs = left[_i].d;
18669
- var rightArgs = right[_i].d;
18759
+ if (left.length !== right.length) {
18760
+ var merged = mergeMatrices(left, right); // @ts-ignore
18761
+
18762
+ leftResult = [merged[0]]; // @ts-ignore
18763
+
18764
+ rightResult = [merged[1]];
18765
+ types = [['matrix', [merged[2]]]];
18766
+ } else {
18767
+ for (var _i3 = 0; _i3 < left.length; _i3++) {
18768
+ var leftType = left[_i3].t;
18769
+ var rightType = right[_i3].t;
18770
+ var leftArgs = left[_i3].d;
18771
+ var rightArgs = right[_i3].d;
18670
18772
  var leftFunctionData = transformFunctions[leftType];
18671
18773
  var rightFunctionData = transformFunctions[rightType];
18672
18774
  var type = void 0;
18673
18775
 
18674
18776
  if (isMatrixOrPerspective(leftType, rightType)) {
18675
- // const merged = mergeMatrices([left[i]], [right[i]]);
18676
- // leftResult.push(merged[0]);
18677
- // rightResult.push(merged[1]);
18678
- // types.push(['matrix', [merged[2]]]);
18777
+ var _merged = mergeMatrices([left[_i3]], [right[_i3]]); // @ts-ignore
18778
+
18779
+
18780
+ leftResult.push(_merged[0]); // @ts-ignore
18781
+
18782
+ rightResult.push(_merged[1]);
18783
+ types.push(['matrix', [_merged[2]]]);
18679
18784
  continue;
18680
18785
  } else if (leftType === rightType) {
18681
18786
  type = leftType;
@@ -18692,10 +18797,13 @@
18692
18797
 
18693
18798
  rightArgs = rightFunctionData[1](rightArgs);
18694
18799
  } else {
18695
- // const merged = mergeMatrices(left, right);
18696
- // leftResult = [merged[0]];
18697
- // rightResult = [merged[1]];
18698
- // types = [['matrix', [merged[2]]]];
18800
+ var _merged2 = mergeMatrices(left, right); // @ts-ignore
18801
+
18802
+
18803
+ leftResult = [_merged2[0]]; // @ts-ignore
18804
+
18805
+ rightResult = [_merged2[1]];
18806
+ types = [['matrix', [_merged2[2]]]];
18699
18807
  break;
18700
18808
  }
18701
18809
 
@@ -18706,10 +18814,11 @@
18706
18814
  for (var j = 0; j < leftArgs.length; j++) {
18707
18815
  var merge = leftArgs[j].unit === exports.UnitType.kNumber ? mergeNumbers : mergeDimensions; // @ts-ignore
18708
18816
 
18709
- var merged = merge(leftArgs[j], rightArgs[j], target, false, j);
18710
- leftArgsCopy[j] = merged[0];
18711
- rightArgsCopy[j] = merged[1];
18712
- stringConversions.push(merged[2]);
18817
+ var _merged3 = merge(leftArgs[j], rightArgs[j], target, false, j);
18818
+
18819
+ leftArgsCopy[j] = _merged3[0];
18820
+ rightArgsCopy[j] = _merged3[1];
18821
+ stringConversions.push(_merged3[2]);
18713
18822
  }
18714
18823
 
18715
18824
  leftResult.push(leftArgsCopy);
@@ -18850,8 +18959,8 @@
18850
18959
  */
18851
18960
 
18852
18961
  ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
18853
- ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
18854
- ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
18962
+ ElementEvent["BOUNDS_CHANGED"] = "bounds-changed"; // GEOMETRY_BOUNDS_CHANGED = 'geometry-bounds-changed',
18963
+
18855
18964
  /**
18856
18965
  * trigger when z-index changed
18857
18966
  */
@@ -19613,6 +19722,7 @@
19613
19722
  this.localRotation = fromValues$3(0, 0, 0, 1);
19614
19723
  this.localScale = fromValues$1(1, 1, 1);
19615
19724
  this.localTransform = create$1();
19725
+ this.localSkew = fromValues$4(0, 0);
19616
19726
  this.position = fromValues$1(0, 0, 0);
19617
19727
  this.rotation = fromValues$3(0, 0, 0, 1);
19618
19728
  this.scaling = fromValues$1(1, 1, 1);
@@ -21065,7 +21175,8 @@
21065
21175
  fontVariant: '',
21066
21176
  textAlign: '',
21067
21177
  textBaseline: '',
21068
- textTransform: ''
21178
+ textTransform: '',
21179
+ zIndex: ''
21069
21180
  };
21070
21181
  /**
21071
21182
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
@@ -21097,7 +21208,7 @@
21097
21208
  * push to active animations after calling `animate()`
21098
21209
  */
21099
21210
  function DisplayObject(config) {
21100
- var _this$config$capture, _this$config$zIndex, _this$config$interact;
21211
+ var _this$config$capture;
21101
21212
 
21102
21213
  var _this;
21103
21214
 
@@ -21121,10 +21232,7 @@
21121
21232
 
21122
21233
  _this.nodeName = _this.config.type || exports.Shape.GROUP; // compatible with G 3.0
21123
21234
 
21124
- _this.config.style = _extends({}, DEFAULT_STYLE_PROPS, {
21125
- zIndex: (_this$config$zIndex = _this.config.zIndex) !== null && _this$config$zIndex !== void 0 ? _this$config$zIndex : 0,
21126
- interactive: (_this$config$interact = _this.config.interactive) !== null && _this$config$interact !== void 0 ? _this$config$interact : true
21127
- }, _this.config.style, _this.config.attrs);
21235
+ _this.config.style = _extends({}, DEFAULT_STYLE_PROPS, _this.config.style, _this.config.attrs);
21128
21236
 
21129
21237
  if (_this.config.visible != null) {
21130
21238
  _this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
@@ -21255,8 +21363,8 @@
21255
21363
  var oldParsedValue = this.parsedStyle[name];
21256
21364
  this.styleValueRegistry.processProperties(this, (_this$styleValueRegis = {}, _this$styleValueRegis[name] = value, _this$styleValueRegis), parseOptions); // inform clip path targets
21257
21365
 
21258
- if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
21259
- this.attributes.clipPathTargets.forEach(function (target) {
21366
+ if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
21367
+ this.parsedStyle.clipPathTargets.forEach(function (target) {
21260
21368
  dirtifyToRoot(target);
21261
21369
  target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, target, _this2, _this2, 'clipPath', MutationEvent.MODIFICATION, _this2, _this2));
21262
21370
 
@@ -21526,6 +21634,11 @@
21526
21634
  return this;
21527
21635
  };
21528
21636
 
21637
+ _proto.setLocalSkew = function setLocalSkew(skew, y) {
21638
+ this.sceneGraphService.setLocalSkew(this, skew, y);
21639
+ return this;
21640
+ };
21641
+
21529
21642
  _proto.getRotation = function getRotation() {
21530
21643
  return this.sceneGraphService.getRotation(this);
21531
21644
  };
@@ -21534,6 +21647,10 @@
21534
21647
  return this.sceneGraphService.getLocalRotation(this);
21535
21648
  };
21536
21649
 
21650
+ _proto.getLocalSkew = function getLocalSkew() {
21651
+ return this.sceneGraphService.getLocalSkew(this);
21652
+ };
21653
+
21537
21654
  _proto.getLocalTransform = function getLocalTransform() {
21538
21655
  return this.sceneGraphService.getLocalTransform(this);
21539
21656
  };
@@ -21572,10 +21689,10 @@
21572
21689
 
21573
21690
  var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline; // account for clip path, use target's timeline
21574
21691
 
21575
- if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
21692
+ if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
21576
21693
  var _target$ownerDocument;
21577
21694
 
21578
- var target = this.attributes.clipPathTargets[0];
21695
+ var target = this.parsedStyle.clipPathTargets[0];
21579
21696
  timeline = (_target$ownerDocument = target.ownerDocument) === null || _target$ownerDocument === void 0 ? void 0 : _target$ownerDocument.timeline;
21580
21697
  } // clear old parsed transform
21581
21698
 
@@ -21981,9 +22098,7 @@
21981
22098
  style: _extends({
21982
22099
  cx: '',
21983
22100
  cy: '',
21984
- r: '',
21985
- anchor: '0.5 0.5',
21986
- transformOrigin: 'center'
22101
+ r: ''
21987
22102
  }, style)
21988
22103
  }, rest)) || this;
21989
22104
  }
@@ -22006,9 +22121,7 @@
22006
22121
  cx: '',
22007
22122
  cy: '',
22008
22123
  rx: '',
22009
- ry: '',
22010
- anchor: '0.5 0.5',
22011
- transformOrigin: 'center'
22124
+ ry: ''
22012
22125
  }, style)
22013
22126
  }, rest)) || this;
22014
22127
  }
@@ -24523,6 +24636,16 @@
24523
24636
  this.dirtifyLocal(element, transform);
24524
24637
  };
24525
24638
 
24639
+ _proto.setLocalSkew = function setLocalSkew(element, skew, y) {
24640
+ if (typeof skew === 'number') {
24641
+ skew = fromValues$4(skew, y);
24642
+ }
24643
+
24644
+ var transform = element.transformable;
24645
+ copy$4(transform.localSkew, skew);
24646
+ this.dirtifyLocal(element, transform);
24647
+ };
24648
+
24526
24649
  _proto.dirtifyLocal = function dirtifyLocal(element, transform) {
24527
24650
  if (!transform.localDirtyFlag) {
24528
24651
  transform.localDirtyFlag = true;
@@ -24586,11 +24709,37 @@
24586
24709
  return element.transformable.localScale;
24587
24710
  };
24588
24711
 
24712
+ _proto.getLocalSkew = function getLocalSkew(element) {
24713
+ return element.transformable.localSkew;
24714
+ };
24715
+
24716
+ _proto.calcLocalTransform = function calcLocalTransform(transform) {
24717
+ // @see https://github.com/mattdesl/css-mat4/blob/master/index.js
24718
+ // mat4.fromRotationTranslationScaleOrigin(
24719
+ // transform.localTransform,
24720
+ // transform.localRotation,
24721
+ // transform.localPosition,
24722
+ // transform.localScale,
24723
+ // transform.origin,
24724
+ // );
24725
+ fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, fromValues$1(1, 1, 1), transform.origin); // apply skew2D
24726
+
24727
+ if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
24728
+ var tmpMat4 = identity(create$1());
24729
+ tmpMat4[4] = Math.tan(transform.localSkew[0]);
24730
+ tmpMat4[1] = Math.tan(transform.localSkew[1]);
24731
+ multiply(transform.localTransform, transform.localTransform, tmpMat4);
24732
+ }
24733
+
24734
+ var scaling = fromRotationTranslationScaleOrigin(create$1(), fromValues$3(0, 0, 0, 1), create$2(), transform.localScale, transform.origin);
24735
+ multiply(transform.localTransform, transform.localTransform, scaling);
24736
+ };
24737
+
24589
24738
  _proto.getLocalTransform = function getLocalTransform(element) {
24590
24739
  var transform = element.transformable;
24591
24740
 
24592
24741
  if (transform.localDirtyFlag) {
24593
- fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
24742
+ this.calcLocalTransform(transform);
24594
24743
  transform.localDirtyFlag = false;
24595
24744
  }
24596
24745
 
@@ -24610,6 +24759,7 @@
24610
24759
  this.setLocalScale(element, [1, 1, 1]);
24611
24760
  this.setLocalPosition(element, [0, 0, 0]);
24612
24761
  this.setLocalEulerAngles(element, [0, 0, 0]);
24762
+ this.setLocalSkew(element, [0, 0]);
24613
24763
  };
24614
24764
 
24615
24765
  _proto.getTransformedGeometryBounds = function getTransformedGeometryBounds(element, render) {
@@ -24638,8 +24788,9 @@
24638
24788
  }
24639
24789
 
24640
24790
  var geometry = element.geometry;
24641
- var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
24642
- return bounds && new AABB(bounds.center, bounds.halfExtents) || new AABB();
24791
+ var bounds = render ? geometry.renderBounds : geometry.contentBounds || null; // return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
24792
+
24793
+ return bounds || new AABB();
24643
24794
  }
24644
24795
  /**
24645
24796
  * account for children in world space
@@ -24817,7 +24968,7 @@
24817
24968
 
24818
24969
  _proto.sync = function sync(element, transform) {
24819
24970
  if (transform.localDirtyFlag) {
24820
- fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
24971
+ this.calcLocalTransform(transform);
24821
24972
  transform.localDirtyFlag = false;
24822
24973
  }
24823
24974
 
@@ -28242,17 +28393,17 @@
28242
28393
  } // clear ref to old clip path
28243
28394
 
28244
28395
 
28245
- if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
28246
- var index = oldClipPath.style.clipPathTargets.indexOf(object);
28247
- oldClipPath.style.clipPathTargets.splice(index, 1);
28396
+ if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.parsedStyle.clipPathTargets) {
28397
+ var index = oldClipPath.parsedStyle.clipPathTargets.indexOf(object);
28398
+ oldClipPath.parsedStyle.clipPathTargets.splice(index, 1);
28248
28399
  }
28249
28400
 
28250
28401
  if (newClipPath) {
28251
- if (!newClipPath.style.clipPathTargets) {
28252
- newClipPath.style.clipPathTargets = [];
28402
+ if (!newClipPath.parsedStyle.clipPathTargets) {
28403
+ newClipPath.parsedStyle.clipPathTargets = [];
28253
28404
  }
28254
28405
 
28255
- newClipPath.style.clipPathTargets.push(object);
28406
+ newClipPath.parsedStyle.clipPathTargets.push(object);
28256
28407
  }
28257
28408
 
28258
28409
  dirtifyToRoot(object);
@@ -28869,9 +29020,9 @@
28869
29020
  // reset transform
28870
29021
  object.resetLocalTransform();
28871
29022
  object.setLocalPosition(defX, defY);
28872
- transform.forEach(function (_ref) {
28873
- var t = _ref.t,
28874
- d = _ref.d;
29023
+ transform.forEach(function (parsed) {
29024
+ var t = parsed.t,
29025
+ d = parsed.d;
28875
29026
 
28876
29027
  if (t === 'scale') {
28877
29028
  // scale(1) scale(1, 1)
@@ -28937,7 +29088,24 @@
28937
29088
  var _newAngles3 = d || [Odeg];
28938
29089
 
28939
29090
  object.rotateLocal(0, 0, _newAngles3[0].value);
28940
- } else ;
29091
+ } else if (t === 'rotate3d') ; else if (t === 'skew') {
29092
+ var newSkew = d.map(function (s) {
29093
+ return s.value;
29094
+ }) || [0, 0];
29095
+ object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
29096
+ } else if (t === 'skewx') {
29097
+ var _newSkew = d.map(function (s) {
29098
+ return s.value;
29099
+ }) || [0];
29100
+
29101
+ object.setLocalSkew(deg2rad(_newSkew[0]), object.getLocalSkew()[1]);
29102
+ } else if (t === 'skewy') {
29103
+ var _newSkew2 = d.map(function (s) {
29104
+ return s.value;
29105
+ }) || [0];
29106
+
29107
+ object.setLocalSkew(object.getLocalSkew()[0], deg2rad(_newSkew2[0]));
29108
+ }
28941
29109
  });
28942
29110
  }
28943
29111
  };
@@ -29192,13 +29360,25 @@
29192
29360
  name: 'transformOrigin',
29193
29361
  parsePriority: 100,
29194
29362
  // interpolable: true,
29195
- defaultValue: 'left top',
29363
+ defaultValue: function defaultValue(nodeName) {
29364
+ if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
29365
+ return 'center';
29366
+ }
29367
+
29368
+ return 'left top';
29369
+ },
29196
29370
  layoutDependent: true,
29197
29371
  syntax: exports.PropertySyntax.TRANSFORM_ORIGIN
29198
29372
  }, {
29199
29373
  name: 'anchor',
29200
29374
  parsePriority: 99,
29201
- defaultValue: '0 0',
29375
+ defaultValue: function defaultValue(nodeName) {
29376
+ if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
29377
+ return '0.5 0.5';
29378
+ }
29379
+
29380
+ return '0 0';
29381
+ },
29202
29382
  layoutDependent: true,
29203
29383
  syntax: exports.PropertySyntax.LENGTH_PERCENTAGE_12
29204
29384
  }, // <circle> & <ellipse>
@@ -29623,7 +29803,7 @@
29623
29803
  if (value === 'initial') {
29624
29804
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
29625
29805
  if (!isNil(defaultValue)) {
29626
- computed = this.parseProperty(name, defaultValue, object);
29806
+ computed = this.parseProperty(name, isFunction(defaultValue) ? defaultValue(object.nodeName) : defaultValue, object);
29627
29807
  }
29628
29808
  } else if (value === 'inherit') {
29629
29809
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
@@ -29863,8 +30043,8 @@
29863
30043
  var usedOriginYValue = (flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
29864
30044
  usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0].value || 0) * geometry.contentBounds.halfExtents[0] * 2;
29865
30045
  usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1].value || 0) * geometry.contentBounds.halfExtents[1] * 2;
29866
- object.setOrigin(usedOriginXValue, usedOriginYValue);
29867
- object.dispatchEvent(new CustomEvent(exports.ElementEvent.GEOMETRY_BOUNDS_CHANGED));
30046
+ object.setOrigin(usedOriginXValue, usedOriginYValue); // object.dispatchEvent(new CustomEvent(ElementEvent.GEOMETRY_BOUNDS_CHANGED));
30047
+
29868
30048
  dirtifyToRoot(object);
29869
30049
  }
29870
30050
  };
@@ -30064,7 +30244,7 @@
30064
30244
  * only dirty object will cause re-render
30065
30245
  */
30066
30246
  enableDirtyCheck: true,
30067
- enableCulling: true,
30247
+ enableCulling: false,
30068
30248
 
30069
30249
  /**
30070
30250
  * enable auto rendering by default
@@ -30115,7 +30295,7 @@
30115
30295
  return AbstractRenderer;
30116
30296
  }();
30117
30297
 
30118
- let uId=1;const root$1="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},nowOffset=Date.now();let reservedCBs={},lastTime=Date.now();const polyfillRaf=e=>{if("function"!=typeof e)throw new TypeError(e+" is not a function");const o=Date.now(),t=o-lastTime,n=t>16?0:16-t,r=uId++;return reservedCBs[r]=e,Object.keys(reservedCBs).length>1||setTimeout((()=>{lastTime=o;const e=reservedCBs;reservedCBs={},Object.keys(e).forEach((o=>e[o](root$1.performance&&"function"==typeof root$1.performance.now?root$1.performance.now():Date.now()-nowOffset)));}),n),r},polyfillCaf=e=>{delete reservedCBs[e];},vendorPrefixes=["","webkit","moz","ms","o"],getRequestAnimationFrame=e=>"string"!=typeof e?polyfillRaf:""===e?root$1.requestAnimationFrame:root$1[e+"RequestAnimationFrame"],getCancelAnimationFrame=e=>"string"!=typeof e?polyfillCaf:""===e?root$1.cancelAnimationFrame:root$1[e+"CancelAnimationFrame"]||root$1[e+"CancelRequestAnimationFrame"],find=(e,o)=>{let t=0;for(;void 0!==e[t];){if(o(e[t]))return e[t];t+=1;}},vp=find(vendorPrefixes,(e=>!!getRequestAnimationFrame(e))),raf=getRequestAnimationFrame(vp),caf=getCancelAnimationFrame(vp);root$1.requestAnimationFrame=raf,root$1.cancelAnimationFrame=caf,"undefined"!=typeof module&&module.exports&&(module.exports={requestAnimationFrame:raf,cancelAnimationFrame:caf});
30298
+ let uId=1;const root="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},nowOffset=Date.now();let reservedCBs={},lastTime=Date.now();const polyfillRaf=e=>{if("function"!=typeof e)throw new TypeError(e+" is not a function");const o=Date.now(),t=o-lastTime,n=t>16?0:16-t,r=uId++;return reservedCBs[r]=e,Object.keys(reservedCBs).length>1||setTimeout((()=>{lastTime=o;const e=reservedCBs;reservedCBs={},Object.keys(e).forEach((o=>e[o](root.performance&&"function"==typeof root.performance.now?root.performance.now():Date.now()-nowOffset)));}),n),r},polyfillCaf=e=>{delete reservedCBs[e];},vendorPrefixes=["","webkit","moz","ms","o"],getRequestAnimationFrame=e=>"string"!=typeof e?polyfillRaf:""===e?root.requestAnimationFrame:root[e+"RequestAnimationFrame"],getCancelAnimationFrame=e=>"string"!=typeof e?polyfillCaf:""===e?root.cancelAnimationFrame:root[e+"CancelAnimationFrame"]||root[e+"CancelRequestAnimationFrame"],find=(e,o)=>{let t=0;for(;void 0!==e[t];){if(o(e[t]))return e[t];t+=1;}},vp=find(vendorPrefixes,(e=>!!getRequestAnimationFrame(e))),raf=getRequestAnimationFrame(vp),caf=getCancelAnimationFrame(vp);root.requestAnimationFrame=raf,root.cancelAnimationFrame=caf,"undefined"!=typeof module&&module.exports&&(module.exports={requestAnimationFrame:raf,cancelAnimationFrame:caf});
30119
30299
 
30120
30300
  var _class$1;
30121
30301
 
@@ -30138,26 +30318,29 @@
30138
30318
  _proto.apply = function apply(renderingService) {
30139
30319
  var _this = this;
30140
30320
 
30141
- // const strategies = this.strategyProvider.getContributions();
30321
+ var strategies = this.strategyProvider.getContributions();
30142
30322
  renderingService.hooks.cull.tap(CullingPlugin_1.tag, function (object) {
30143
30323
  if (object) {
30144
- var cullable = object.cullable;
30145
- cullable.visible = true; // // const renderBounds = object.getRenderBounds();
30146
- // // if (AABB.isEmpty(renderBounds)) {
30147
- // // cullable.visible = false;
30148
- // // } else {
30149
- // // const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
30150
- // // const [p0, p1, p2, p3] = camera.getFrustum().planes;
30151
- // // tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
30152
- // // cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
30153
- // // }
30154
- // if (strategies.length === 0) {
30155
- // cullable.visible = this.renderingContext.unculledEntities.indexOf(object.entity) > -1;
30324
+ var cullable = object.cullable; // cullable.visible = true;
30325
+ // const renderBounds = object.getRenderBounds();
30326
+ // if (AABB.isEmpty(renderBounds)) {
30327
+ // cullable.visible = false;
30156
30328
  // } else {
30157
- // // eg. implemented by g-webgl(frustum culling)
30158
- // cullable.visible = strategies.every((strategy) => strategy.isVisible(object));
30329
+ // const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
30330
+ // const [p0, p1, p2, p3] = camera.getFrustum().planes;
30331
+ // tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
30332
+ // cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
30159
30333
  // }
30160
30334
 
30335
+ if (strategies.length === 0) {
30336
+ cullable.visible = _this.renderingContext.unculledEntities.indexOf(object.entity) > -1;
30337
+ } else {
30338
+ // eg. implemented by g-webgl(frustum culling)
30339
+ cullable.visible = strategies.every(function (strategy) {
30340
+ return strategy.isVisible(object);
30341
+ });
30342
+ }
30343
+
30161
30344
  if (!cullable.isCulled() && object.isVisible()) {
30162
30345
  return object;
30163
30346
  } else {
@@ -31624,6 +31807,7 @@
31624
31807
  exports.contrib = contrib;
31625
31808
  exports.convertAngleUnit = convertAngleUnit;
31626
31809
  exports.convertEffectInput = convertEffectInput;
31810
+ exports.convertItemToMatrix = convertItemToMatrix;
31627
31811
  exports.convertPercentUnit = convertPercentUnit;
31628
31812
  exports.convertToDash = convertToDash;
31629
31813
  exports.convertToPath = convertToPath;
@@ -31665,6 +31849,7 @@
31665
31849
  exports.makePerspective = makePerspective;
31666
31850
  exports.makeQuerablePromise = makeQuerablePromise;
31667
31851
  exports.makeTiming = makeTiming;
31852
+ exports.memoize = memoize;
31668
31853
  exports.mergeColors = mergeColors;
31669
31854
  exports.mergeDimensionList = mergeDimensionList;
31670
31855
  exports.mergeDimensions = mergeDimensions;