@antv/g 5.0.22-alpha.6 → 5.0.23-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/index.umd.min.js +3 -3
  2. package/es/AbstractRenderer.js +5 -0
  3. package/es/camera/Camera.js +2 -2
  4. package/es/css/cssom/CSSKeywordValue.d.ts +1 -1
  5. package/es/css/cssom/CSSNumericSumValue.d.ts +1 -1
  6. package/es/css/cssom/CSSNumericValue.d.ts +108 -4
  7. package/es/css/cssom/CSSNumericValue.js +908 -5
  8. package/es/css/cssom/CSSNumericValueType.d.ts +1 -1
  9. package/es/css/cssom/CSSNumericValueType.js +1 -1
  10. package/es/css/cssom/CSSTransformValue.d.ts +1 -1
  11. package/es/css/cssom/index.d.ts +0 -9
  12. package/es/css/cssom/index.js +1 -10
  13. package/es/css/parser/color.js +1 -1
  14. package/es/css/parser/dimension.js +1 -2
  15. package/es/css/parser/numeric.js +1 -1
  16. package/es/css/parser/path.d.ts +2 -2
  17. package/es/css/parser/path.js +1 -1
  18. package/es/css/parser/points.js +1 -1
  19. package/es/css/parser/transform-origin.js +1 -1
  20. package/es/css/properties/CSSPropertyPath.d.ts +14 -2
  21. package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -2
  22. package/es/css/properties/CSSPropertyTransform.js +1 -2
  23. package/es/display-objects/DisplayObject.js +4 -5
  24. package/es/display-objects/Path.d.ts +15 -15
  25. package/es/display-objects/Path.js +1 -1
  26. package/es/display-objects/Polygon.d.ts +8 -1
  27. package/es/display-objects/Polyline.d.ts +7 -5
  28. package/es/dom/Document.js +2 -2
  29. package/es/dom/Element.js +1 -2
  30. package/es/dom/EventTarget.js +1 -1
  31. package/es/dom/FederatedTouchEvent.d.ts +5 -3
  32. package/es/plugins/CullingPlugin.d.ts +0 -1
  33. package/es/plugins/CullingPlugin.js +3 -8
  34. package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
  35. package/es/plugins/DirtyCheckPlugin.js +9 -8
  36. package/es/plugins/EventPlugin.d.ts +1 -1
  37. package/es/plugins/EventPlugin.js +163 -148
  38. package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
  39. package/es/plugins/PrepareRendererPlugin.js +15 -16
  40. package/es/services/EventService.d.ts +8 -0
  41. package/es/services/EventService.js +274 -20
  42. package/es/services/RenderingService.d.ts +17 -16
  43. package/es/services/RenderingService.js +18 -17
  44. package/es/services/SceneGraphService.js +1 -1
  45. package/es/services/aabb/PathUpdater.d.ts +3 -3
  46. package/es/services/aabb/PolylineUpdater.d.ts +3 -3
  47. package/es/services/aabb/RectUpdater.js +1 -1
  48. package/es/types.d.ts +5 -3
  49. package/es/utils/assert.d.ts +6 -0
  50. package/es/utils/assert.js +18 -0
  51. package/es/utils/event.d.ts +18 -16
  52. package/es/utils/hooks.d.ts +280 -0
  53. package/es/utils/hooks.js +753 -0
  54. package/es/utils/index.d.ts +1 -0
  55. package/es/utils/index.js +2 -1
  56. package/es/utils/math.d.ts +1 -0
  57. package/es/utils/math.js +13 -2
  58. package/es/utils/string.d.ts +1 -0
  59. package/es/utils/string.js +8 -0
  60. package/es/utils/text.js +2 -1
  61. package/lib/AbstractRenderer.js +5 -0
  62. package/lib/camera/Camera.js +4 -4
  63. package/lib/css/cssom/CSSKeywordValue.d.ts +1 -1
  64. package/lib/css/cssom/CSSNumericSumValue.d.ts +1 -1
  65. package/lib/css/cssom/CSSNumericValue.d.ts +108 -4
  66. package/lib/css/cssom/CSSNumericValue.js +965 -52
  67. package/lib/css/cssom/CSSNumericValueType.d.ts +1 -1
  68. package/lib/css/cssom/CSSNumericValueType.js +59 -59
  69. package/lib/css/cssom/CSSTransformValue.d.ts +1 -1
  70. package/lib/css/cssom/index.d.ts +0 -9
  71. package/lib/css/cssom/index.js +0 -117
  72. package/lib/css/parser/color.js +5 -5
  73. package/lib/css/parser/dimension.js +1 -3
  74. package/lib/css/parser/numeric.js +3 -3
  75. package/lib/css/parser/path.d.ts +2 -2
  76. package/lib/css/parser/path.js +4 -4
  77. package/lib/css/parser/points.js +2 -2
  78. package/lib/css/parser/transform-origin.js +2 -2
  79. package/lib/css/properties/CSSPropertyPath.d.ts +14 -2
  80. package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -2
  81. package/lib/css/properties/CSSPropertyTransform.js +0 -2
  82. package/lib/display-objects/DisplayObject.js +7 -9
  83. package/lib/display-objects/Path.d.ts +15 -15
  84. package/lib/display-objects/Path.js +3 -3
  85. package/lib/display-objects/Polygon.d.ts +8 -1
  86. package/lib/display-objects/Polyline.d.ts +7 -5
  87. package/lib/dom/Document.js +2 -2
  88. package/lib/dom/Element.js +1 -3
  89. package/lib/dom/EventTarget.js +9 -9
  90. package/lib/dom/FederatedTouchEvent.d.ts +5 -3
  91. package/lib/plugins/CullingPlugin.d.ts +0 -1
  92. package/lib/plugins/CullingPlugin.js +3 -7
  93. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
  94. package/lib/plugins/DirtyCheckPlugin.js +10 -8
  95. package/lib/plugins/EventPlugin.d.ts +1 -1
  96. package/lib/plugins/EventPlugin.js +172 -156
  97. package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
  98. package/lib/plugins/PrepareRendererPlugin.js +14 -14
  99. package/lib/services/EventService.d.ts +8 -0
  100. package/lib/services/EventService.js +274 -19
  101. package/lib/services/RenderingService.d.ts +17 -16
  102. package/lib/services/RenderingService.js +19 -18
  103. package/lib/services/SceneGraphService.js +3 -3
  104. package/lib/services/aabb/PathUpdater.d.ts +3 -3
  105. package/lib/services/aabb/PolylineUpdater.d.ts +3 -3
  106. package/lib/services/aabb/RectUpdater.js +3 -3
  107. package/lib/types.d.ts +5 -3
  108. package/lib/utils/assert.d.ts +6 -0
  109. package/lib/utils/assert.js +30 -0
  110. package/lib/utils/event.d.ts +18 -16
  111. package/lib/utils/hooks.d.ts +280 -0
  112. package/lib/utils/hooks.js +759 -0
  113. package/lib/utils/index.d.ts +1 -0
  114. package/lib/utils/index.js +13 -0
  115. package/lib/utils/math.d.ts +1 -0
  116. package/lib/utils/math.js +17 -4
  117. package/lib/utils/string.d.ts +1 -0
  118. package/lib/utils/string.js +11 -0
  119. package/lib/utils/text.js +5 -3
  120. package/package.json +4 -7
  121. package/es/css/cssom/CSSMathInvert.d.ts +0 -14
  122. package/es/css/cssom/CSSMathInvert.js +0 -84
  123. package/es/css/cssom/CSSMathMax.d.ts +0 -17
  124. package/es/css/cssom/CSSMathMax.js +0 -118
  125. package/es/css/cssom/CSSMathMin.d.ts +0 -17
  126. package/es/css/cssom/CSSMathMin.js +0 -119
  127. package/es/css/cssom/CSSMathNegate.d.ts +0 -14
  128. package/es/css/cssom/CSSMathNegate.js +0 -80
  129. package/es/css/cssom/CSSMathProduct.d.ts +0 -16
  130. package/es/css/cssom/CSSMathProduct.js +0 -109
  131. package/es/css/cssom/CSSMathSum.d.ts +0 -17
  132. package/es/css/cssom/CSSMathSum.js +0 -117
  133. package/es/css/cssom/CSSMathValue.d.ts +0 -11
  134. package/es/css/cssom/CSSMathValue.js +0 -27
  135. package/es/css/cssom/CSSMathVariadic.d.ts +0 -9
  136. package/es/css/cssom/CSSMathVariadic.js +0 -44
  137. package/es/css/cssom/CSSUnitValue.d.ts +0 -33
  138. package/es/css/cssom/CSSUnitValue.js +0 -252
  139. package/lib/css/cssom/CSSMathInvert.d.ts +0 -14
  140. package/lib/css/cssom/CSSMathInvert.js +0 -94
  141. package/lib/css/cssom/CSSMathMax.d.ts +0 -17
  142. package/lib/css/cssom/CSSMathMax.js +0 -128
  143. package/lib/css/cssom/CSSMathMin.d.ts +0 -17
  144. package/lib/css/cssom/CSSMathMin.js +0 -128
  145. package/lib/css/cssom/CSSMathNegate.d.ts +0 -14
  146. package/lib/css/cssom/CSSMathNegate.js +0 -89
  147. package/lib/css/cssom/CSSMathProduct.d.ts +0 -16
  148. package/lib/css/cssom/CSSMathProduct.js +0 -119
  149. package/lib/css/cssom/CSSMathSum.d.ts +0 -17
  150. package/lib/css/cssom/CSSMathSum.js +0 -129
  151. package/lib/css/cssom/CSSMathValue.d.ts +0 -11
  152. package/lib/css/cssom/CSSMathValue.js +0 -35
  153. package/lib/css/cssom/CSSMathVariadic.d.ts +0 -9
  154. package/lib/css/cssom/CSSMathVariadic.js +0 -55
  155. package/lib/css/cssom/CSSUnitValue.d.ts +0 -33
  156. package/lib/css/cssom/CSSUnitValue.js +0 -267
@@ -1,7 +1,9 @@
1
- import { __extends, __read, __spreadArray, __values } from "tslib";
2
- import { DCHECK } from '../../utils';
3
- import { CSSStyleValue } from './CSSStyleValue';
4
- import { UnitType, CSSStyleValueType, BaseType, baseTypeToString, CSSUnitValue, CSSMathOperator, CSSMathInvert, CSSMathMax, CSSMathMin, CSSMathNegate, CSSMathSum, CSSMathProduct } from '.';
1
+ import { __assign, __extends, __read, __spreadArray, __values } from "tslib";
2
+ import { DCHECK, DCHECK_NE } from '../../utils';
3
+ import { CSSMathOperator } from './CSSMathOperator';
4
+ import { BaseType, baseTypeToString, CSSNumericValueType } from './CSSNumericValueType';
5
+ import { CSSStyleValue, CSSStyleValueType } from './CSSStyleValue';
6
+ import { Nested, ParenLess, UnitType } from './types';
5
7
  /**
6
8
  * CSSNumericValue is the base class for numeric and length typed CSS Values.
7
9
  * @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
@@ -497,4 +499,905 @@ function maybeMultiplyAsUnitValue(values) {
497
499
  }
498
500
 
499
501
  return new CSSUnitValue(final_value, unit_other_than_number);
500
- }
502
+ }
503
+ /**
504
+ * Represents numeric values that can be expressed as a single number plus a
505
+ * unit (or a naked number or percentage).
506
+ * @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
507
+ */
508
+
509
+
510
+ var CSSUnitValue =
511
+ /** @class */
512
+ function (_super) {
513
+ __extends(CSSUnitValue, _super);
514
+
515
+ function CSSUnitValue(value, unitOrName) {
516
+ if (unitOrName === void 0) {
517
+ unitOrName = UnitType.kNumber;
518
+ }
519
+
520
+ var _this = this;
521
+
522
+ var unit;
523
+
524
+ if (typeof unitOrName === 'string') {
525
+ unit = CSSUnitValue.unitFromName(unitOrName);
526
+ } else {
527
+ unit = unitOrName;
528
+ }
529
+
530
+ DCHECK(CSSUnitValue.isValidUnit(unit));
531
+ _this = _super.call(this, new CSSNumericValueType(unit)) || this;
532
+ _this.unit = unit;
533
+ _this.value = value;
534
+ return _this;
535
+ } // static fromCSSValue(value: CSSNumericLiteralValue) {
536
+ // let unit = value.type;
537
+ // if (unit === UnitType.kInteger) unit = UnitType.kNumber;
538
+ // if (!this.isValidUnit(unit)) return null;
539
+ // return new CSSUnitValue(value.getDoubleValue(), unit);
540
+ // }
541
+
542
+
543
+ CSSUnitValue.toCanonicalUnit = function (unit) {
544
+ return this.canonicalUnitTypeForCategory(this.unitTypeToUnitCategory(unit));
545
+ };
546
+
547
+ CSSUnitValue.toCanonicalUnitIfPossible = function (unit) {
548
+ var canonical_unit = this.toCanonicalUnit(unit);
549
+ if (canonical_unit === UnitType.kUnknown) return unit;
550
+ return canonical_unit;
551
+ };
552
+
553
+ CSSUnitValue.formatInfinityOrNaN = function (number, suffix) {
554
+ if (suffix === void 0) {
555
+ suffix = '';
556
+ }
557
+
558
+ var result = '';
559
+
560
+ if (!Number.isFinite(number)) {
561
+ if (number > 0) result = 'infinity';else result = '-infinity';
562
+ } else {
563
+ DCHECK(Number.isNaN(number));
564
+ result = 'NaN';
565
+ }
566
+
567
+ return result += suffix;
568
+ };
569
+
570
+ CSSUnitValue.formatNumber = function (number, suffix) {
571
+ if (suffix === void 0) {
572
+ suffix = '';
573
+ }
574
+
575
+ return number + suffix;
576
+ };
577
+
578
+ CSSUnitValue.prototype.clone = function () {
579
+ return new CSSUnitValue(this.value, this.unit);
580
+ };
581
+
582
+ CSSUnitValue.prototype.convertTo = function (target_unit) {
583
+ if (this.unit === target_unit) {
584
+ return new CSSUnitValue(this.value, this.unit);
585
+ } // Instead of defining the scale factors for every unit to every other unit,
586
+ // we simply convert to the canonical unit and back since we already have
587
+ // the scale factors for canonical units.
588
+
589
+
590
+ var canonical_unit = CSSUnitValue.toCanonicalUnit(this.unit);
591
+
592
+ if (canonical_unit !== CSSUnitValue.toCanonicalUnit(target_unit) || canonical_unit === UnitType.kUnknown) {
593
+ return null;
594
+ }
595
+
596
+ var scale_factor = CSSStyleValue.conversionToCanonicalUnitsScaleFactor(this.unit) / CSSStyleValue.conversionToCanonicalUnitsScaleFactor(target_unit);
597
+ return new CSSUnitValue(this.value * scale_factor, target_unit);
598
+ };
599
+
600
+ CSSUnitValue.prototype.equals = function (other) {
601
+ var other_unit_value = other;
602
+ return this.value === other_unit_value.value && this.unit === other_unit_value.unit;
603
+ };
604
+
605
+ CSSUnitValue.prototype.getType = function () {
606
+ return CSSStyleValueType.kUnitType;
607
+ }; // toCSSValue() {
608
+ // return new CSSNumericLiteralValue(this.value, this.unit);
609
+ // }
610
+ // // const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final;
611
+ // toCalcExpressionNode() {
612
+ // return CSSMathExpressionNumericLiteral.create(
613
+ // new CSSNumericLiteralValue(this.value, this.unit),
614
+ // );
615
+ // }
616
+
617
+
618
+ CSSUnitValue.prototype.sumValue = function () {
619
+ var sum = [];
620
+ var unit_map = {};
621
+
622
+ if (this.unit !== UnitType.kNumber) {
623
+ unit_map[CSSUnitValue.toCanonicalUnitIfPossible(this.unit)] = 1;
624
+ }
625
+
626
+ sum.push({
627
+ value: this.value * CSSStyleValue.conversionToCanonicalUnitsScaleFactor(this.unit),
628
+ units: unit_map
629
+ });
630
+ return sum;
631
+ };
632
+
633
+ CSSUnitValue.prototype.negate = function () {
634
+ return new CSSUnitValue(-this.value, this.unit);
635
+ };
636
+
637
+ CSSUnitValue.prototype.invert = function () {
638
+ if (this.unit === UnitType.kNumber) {
639
+ if (this.value === 0) return null;
640
+ return new CSSUnitValue(1.0 / this.value, this.unit);
641
+ }
642
+
643
+ return CSSMathInvert.create(this);
644
+ };
645
+
646
+ CSSUnitValue.prototype.buildCSSText = function (n, p, result) {
647
+ var text;
648
+
649
+ switch (this.unit) {
650
+ case UnitType.kUnknown:
651
+ // FIXME
652
+ break;
653
+
654
+ case UnitType.kInteger:
655
+ text = Number(this.value).toFixed(0);
656
+ break;
657
+
658
+ case UnitType.kNumber:
659
+ case UnitType.kPercentage:
660
+ case UnitType.kEms:
661
+ case UnitType.kQuirkyEms:
662
+ case UnitType.kExs:
663
+ case UnitType.kRems:
664
+ case UnitType.kChs:
665
+ case UnitType.kPixels:
666
+ case UnitType.kCentimeters:
667
+ case UnitType.kDotsPerPixel:
668
+ case UnitType.kDotsPerInch:
669
+ case UnitType.kDotsPerCentimeter:
670
+ case UnitType.kMillimeters:
671
+ case UnitType.kQuarterMillimeters:
672
+ case UnitType.kInches:
673
+ case UnitType.kPoints:
674
+ case UnitType.kPicas:
675
+ case UnitType.kUserUnits:
676
+ case UnitType.kDegrees:
677
+ case UnitType.kRadians:
678
+ case UnitType.kGradians:
679
+ case UnitType.kMilliseconds:
680
+ case UnitType.kSeconds:
681
+ case UnitType.kHertz:
682
+ case UnitType.kKilohertz:
683
+ case UnitType.kTurns:
684
+ case UnitType.kFraction:
685
+ case UnitType.kViewportWidth:
686
+ case UnitType.kViewportHeight:
687
+ case UnitType.kViewportInlineSize:
688
+ case UnitType.kViewportBlockSize:
689
+ case UnitType.kViewportMin:
690
+ case UnitType.kViewportMax:
691
+ case UnitType.kSmallViewportWidth:
692
+ case UnitType.kSmallViewportHeight:
693
+ case UnitType.kSmallViewportInlineSize:
694
+ case UnitType.kSmallViewportBlockSize:
695
+ case UnitType.kSmallViewportMin:
696
+ case UnitType.kSmallViewportMax:
697
+ case UnitType.kLargeViewportWidth:
698
+ case UnitType.kLargeViewportHeight:
699
+ case UnitType.kLargeViewportInlineSize:
700
+ case UnitType.kLargeViewportBlockSize:
701
+ case UnitType.kLargeViewportMin:
702
+ case UnitType.kLargeViewportMax:
703
+ case UnitType.kDynamicViewportWidth:
704
+ case UnitType.kDynamicViewportHeight:
705
+ case UnitType.kDynamicViewportInlineSize:
706
+ case UnitType.kDynamicViewportBlockSize:
707
+ case UnitType.kDynamicViewportMin:
708
+ case UnitType.kDynamicViewportMax:
709
+ case UnitType.kContainerWidth:
710
+ case UnitType.kContainerHeight:
711
+ case UnitType.kContainerInlineSize:
712
+ case UnitType.kContainerBlockSize:
713
+ case UnitType.kContainerMin:
714
+ case UnitType.kContainerMax:
715
+ {
716
+ var kMinInteger = -999999;
717
+ var kMaxInteger = 999999;
718
+ var value = this.value;
719
+ var unit = CSSUnitValue.unitTypeToString(this.unit);
720
+
721
+ if (value < kMinInteger || value > kMaxInteger) {
722
+ var unit_1 = CSSUnitValue.unitTypeToString(this.unit);
723
+
724
+ if (!Number.isFinite(value) || Number.isNaN(value)) {
725
+ text = CSSUnitValue.formatInfinityOrNaN(value, unit_1);
726
+ } else {
727
+ text = CSSUnitValue.formatNumber(value, unit_1);
728
+ }
729
+ } else {
730
+ text = "".concat(value).concat(unit);
731
+ }
732
+ }
733
+ }
734
+
735
+ result += text;
736
+ return result;
737
+ };
738
+
739
+ return CSSUnitValue;
740
+ }(CSSNumericValue);
741
+
742
+ export { CSSUnitValue };
743
+ /**
744
+ * The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
745
+ *
746
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
747
+ * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
748
+ */
749
+
750
+ var CSSMathValue =
751
+ /** @class */
752
+ function (_super) {
753
+ __extends(CSSMathValue, _super);
754
+
755
+ function CSSMathValue() {
756
+ return _super !== null && _super.apply(this, arguments) || this;
757
+ } // From CSSNumericValue
758
+
759
+
760
+ CSSMathValue.prototype.isUnitValue = function () {
761
+ return false;
762
+ };
763
+
764
+ return CSSMathValue;
765
+ }(CSSNumericValue);
766
+
767
+ export { CSSMathValue };
768
+
769
+ var CSSMathInvert =
770
+ /** @class */
771
+ function (_super) {
772
+ __extends(CSSMathInvert, _super);
773
+
774
+ function CSSMathInvert(value, type) {
775
+ var _this = _super.call(this, type) || this;
776
+
777
+ _this.value = value;
778
+ _this.operator = 'invert';
779
+ return _this;
780
+ }
781
+
782
+ CSSMathInvert.create = function (value) {
783
+ var type = CSSNumericValueType.negateExponents(value.type_);
784
+ return new CSSMathInvert(value, type);
785
+ };
786
+
787
+ CSSMathInvert.prototype.clone = function () {
788
+ return new CSSMathInvert(this.value, this.type_);
789
+ };
790
+
791
+ CSSMathInvert.prototype.getType = function () {
792
+ return CSSStyleValueType.kInvertType;
793
+ };
794
+
795
+ CSSMathInvert.prototype.equals = function (other) {
796
+ if (other.getType() !== CSSStyleValueType.kInvertType) {
797
+ return false;
798
+ } // We can safely cast here as we know 'other' has the same type as us.
799
+
800
+
801
+ var other_invert = other;
802
+ return this.value.equals(other_invert.value);
803
+ };
804
+
805
+ CSSMathInvert.prototype.sumValue = function () {
806
+ var sum = this.value.sumValue();
807
+
808
+ if (sum.length === 0 || sum.length !== 1 || sum[0].value === 0) {
809
+ return null;
810
+ }
811
+
812
+ Object.keys(sum[0].units).forEach(function (key) {
813
+ sum[0].units[key] *= -1;
814
+ });
815
+ sum[0].value = 1.0 / sum[0].value;
816
+ return sum;
817
+ }; // toCalcExpressionNode(): CSSMathExpressionNode {
818
+ // const right_side = this.value.toCalcExpressionNode();
819
+ // if (!right_side) {
820
+ // return null;
821
+ // }
822
+ // // return CSSMathExpressionOperation::CreateArithmeticOperation(
823
+ // // CSSMathExpressionNumericLiteral::Create(
824
+ // // 1, UnitType.kNumber),
825
+ // // right_side, CSSMathOperator.kDivide);
826
+ // return null;
827
+ // }
828
+
829
+
830
+ CSSMathInvert.prototype.buildCSSText = function (nested, paren_less, result) {
831
+ if (paren_less == ParenLess.kNo) {
832
+ result += nested === Nested.kYes ? '(' : 'calc(';
833
+ }
834
+
835
+ result += '1 / ';
836
+ result = this.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
837
+
838
+ if (paren_less === ParenLess.kNo) {
839
+ result += ')';
840
+ }
841
+
842
+ return result;
843
+ };
844
+
845
+ return CSSMathInvert;
846
+ }(CSSMathValue);
847
+
848
+ export { CSSMathInvert };
849
+
850
+ var CSSMathNegate =
851
+ /** @class */
852
+ function (_super) {
853
+ __extends(CSSMathNegate, _super);
854
+
855
+ function CSSMathNegate(value, type) {
856
+ var _this = _super.call(this, type) || this;
857
+
858
+ _this.value = value;
859
+ _this.operator = 'negate';
860
+ return _this;
861
+ }
862
+
863
+ CSSMathNegate.create = function (value) {
864
+ return new CSSMathNegate(value, value.type_);
865
+ };
866
+
867
+ CSSMathNegate.prototype.clone = function () {
868
+ return new CSSMathNegate(this.value, this.type_);
869
+ };
870
+
871
+ CSSMathNegate.prototype.getType = function () {
872
+ return CSSStyleValueType.kNegateType;
873
+ };
874
+
875
+ CSSMathNegate.prototype.equals = function (other) {
876
+ if (other.getType() !== CSSStyleValueType.kNegateType) {
877
+ return false;
878
+ }
879
+
880
+ var other_invert = other;
881
+ return this.value.equals(other_invert.value);
882
+ };
883
+
884
+ CSSMathNegate.prototype.sumValue = function () {
885
+ var sum = this.value.sumValue();
886
+
887
+ if (sum.length === 0) {
888
+ return null;
889
+ }
890
+
891
+ sum.forEach(function (term) {
892
+ term.value *= -1;
893
+ });
894
+ return sum;
895
+ }; // toCalcExpressionNode(): CSSMathExpressionNode {
896
+ // const right_side = this.value.toCalcExpressionNode();
897
+ // if (!right_side) {
898
+ // return null;
899
+ // }
900
+ // // return CSSMathExpressionOperation::CreateArithmeticOperationSimplified(
901
+ // // CSSMathExpressionNumericLiteral::Create(
902
+ // // -1, CSSPrimitiveValue::UnitType::kNumber),
903
+ // // right_side, CSSMathOperator::kMultiply);
904
+ // }
905
+
906
+
907
+ CSSMathNegate.prototype.buildCSSText = function (nested, paren_less, result) {
908
+ if (paren_less == ParenLess.kNo) {
909
+ result += nested === Nested.kYes ? '(' : 'calc(';
910
+ }
911
+
912
+ result += '-';
913
+ result = this.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
914
+
915
+ if (paren_less === ParenLess.kNo) {
916
+ result += ')';
917
+ }
918
+
919
+ return result;
920
+ };
921
+
922
+ return CSSMathNegate;
923
+ }(CSSMathValue);
924
+
925
+ export { CSSMathNegate };
926
+ export function typeCheck(values, op, error) {
927
+ error = false;
928
+ var final_type = values[0].type_;
929
+
930
+ for (var i = 1; i < values.length; i++) {
931
+ final_type = op(final_type, values[i].type_, error);
932
+ if (error) return final_type;
933
+ }
934
+
935
+ return final_type;
936
+ } // Represents an arithmetic operation with one or more CSSNumericValues.
937
+
938
+ var CSSMathVariadic =
939
+ /** @class */
940
+ function (_super) {
941
+ __extends(CSSMathVariadic, _super);
942
+
943
+ function CSSMathVariadic(values, type) {
944
+ var _this = _super.call(this, type) || this;
945
+
946
+ _this.values = values;
947
+ return _this;
948
+ }
949
+
950
+ CSSMathVariadic.prototype.numericValues = function () {
951
+ return this.values;
952
+ };
953
+
954
+ CSSMathVariadic.prototype.equals = function (other) {
955
+ if (this.getType() !== other.getType()) {
956
+ return false;
957
+ }
958
+
959
+ return this.values.every(function (value, i) {
960
+ return value.equals(other.values[i]);
961
+ });
962
+ };
963
+
964
+ return CSSMathVariadic;
965
+ }(CSSMathValue);
966
+
967
+ export { CSSMathVariadic }; // Represents the minimum of one or more CSSNumericValues.
968
+ // @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
969
+
970
+ var CSSMathMin =
971
+ /** @class */
972
+ function (_super) {
973
+ __extends(CSSMathMin, _super);
974
+
975
+ function CSSMathMin() {
976
+ var _this = _super !== null && _super.apply(this, arguments) || this;
977
+
978
+ _this.operator = 'min';
979
+ return _this;
980
+ }
981
+
982
+ CSSMathMin.create = function (values) {
983
+ var error = false;
984
+ var final_type = typeCheck(values, CSSNumericValueType.add, error);
985
+ return error ? null : new CSSMathMin(values, final_type);
986
+ };
987
+
988
+ CSSMathMin.prototype.clone = function () {
989
+ return new CSSMathMin(this.values, this.type_);
990
+ };
991
+
992
+ CSSMathMin.prototype.getType = function () {
993
+ return CSSStyleValueType.kMinType;
994
+ };
995
+
996
+ CSSMathMin.prototype.sumValue = function () {
997
+ var e_4, _a;
998
+
999
+ var cur_min = this.numericValues()[0].sumValue();
1000
+
1001
+ if (!cur_min.length) {
1002
+ return null;
1003
+ }
1004
+
1005
+ try {
1006
+ for (var _b = __values(this.numericValues()), _c = _b.next(); !_c.done; _c = _b.next()) {
1007
+ var value = _c.value;
1008
+ var child_sum = value.sumValue();
1009
+
1010
+ if (!child_sum.length || JSON.stringify(child_sum[0].units) !== JSON.stringify(cur_min[0].units)) {
1011
+ return null;
1012
+ }
1013
+
1014
+ if (child_sum[0].value < cur_min[0].value) {
1015
+ cur_min = child_sum;
1016
+ }
1017
+ }
1018
+ } catch (e_4_1) {
1019
+ e_4 = {
1020
+ error: e_4_1
1021
+ };
1022
+ } finally {
1023
+ try {
1024
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1025
+ } finally {
1026
+ if (e_4) throw e_4.error;
1027
+ }
1028
+ }
1029
+
1030
+ return cur_min;
1031
+ }; // toCalcExpressionNode() {
1032
+ // const operands: CSSMathExpressionOperation[] = [];
1033
+ // for (const value of this.numericValues()) {
1034
+ // const operand = value.toCalcExpressionNode();
1035
+ // if (!operand) {
1036
+ // continue;
1037
+ // }
1038
+ // operands.push(operand as CSSMathExpressionOperation);
1039
+ // }
1040
+ // return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMin);
1041
+ // }
1042
+
1043
+
1044
+ CSSMathMin.prototype.buildCSSText = function (nested, paren_less, result) {
1045
+ var e_5, _a;
1046
+
1047
+ result += 'min(';
1048
+ var first_iteration = true;
1049
+
1050
+ try {
1051
+ for (var _b = __values(this.numericValues()), _c = _b.next(); !_c.done; _c = _b.next()) {
1052
+ var value = _c.value;
1053
+ if (!first_iteration) result += ', ';
1054
+ first_iteration = false;
1055
+ result = value.buildCSSText(Nested.kYes, ParenLess.kYes, result);
1056
+ }
1057
+ } catch (e_5_1) {
1058
+ e_5 = {
1059
+ error: e_5_1
1060
+ };
1061
+ } finally {
1062
+ try {
1063
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1064
+ } finally {
1065
+ if (e_5) throw e_5.error;
1066
+ }
1067
+ }
1068
+
1069
+ result += ')';
1070
+ return result;
1071
+ };
1072
+
1073
+ return CSSMathMin;
1074
+ }(CSSMathVariadic);
1075
+
1076
+ export { CSSMathMin }; // Represents the maximum of one or more CSSNumericValues.
1077
+ // @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
1078
+
1079
+ var CSSMathMax =
1080
+ /** @class */
1081
+ function (_super) {
1082
+ __extends(CSSMathMax, _super);
1083
+
1084
+ function CSSMathMax() {
1085
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1086
+
1087
+ _this.operator = 'max';
1088
+ return _this;
1089
+ }
1090
+
1091
+ CSSMathMax.create = function (values) {
1092
+ var error = false;
1093
+ var final_type = typeCheck(values, CSSNumericValueType.add, error);
1094
+ return error ? null : new CSSMathMax(values, final_type);
1095
+ };
1096
+
1097
+ CSSMathMax.prototype.clone = function () {
1098
+ return new CSSMathMax(this.values, this.type_);
1099
+ };
1100
+
1101
+ CSSMathMax.prototype.getType = function () {
1102
+ return CSSStyleValueType.kMaxType;
1103
+ };
1104
+
1105
+ CSSMathMax.prototype.sumValue = function () {
1106
+ var e_6, _a;
1107
+
1108
+ var cur_max = this.numericValues()[0].sumValue();
1109
+
1110
+ if (!cur_max.length) {
1111
+ return null;
1112
+ }
1113
+
1114
+ try {
1115
+ for (var _b = __values(this.numericValues()), _c = _b.next(); !_c.done; _c = _b.next()) {
1116
+ var value = _c.value;
1117
+ var child_sum = value.sumValue();
1118
+
1119
+ if (!child_sum.length || JSON.stringify(child_sum[0].units) !== JSON.stringify(cur_max[0].units)) {
1120
+ return null;
1121
+ }
1122
+
1123
+ if (child_sum[0].value < cur_max[0].value) {
1124
+ cur_max = child_sum;
1125
+ }
1126
+ }
1127
+ } catch (e_6_1) {
1128
+ e_6 = {
1129
+ error: e_6_1
1130
+ };
1131
+ } finally {
1132
+ try {
1133
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1134
+ } finally {
1135
+ if (e_6) throw e_6.error;
1136
+ }
1137
+ }
1138
+
1139
+ return cur_max;
1140
+ }; // toCalcExpressionNode() {
1141
+ // const operands: CSSMathExpressionOperation[] = [];
1142
+ // for (const value of this.numericValues()) {
1143
+ // const operand = value.toCalcExpressionNode();
1144
+ // if (!operand) {
1145
+ // continue;
1146
+ // }
1147
+ // operands.push(operand as CSSMathExpressionOperation);
1148
+ // }
1149
+ // return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMax);
1150
+ // }
1151
+
1152
+
1153
+ CSSMathMax.prototype.buildCSSText = function (nested, paren_less, result) {
1154
+ var e_7, _a;
1155
+
1156
+ result += 'max(';
1157
+ var first_iteration = true;
1158
+
1159
+ try {
1160
+ for (var _b = __values(this.numericValues()), _c = _b.next(); !_c.done; _c = _b.next()) {
1161
+ var value = _c.value;
1162
+ if (!first_iteration) result += ', ';
1163
+ first_iteration = false;
1164
+ result = value.buildCSSText(Nested.kYes, ParenLess.kYes, result);
1165
+ }
1166
+ } catch (e_7_1) {
1167
+ e_7 = {
1168
+ error: e_7_1
1169
+ };
1170
+ } finally {
1171
+ try {
1172
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1173
+ } finally {
1174
+ if (e_7) throw e_7.error;
1175
+ }
1176
+ }
1177
+
1178
+ result += ')';
1179
+ return result;
1180
+ };
1181
+
1182
+ return CSSMathMax;
1183
+ }(CSSMathVariadic);
1184
+
1185
+ export { CSSMathMax };
1186
+ /**
1187
+ * Represents the sum of one or more CSSNumericValues.
1188
+ * @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
1189
+ */
1190
+
1191
+ var CSSMathSum =
1192
+ /** @class */
1193
+ function (_super) {
1194
+ __extends(CSSMathSum, _super);
1195
+
1196
+ function CSSMathSum() {
1197
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1198
+
1199
+ _this.operator = 'sum';
1200
+ return _this;
1201
+ }
1202
+
1203
+ CSSMathSum.create = function (values) {
1204
+ var error = false;
1205
+ var finalType = typeCheck(values, CSSNumericValueType.add, error);
1206
+ return error ? null : new CSSMathSum(values, finalType);
1207
+ };
1208
+
1209
+ CSSMathSum.numericTypeFromUnitMap = function (units) {
1210
+ var type = new CSSNumericValueType();
1211
+ Object.keys(units).forEach(function (key) {
1212
+ var exp = units[key];
1213
+ var error = false;
1214
+ type = CSSNumericValueType.multiply(type, new CSSNumericValueType(Number(key), exp), error);
1215
+ DCHECK(!error);
1216
+ });
1217
+ return type;
1218
+ };
1219
+
1220
+ CSSMathSum.canCreateNumericTypeFromSumValue = function (sum) {
1221
+ var _this = this;
1222
+
1223
+ DCHECK(!!sum.length);
1224
+ var first_type = this.numericTypeFromUnitMap(sum[0].units);
1225
+ return sum.every(function (term) {
1226
+ var error = false;
1227
+ CSSNumericValueType.add(first_type, _this.numericTypeFromUnitMap(term.units), error);
1228
+ return !error;
1229
+ });
1230
+ };
1231
+
1232
+ CSSMathSum.prototype.clone = function () {
1233
+ return new CSSMathSum(this.values, this.type_);
1234
+ };
1235
+
1236
+ CSSMathSum.prototype.getType = function () {
1237
+ return CSSStyleValueType.kSumType;
1238
+ }; // toCalcExpressionNode() {
1239
+ // return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kAdd);
1240
+ // }
1241
+
1242
+
1243
+ CSSMathSum.prototype.sumValue = function () {
1244
+ var sum = [];
1245
+ this.numericValues().forEach(function (value) {
1246
+ var child_sum = value.sumValue();
1247
+
1248
+ if (!child_sum.length) {
1249
+ return null;
1250
+ }
1251
+
1252
+ child_sum.forEach(function (term) {
1253
+ var index = sum.findIndex(function (s) {
1254
+ return JSON.stringify(s.units) === JSON.stringify(term.units);
1255
+ });
1256
+
1257
+ if (index === -1) {
1258
+ sum.push(__assign({}, term));
1259
+ } else {
1260
+ sum[index].value += term.value;
1261
+ }
1262
+ });
1263
+ });
1264
+ if (!CSSMathSum.canCreateNumericTypeFromSumValue(sum)) return null;
1265
+ return sum;
1266
+ };
1267
+
1268
+ CSSMathSum.prototype.buildCSSText = function (nested, paren_less, result) {
1269
+ if (paren_less == ParenLess.kNo) {
1270
+ result += nested === Nested.kYes ? '(' : 'calc(';
1271
+ }
1272
+
1273
+ var values = this.numericValues();
1274
+ result = values[0].buildCSSText(Nested.kYes, ParenLess.kNo, result);
1275
+
1276
+ for (var i = 1; i < values.length; i++) {
1277
+ var arg = values[i];
1278
+
1279
+ if (arg.getType() === CSSStyleValueType.kNegateType) {
1280
+ result += ' - ';
1281
+ result = arg.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
1282
+ } else {
1283
+ result += ' + ';
1284
+ result = arg.buildCSSText(Nested.kYes, ParenLess.kNo, result);
1285
+ }
1286
+ }
1287
+
1288
+ if (paren_less === ParenLess.kNo) {
1289
+ result += ')';
1290
+ }
1291
+
1292
+ return result;
1293
+ };
1294
+
1295
+ return CSSMathSum;
1296
+ }(CSSMathVariadic);
1297
+
1298
+ export { CSSMathSum };
1299
+ /**
1300
+ * Represents the product of one or more CSSNumericValues.
1301
+ * @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct
1302
+ */
1303
+
1304
+ var CSSMathProduct =
1305
+ /** @class */
1306
+ function (_super) {
1307
+ __extends(CSSMathProduct, _super);
1308
+
1309
+ function CSSMathProduct() {
1310
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1311
+
1312
+ _this.operator = 'product';
1313
+ return _this;
1314
+ }
1315
+
1316
+ CSSMathProduct.create = function (values) {
1317
+ var error = false;
1318
+ var finalType = typeCheck(values, CSSNumericValueType.multiply, error);
1319
+ return error ? null : new CSSMathProduct(values, finalType);
1320
+ };
1321
+
1322
+ CSSMathProduct.multiplyUnitMaps = function (a, b) {
1323
+ Object.keys(b).forEach(function (key) {
1324
+ DCHECK_NE(b[key].value, 0);
1325
+ var old_value = key in a ? a[key].value : 0;
1326
+
1327
+ if (old_value + b[key].value === 0) {
1328
+ delete a[key];
1329
+ } else {
1330
+ a[key] = old_value + b[key].value;
1331
+ }
1332
+ });
1333
+ return a;
1334
+ };
1335
+
1336
+ CSSMathProduct.prototype.clone = function () {
1337
+ return new CSSMathProduct(this.values, this.type_);
1338
+ };
1339
+
1340
+ CSSMathProduct.prototype.getType = function () {
1341
+ return CSSStyleValueType.kProductType;
1342
+ }; // toCalcExpressionNode() {
1343
+ // return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kMultiply);
1344
+ // }
1345
+
1346
+
1347
+ CSSMathProduct.prototype.sumValue = function () {
1348
+ var sum = [{
1349
+ value: 1,
1350
+ units: {}
1351
+ }];
1352
+ this.numericValues().forEach(function (value) {
1353
+ var child_sum = value.sumValue();
1354
+
1355
+ if (!child_sum.length) {
1356
+ return null;
1357
+ }
1358
+
1359
+ var new_sum = [];
1360
+ sum.forEach(function (a) {
1361
+ child_sum.forEach(function (b) {
1362
+ new_sum.push({
1363
+ value: a.value * b.value,
1364
+ units: CSSMathProduct.multiplyUnitMaps(a.units, b.units)
1365
+ });
1366
+ });
1367
+ });
1368
+ sum = new_sum;
1369
+ });
1370
+ return sum;
1371
+ };
1372
+
1373
+ CSSMathProduct.prototype.buildCSSText = function (nested, paren_less, result) {
1374
+ if (paren_less == ParenLess.kNo) {
1375
+ result += nested === Nested.kYes ? '(' : 'calc(';
1376
+ }
1377
+
1378
+ var values = this.numericValues();
1379
+ result = values[0].buildCSSText(Nested.kYes, ParenLess.kNo, result);
1380
+
1381
+ for (var i = 1; i < values.length; i++) {
1382
+ var arg = values[i];
1383
+
1384
+ if (arg.getType() === CSSStyleValueType.kInvertType) {
1385
+ result += ' / ';
1386
+ result = arg.value.buildCSSText(Nested.kYes, ParenLess.kNo, result);
1387
+ } else {
1388
+ result += ' * ';
1389
+ result = arg.buildCSSText(Nested.kYes, ParenLess.kNo, result);
1390
+ }
1391
+ }
1392
+
1393
+ if (paren_less === ParenLess.kNo) {
1394
+ result += ')';
1395
+ }
1396
+
1397
+ return result;
1398
+ };
1399
+
1400
+ return CSSMathProduct;
1401
+ }(CSSMathVariadic);
1402
+
1403
+ export { CSSMathProduct };