@uxbertlabs/reportly 1.0.4 → 1.0.5

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.
@@ -346,24 +346,26 @@ class Modal {
346
346
  }
347
347
 
348
348
  class Toolbar {
349
+ // private currentTool: AnnotationTool;
350
+ // private currentColor: string;
349
351
  constructor(callbacks) {
350
352
  this.callbacks = callbacks;
351
353
  this.toolbar = null;
352
354
  this.toggleButton = null;
353
355
  this.isToolbarExpanded = false;
354
- this.currentTool = 'pen';
355
- this.currentColor = '#ef4444';
356
+ // this.currentTool = "pen";
357
+ // this.currentColor = "#ef4444";
356
358
  }
357
359
  create() {
358
360
  // Create toggle button
359
- this.toggleButton = document.createElement('button');
360
- this.toggleButton.className = 'uxbert-toolbar-toggle';
361
- this.toggleButton.innerHTML = '🛠️';
362
- this.toggleButton.title = 'Toggle Annotation Tools';
361
+ this.toggleButton = document.createElement("button");
362
+ this.toggleButton.className = "uxbert-toolbar-toggle";
363
+ this.toggleButton.innerHTML = "🛠️";
364
+ this.toggleButton.title = "Toggle Annotation Tools";
363
365
  document.body.appendChild(this.toggleButton);
364
366
  // Create toolbar
365
- this.toolbar = document.createElement('div');
366
- this.toolbar.className = 'uxbert-toolbar';
367
+ this.toolbar = document.createElement("div");
368
+ this.toolbar.className = "uxbert-toolbar";
367
369
  this.toolbar.innerHTML = `
368
370
  <div class="uxbert-toolbar-header">
369
371
  <div class="uxbert-toolbar-title">Annotation Tools</div>
@@ -403,19 +405,19 @@ class Toolbar {
403
405
  if (!this.toolbar || !this.toggleButton)
404
406
  return;
405
407
  // Toggle button
406
- this.toggleButton.addEventListener('click', () => {
408
+ this.toggleButton.addEventListener("click", () => {
407
409
  this.toggleToolbar();
408
410
  });
409
411
  // Minimize button
410
- const minimizeBtn = this.toolbar.querySelector('#uxbert-minimize-btn');
411
- minimizeBtn.addEventListener('click', () => {
412
+ const minimizeBtn = this.toolbar.querySelector("#uxbert-minimize-btn");
413
+ minimizeBtn.addEventListener("click", () => {
412
414
  this.toggleToolbar();
413
415
  });
414
416
  // Tool buttons
415
- const toolBtns = this.toolbar.querySelectorAll('[data-tool]');
416
- toolBtns.forEach(btn => {
417
- btn.addEventListener('click', () => {
418
- const tool = btn.getAttribute('data-tool');
417
+ const toolBtns = this.toolbar.querySelectorAll("[data-tool]");
418
+ toolBtns.forEach((btn) => {
419
+ btn.addEventListener("click", () => {
420
+ const tool = btn.getAttribute("data-tool");
419
421
  this.setTool(tool);
420
422
  if (this.callbacks.onToolChange) {
421
423
  this.callbacks.onToolChange(tool);
@@ -423,10 +425,10 @@ class Toolbar {
423
425
  });
424
426
  });
425
427
  // Color buttons
426
- const colorBtns = this.toolbar.querySelectorAll('[data-color]');
427
- colorBtns.forEach(btn => {
428
- btn.addEventListener('click', () => {
429
- const color = btn.getAttribute('data-color');
428
+ const colorBtns = this.toolbar.querySelectorAll("[data-color]");
429
+ colorBtns.forEach((btn) => {
430
+ btn.addEventListener("click", () => {
431
+ const color = btn.getAttribute("data-color");
430
432
  this.setColor(color);
431
433
  if (this.callbacks.onColorChange) {
432
434
  this.callbacks.onColorChange(color);
@@ -434,57 +436,57 @@ class Toolbar {
434
436
  });
435
437
  });
436
438
  // Action buttons
437
- const undoBtn = this.toolbar.querySelector('#uxbert-undo-btn');
438
- undoBtn.addEventListener('click', () => {
439
+ const undoBtn = this.toolbar.querySelector("#uxbert-undo-btn");
440
+ undoBtn.addEventListener("click", () => {
439
441
  if (this.callbacks.onUndo) {
440
442
  this.callbacks.onUndo();
441
443
  }
442
444
  });
443
- const clearBtn = this.toolbar.querySelector('#uxbert-clear-btn');
444
- clearBtn.addEventListener('click', () => {
445
+ const clearBtn = this.toolbar.querySelector("#uxbert-clear-btn");
446
+ clearBtn.addEventListener("click", () => {
445
447
  if (this.callbacks.onClear) {
446
448
  this.callbacks.onClear();
447
449
  }
448
450
  });
449
- const doneBtn = this.toolbar.querySelector('#uxbert-done-btn');
450
- doneBtn.addEventListener('click', () => {
451
+ const doneBtn = this.toolbar.querySelector("#uxbert-done-btn");
452
+ doneBtn.addEventListener("click", () => {
451
453
  if (this.callbacks.onDone) {
452
454
  this.callbacks.onDone();
453
455
  }
454
456
  });
455
457
  // Exit button
456
- const exitBtn = this.toolbar.querySelector('#uxbert-exit-btn');
457
- exitBtn.addEventListener('click', () => {
458
+ const exitBtn = this.toolbar.querySelector("#uxbert-exit-btn");
459
+ exitBtn.addEventListener("click", () => {
458
460
  if (this.callbacks.onExit) {
459
461
  this.callbacks.onExit();
460
462
  }
461
463
  });
462
464
  }
463
465
  setTool(tool) {
464
- this.currentTool = tool;
466
+ // this.currentTool = tool;
465
467
  if (!this.toolbar)
466
468
  return;
467
- const toolBtns = this.toolbar.querySelectorAll('[data-tool]');
468
- toolBtns.forEach(btn => {
469
- if (btn.getAttribute('data-tool') === tool) {
470
- btn.classList.add('active');
469
+ const toolBtns = this.toolbar.querySelectorAll("[data-tool]");
470
+ toolBtns.forEach((btn) => {
471
+ if (btn.getAttribute("data-tool") === tool) {
472
+ btn.classList.add("active");
471
473
  }
472
474
  else {
473
- btn.classList.remove('active');
475
+ btn.classList.remove("active");
474
476
  }
475
477
  });
476
478
  }
477
479
  setColor(color) {
478
- this.currentColor = color;
480
+ // this.currentColor = color;
479
481
  if (!this.toolbar)
480
482
  return;
481
- const colorBtns = this.toolbar.querySelectorAll('[data-color]');
482
- colorBtns.forEach(btn => {
483
- if (btn.getAttribute('data-color') === color) {
484
- btn.classList.add('active');
483
+ const colorBtns = this.toolbar.querySelectorAll("[data-color]");
484
+ colorBtns.forEach((btn) => {
485
+ if (btn.getAttribute("data-color") === color) {
486
+ btn.classList.add("active");
485
487
  }
486
488
  else {
487
- btn.classList.remove('active');
489
+ btn.classList.remove("active");
488
490
  }
489
491
  });
490
492
  }
@@ -493,40 +495,40 @@ class Toolbar {
493
495
  return;
494
496
  this.isToolbarExpanded = !this.isToolbarExpanded;
495
497
  if (this.isToolbarExpanded) {
496
- this.toolbar.classList.add('expanded');
497
- this.toggleButton.classList.add('hidden');
498
+ this.toolbar.classList.add("expanded");
499
+ this.toggleButton.classList.add("hidden");
498
500
  }
499
501
  else {
500
- this.toolbar.classList.remove('expanded');
501
- this.toggleButton.classList.remove('hidden');
502
+ this.toolbar.classList.remove("expanded");
503
+ this.toggleButton.classList.remove("hidden");
502
504
  }
503
505
  }
504
506
  show() {
505
507
  if (this.toolbar && this.toggleButton) {
506
- this.toolbar.classList.add('active');
507
- this.toggleButton.classList.add('active');
508
+ this.toolbar.classList.add("active");
509
+ this.toggleButton.classList.add("active");
508
510
  // Use setTimeout to ensure DOM is ready before checking width and applying classes
509
511
  setTimeout(() => {
510
512
  // Auto-expand on desktop, collapsed on mobile
511
513
  if (window.innerWidth > 768) {
512
514
  this.isToolbarExpanded = true;
513
- this.toolbar.classList.add('expanded');
514
- this.toggleButton.classList.add('hidden');
515
+ this.toolbar.classList.add("expanded");
516
+ this.toggleButton.classList.add("hidden");
515
517
  }
516
518
  else {
517
519
  this.isToolbarExpanded = false;
518
- this.toolbar.classList.remove('expanded');
519
- this.toggleButton.classList.remove('hidden');
520
+ this.toolbar.classList.remove("expanded");
521
+ this.toggleButton.classList.remove("hidden");
520
522
  }
521
523
  }, 50);
522
524
  }
523
525
  }
524
526
  hide() {
525
527
  if (this.toolbar && this.toggleButton) {
526
- this.toolbar.classList.remove('active');
527
- this.toolbar.classList.remove('expanded');
528
- this.toggleButton.classList.remove('active');
529
- this.toggleButton.classList.remove('hidden');
528
+ this.toolbar.classList.remove("active");
529
+ this.toolbar.classList.remove("expanded");
530
+ this.toggleButton.classList.remove("active");
531
+ this.toggleButton.classList.remove("hidden");
530
532
  this.isToolbarExpanded = false;
531
533
  }
532
534
  }
@@ -543,11 +545,11 @@ class Toolbar {
543
545
  }
544
546
 
545
547
  /*!
546
- * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
547
- * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
548
+ * html2canvas-pro 1.5.12 <https://yorickshan.github.io/html2canvas-pro/>
549
+ * Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
548
550
  * Released under MIT License
549
551
  */
550
- /*! *****************************************************************************
552
+ /******************************************************************************
551
553
  Copyright (c) Microsoft Corporation.
552
554
 
553
555
  Permission to use, copy, modify, and/or distribute this software for any
@@ -561,7 +563,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
561
563
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
562
564
  PERFORMANCE OF THIS SOFTWARE.
563
565
  ***************************************************************************** */
564
- /* global Reflect, Promise */
566
+ /* global Reflect, Promise, SuppressedError, Symbol */
565
567
 
566
568
  var extendStatics = function(d, b) {
567
569
  extendStatics = Object.setPrototypeOf ||
@@ -605,7 +607,7 @@ function __generator(thisArg, body) {
605
607
  function verb(n) { return function (v) { return step([n, v]); }; }
606
608
  function step(op) {
607
609
  if (f) throw new TypeError("Generator is already executing.");
608
- while (_) try {
610
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
609
611
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
610
612
  if (y = 0, t) op = [op[0] & 2, t.value];
611
613
  switch (op[0]) {
@@ -634,8 +636,13 @@ function __spreadArray(to, from, pack) {
634
636
  ar[i] = from[i];
635
637
  }
636
638
  }
637
- return to.concat(ar || from);
638
- }
639
+ return to.concat(ar || Array.prototype.slice.call(from));
640
+ }
641
+
642
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
643
+ var e = new Error(message);
644
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
645
+ };
639
646
 
640
647
  var Bounds = /** @class */ (function () {
641
648
  function Bounds(left, top, width, height) {
@@ -1530,38 +1537,38 @@ var stringToNumber = function (codePoints) {
1530
1537
  return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);
1531
1538
  };
1532
1539
  var LEFT_PARENTHESIS_TOKEN = {
1533
- type: 2 /* LEFT_PARENTHESIS_TOKEN */
1540
+ type: 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */
1534
1541
  };
1535
1542
  var RIGHT_PARENTHESIS_TOKEN = {
1536
- type: 3 /* RIGHT_PARENTHESIS_TOKEN */
1537
- };
1538
- var COMMA_TOKEN = { type: 4 /* COMMA_TOKEN */ };
1539
- var SUFFIX_MATCH_TOKEN = { type: 13 /* SUFFIX_MATCH_TOKEN */ };
1540
- var PREFIX_MATCH_TOKEN = { type: 8 /* PREFIX_MATCH_TOKEN */ };
1541
- var COLUMN_TOKEN = { type: 21 /* COLUMN_TOKEN */ };
1542
- var DASH_MATCH_TOKEN = { type: 9 /* DASH_MATCH_TOKEN */ };
1543
- var INCLUDE_MATCH_TOKEN = { type: 10 /* INCLUDE_MATCH_TOKEN */ };
1543
+ type: 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */
1544
+ };
1545
+ var COMMA_TOKEN = { type: 4 /* TokenType.COMMA_TOKEN */ };
1546
+ var SUFFIX_MATCH_TOKEN = { type: 13 /* TokenType.SUFFIX_MATCH_TOKEN */ };
1547
+ var PREFIX_MATCH_TOKEN = { type: 8 /* TokenType.PREFIX_MATCH_TOKEN */ };
1548
+ var COLUMN_TOKEN = { type: 21 /* TokenType.COLUMN_TOKEN */ };
1549
+ var DASH_MATCH_TOKEN = { type: 9 /* TokenType.DASH_MATCH_TOKEN */ };
1550
+ var INCLUDE_MATCH_TOKEN = { type: 10 /* TokenType.INCLUDE_MATCH_TOKEN */ };
1544
1551
  var LEFT_CURLY_BRACKET_TOKEN = {
1545
- type: 11 /* LEFT_CURLY_BRACKET_TOKEN */
1552
+ type: 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */
1546
1553
  };
1547
1554
  var RIGHT_CURLY_BRACKET_TOKEN = {
1548
- type: 12 /* RIGHT_CURLY_BRACKET_TOKEN */
1549
- };
1550
- var SUBSTRING_MATCH_TOKEN = { type: 14 /* SUBSTRING_MATCH_TOKEN */ };
1551
- var BAD_URL_TOKEN = { type: 23 /* BAD_URL_TOKEN */ };
1552
- var BAD_STRING_TOKEN = { type: 1 /* BAD_STRING_TOKEN */ };
1553
- var CDO_TOKEN = { type: 25 /* CDO_TOKEN */ };
1554
- var CDC_TOKEN = { type: 24 /* CDC_TOKEN */ };
1555
- var COLON_TOKEN = { type: 26 /* COLON_TOKEN */ };
1556
- var SEMICOLON_TOKEN = { type: 27 /* SEMICOLON_TOKEN */ };
1555
+ type: 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */
1556
+ };
1557
+ var SUBSTRING_MATCH_TOKEN = { type: 14 /* TokenType.SUBSTRING_MATCH_TOKEN */ };
1558
+ var BAD_URL_TOKEN = { type: 23 /* TokenType.BAD_URL_TOKEN */ };
1559
+ var BAD_STRING_TOKEN = { type: 1 /* TokenType.BAD_STRING_TOKEN */ };
1560
+ var CDO_TOKEN = { type: 25 /* TokenType.CDO_TOKEN */ };
1561
+ var CDC_TOKEN = { type: 24 /* TokenType.CDC_TOKEN */ };
1562
+ var COLON_TOKEN = { type: 26 /* TokenType.COLON_TOKEN */ };
1563
+ var SEMICOLON_TOKEN = { type: 27 /* TokenType.SEMICOLON_TOKEN */ };
1557
1564
  var LEFT_SQUARE_BRACKET_TOKEN = {
1558
- type: 28 /* LEFT_SQUARE_BRACKET_TOKEN */
1565
+ type: 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */
1559
1566
  };
1560
1567
  var RIGHT_SQUARE_BRACKET_TOKEN = {
1561
- type: 29 /* RIGHT_SQUARE_BRACKET_TOKEN */
1568
+ type: 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */
1562
1569
  };
1563
- var WHITESPACE_TOKEN = { type: 31 /* WHITESPACE_TOKEN */ };
1564
- var EOF_TOKEN = { type: 32 /* EOF_TOKEN */ };
1570
+ var WHITESPACE_TOKEN = { type: 31 /* TokenType.WHITESPACE_TOKEN */ };
1571
+ var EOF_TOKEN = { type: 32 /* TokenType.EOF_TOKEN */ };
1565
1572
  var Tokenizer = /** @class */ (function () {
1566
1573
  function Tokenizer() {
1567
1574
  this._value = [];
@@ -1590,7 +1597,7 @@ var Tokenizer = /** @class */ (function () {
1590
1597
  if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {
1591
1598
  var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;
1592
1599
  var value = this.consumeName();
1593
- return { type: 5 /* HASH_TOKEN */, value: value, flags: flags };
1600
+ return { type: 5 /* TokenType.HASH_TOKEN */, value: value, flags: flags };
1594
1601
  }
1595
1602
  break;
1596
1603
  case DOLLAR_SIGN:
@@ -1679,7 +1686,7 @@ var Tokenizer = /** @class */ (function () {
1679
1686
  var a3 = this.peekCodePoint(2);
1680
1687
  if (isIdentifierStart(a1, a2, a3)) {
1681
1688
  var value = this.consumeName();
1682
- return { type: 7 /* AT_KEYWORD_TOKEN */, value: value };
1689
+ return { type: 7 /* TokenType.AT_KEYWORD_TOKEN */, value: value };
1683
1690
  }
1684
1691
  break;
1685
1692
  case LEFT_SQUARE_BRACKET:
@@ -1743,7 +1750,7 @@ var Tokenizer = /** @class */ (function () {
1743
1750
  this.reconsumeCodePoint(codePoint);
1744
1751
  return this.consumeIdentLikeToken();
1745
1752
  }
1746
- return { type: 6 /* DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
1753
+ return { type: 6 /* TokenType.DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
1747
1754
  };
1748
1755
  Tokenizer.prototype.consumeCodePoint = function () {
1749
1756
  var value = this._value.shift();
@@ -1774,7 +1781,7 @@ var Tokenizer = /** @class */ (function () {
1774
1781
  if (questionMarks) {
1775
1782
  var start_1 = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);
1776
1783
  var end = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);
1777
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start_1, end: end };
1784
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start_1, end: end };
1778
1785
  }
1779
1786
  var start = parseInt(fromCodePoint$1.apply(void 0, digits), 16);
1780
1787
  if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {
@@ -1786,10 +1793,10 @@ var Tokenizer = /** @class */ (function () {
1786
1793
  codePoint = this.consumeCodePoint();
1787
1794
  }
1788
1795
  var end = parseInt(fromCodePoint$1.apply(void 0, endDigits), 16);
1789
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: end };
1796
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start, end: end };
1790
1797
  }
1791
1798
  else {
1792
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: start };
1799
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start, end: start };
1793
1800
  }
1794
1801
  };
1795
1802
  Tokenizer.prototype.consumeIdentLikeToken = function () {
@@ -1800,24 +1807,24 @@ var Tokenizer = /** @class */ (function () {
1800
1807
  }
1801
1808
  else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {
1802
1809
  this.consumeCodePoint();
1803
- return { type: 19 /* FUNCTION_TOKEN */, value: value };
1810
+ return { type: 19 /* TokenType.FUNCTION_TOKEN */, value: value };
1804
1811
  }
1805
- return { type: 20 /* IDENT_TOKEN */, value: value };
1812
+ return { type: 20 /* TokenType.IDENT_TOKEN */, value: value };
1806
1813
  };
1807
1814
  Tokenizer.prototype.consumeUrlToken = function () {
1808
1815
  var value = [];
1809
1816
  this.consumeWhiteSpace();
1810
1817
  if (this.peekCodePoint(0) === EOF) {
1811
- return { type: 22 /* URL_TOKEN */, value: '' };
1818
+ return { type: 22 /* TokenType.URL_TOKEN */, value: '' };
1812
1819
  }
1813
1820
  var next = this.peekCodePoint(0);
1814
1821
  if (next === APOSTROPHE || next === QUOTATION_MARK) {
1815
1822
  var stringToken = this.consumeStringToken(this.consumeCodePoint());
1816
- if (stringToken.type === 0 /* STRING_TOKEN */) {
1823
+ if (stringToken.type === 0 /* TokenType.STRING_TOKEN */) {
1817
1824
  this.consumeWhiteSpace();
1818
1825
  if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
1819
1826
  this.consumeCodePoint();
1820
- return { type: 22 /* URL_TOKEN */, value: stringToken.value };
1827
+ return { type: 22 /* TokenType.URL_TOKEN */, value: stringToken.value };
1821
1828
  }
1822
1829
  }
1823
1830
  this.consumeBadUrlRemnants();
@@ -1826,13 +1833,13 @@ var Tokenizer = /** @class */ (function () {
1826
1833
  while (true) {
1827
1834
  var codePoint = this.consumeCodePoint();
1828
1835
  if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {
1829
- return { type: 22 /* URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1836
+ return { type: 22 /* TokenType.URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1830
1837
  }
1831
1838
  else if (isWhiteSpace(codePoint)) {
1832
1839
  this.consumeWhiteSpace();
1833
1840
  if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
1834
1841
  this.consumeCodePoint();
1835
- return { type: 22 /* URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1842
+ return { type: 22 /* TokenType.URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1836
1843
  }
1837
1844
  this.consumeBadUrlRemnants();
1838
1845
  return BAD_URL_TOKEN;
@@ -1892,7 +1899,7 @@ var Tokenizer = /** @class */ (function () {
1892
1899
  var codePoint = this._value[i];
1893
1900
  if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {
1894
1901
  value += this.consumeStringSlice(i);
1895
- return { type: 0 /* STRING_TOKEN */, value: value };
1902
+ return { type: 0 /* TokenType.STRING_TOKEN */, value: value };
1896
1903
  }
1897
1904
  if (codePoint === LINE_FEED) {
1898
1905
  this._value.splice(0, i);
@@ -1954,13 +1961,13 @@ var Tokenizer = /** @class */ (function () {
1954
1961
  var c3 = this.peekCodePoint(2);
1955
1962
  if (isIdentifierStart(c1, c2, c3)) {
1956
1963
  var unit = this.consumeName();
1957
- return { type: 15 /* DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
1964
+ return { type: 15 /* TokenType.DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
1958
1965
  }
1959
1966
  if (c1 === PERCENTAGE_SIGN) {
1960
1967
  this.consumeCodePoint();
1961
- return { type: 16 /* PERCENTAGE_TOKEN */, number: number, flags: flags };
1968
+ return { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number: number, flags: flags };
1962
1969
  }
1963
- return { type: 17 /* NUMBER_TOKEN */, number: number, flags: flags };
1970
+ return { type: 17 /* TokenType.NUMBER_TOKEN */, number: number, flags: flags };
1964
1971
  };
1965
1972
  Tokenizer.prototype.consumeEscapedCodePoint = function () {
1966
1973
  var codePoint = this.consumeCodePoint();
@@ -2019,18 +2026,18 @@ var Parser = /** @class */ (function () {
2019
2026
  };
2020
2027
  Parser.prototype.parseComponentValue = function () {
2021
2028
  var token = this.consumeToken();
2022
- while (token.type === 31 /* WHITESPACE_TOKEN */) {
2029
+ while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */) {
2023
2030
  token = this.consumeToken();
2024
2031
  }
2025
- if (token.type === 32 /* EOF_TOKEN */) {
2032
+ if (token.type === 32 /* TokenType.EOF_TOKEN */) {
2026
2033
  throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
2027
2034
  }
2028
2035
  this.reconsumeToken(token);
2029
2036
  var value = this.consumeComponentValue();
2030
2037
  do {
2031
2038
  token = this.consumeToken();
2032
- } while (token.type === 31 /* WHITESPACE_TOKEN */);
2033
- if (token.type === 32 /* EOF_TOKEN */) {
2039
+ } while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */);
2040
+ if (token.type === 32 /* TokenType.EOF_TOKEN */) {
2034
2041
  return value;
2035
2042
  }
2036
2043
  throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
@@ -2039,7 +2046,7 @@ var Parser = /** @class */ (function () {
2039
2046
  var values = [];
2040
2047
  while (true) {
2041
2048
  var value = this.consumeComponentValue();
2042
- if (value.type === 32 /* EOF_TOKEN */) {
2049
+ if (value.type === 32 /* TokenType.EOF_TOKEN */) {
2043
2050
  return values;
2044
2051
  }
2045
2052
  values.push(value);
@@ -2049,11 +2056,11 @@ var Parser = /** @class */ (function () {
2049
2056
  Parser.prototype.consumeComponentValue = function () {
2050
2057
  var token = this.consumeToken();
2051
2058
  switch (token.type) {
2052
- case 11 /* LEFT_CURLY_BRACKET_TOKEN */:
2053
- case 28 /* LEFT_SQUARE_BRACKET_TOKEN */:
2054
- case 2 /* LEFT_PARENTHESIS_TOKEN */:
2059
+ case 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */:
2060
+ case 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */:
2061
+ case 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */:
2055
2062
  return this.consumeSimpleBlock(token.type);
2056
- case 19 /* FUNCTION_TOKEN */:
2063
+ case 19 /* TokenType.FUNCTION_TOKEN */:
2057
2064
  return this.consumeFunction(token);
2058
2065
  }
2059
2066
  return token;
@@ -2062,7 +2069,7 @@ var Parser = /** @class */ (function () {
2062
2069
  var block = { type: type, values: [] };
2063
2070
  var token = this.consumeToken();
2064
2071
  while (true) {
2065
- if (token.type === 32 /* EOF_TOKEN */ || isEndingTokenFor(token, type)) {
2072
+ if (token.type === 32 /* TokenType.EOF_TOKEN */ || isEndingTokenFor(token, type)) {
2066
2073
  return block;
2067
2074
  }
2068
2075
  this.reconsumeToken(token);
@@ -2074,11 +2081,11 @@ var Parser = /** @class */ (function () {
2074
2081
  var cssFunction = {
2075
2082
  name: functionToken.value,
2076
2083
  values: [],
2077
- type: 18 /* FUNCTION */
2084
+ type: 18 /* TokenType.FUNCTION */
2078
2085
  };
2079
2086
  while (true) {
2080
2087
  var token = this.consumeToken();
2081
- if (token.type === 32 /* EOF_TOKEN */ || token.type === 3 /* RIGHT_PARENTHESIS_TOKEN */) {
2088
+ if (token.type === 32 /* TokenType.EOF_TOKEN */ || token.type === 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */) {
2082
2089
  return cssFunction;
2083
2090
  }
2084
2091
  this.reconsumeToken(token);
@@ -2094,22 +2101,22 @@ var Parser = /** @class */ (function () {
2094
2101
  };
2095
2102
  return Parser;
2096
2103
  }());
2097
- var isDimensionToken = function (token) { return token.type === 15 /* DIMENSION_TOKEN */; };
2098
- var isNumberToken = function (token) { return token.type === 17 /* NUMBER_TOKEN */; };
2099
- var isIdentToken = function (token) { return token.type === 20 /* IDENT_TOKEN */; };
2100
- var isStringToken = function (token) { return token.type === 0 /* STRING_TOKEN */; };
2104
+ var isDimensionToken = function (token) { return token.type === 15 /* TokenType.DIMENSION_TOKEN */; };
2105
+ var isNumberToken = function (token) { return token.type === 17 /* TokenType.NUMBER_TOKEN */; };
2106
+ var isIdentToken = function (token) { return token.type === 20 /* TokenType.IDENT_TOKEN */; };
2107
+ var isStringToken = function (token) { return token.type === 0 /* TokenType.STRING_TOKEN */; };
2101
2108
  var isIdentWithValue = function (token, value) {
2102
2109
  return isIdentToken(token) && token.value === value;
2103
2110
  };
2104
- var nonWhiteSpace = function (token) { return token.type !== 31 /* WHITESPACE_TOKEN */; };
2111
+ var nonWhiteSpace = function (token) { return token.type !== 31 /* TokenType.WHITESPACE_TOKEN */; };
2105
2112
  var nonFunctionArgSeparator = function (token) {
2106
- return token.type !== 31 /* WHITESPACE_TOKEN */ && token.type !== 4 /* COMMA_TOKEN */;
2113
+ return token.type !== 31 /* TokenType.WHITESPACE_TOKEN */ && token.type !== 4 /* TokenType.COMMA_TOKEN */;
2107
2114
  };
2108
2115
  var parseFunctionArgs = function (tokens) {
2109
2116
  var args = [];
2110
2117
  var arg = [];
2111
2118
  tokens.forEach(function (token) {
2112
- if (token.type === 4 /* COMMA_TOKEN */) {
2119
+ if (token.type === 4 /* TokenType.COMMA_TOKEN */) {
2113
2120
  if (arg.length === 0) {
2114
2121
  throw new Error("Error parsing function args, zero tokens for arg");
2115
2122
  }
@@ -2117,7 +2124,7 @@ var parseFunctionArgs = function (tokens) {
2117
2124
  arg = [];
2118
2125
  return;
2119
2126
  }
2120
- if (token.type !== 31 /* WHITESPACE_TOKEN */) {
2127
+ if (token.type !== 31 /* TokenType.WHITESPACE_TOKEN */) {
2121
2128
  arg.push(token);
2122
2129
  }
2123
2130
  });
@@ -2127,37 +2134,37 @@ var parseFunctionArgs = function (tokens) {
2127
2134
  return args;
2128
2135
  };
2129
2136
  var isEndingTokenFor = function (token, type) {
2130
- if (type === 11 /* LEFT_CURLY_BRACKET_TOKEN */ && token.type === 12 /* RIGHT_CURLY_BRACKET_TOKEN */) {
2137
+ if (type === 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */ && token.type === 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */) {
2131
2138
  return true;
2132
2139
  }
2133
- if (type === 28 /* LEFT_SQUARE_BRACKET_TOKEN */ && token.type === 29 /* RIGHT_SQUARE_BRACKET_TOKEN */) {
2140
+ if (type === 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */ && token.type === 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */) {
2134
2141
  return true;
2135
2142
  }
2136
- return type === 2 /* LEFT_PARENTHESIS_TOKEN */ && token.type === 3 /* RIGHT_PARENTHESIS_TOKEN */;
2143
+ return type === 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */ && token.type === 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */;
2137
2144
  };
2138
2145
 
2139
2146
  var isLength = function (token) {
2140
- return token.type === 17 /* NUMBER_TOKEN */ || token.type === 15 /* DIMENSION_TOKEN */;
2147
+ return token.type === 17 /* TokenType.NUMBER_TOKEN */ || token.type === 15 /* TokenType.DIMENSION_TOKEN */;
2141
2148
  };
2142
2149
 
2143
2150
  var isLengthPercentage = function (token) {
2144
- return token.type === 16 /* PERCENTAGE_TOKEN */ || isLength(token);
2151
+ return token.type === 16 /* TokenType.PERCENTAGE_TOKEN */ || isLength(token);
2145
2152
  };
2146
2153
  var parseLengthPercentageTuple = function (tokens) {
2147
2154
  return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];
2148
2155
  };
2149
2156
  var ZERO_LENGTH = {
2150
- type: 17 /* NUMBER_TOKEN */,
2157
+ type: 17 /* TokenType.NUMBER_TOKEN */,
2151
2158
  number: 0,
2152
2159
  flags: FLAG_INTEGER
2153
2160
  };
2154
2161
  var FIFTY_PERCENT = {
2155
- type: 16 /* PERCENTAGE_TOKEN */,
2162
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
2156
2163
  number: 50,
2157
2164
  flags: FLAG_INTEGER
2158
2165
  };
2159
2166
  var HUNDRED_PERCENT = {
2160
- type: 16 /* PERCENTAGE_TOKEN */,
2167
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
2161
2168
  number: 100,
2162
2169
  flags: FLAG_INTEGER
2163
2170
  };
@@ -2166,7 +2173,7 @@ var getAbsoluteValueForTuple = function (tuple, width, height) {
2166
2173
  return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];
2167
2174
  };
2168
2175
  var getAbsoluteValue = function (token, parent) {
2169
- if (token.type === 16 /* PERCENTAGE_TOKEN */) {
2176
+ if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
2170
2177
  return (token.number / 100) * parent;
2171
2178
  }
2172
2179
  if (isDimensionToken(token)) {
@@ -2189,7 +2196,7 @@ var TURN = 'turn';
2189
2196
  var angle = {
2190
2197
  name: 'angle',
2191
2198
  parse: function (_context, value) {
2192
- if (value.type === 15 /* DIMENSION_TOKEN */) {
2199
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
2193
2200
  switch (value.unit) {
2194
2201
  case DEG:
2195
2202
  return (Math.PI * value.number) / 180;
@@ -2205,7 +2212,7 @@ var angle = {
2205
2212
  }
2206
2213
  };
2207
2214
  var isAngle = function (value) {
2208
- if (value.type === 15 /* DIMENSION_TOKEN */) {
2215
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
2209
2216
  if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {
2210
2217
  return true;
2211
2218
  }
@@ -2255,87 +2262,154 @@ var parseNamedSide = function (tokens) {
2255
2262
  };
2256
2263
  var deg = function (deg) { return (Math.PI * deg) / 180; };
2257
2264
 
2258
- var color$1 = {
2259
- name: 'color',
2260
- parse: function (context, value) {
2261
- if (value.type === 18 /* FUNCTION */) {
2262
- var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
2263
- if (typeof colorFunction === 'undefined') {
2264
- throw new Error("Attempting to parse an unsupported color function \"" + value.name + "\"");
2265
- }
2266
- return colorFunction(context, value.values);
2267
- }
2268
- if (value.type === 5 /* HASH_TOKEN */) {
2269
- if (value.value.length === 3) {
2270
- var r = value.value.substring(0, 1);
2271
- var g = value.value.substring(1, 2);
2272
- var b = value.value.substring(2, 3);
2273
- return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);
2274
- }
2275
- if (value.value.length === 4) {
2276
- var r = value.value.substring(0, 1);
2277
- var g = value.value.substring(1, 2);
2278
- var b = value.value.substring(2, 3);
2279
- var a = value.value.substring(3, 4);
2280
- return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);
2281
- }
2282
- if (value.value.length === 6) {
2283
- var r = value.value.substring(0, 2);
2284
- var g = value.value.substring(2, 4);
2285
- var b = value.value.substring(4, 6);
2286
- return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);
2287
- }
2288
- if (value.value.length === 8) {
2289
- var r = value.value.substring(0, 2);
2290
- var g = value.value.substring(2, 4);
2291
- var b = value.value.substring(4, 6);
2292
- var a = value.value.substring(6, 8);
2293
- return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);
2294
- }
2295
- }
2296
- if (value.type === 20 /* IDENT_TOKEN */) {
2297
- var namedColor = COLORS[value.value.toUpperCase()];
2298
- if (typeof namedColor !== 'undefined') {
2299
- return namedColor;
2300
- }
2301
- }
2302
- return COLORS.TRANSPARENT;
2303
- }
2304
- };
2305
2265
  var isTransparent = function (color) { return (0xff & color) === 0; };
2306
2266
  var asString = function (color) {
2307
2267
  var alpha = 0xff & color;
2308
2268
  var blue = 0xff & (color >> 8);
2309
2269
  var green = 0xff & (color >> 16);
2310
2270
  var red = 0xff & (color >> 24);
2311
- return alpha < 255 ? "rgba(" + red + "," + green + "," + blue + "," + alpha / 255 + ")" : "rgb(" + red + "," + green + "," + blue + ")";
2271
+ return alpha < 255 ? "rgba(".concat(red, ",").concat(green, ",").concat(blue, ",").concat(alpha / 255, ")") : "rgb(".concat(red, ",").concat(green, ",").concat(blue, ")");
2312
2272
  };
2313
2273
  var pack = function (r, g, b, a) {
2314
2274
  return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;
2315
2275
  };
2316
2276
  var getTokenColorValue = function (token, i) {
2317
- if (token.type === 17 /* NUMBER_TOKEN */) {
2277
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
2318
2278
  return token.number;
2319
2279
  }
2320
- if (token.type === 16 /* PERCENTAGE_TOKEN */) {
2280
+ if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
2321
2281
  var max = i === 3 ? 1 : 255;
2322
2282
  return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);
2323
2283
  }
2324
2284
  return 0;
2325
2285
  };
2326
- var rgb = function (_context, args) {
2327
- var tokens = args.filter(nonFunctionArgSeparator);
2328
- if (tokens.length === 3) {
2329
- var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
2330
- return pack(r, g, b, 1);
2331
- }
2332
- if (tokens.length === 4) {
2333
- var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
2334
- return pack(r, g, b, a);
2335
- }
2336
- return 0;
2286
+ var isRelativeTransform = function (tokens) {
2287
+ return (tokens[0].type === 20 /* TokenType.IDENT_TOKEN */ ? tokens[0].value : 'unknown') === 'from';
2288
+ };
2289
+ var clamp = function (value, min, max) {
2290
+ return Math.min(Math.max(value, min), max);
2291
+ };
2292
+ var multiplyMatrices = function (A, B) {
2293
+ return [
2294
+ A[0] * B[0] + A[1] * B[1] + A[2] * B[2],
2295
+ A[3] * B[0] + A[4] * B[1] + A[5] * B[2],
2296
+ A[6] * B[0] + A[7] * B[1] + A[8] * B[2]
2297
+ ];
2337
2298
  };
2338
- function hue2rgb(t1, t2, hue) {
2299
+ var packSrgb = function (args) {
2300
+ return pack(clamp(Math.round(args[0] * 255), 0, 255), clamp(Math.round(args[1] * 255), 0, 255), clamp(Math.round(args[2] * 255), 0, 255), clamp(args[3], 0, 1));
2301
+ };
2302
+ var packSrgbLinear = function (_a) {
2303
+ var r = _a[0], g = _a[1], b = _a[2], a = _a[3];
2304
+ var rgb = srgbLinear2rgb([r, g, b]);
2305
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), a);
2306
+ };
2307
+ var packXYZ = function (args) {
2308
+ var srgb_linear = xyz2rgbLinear([args[0], args[1], args[2]]);
2309
+ return packSrgbLinear([srgb_linear[0], srgb_linear[1], srgb_linear[2], args[3]]);
2310
+ };
2311
+ var packLab = function (_context, args) {
2312
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2313
+ throw new Error('Relative color not supported for lab()');
2314
+ }
2315
+ var _a = extractLabComponents(args), l = _a[0], a = _a[1], b = _a[2], alpha = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(lab2xyz([l, a, b])));
2316
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), alpha);
2317
+ };
2318
+ var packOkLab = function (_context, args) {
2319
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2320
+ throw new Error('Relative color not supported for oklab()');
2321
+ }
2322
+ var _a = extractLabComponents(args), l = _a[0], a = _a[1], b = _a[2], alpha = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(oklab2xyz([l, a, b])));
2323
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), alpha);
2324
+ };
2325
+ var packOkLch = function (_context, args) {
2326
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2327
+ throw new Error('Relative color not supported for oklch()');
2328
+ }
2329
+ var _a = extractOkLchComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(oklab2xyz(lch2lab([l, c, h]))));
2330
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), alpha);
2331
+ };
2332
+ var packLch = function (_context, args) {
2333
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2334
+ throw new Error('Relative color not supported for lch()');
2335
+ }
2336
+ var _a = extractLchComponents(args), l = _a[0], c = _a[1], h = _a[2], a = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(lab2xyz(lch2lab([l, c, h]))));
2337
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), a);
2338
+ };
2339
+ var extractHslComponents = function (context, args) {
2340
+ var tokens = args.filter(nonFunctionArgSeparator), hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3], h = (hue.type === 17 /* TokenType.NUMBER_TOKEN */ ? deg(hue.number) : angle.parse(context, hue)) / (Math.PI * 2), s = isLengthPercentage(saturation) ? saturation.number / 100 : 0, l = isLengthPercentage(lightness) ? lightness.number / 100 : 0, a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;
2341
+ return [h, s, l, a];
2342
+ };
2343
+ var packHSL = function (context, args) {
2344
+ if (isRelativeTransform(args)) {
2345
+ throw new Error('Relative color not supported for hsl()');
2346
+ }
2347
+ var _a = extractHslComponents(context, args), h = _a[0], s = _a[1], l = _a[2], a = _a[3], rgb = hsl2rgb([h, s, l]);
2348
+ return pack(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255, s === 0 ? 1 : a);
2349
+ };
2350
+ var extractLchComponents = function (args) {
2351
+ var tokens = args.filter(nonFunctionArgSeparator), l = isLengthPercentage(tokens[0]) ? tokens[0].number : 0, c = isLengthPercentage(tokens[1]) ? tokens[1].number : 0, h = isNumberToken(tokens[2]) || isDimensionToken(tokens[2]) ? tokens[2].number : 0, a = typeof tokens[4] !== 'undefined' && isLengthPercentage(tokens[4]) ? getAbsoluteValue(tokens[4], 1) : 1;
2352
+ return [l, c, h, a];
2353
+ };
2354
+ var extractLabComponents = function (args) {
2355
+ var tokens = args.filter(nonFunctionArgSeparator),
2356
+ // eslint-disable-next-line prettier/prettier
2357
+ l = tokens[0].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2358
+ ? tokens[0].number / 100
2359
+ : isNumberToken(tokens[0])
2360
+ ? tokens[0].number
2361
+ : 0,
2362
+ // eslint-disable-next-line prettier/prettier
2363
+ a = tokens[1].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2364
+ ? tokens[1].number / 100
2365
+ : isNumberToken(tokens[1])
2366
+ ? tokens[1].number
2367
+ : 0, b = isNumberToken(tokens[2]) || isDimensionToken(tokens[2]) ? tokens[2].number : 0, alpha = typeof tokens[4] !== 'undefined' && isLengthPercentage(tokens[4]) ? getAbsoluteValue(tokens[4], 1) : 1;
2368
+ return [l, a, b, alpha];
2369
+ };
2370
+ var extractOkLchComponents = function (args) {
2371
+ var tokens = args.filter(nonFunctionArgSeparator),
2372
+ // eslint-disable-next-line prettier/prettier
2373
+ l = tokens[0].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2374
+ ? tokens[0].number / 100
2375
+ : isNumberToken(tokens[0])
2376
+ ? tokens[0].number
2377
+ : 0,
2378
+ // eslint-disable-next-line prettier/prettier
2379
+ c = tokens[1].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2380
+ ? tokens[1].number / 100
2381
+ : isNumberToken(tokens[1])
2382
+ ? tokens[1].number
2383
+ : 0, h = isNumberToken(tokens[2]) || isDimensionToken(tokens[2]) ? tokens[2].number : 0, a = typeof tokens[4] !== 'undefined' && isLengthPercentage(tokens[4]) ? getAbsoluteValue(tokens[4], 1) : 1;
2384
+ return [l, c, h, a];
2385
+ };
2386
+ /**
2387
+ * Convert D65 to D50
2388
+ *
2389
+ * @param xyz
2390
+ */
2391
+ var d65toD50 = function (xyz) {
2392
+ return multiplyMatrices(
2393
+ // eslint-disable-next-line prettier/prettier
2394
+ [
2395
+ 1.0479297925449969, 0.022946870601609652, -0.05019226628920524, 0.02962780877005599, 0.9904344267538799,
2396
+ -0.017073799063418826, -0.009243040646204504, 0.015055191490298152, 0.7518742814281371
2397
+ ], xyz);
2398
+ };
2399
+ /**
2400
+ * Convert D50 to D65
2401
+ *
2402
+ * @param xyz
2403
+ */
2404
+ var d50toD65 = function (xyz) {
2405
+ return multiplyMatrices(
2406
+ // eslint-disable-next-line prettier/prettier
2407
+ [
2408
+ 0.955473421488075, -0.02309845494876471, 0.06325924320057072, -0.0283697093338637, 1.0099953980813041,
2409
+ 0.021041441191917323, 0.012314014864481998, -0.020507649298898964, 1.330365926242124
2410
+ ], xyz);
2411
+ };
2412
+ var hue2rgb = function (t1, t2, hue) {
2339
2413
  if (hue < 0) {
2340
2414
  hue += 1;
2341
2415
  }
@@ -2354,29 +2428,783 @@ function hue2rgb(t1, t2, hue) {
2354
2428
  else {
2355
2429
  return t1;
2356
2430
  }
2357
- }
2358
- var hsl = function (context, args) {
2359
- var tokens = args.filter(nonFunctionArgSeparator);
2360
- var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];
2361
- var h = (hue.type === 17 /* NUMBER_TOKEN */ ? deg(hue.number) : angle.parse(context, hue)) / (Math.PI * 2);
2362
- var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;
2363
- var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;
2364
- var a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;
2431
+ };
2432
+ var hsl2rgb = function (_a) {
2433
+ var h = _a[0], s = _a[1], l = _a[2];
2365
2434
  if (s === 0) {
2366
- return pack(l * 255, l * 255, l * 255, 1);
2435
+ return [l * 255, l * 255, l * 255];
2367
2436
  }
2368
- var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
2369
- var t1 = l * 2 - t2;
2370
- var r = hue2rgb(t1, t2, h + 1 / 3);
2371
- var g = hue2rgb(t1, t2, h);
2372
- var b = hue2rgb(t1, t2, h - 1 / 3);
2373
- return pack(r * 255, g * 255, b * 255, a);
2437
+ var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s, t1 = l * 2 - t2, r = hue2rgb(t1, t2, h + 1 / 3), g = hue2rgb(t1, t2, h), b = hue2rgb(t1, t2, h - 1 / 3);
2438
+ return [r, g, b];
2439
+ };
2440
+ /**
2441
+ * Convert lch to OKLab
2442
+ *
2443
+ * @param l
2444
+ * @param c
2445
+ * @param h
2446
+ */
2447
+ var lch2lab = function (_a) {
2448
+ var l = _a[0], c = _a[1], h = _a[2];
2449
+ if (c < 0) {
2450
+ c = 0;
2451
+ }
2452
+ if (isNaN(h)) {
2453
+ h = 0;
2454
+ }
2455
+ return [l, c * Math.cos((h * Math.PI) / 180), c * Math.sin((h * Math.PI) / 180)];
2456
+ };
2457
+ /**
2458
+ * Convert OKLab to XYZ relative to D65
2459
+ *
2460
+ * @param lab
2461
+ */
2462
+ var oklab2xyz = function (lab) {
2463
+ var LMSg = multiplyMatrices(
2464
+ // eslint-disable-next-line prettier/prettier
2465
+ [
2466
+ 1, 0.3963377773761749, 0.2158037573099136, 1, -0.1055613458156586, -0.0638541728258133, 1,
2467
+ -0.0894841775298119, -1.2914855480194092
2468
+ ], lab), LMS = LMSg.map(function (val) { return Math.pow(val, 3); });
2469
+ return multiplyMatrices(
2470
+ // eslint-disable-next-line prettier/prettier
2471
+ [
2472
+ 1.2268798758459243, -0.5578149944602171, 0.2813910456659647, -0.0405757452148008, 1.112286803280317,
2473
+ -0.0717110580655164, -0.0763729366746601, -0.4214933324022432, 1.5869240198367816
2474
+ ], LMS);
2475
+ };
2476
+ /**
2477
+ * Convert Lab to D50-adapted XYZ
2478
+ *
2479
+ * @param lab
2480
+ */
2481
+ var lab2xyz = function (lab) {
2482
+ var fy = (lab[0] + 16) / 116, fx = lab[1] / 500 + fy, fz = fy - lab[2] / 200, k = 24389 / 27, e = 24 / 116, xyz = [
2483
+ ((fx > e ? Math.pow(fx, 3) : (116 * fx - 16) / k) * 0.3457) / 0.3585,
2484
+ lab[0] > 8 ? Math.pow(fy, 3) : lab[0] / k,
2485
+ ((fz > e ? Math.pow(fz, 3) : (116 * fz - 16) / k) * (1.0 - 0.3457 - 0.3585)) / 0.3585
2486
+ ];
2487
+ return d50toD65([xyz[0], xyz[1], xyz[2]]);
2488
+ };
2489
+ /**
2490
+ * Convert RGB to XYZ
2491
+ *
2492
+ * @param _context
2493
+ * @param args
2494
+ */
2495
+ var rgbToXyz = function (_context, args) {
2496
+ var tokens = args.filter(nonFunctionArgSeparator);
2497
+ if (tokens.length === 3) {
2498
+ var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2], rgb_linear = rgb2rgbLinear([r / 255, g / 255, b / 255]), _b = rgbLinear2xyz([rgb_linear[0], rgb_linear[1], rgb_linear[2]]), x = _b[0], y = _b[1], z = _b[2];
2499
+ return [x, y, z, 1];
2500
+ }
2501
+ if (tokens.length === 4) {
2502
+ var _c = tokens.map(getTokenColorValue), r = _c[0], g = _c[1], b = _c[2], a = _c[3], rgb_linear = rgb2rgbLinear([r / 255, g / 255, b / 255]), _d = rgbLinear2xyz([rgb_linear[0], rgb_linear[1], rgb_linear[2]]), x = _d[0], y = _d[1], z = _d[2];
2503
+ return [x, y, z, a];
2504
+ }
2505
+ return [0, 0, 0, 1];
2506
+ };
2507
+ /**
2508
+ * HSL to XYZ
2509
+ *
2510
+ * @param context
2511
+ * @param args
2512
+ */
2513
+ var hslToXyz = function (context, args) {
2514
+ var _a = extractHslComponents(context, args), h = _a[0], s = _a[1], l = _a[2], a = _a[3], rgb_linear = rgb2rgbLinear(hsl2rgb([h, s, l])), _b = rgbLinear2xyz([rgb_linear[0], rgb_linear[1], rgb_linear[2]]), x = _b[0], y = _b[1], z = _b[2];
2515
+ return [x, y, z, a];
2516
+ };
2517
+ /**
2518
+ * LAB to XYZ
2519
+ *
2520
+ * @param _context
2521
+ * @param args
2522
+ */
2523
+ var labToXyz = function (_context, args) {
2524
+ var _a = extractLabComponents(args), l = _a[0], a = _a[1], b = _a[2], alpha = _a[3], _b = lab2xyz([l, a, b]), x = _b[0], y = _b[1], z = _b[2];
2525
+ return [x, y, z, alpha];
2526
+ };
2527
+ /**
2528
+ * LCH to XYZ
2529
+ *
2530
+ * @param _context
2531
+ * @param args
2532
+ */
2533
+ var lchToXyz = function (_context, args) {
2534
+ var _a = extractLchComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], _b = lab2xyz(lch2lab([l, c, h])), x = _b[0], y = _b[1], z = _b[2];
2535
+ return [x, y, z, alpha];
2536
+ };
2537
+ /**
2538
+ * OKLch to XYZ
2539
+ *
2540
+ * @param _context
2541
+ * @param args
2542
+ */
2543
+ var oklchToXyz = function (_context, args) {
2544
+ var _a = extractOkLchComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], _b = oklab2xyz(lch2lab([l, c, h])), x = _b[0], y = _b[1], z = _b[2];
2545
+ return [x, y, z, alpha];
2546
+ };
2547
+ /**
2548
+ * OKLab to XYZ
2549
+ *
2550
+ * @param _context
2551
+ * @param args
2552
+ */
2553
+ var oklabToXyz = function (_context, args) {
2554
+ var _a = extractLabComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], _b = oklab2xyz([l, c, h]), x = _b[0], y = _b[1], z = _b[2];
2555
+ return [x, y, z, alpha];
2556
+ };
2557
+ /**
2558
+ * XYZ-50 to XYZ
2559
+ *
2560
+ * @param args
2561
+ */
2562
+ var xyz50ToXYZ = function (args) {
2563
+ return d50toD65([args[0], args[1], args[2]]);
2564
+ };
2565
+ /**
2566
+ * Does nothing, required for SUPPORTED_COLOR_SPACES_FROM_XYZ in the _color() function
2567
+ *
2568
+ * @param args
2569
+ */
2570
+ var xyzFromXYZ = function (args) {
2571
+ return args;
2572
+ };
2573
+ /**
2574
+ * XYZ-65 to XYZ-50
2575
+ *
2576
+ * @param args
2577
+ */
2578
+ var xyz50FromXYZ = function (args) {
2579
+ var _a = d65toD50([args[0], args[2], args[3]]), x = _a[0], y = _a[1], z = _a[2];
2580
+ return [x, y, z, args[3]];
2581
+ };
2582
+ /**
2583
+ * Convert XYZ to SRGB and Pack
2584
+ *
2585
+ * @param args
2586
+ */
2587
+ var convertXyz = function (args) {
2588
+ return packXYZ([args[0], args[1], args[2], args[3]]);
2589
+ };
2590
+ /**
2591
+ * Convert XYZ-50 to SRGB and Pack
2592
+ *
2593
+ * @param args
2594
+ */
2595
+ var convertXyz50 = function (args) {
2596
+ var xyz = xyz50ToXYZ([args[0], args[1], args[2]]);
2597
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2598
+ };
2599
+
2600
+ /**
2601
+ * SRGB related functions
2602
+ */
2603
+ /**
2604
+ * Convert XYZ to linear-light sRGB
2605
+ *
2606
+ * @param xyz
2607
+ */
2608
+ var xyz2rgbLinear = function (xyz) {
2609
+ return multiplyMatrices(
2610
+ // eslint-disable-next-line prettier/prettier
2611
+ [
2612
+ 3.2409699419045226, -1.537383177570094, -0.4986107602930034, -0.9692436362808796, 1.8759675015077202,
2613
+ 0.04155505740717559, 0.05563007969699366, -0.20397695888897652, 1.0569715142428786
2614
+ ], xyz);
2615
+ };
2616
+ /**
2617
+ * Convert XYZ to linear-light sRGB
2618
+ *
2619
+ * @param xyz
2620
+ */
2621
+ var rgbLinear2xyz = function (xyz) {
2622
+ return multiplyMatrices(
2623
+ // eslint-disable-next-line prettier/prettier
2624
+ [
2625
+ 0.41239079926595934, 0.357584339383878, 0.1804807884018343, 0.21263900587151027, 0.715168678767756,
2626
+ 0.07219231536073371, 0.01933081871559182, 0.11919477979462598, 0.9505321522496607
2627
+ ], xyz);
2628
+ };
2629
+ /**
2630
+ * Convert sRGB to RGB
2631
+ *
2632
+ * @param rgb
2633
+ */
2634
+ var srgbLinear2rgb = function (rgb) {
2635
+ return rgb.map(function (c) {
2636
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2637
+ // eslint-disable-next-line prettier/prettier
2638
+ return abs > 0.0031308 ? sign * (1.055 * Math.pow(abs, (1 / 2.4)) - 0.055) : 12.92 * c;
2639
+ });
2640
+ };
2641
+ /**
2642
+ * Convert RGB to sRGB
2643
+ *
2644
+ * @param rgb
2645
+ */
2646
+ var rgb2rgbLinear = function (rgb) {
2647
+ return rgb.map(function (c) {
2648
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2649
+ // eslint-disable-next-line prettier/prettier
2650
+ return abs <= 0.04045 ? c / 12.92 : sign * Math.pow(((abs + 0.055) / 1.055), 2.4);
2651
+ });
2652
+ };
2653
+ /**
2654
+ * XYZ to SRGB
2655
+ *
2656
+ * @param args
2657
+ */
2658
+ var srgbFromXYZ = function (args) {
2659
+ var _a = srgbLinear2rgb(xyz2rgbLinear([args[0], args[1], args[2]])), r = _a[0], g = _a[1], b = _a[2];
2660
+ return [r, g, b, args[3]];
2661
+ };
2662
+ /**
2663
+ * XYZ to SRGB-Linear
2664
+ * @param args
2665
+ */
2666
+ var srgbLinearFromXYZ = function (args) {
2667
+ var _a = xyz2rgbLinear([args[0], args[1], args[2]]), r = _a[0], g = _a[1], b = _a[2];
2668
+ return [
2669
+ clamp(Math.round(r * 255), 0, 255),
2670
+ clamp(Math.round(g * 255), 0, 255),
2671
+ clamp(Math.round(b * 255), 0, 255),
2672
+ args[3]
2673
+ ];
2674
+ };
2675
+
2676
+ /**
2677
+ * Display-P3 related functions
2678
+ */
2679
+ /**
2680
+ * Convert P3 Linear to xyz
2681
+ *
2682
+ * @param p3l
2683
+ */
2684
+ var p3LinearToXyz = function (p3l) {
2685
+ return multiplyMatrices(
2686
+ // eslint-disable-next-line prettier/prettier
2687
+ [
2688
+ 0.4865709486482162, 0.26566769316909306, 0.1982172852343625, 0.2289745640697488, 0.6917385218365064,
2689
+ 0.079286914093745, 0.0, 0.04511338185890264, 1.043944368900976
2690
+ ], p3l);
2691
+ };
2692
+ /**
2693
+ * Convert XYZ to P3 Linear
2694
+ *
2695
+ * @param xyz
2696
+ */
2697
+ var xyzToP3Linear = function (xyz) {
2698
+ return multiplyMatrices(
2699
+ // eslint-disable-next-line prettier/prettier
2700
+ [
2701
+ 2.493496911941425, -0.9313836179191239, -0.40271078445071684, -0.8294889695615747, 1.7626640603183463,
2702
+ 0.023624685841943577, 0.03584583024378447, -0.07617238926804182, 0.9568845240076872
2703
+ ], xyz);
2704
+ };
2705
+ /**
2706
+ * Convert P3 to P3 linear
2707
+ *
2708
+ * @param p3
2709
+ */
2710
+ var p32p3Linear = function (p3) {
2711
+ return p3.map(function (c) {
2712
+ var sign = c < 0 ? -1 : 1, abs = c * sign;
2713
+ if (abs <= 0.04045) {
2714
+ return c / 12.92;
2715
+ }
2716
+ // eslint-disable-next-line prettier/prettier
2717
+ return sign * Math.pow(((c + 0.055) / 1.055), 2.4) || 0;
2718
+ });
2719
+ };
2720
+ /**
2721
+ * Convert P3 Linear to P3
2722
+ *
2723
+ * @param p3l
2724
+ */
2725
+ var p3Linear2p3 = function (p3l) {
2726
+ return srgbLinear2rgb(p3l);
2727
+ };
2728
+ /**
2729
+ * Convert P3 to XYZ
2730
+ *
2731
+ * @param args
2732
+ */
2733
+ var p3ToXYZ = function (args) {
2734
+ var p3_linear = p32p3Linear([args[0], args[1], args[2]]);
2735
+ return p3LinearToXyz([p3_linear[0], p3_linear[1], p3_linear[2]]);
2736
+ };
2737
+ /**
2738
+ * Convert XYZ to P3
2739
+ *
2740
+ * @param args
2741
+ */
2742
+ var p3FromXYZ = function (args) {
2743
+ var _a = p3Linear2p3(xyzToP3Linear([args[0], args[1], args[2]])), r = _a[0], g = _a[1], b = _a[2];
2744
+ return [r, g, b, args[3]];
2745
+ };
2746
+ /**
2747
+ * Convert P3 to SRGB and Pack
2748
+ *
2749
+ * @param args
2750
+ */
2751
+ var convertP3 = function (args) {
2752
+ var xyz = p3ToXYZ([args[0], args[1], args[2]]);
2753
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2754
+ };
2755
+
2756
+ /**
2757
+ * A98-RGB related functions
2758
+ */
2759
+ /**
2760
+ * Convert XYZ to a98 linear
2761
+ *
2762
+ * @param xyz
2763
+ */
2764
+ var xyz2a98Linear = function (xyz) {
2765
+ return multiplyMatrices(
2766
+ // eslint-disable-next-line prettier/prettier
2767
+ [
2768
+ 2.0415879038107465, -0.5650069742788596, -0.34473135077832956, -0.9692436362808795, 1.8759675015077202,
2769
+ 0.04155505740717557, 0.013444280632031142, -0.11836239223101838, 1.0151749943912054
2770
+ ], xyz);
2771
+ };
2772
+ /**
2773
+ * Convert XYZ to a98 linear
2774
+ *
2775
+ * @param a98
2776
+ */
2777
+ var a98Linear2xyz = function (a98) {
2778
+ return multiplyMatrices(
2779
+ // eslint-disable-next-line prettier/prettier
2780
+ [
2781
+ 0.5766690429101305, 0.1855582379065463, 0.1882286462349947, 0.29734497525053605, 0.6273635662554661,
2782
+ 0.0752914584939978, 0.02703136138641234, 0.07068885253582723, 0.9913375368376388
2783
+ ], a98);
2784
+ };
2785
+ /**
2786
+ * Convert A98 RGB to rgb linear
2787
+ *
2788
+ * @param rgb
2789
+ */
2790
+ var a982a98Linear = function (rgb) {
2791
+ var mapped = rgb.map(function (c) {
2792
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2793
+ return sign * Math.pow(abs, (563 / 256));
2794
+ });
2795
+ return [mapped[0], mapped[1], mapped[2]];
2796
+ };
2797
+ /**
2798
+ * Convert A98 RGB Linear to A98
2799
+ *
2800
+ * @param rgb
2801
+ */
2802
+ var a98Linear2a98 = function (rgb) {
2803
+ var mapped = rgb.map(function (c) {
2804
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2805
+ return sign * Math.pow(abs, (256 / 563));
2806
+ });
2807
+ return [mapped[0], mapped[1], mapped[2]];
2808
+ };
2809
+ /**
2810
+ * Convert XYZ to A98
2811
+ *
2812
+ * @param args
2813
+ */
2814
+ var a98FromXYZ = function (args) {
2815
+ var _a = a98Linear2a98(xyz2a98Linear([args[0], args[1], args[2]])), r = _a[0], g = _a[1], b = _a[2];
2816
+ return [r, g, b, args[3]];
2817
+ };
2818
+ /**
2819
+ * Convert A98 to XYZ and Pack
2820
+ *
2821
+ * @param args
2822
+ */
2823
+ var convertA98rgb = function (args) {
2824
+ var srgb_linear = xyz2rgbLinear(a98Linear2xyz(a982a98Linear([args[0], args[1], args[2]])));
2825
+ return packSrgbLinear([srgb_linear[0], srgb_linear[1], srgb_linear[2], args[3]]);
2826
+ };
2827
+
2828
+ /**
2829
+ * Pro Photo related functions
2830
+ */
2831
+ /**
2832
+ * Convert linear-light display-p3 to XYZ D65
2833
+ *
2834
+ * @param p3
2835
+ */
2836
+ var proPhotoLinearToXyz = function (p3) {
2837
+ return multiplyMatrices(
2838
+ // eslint-disable-next-line prettier/prettier
2839
+ [
2840
+ 0.7977666449006423, 0.13518129740053308, 0.0313477341283922, 0.2880748288194013, 0.711835234241873,
2841
+ 0.00008993693872564, 0.0, 0.0, 0.8251046025104602
2842
+ ], p3);
2843
+ };
2844
+ /**
2845
+ * Convert XYZ D65 to linear-light display-p3
2846
+ *
2847
+ * @param xyz
2848
+ */
2849
+ var xyzToProPhotoLinear = function (xyz) {
2850
+ return multiplyMatrices(
2851
+ // eslint-disable-next-line prettier/prettier
2852
+ [
2853
+ 1.3457868816471583, -0.25557208737979464, -0.05110186497554526, -0.5446307051249019, 1.5082477428451468,
2854
+ 0.02052744743642139, 0.0, 0.0, 1.2119675456389452
2855
+ ], xyz);
2856
+ };
2857
+ /**
2858
+ * Convert Pro-Photo to Pro-Photo Linear
2859
+ *
2860
+ * @param p3
2861
+ */
2862
+ var proPhotoToProPhotoLinear = function (p3) {
2863
+ return p3.map(function (c) {
2864
+ return c < 16 / 512 ? c / 16 : Math.pow(c, 1.8);
2865
+ });
2866
+ };
2867
+ /**
2868
+ * Convert Pro-Photo Linear to Pro-Photo
2869
+ *
2870
+ * @param p3
2871
+ */
2872
+ var proPhotoLinearToProPhoto = function (p3) {
2873
+ return p3.map(function (c) {
2874
+ return c > 1 / 512 ? Math.pow(c, (1 / 1.8)) : c * 16;
2875
+ });
2876
+ };
2877
+ /**
2878
+ * Convert Pro-Photo to XYZ
2879
+ *
2880
+ * @param args
2881
+ */
2882
+ var proPhotoToXYZ = function (args) {
2883
+ var prophoto_linear = proPhotoToProPhotoLinear([args[0], args[1], args[2]]);
2884
+ return d50toD65(proPhotoLinearToXyz([prophoto_linear[0], prophoto_linear[1], prophoto_linear[2]]));
2885
+ };
2886
+ /**
2887
+ * Convert XYZ to Pro-Photo
2888
+ *
2889
+ * @param args
2890
+ */
2891
+ var proPhotoFromXYZ = function (args) {
2892
+ var _a = proPhotoLinearToProPhoto(xyzToProPhotoLinear(d65toD50([args[0], args[1], args[2]]))), r = _a[0], g = _a[1], b = _a[2];
2893
+ return [r, g, b, args[3]];
2894
+ };
2895
+ /**
2896
+ * Convert Pro-Photo to XYZ and Pack
2897
+ *
2898
+ * @param args
2899
+ */
2900
+ var convertProPhoto = function (args) {
2901
+ var xyz = proPhotoToXYZ([args[0], args[1], args[2]]);
2902
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2903
+ };
2904
+
2905
+ /**
2906
+ * REC2020 related functions
2907
+ */
2908
+ var _a = 1.09929682680944;
2909
+ var _b = 0.018053968510807;
2910
+ /**
2911
+ * Convert rec2020 to rec2020 linear
2912
+ *
2913
+ * @param rgb
2914
+ */
2915
+ var rec20202rec2020Linear = function (rgb) {
2916
+ return rgb.map(function (c) {
2917
+ return c < _b * 4.5 ? c / 4.5 : Math.pow((c + _a - 1) / _a, 1 / 0.45);
2918
+ });
2919
+ };
2920
+ /**
2921
+ * Convert rec2020 linear to rec2020
2922
+ *
2923
+ * @param rgb
2924
+ */
2925
+ var rec2020Linear2rec2020 = function (rgb) {
2926
+ return rgb.map(function (c) {
2927
+ return c >= _b ? _a * Math.pow(c, 0.45) - (_a - 1) : 4.5 * c;
2928
+ });
2929
+ };
2930
+ /**
2931
+ * Convert rec2020 linear to XYZ D65
2932
+ *
2933
+ * @param rec
2934
+ */
2935
+ var rec2020LinearToXyz = function (rec) {
2936
+ return multiplyMatrices(
2937
+ // eslint-disable-next-line prettier/prettier
2938
+ [
2939
+ 0.6369580483012914, 0.14461690358620832, 0.1688809751641721, 0.2627002120112671, 0.6779980715188708,
2940
+ 0.05930171646986196, 0.0, 0.028072693049087428, 1.060985057710791
2941
+ ], rec);
2942
+ };
2943
+ /**
2944
+ * Convert XYZ D65 to rec2020 linear
2945
+ *
2946
+ * @param xyz
2947
+ */
2948
+ var xyzToRec2020Linear = function (xyz) {
2949
+ return multiplyMatrices(
2950
+ // eslint-disable-next-line prettier/prettier
2951
+ [
2952
+ 1.716651187971268, -0.355670783776392, -0.25336628137366, -0.666684351832489, 1.616481236634939,
2953
+ 0.0157685458139111, 0.017639857445311, -0.042770613257809, 0.942103121235474
2954
+ ], xyz);
2955
+ };
2956
+ /**
2957
+ * Convert Rec2020 to XYZ
2958
+ *
2959
+ * @param args
2960
+ */
2961
+ var rec2020ToXYZ = function (args) {
2962
+ var rec2020_linear = rec20202rec2020Linear([args[0], args[1], args[2]]);
2963
+ return rec2020LinearToXyz([rec2020_linear[0], rec2020_linear[1], rec2020_linear[2]]);
2964
+ };
2965
+ /**
2966
+ * Convert XYZ to Rec2020
2967
+ *
2968
+ * @param args
2969
+ */
2970
+ var rec2020FromXYZ = function (args) {
2971
+ var _c = rec2020Linear2rec2020(xyzToRec2020Linear([args[0], args[1], args[2]])), r = _c[0], g = _c[1], b = _c[2];
2972
+ return [r, g, b, args[3]];
2973
+ };
2974
+ /**
2975
+ * Convert Rec2020 to SRGB and Pack
2976
+ *
2977
+ * @param args
2978
+ */
2979
+ var convertRec2020 = function (args) {
2980
+ var xyz = rec2020ToXYZ([args[0], args[1], args[2]]);
2981
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2982
+ };
2983
+
2984
+ var color$1 = {
2985
+ name: 'color',
2986
+ parse: function (context, value) {
2987
+ if (value.type === 18 /* TokenType.FUNCTION */) {
2988
+ var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
2989
+ if (typeof colorFunction === 'undefined') {
2990
+ throw new Error("Attempting to parse an unsupported color function \"".concat(value.name, "\""));
2991
+ }
2992
+ return colorFunction(context, value.values);
2993
+ }
2994
+ if (value.type === 5 /* TokenType.HASH_TOKEN */) {
2995
+ var _a = hash2rgb(value), r = _a[0], g = _a[1], b = _a[2], a = _a[3];
2996
+ return pack(r, g, b, a);
2997
+ }
2998
+ if (value.type === 20 /* TokenType.IDENT_TOKEN */) {
2999
+ var namedColor = COLORS[value.value.toUpperCase()];
3000
+ if (typeof namedColor !== 'undefined') {
3001
+ return namedColor;
3002
+ }
3003
+ }
3004
+ return COLORS.TRANSPARENT;
3005
+ }
3006
+ };
3007
+ var hash2rgb = function (token) {
3008
+ if (token.value.length === 3) {
3009
+ var r = token.value.substring(0, 1);
3010
+ var g = token.value.substring(1, 2);
3011
+ var b = token.value.substring(2, 3);
3012
+ return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1];
3013
+ }
3014
+ if (token.value.length === 4) {
3015
+ var r = token.value.substring(0, 1);
3016
+ var g = token.value.substring(1, 2);
3017
+ var b = token.value.substring(2, 3);
3018
+ var a = token.value.substring(3, 4);
3019
+ return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255];
3020
+ }
3021
+ if (token.value.length === 6) {
3022
+ var r = token.value.substring(0, 2);
3023
+ var g = token.value.substring(2, 4);
3024
+ var b = token.value.substring(4, 6);
3025
+ return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1];
3026
+ }
3027
+ if (token.value.length === 8) {
3028
+ var r = token.value.substring(0, 2);
3029
+ var g = token.value.substring(2, 4);
3030
+ var b = token.value.substring(4, 6);
3031
+ var a = token.value.substring(6, 8);
3032
+ return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255];
3033
+ }
3034
+ return [0, 0, 0, 1];
3035
+ };
3036
+ var rgb = function (_context, args) {
3037
+ var tokens = args.filter(nonFunctionArgSeparator);
3038
+ if (isRelativeTransform(tokens)) {
3039
+ throw new Error('Relative color not supported for rgb()');
3040
+ }
3041
+ if (tokens.length === 3) {
3042
+ var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
3043
+ return pack(r, g, b, 1);
3044
+ }
3045
+ if (tokens.length === 4) {
3046
+ var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
3047
+ return pack(r, g, b, a);
3048
+ }
3049
+ return 0;
3050
+ };
3051
+ /**
3052
+ * Handle the CSS color() function
3053
+ *
3054
+ * @param context
3055
+ * @param args
3056
+ */
3057
+ var _color = function (context, args) {
3058
+ var tokens = args.filter(nonFunctionArgSeparator), token_1_value = tokens[0].type === 20 /* TokenType.IDENT_TOKEN */ ? tokens[0].value : 'unknown', is_absolute = !isRelativeTransform(tokens);
3059
+ if (is_absolute) {
3060
+ var color_space = token_1_value, colorSpaceFunction = SUPPORTED_COLOR_SPACES_ABSOLUTE[color_space];
3061
+ if (typeof colorSpaceFunction === 'undefined') {
3062
+ throw new Error("Attempting to parse an unsupported color space \"".concat(color_space, "\" for color() function"));
3063
+ }
3064
+ var c1 = isNumberToken(tokens[1]) ? tokens[1].number : 0, c2 = isNumberToken(tokens[2]) ? tokens[2].number : 0, c3 = isNumberToken(tokens[3]) ? tokens[3].number : 0, a = tokens.length > 4 &&
3065
+ tokens[4].type === 6 /* TokenType.DELIM_TOKEN */ &&
3066
+ tokens[4].value === '/' &&
3067
+ isNumberToken(tokens[5])
3068
+ ? tokens[5].number
3069
+ : 1;
3070
+ return colorSpaceFunction([c1, c2, c3, a]);
3071
+ }
3072
+ else {
3073
+ var extractComponent = function (color, token) {
3074
+ if (isNumberToken(token)) {
3075
+ return token.number;
3076
+ }
3077
+ var posFromVal = function (value) {
3078
+ return value === 'r' || value === 'x' ? 0 : value === 'g' || value === 'y' ? 1 : 2;
3079
+ };
3080
+ if (isIdentToken(token)) {
3081
+ var position = posFromVal(token.value);
3082
+ return color[position];
3083
+ }
3084
+ var parseCalc = function (args) {
3085
+ var parts = args.filter(nonFunctionArgSeparator);
3086
+ var expression = '(';
3087
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
3088
+ var part = parts_1[_i];
3089
+ expression +=
3090
+ part.type === 18 /* TokenType.FUNCTION */ && part.name === 'calc'
3091
+ ? parseCalc(part.values)
3092
+ : isNumberToken(part)
3093
+ ? part.number
3094
+ : part.type === 6 /* TokenType.DELIM_TOKEN */ || isIdentToken(part)
3095
+ ? part.value
3096
+ : '';
3097
+ }
3098
+ expression += ')';
3099
+ return expression;
3100
+ };
3101
+ if (token.type === 18 /* TokenType.FUNCTION */) {
3102
+ var args_1 = token.values.filter(nonFunctionArgSeparator);
3103
+ if (token.name === 'calc') {
3104
+ var expression = parseCalc(args_1)
3105
+ .replace(/r|x/, color[0].toString())
3106
+ .replace(/g|y/, color[1].toString())
3107
+ .replace(/b|z/, color[2].toString());
3108
+ return new Function('return ' + expression)();
3109
+ }
3110
+ }
3111
+ return null;
3112
+ };
3113
+ var from_colorspace = tokens[1].type === 18 /* TokenType.FUNCTION */
3114
+ ? tokens[1].name
3115
+ : isIdentToken(tokens[1]) || tokens[1].type === 5 /* TokenType.HASH_TOKEN */
3116
+ ? 'rgb'
3117
+ : 'unknown', to_colorspace = isIdentToken(tokens[2]) ? tokens[2].value : 'unknown';
3118
+ var from = tokens[1].type === 18 /* TokenType.FUNCTION */ ? tokens[1].values : isIdentToken(tokens[1]) ? [tokens[1]] : [];
3119
+ if (isIdentToken(tokens[1])) {
3120
+ var named_color = COLORS[tokens[1].value.toUpperCase()];
3121
+ if (typeof named_color === 'undefined') {
3122
+ throw new Error("Attempting to use unknown color in relative color 'from'");
3123
+ }
3124
+ else {
3125
+ var _c = parseColor(context, tokens[1].value), alpha = 0xff & _c, blue = 0xff & (_c >> 8), green = 0xff & (_c >> 16), red = 0xff & (_c >> 24);
3126
+ from = [
3127
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: red, flags: 1 },
3128
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: green, flags: 1 },
3129
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: blue, flags: 1 },
3130
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: alpha > 1 ? alpha / 255 : alpha, flags: 1 }
3131
+ ];
3132
+ }
3133
+ }
3134
+ else if (tokens[1].type === 5 /* TokenType.HASH_TOKEN */) {
3135
+ var _a = hash2rgb(tokens[1]), red = _a[0], green = _a[1], blue = _a[2], alpha = _a[3];
3136
+ from = [
3137
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: red, flags: 1 },
3138
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: green, flags: 1 },
3139
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: blue, flags: 1 },
3140
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: alpha > 1 ? alpha / 255 : alpha, flags: 1 }
3141
+ ];
3142
+ }
3143
+ if (from.length === 0) {
3144
+ throw new Error("Attempting to use unknown color in relative color 'from'");
3145
+ }
3146
+ if (to_colorspace === 'unknown') {
3147
+ throw new Error("Attempting to use unknown colorspace in relative color 'to'");
3148
+ }
3149
+ var fromColorToXyz = SUPPORTED_COLOR_SPACES_TO_XYZ[from_colorspace], toColorFromXyz = SUPPORTED_COLOR_SPACES_FROM_XYZ[to_colorspace], toColorPack = SUPPORTED_COLOR_SPACES_ABSOLUTE[to_colorspace];
3150
+ if (typeof fromColorToXyz === 'undefined') {
3151
+ throw new Error("Attempting to parse an unsupported color space \"".concat(from_colorspace, "\" for color() function"));
3152
+ }
3153
+ if (typeof toColorFromXyz === 'undefined') {
3154
+ throw new Error("Attempting to parse an unsupported color space \"".concat(to_colorspace, "\" for color() function"));
3155
+ }
3156
+ var from_color = fromColorToXyz(context, from), from_final_colorspace = toColorFromXyz(from_color), c1 = extractComponent(from_final_colorspace, tokens[3]), c2 = extractComponent(from_final_colorspace, tokens[4]), c3 = extractComponent(from_final_colorspace, tokens[5]), a = tokens.length > 6 &&
3157
+ tokens[6].type === 6 /* TokenType.DELIM_TOKEN */ &&
3158
+ tokens[6].value === '/' &&
3159
+ isNumberToken(tokens[7])
3160
+ ? tokens[7].number
3161
+ : 1;
3162
+ if (c1 === null || c2 === null || c3 === null) {
3163
+ throw new Error("Invalid relative color in color() function");
3164
+ }
3165
+ return toColorPack([c1, c2, c3, a]);
3166
+ }
3167
+ };
3168
+ var SUPPORTED_COLOR_SPACES_ABSOLUTE = {
3169
+ srgb: packSrgb,
3170
+ 'srgb-linear': packSrgbLinear,
3171
+ 'display-p3': convertP3,
3172
+ 'a98-rgb': convertA98rgb,
3173
+ 'prophoto-rgb': convertProPhoto,
3174
+ xyz: convertXyz,
3175
+ 'xyz-d50': convertXyz50,
3176
+ 'xyz-d65': convertXyz,
3177
+ rec2020: convertRec2020
3178
+ };
3179
+ var SUPPORTED_COLOR_SPACES_TO_XYZ = {
3180
+ rgb: rgbToXyz,
3181
+ hsl: hslToXyz,
3182
+ lab: labToXyz,
3183
+ lch: lchToXyz,
3184
+ oklab: oklabToXyz,
3185
+ oklch: oklchToXyz
3186
+ };
3187
+ var SUPPORTED_COLOR_SPACES_FROM_XYZ = {
3188
+ srgb: srgbFromXYZ,
3189
+ 'srgb-linear': srgbLinearFromXYZ,
3190
+ 'display-p3': p3FromXYZ,
3191
+ 'a98-rgb': a98FromXYZ,
3192
+ 'prophoto-rgb': proPhotoFromXYZ,
3193
+ xyz: xyzFromXYZ,
3194
+ 'xyz-d50': xyz50FromXYZ,
3195
+ 'xyz-d65': xyzFromXYZ,
3196
+ rec2020: rec2020FromXYZ
2374
3197
  };
2375
3198
  var SUPPORTED_COLOR_FUNCTIONS = {
2376
- hsl: hsl,
2377
- hsla: hsl,
3199
+ hsl: packHSL,
3200
+ hsla: packHSL,
2378
3201
  rgb: rgb,
2379
- rgba: rgb
3202
+ rgba: rgb,
3203
+ lch: packLch,
3204
+ oklch: packOkLch,
3205
+ oklab: packOkLab,
3206
+ lab: packLab,
3207
+ color: _color
2380
3208
  };
2381
3209
  var parseColor = function (context, value) {
2382
3210
  return color$1.parse(context, Parser.create(value).parseComponentValue());
@@ -2537,18 +3365,18 @@ var backgroundClip = {
2537
3365
  name: 'background-clip',
2538
3366
  initialValue: 'border-box',
2539
3367
  prefix: false,
2540
- type: 1 /* LIST */,
3368
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
2541
3369
  parse: function (_context, tokens) {
2542
3370
  return tokens.map(function (token) {
2543
3371
  if (isIdentToken(token)) {
2544
3372
  switch (token.value) {
2545
3373
  case 'padding-box':
2546
- return 1 /* PADDING_BOX */;
3374
+ return 1 /* BACKGROUND_CLIP.PADDING_BOX */;
2547
3375
  case 'content-box':
2548
- return 2 /* CONTENT_BOX */;
3376
+ return 2 /* BACKGROUND_CLIP.CONTENT_BOX */;
2549
3377
  }
2550
3378
  }
2551
- return 0 /* BORDER_BOX */;
3379
+ return 0 /* BACKGROUND_CLIP.BORDER_BOX */;
2552
3380
  });
2553
3381
  }
2554
3382
  };
@@ -2557,7 +3385,7 @@ var backgroundColor = {
2557
3385
  name: "background-color",
2558
3386
  initialValue: 'transparent',
2559
3387
  prefix: false,
2560
- type: 3 /* TYPE_VALUE */,
3388
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
2561
3389
  format: 'color'
2562
3390
  };
2563
3391
 
@@ -2660,24 +3488,24 @@ var calculateRadius = function (gradient, x, y, width, height) {
2660
3488
  var rx = 0;
2661
3489
  var ry = 0;
2662
3490
  switch (gradient.size) {
2663
- case 0 /* CLOSEST_SIDE */:
3491
+ case 0 /* CSSRadialExtent.CLOSEST_SIDE */:
2664
3492
  // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.
2665
3493
  // If the shape is an ellipse, it exactly meets the closest side in each dimension.
2666
- if (gradient.shape === 0 /* CIRCLE */) {
3494
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2667
3495
  rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
2668
3496
  }
2669
- else if (gradient.shape === 1 /* ELLIPSE */) {
3497
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2670
3498
  rx = Math.min(Math.abs(x), Math.abs(x - width));
2671
3499
  ry = Math.min(Math.abs(y), Math.abs(y - height));
2672
3500
  }
2673
3501
  break;
2674
- case 2 /* CLOSEST_CORNER */:
3502
+ case 2 /* CSSRadialExtent.CLOSEST_CORNER */:
2675
3503
  // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.
2676
3504
  // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.
2677
- if (gradient.shape === 0 /* CIRCLE */) {
3505
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2678
3506
  rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
2679
3507
  }
2680
- else if (gradient.shape === 1 /* ELLIPSE */) {
3508
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2681
3509
  // Compute the ratio ry/rx (which is to be the same as for "closest-side")
2682
3510
  var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));
2683
3511
  var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];
@@ -2685,23 +3513,23 @@ var calculateRadius = function (gradient, x, y, width, height) {
2685
3513
  ry = c * rx;
2686
3514
  }
2687
3515
  break;
2688
- case 1 /* FARTHEST_SIDE */:
3516
+ case 1 /* CSSRadialExtent.FARTHEST_SIDE */:
2689
3517
  // Same as closest-side, except the ending shape is sized based on the farthest side(s)
2690
- if (gradient.shape === 0 /* CIRCLE */) {
3518
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2691
3519
  rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
2692
3520
  }
2693
- else if (gradient.shape === 1 /* ELLIPSE */) {
3521
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2694
3522
  rx = Math.max(Math.abs(x), Math.abs(x - width));
2695
3523
  ry = Math.max(Math.abs(y), Math.abs(y - height));
2696
3524
  }
2697
3525
  break;
2698
- case 3 /* FARTHEST_CORNER */:
3526
+ case 3 /* CSSRadialExtent.FARTHEST_CORNER */:
2699
3527
  // Same as closest-corner, except the ending shape is sized based on the farthest corner.
2700
3528
  // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.
2701
- if (gradient.shape === 0 /* CIRCLE */) {
3529
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2702
3530
  rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
2703
3531
  }
2704
- else if (gradient.shape === 1 /* ELLIPSE */) {
3532
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2705
3533
  // Compute the ratio ry/rx (which is to be the same as for "farthest-side")
2706
3534
  var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));
2707
3535
  var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];
@@ -2723,7 +3551,7 @@ var linearGradient = function (context, tokens) {
2723
3551
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2724
3552
  if (i === 0) {
2725
3553
  var firstToken = arg[0];
2726
- if (firstToken.type === 20 /* IDENT_TOKEN */ && firstToken.value === 'to') {
3554
+ if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ && firstToken.value === 'to') {
2727
3555
  angle$1 = parseNamedSide(arg);
2728
3556
  return;
2729
3557
  }
@@ -2735,7 +3563,7 @@ var linearGradient = function (context, tokens) {
2735
3563
  var colorStop = parseColorStop(context, arg);
2736
3564
  stops.push(colorStop);
2737
3565
  });
2738
- return { angle: angle$1, stops: stops, type: 1 /* LINEAR_GRADIENT */ };
3566
+ return { angle: angle$1, stops: stops, type: 1 /* CSSImageType.LINEAR_GRADIENT */ };
2739
3567
  };
2740
3568
 
2741
3569
  var prefixLinearGradient = function (context, tokens) {
@@ -2744,7 +3572,7 @@ var prefixLinearGradient = function (context, tokens) {
2744
3572
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2745
3573
  if (i === 0) {
2746
3574
  var firstToken = arg[0];
2747
- if (firstToken.type === 20 /* IDENT_TOKEN */ &&
3575
+ if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ &&
2748
3576
  ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {
2749
3577
  angle$1 = parseNamedSide(arg);
2750
3578
  return;
@@ -2760,30 +3588,30 @@ var prefixLinearGradient = function (context, tokens) {
2760
3588
  return {
2761
3589
  angle: angle$1,
2762
3590
  stops: stops,
2763
- type: 1 /* LINEAR_GRADIENT */
3591
+ type: 1 /* CSSImageType.LINEAR_GRADIENT */
2764
3592
  };
2765
3593
  };
2766
3594
 
2767
3595
  var webkitGradient = function (context, tokens) {
2768
3596
  var angle = deg(180);
2769
3597
  var stops = [];
2770
- var type = 1 /* LINEAR_GRADIENT */;
2771
- var shape = 0 /* CIRCLE */;
2772
- var size = 3 /* FARTHEST_CORNER */;
3598
+ var type = 1 /* CSSImageType.LINEAR_GRADIENT */;
3599
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3600
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2773
3601
  var position = [];
2774
3602
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2775
3603
  var firstToken = arg[0];
2776
3604
  if (i === 0) {
2777
3605
  if (isIdentToken(firstToken) && firstToken.value === 'linear') {
2778
- type = 1 /* LINEAR_GRADIENT */;
3606
+ type = 1 /* CSSImageType.LINEAR_GRADIENT */;
2779
3607
  return;
2780
3608
  }
2781
3609
  else if (isIdentToken(firstToken) && firstToken.value === 'radial') {
2782
- type = 2 /* RADIAL_GRADIENT */;
3610
+ type = 2 /* CSSImageType.RADIAL_GRADIENT */;
2783
3611
  return;
2784
3612
  }
2785
3613
  }
2786
- if (firstToken.type === 18 /* FUNCTION */) {
3614
+ if (firstToken.type === 18 /* TokenType.FUNCTION */) {
2787
3615
  if (firstToken.name === 'from') {
2788
3616
  var color = color$1.parse(context, firstToken.values[0]);
2789
3617
  stops.push({ stop: ZERO_LENGTH, color: color });
@@ -2799,7 +3627,7 @@ var webkitGradient = function (context, tokens) {
2799
3627
  var stop_1 = values[0];
2800
3628
  if (isNumberToken(stop_1)) {
2801
3629
  stops.push({
2802
- stop: { type: 16 /* PERCENTAGE_TOKEN */, number: stop_1.number * 100, flags: stop_1.flags },
3630
+ stop: { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number: stop_1.number * 100, flags: stop_1.flags },
2803
3631
  color: color
2804
3632
  });
2805
3633
  }
@@ -2807,7 +3635,7 @@ var webkitGradient = function (context, tokens) {
2807
3635
  }
2808
3636
  }
2809
3637
  });
2810
- return type === 1 /* LINEAR_GRADIENT */
3638
+ return type === 1 /* CSSImageType.LINEAR_GRADIENT */
2811
3639
  ? {
2812
3640
  angle: (angle + deg(180)) % deg(360),
2813
3641
  stops: stops,
@@ -2825,8 +3653,8 @@ var ELLIPSE = 'ellipse';
2825
3653
  var COVER = 'cover';
2826
3654
  var CONTAIN = 'contain';
2827
3655
  var radialGradient = function (context, tokens) {
2828
- var shape = 0 /* CIRCLE */;
2829
- var size = 3 /* FARTHEST_CORNER */;
3656
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3657
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2830
3658
  var stops = [];
2831
3659
  var position = [];
2832
3660
  parseFunctionArgs(tokens).forEach(function (arg, i) {
@@ -2857,27 +3685,27 @@ var radialGradient = function (context, tokens) {
2857
3685
  else if (isIdentToken(token)) {
2858
3686
  switch (token.value) {
2859
3687
  case CIRCLE:
2860
- shape = 0 /* CIRCLE */;
3688
+ shape = 0 /* CSSRadialShape.CIRCLE */;
2861
3689
  return false;
2862
3690
  case ELLIPSE:
2863
- shape = 1 /* ELLIPSE */;
3691
+ shape = 1 /* CSSRadialShape.ELLIPSE */;
2864
3692
  return false;
2865
3693
  case 'at':
2866
3694
  isAtPosition_1 = true;
2867
3695
  return false;
2868
3696
  case CLOSEST_SIDE:
2869
- size = 0 /* CLOSEST_SIDE */;
3697
+ size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
2870
3698
  return false;
2871
3699
  case COVER:
2872
3700
  case FARTHEST_SIDE:
2873
- size = 1 /* FARTHEST_SIDE */;
3701
+ size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
2874
3702
  return false;
2875
3703
  case CONTAIN:
2876
3704
  case CLOSEST_CORNER:
2877
- size = 2 /* CLOSEST_CORNER */;
3705
+ size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
2878
3706
  return false;
2879
3707
  case FARTHEST_CORNER:
2880
- size = 3 /* FARTHEST_CORNER */;
3708
+ size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2881
3709
  return false;
2882
3710
  }
2883
3711
  }
@@ -2896,12 +3724,12 @@ var radialGradient = function (context, tokens) {
2896
3724
  stops.push(colorStop);
2897
3725
  }
2898
3726
  });
2899
- return { size: size, shape: shape, stops: stops, position: position, type: 2 /* RADIAL_GRADIENT */ };
3727
+ return { size: size, shape: shape, stops: stops, position: position, type: 2 /* CSSImageType.RADIAL_GRADIENT */ };
2900
3728
  };
2901
3729
 
2902
3730
  var prefixRadialGradient = function (context, tokens) {
2903
- var shape = 0 /* CIRCLE */;
2904
- var size = 3 /* FARTHEST_CORNER */;
3731
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3732
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2905
3733
  var stops = [];
2906
3734
  var position = [];
2907
3735
  parseFunctionArgs(tokens).forEach(function (arg, i) {
@@ -2935,24 +3763,24 @@ var prefixRadialGradient = function (context, tokens) {
2935
3763
  if (isIdentToken(token)) {
2936
3764
  switch (token.value) {
2937
3765
  case CIRCLE:
2938
- shape = 0 /* CIRCLE */;
3766
+ shape = 0 /* CSSRadialShape.CIRCLE */;
2939
3767
  return false;
2940
3768
  case ELLIPSE:
2941
- shape = 1 /* ELLIPSE */;
3769
+ shape = 1 /* CSSRadialShape.ELLIPSE */;
2942
3770
  return false;
2943
3771
  case CONTAIN:
2944
3772
  case CLOSEST_SIDE:
2945
- size = 0 /* CLOSEST_SIDE */;
3773
+ size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
2946
3774
  return false;
2947
3775
  case FARTHEST_SIDE:
2948
- size = 1 /* FARTHEST_SIDE */;
3776
+ size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
2949
3777
  return false;
2950
3778
  case CLOSEST_CORNER:
2951
- size = 2 /* CLOSEST_CORNER */;
3779
+ size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
2952
3780
  return false;
2953
3781
  case COVER:
2954
3782
  case FARTHEST_CORNER:
2955
- size = 3 /* FARTHEST_CORNER */;
3783
+ size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2956
3784
  return false;
2957
3785
  }
2958
3786
  }
@@ -2971,36 +3799,36 @@ var prefixRadialGradient = function (context, tokens) {
2971
3799
  stops.push(colorStop);
2972
3800
  }
2973
3801
  });
2974
- return { size: size, shape: shape, stops: stops, position: position, type: 2 /* RADIAL_GRADIENT */ };
3802
+ return { size: size, shape: shape, stops: stops, position: position, type: 2 /* CSSImageType.RADIAL_GRADIENT */ };
2975
3803
  };
2976
3804
 
2977
3805
  var isLinearGradient = function (background) {
2978
- return background.type === 1 /* LINEAR_GRADIENT */;
3806
+ return background.type === 1 /* CSSImageType.LINEAR_GRADIENT */;
2979
3807
  };
2980
3808
  var isRadialGradient = function (background) {
2981
- return background.type === 2 /* RADIAL_GRADIENT */;
3809
+ return background.type === 2 /* CSSImageType.RADIAL_GRADIENT */;
2982
3810
  };
2983
3811
  var image = {
2984
3812
  name: 'image',
2985
3813
  parse: function (context, value) {
2986
- if (value.type === 22 /* URL_TOKEN */) {
2987
- var image_1 = { url: value.value, type: 0 /* URL */ };
3814
+ if (value.type === 22 /* TokenType.URL_TOKEN */) {
3815
+ var image_1 = { url: value.value, type: 0 /* CSSImageType.URL */ };
2988
3816
  context.cache.addImage(value.value);
2989
3817
  return image_1;
2990
3818
  }
2991
- if (value.type === 18 /* FUNCTION */) {
3819
+ if (value.type === 18 /* TokenType.FUNCTION */) {
2992
3820
  var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];
2993
3821
  if (typeof imageFunction === 'undefined') {
2994
- throw new Error("Attempting to parse an unsupported image function \"" + value.name + "\"");
3822
+ throw new Error("Attempting to parse an unsupported image function \"".concat(value.name, "\""));
2995
3823
  }
2996
3824
  return imageFunction(context, value.values);
2997
3825
  }
2998
- throw new Error("Unsupported image type " + value.type);
3826
+ throw new Error("Unsupported image type ".concat(value.type));
2999
3827
  }
3000
3828
  };
3001
3829
  function isSupportedImage(value) {
3002
- return (!(value.type === 20 /* IDENT_TOKEN */ && value.value === 'none') &&
3003
- (value.type !== 18 /* FUNCTION */ || !!SUPPORTED_IMAGE_FUNCTIONS[value.name]));
3830
+ return (!(value.type === 20 /* TokenType.IDENT_TOKEN */ && value.value === 'none') &&
3831
+ (value.type !== 18 /* TokenType.FUNCTION */ || !!SUPPORTED_IMAGE_FUNCTIONS[value.name]));
3004
3832
  }
3005
3833
  var SUPPORTED_IMAGE_FUNCTIONS = {
3006
3834
  'linear-gradient': linearGradient,
@@ -3019,14 +3847,14 @@ var SUPPORTED_IMAGE_FUNCTIONS = {
3019
3847
  var backgroundImage = {
3020
3848
  name: 'background-image',
3021
3849
  initialValue: 'none',
3022
- type: 1 /* LIST */,
3850
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3023
3851
  prefix: false,
3024
3852
  parse: function (context, tokens) {
3025
3853
  if (tokens.length === 0) {
3026
3854
  return [];
3027
3855
  }
3028
3856
  var first = tokens[0];
3029
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
3857
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3030
3858
  return [];
3031
3859
  }
3032
3860
  return tokens
@@ -3039,18 +3867,18 @@ var backgroundOrigin = {
3039
3867
  name: 'background-origin',
3040
3868
  initialValue: 'border-box',
3041
3869
  prefix: false,
3042
- type: 1 /* LIST */,
3870
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3043
3871
  parse: function (_context, tokens) {
3044
3872
  return tokens.map(function (token) {
3045
3873
  if (isIdentToken(token)) {
3046
3874
  switch (token.value) {
3047
3875
  case 'padding-box':
3048
- return 1 /* PADDING_BOX */;
3876
+ return 1 /* BACKGROUND_ORIGIN.PADDING_BOX */;
3049
3877
  case 'content-box':
3050
- return 2 /* CONTENT_BOX */;
3878
+ return 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */;
3051
3879
  }
3052
3880
  }
3053
- return 0 /* BORDER_BOX */;
3881
+ return 0 /* BACKGROUND_ORIGIN.BORDER_BOX */;
3054
3882
  });
3055
3883
  }
3056
3884
  };
@@ -3058,7 +3886,7 @@ var backgroundOrigin = {
3058
3886
  var backgroundPosition = {
3059
3887
  name: 'background-position',
3060
3888
  initialValue: '0% 0%',
3061
- type: 1 /* LIST */,
3889
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3062
3890
  prefix: false,
3063
3891
  parse: function (_context, tokens) {
3064
3892
  return parseFunctionArgs(tokens)
@@ -3071,7 +3899,7 @@ var backgroundRepeat = {
3071
3899
  name: 'background-repeat',
3072
3900
  initialValue: 'repeat',
3073
3901
  prefix: false,
3074
- type: 1 /* LIST */,
3902
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3075
3903
  parse: function (_context, tokens) {
3076
3904
  return parseFunctionArgs(tokens)
3077
3905
  .map(function (values) {
@@ -3086,16 +3914,16 @@ var backgroundRepeat = {
3086
3914
  var parseBackgroundRepeat = function (value) {
3087
3915
  switch (value) {
3088
3916
  case 'no-repeat':
3089
- return 1 /* NO_REPEAT */;
3917
+ return 1 /* BACKGROUND_REPEAT.NO_REPEAT */;
3090
3918
  case 'repeat-x':
3091
3919
  case 'repeat no-repeat':
3092
- return 2 /* REPEAT_X */;
3920
+ return 2 /* BACKGROUND_REPEAT.REPEAT_X */;
3093
3921
  case 'repeat-y':
3094
3922
  case 'no-repeat repeat':
3095
- return 3 /* REPEAT_Y */;
3923
+ return 3 /* BACKGROUND_REPEAT.REPEAT_Y */;
3096
3924
  case 'repeat':
3097
3925
  default:
3098
- return 0 /* REPEAT */;
3926
+ return 0 /* BACKGROUND_REPEAT.REPEAT */;
3099
3927
  }
3100
3928
  };
3101
3929
 
@@ -3109,7 +3937,7 @@ var backgroundSize = {
3109
3937
  name: 'background-size',
3110
3938
  initialValue: '0',
3111
3939
  prefix: false,
3112
- type: 1 /* LIST */,
3940
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3113
3941
  parse: function (_context, tokens) {
3114
3942
  return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });
3115
3943
  }
@@ -3119,10 +3947,10 @@ var isBackgroundSizeInfoToken = function (value) {
3119
3947
  };
3120
3948
 
3121
3949
  var borderColorForSide = function (side) { return ({
3122
- name: "border-" + side + "-color",
3950
+ name: "border-".concat(side, "-color"),
3123
3951
  initialValue: 'transparent',
3124
3952
  prefix: false,
3125
- type: 3 /* TYPE_VALUE */,
3953
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3126
3954
  format: 'color'
3127
3955
  }); };
3128
3956
  var borderTopColor = borderColorForSide('top');
@@ -3131,10 +3959,10 @@ var borderBottomColor = borderColorForSide('bottom');
3131
3959
  var borderLeftColor = borderColorForSide('left');
3132
3960
 
3133
3961
  var borderRadiusForSide = function (side) { return ({
3134
- name: "border-radius-" + side,
3962
+ name: "border-radius-".concat(side),
3135
3963
  initialValue: '0 0',
3136
3964
  prefix: false,
3137
- type: 1 /* LIST */,
3965
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3138
3966
  parse: function (_context, tokens) {
3139
3967
  return parseLengthPercentageTuple(tokens.filter(isLengthPercentage));
3140
3968
  }
@@ -3145,22 +3973,22 @@ var borderBottomRightRadius = borderRadiusForSide('bottom-right');
3145
3973
  var borderBottomLeftRadius = borderRadiusForSide('bottom-left');
3146
3974
 
3147
3975
  var borderStyleForSide = function (side) { return ({
3148
- name: "border-" + side + "-style",
3976
+ name: "border-".concat(side, "-style"),
3149
3977
  initialValue: 'solid',
3150
3978
  prefix: false,
3151
- type: 2 /* IDENT_VALUE */,
3979
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3152
3980
  parse: function (_context, style) {
3153
3981
  switch (style) {
3154
3982
  case 'none':
3155
- return 0 /* NONE */;
3983
+ return 0 /* BORDER_STYLE.NONE */;
3156
3984
  case 'dashed':
3157
- return 2 /* DASHED */;
3985
+ return 2 /* BORDER_STYLE.DASHED */;
3158
3986
  case 'dotted':
3159
- return 3 /* DOTTED */;
3987
+ return 3 /* BORDER_STYLE.DOTTED */;
3160
3988
  case 'double':
3161
- return 4 /* DOUBLE */;
3989
+ return 4 /* BORDER_STYLE.DOUBLE */;
3162
3990
  }
3163
- return 1 /* SOLID */;
3991
+ return 1 /* BORDER_STYLE.SOLID */;
3164
3992
  }
3165
3993
  }); };
3166
3994
  var borderTopStyle = borderStyleForSide('top');
@@ -3169,9 +3997,9 @@ var borderBottomStyle = borderStyleForSide('bottom');
3169
3997
  var borderLeftStyle = borderStyleForSide('left');
3170
3998
 
3171
3999
  var borderWidthForSide = function (side) { return ({
3172
- name: "border-" + side + "-width",
4000
+ name: "border-".concat(side, "-width"),
3173
4001
  initialValue: '0',
3174
- type: 0 /* VALUE */,
4002
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3175
4003
  prefix: false,
3176
4004
  parse: function (_context, token) {
3177
4005
  if (isDimensionToken(token)) {
@@ -3189,7 +4017,7 @@ var color = {
3189
4017
  name: "color",
3190
4018
  initialValue: 'transparent',
3191
4019
  prefix: false,
3192
- type: 3 /* TYPE_VALUE */,
4020
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3193
4021
  format: 'color'
3194
4022
  };
3195
4023
 
@@ -3197,14 +4025,14 @@ var direction = {
3197
4025
  name: 'direction',
3198
4026
  initialValue: 'ltr',
3199
4027
  prefix: false,
3200
- type: 2 /* IDENT_VALUE */,
4028
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3201
4029
  parse: function (_context, direction) {
3202
4030
  switch (direction) {
3203
4031
  case 'rtl':
3204
- return 1 /* RTL */;
4032
+ return 1 /* DIRECTION.RTL */;
3205
4033
  case 'ltr':
3206
4034
  default:
3207
- return 0 /* LTR */;
4035
+ return 0 /* DIRECTION.LTR */;
3208
4036
  }
3209
4037
  }
3210
4038
  };
@@ -3213,97 +4041,97 @@ var display = {
3213
4041
  name: 'display',
3214
4042
  initialValue: 'inline-block',
3215
4043
  prefix: false,
3216
- type: 1 /* LIST */,
4044
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3217
4045
  parse: function (_context, tokens) {
3218
4046
  return tokens.filter(isIdentToken).reduce(function (bit, token) {
3219
- return bit | parseDisplayValue(token.value);
3220
- }, 0 /* NONE */);
4047
+ return bit | parseDisplayValue$1(token.value);
4048
+ }, 0 /* DISPLAY.NONE */);
3221
4049
  }
3222
4050
  };
3223
- var parseDisplayValue = function (display) {
4051
+ var parseDisplayValue$1 = function (display) {
3224
4052
  switch (display) {
3225
4053
  case 'block':
3226
4054
  case '-webkit-box':
3227
- return 2 /* BLOCK */;
4055
+ return 2 /* DISPLAY.BLOCK */;
3228
4056
  case 'inline':
3229
- return 4 /* INLINE */;
4057
+ return 4 /* DISPLAY.INLINE */;
3230
4058
  case 'run-in':
3231
- return 8 /* RUN_IN */;
4059
+ return 8 /* DISPLAY.RUN_IN */;
3232
4060
  case 'flow':
3233
- return 16 /* FLOW */;
4061
+ return 16 /* DISPLAY.FLOW */;
3234
4062
  case 'flow-root':
3235
- return 32 /* FLOW_ROOT */;
4063
+ return 32 /* DISPLAY.FLOW_ROOT */;
3236
4064
  case 'table':
3237
- return 64 /* TABLE */;
4065
+ return 64 /* DISPLAY.TABLE */;
3238
4066
  case 'flex':
3239
4067
  case '-webkit-flex':
3240
- return 128 /* FLEX */;
4068
+ return 128 /* DISPLAY.FLEX */;
3241
4069
  case 'grid':
3242
4070
  case '-ms-grid':
3243
- return 256 /* GRID */;
4071
+ return 256 /* DISPLAY.GRID */;
3244
4072
  case 'ruby':
3245
- return 512 /* RUBY */;
4073
+ return 512 /* DISPLAY.RUBY */;
3246
4074
  case 'subgrid':
3247
- return 1024 /* SUBGRID */;
4075
+ return 1024 /* DISPLAY.SUBGRID */;
3248
4076
  case 'list-item':
3249
- return 2048 /* LIST_ITEM */;
4077
+ return 2048 /* DISPLAY.LIST_ITEM */;
3250
4078
  case 'table-row-group':
3251
- return 4096 /* TABLE_ROW_GROUP */;
4079
+ return 4096 /* DISPLAY.TABLE_ROW_GROUP */;
3252
4080
  case 'table-header-group':
3253
- return 8192 /* TABLE_HEADER_GROUP */;
4081
+ return 8192 /* DISPLAY.TABLE_HEADER_GROUP */;
3254
4082
  case 'table-footer-group':
3255
- return 16384 /* TABLE_FOOTER_GROUP */;
4083
+ return 16384 /* DISPLAY.TABLE_FOOTER_GROUP */;
3256
4084
  case 'table-row':
3257
- return 32768 /* TABLE_ROW */;
4085
+ return 32768 /* DISPLAY.TABLE_ROW */;
3258
4086
  case 'table-cell':
3259
- return 65536 /* TABLE_CELL */;
4087
+ return 65536 /* DISPLAY.TABLE_CELL */;
3260
4088
  case 'table-column-group':
3261
- return 131072 /* TABLE_COLUMN_GROUP */;
4089
+ return 131072 /* DISPLAY.TABLE_COLUMN_GROUP */;
3262
4090
  case 'table-column':
3263
- return 262144 /* TABLE_COLUMN */;
4091
+ return 262144 /* DISPLAY.TABLE_COLUMN */;
3264
4092
  case 'table-caption':
3265
- return 524288 /* TABLE_CAPTION */;
4093
+ return 524288 /* DISPLAY.TABLE_CAPTION */;
3266
4094
  case 'ruby-base':
3267
- return 1048576 /* RUBY_BASE */;
4095
+ return 1048576 /* DISPLAY.RUBY_BASE */;
3268
4096
  case 'ruby-text':
3269
- return 2097152 /* RUBY_TEXT */;
4097
+ return 2097152 /* DISPLAY.RUBY_TEXT */;
3270
4098
  case 'ruby-base-container':
3271
- return 4194304 /* RUBY_BASE_CONTAINER */;
4099
+ return 4194304 /* DISPLAY.RUBY_BASE_CONTAINER */;
3272
4100
  case 'ruby-text-container':
3273
- return 8388608 /* RUBY_TEXT_CONTAINER */;
4101
+ return 8388608 /* DISPLAY.RUBY_TEXT_CONTAINER */;
3274
4102
  case 'contents':
3275
- return 16777216 /* CONTENTS */;
4103
+ return 16777216 /* DISPLAY.CONTENTS */;
3276
4104
  case 'inline-block':
3277
- return 33554432 /* INLINE_BLOCK */;
4105
+ return 33554432 /* DISPLAY.INLINE_BLOCK */;
3278
4106
  case 'inline-list-item':
3279
- return 67108864 /* INLINE_LIST_ITEM */;
4107
+ return 67108864 /* DISPLAY.INLINE_LIST_ITEM */;
3280
4108
  case 'inline-table':
3281
- return 134217728 /* INLINE_TABLE */;
4109
+ return 134217728 /* DISPLAY.INLINE_TABLE */;
3282
4110
  case 'inline-flex':
3283
- return 268435456 /* INLINE_FLEX */;
4111
+ return 268435456 /* DISPLAY.INLINE_FLEX */;
3284
4112
  case 'inline-grid':
3285
- return 536870912 /* INLINE_GRID */;
4113
+ return 536870912 /* DISPLAY.INLINE_GRID */;
3286
4114
  }
3287
- return 0 /* NONE */;
4115
+ return 0 /* DISPLAY.NONE */;
3288
4116
  };
3289
4117
 
3290
4118
  var float = {
3291
4119
  name: 'float',
3292
4120
  initialValue: 'none',
3293
4121
  prefix: false,
3294
- type: 2 /* IDENT_VALUE */,
4122
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3295
4123
  parse: function (_context, float) {
3296
4124
  switch (float) {
3297
4125
  case 'left':
3298
- return 1 /* LEFT */;
4126
+ return 1 /* FLOAT.LEFT */;
3299
4127
  case 'right':
3300
- return 2 /* RIGHT */;
4128
+ return 2 /* FLOAT.RIGHT */;
3301
4129
  case 'inline-start':
3302
- return 3 /* INLINE_START */;
4130
+ return 3 /* FLOAT.INLINE_START */;
3303
4131
  case 'inline-end':
3304
- return 4 /* INLINE_END */;
4132
+ return 4 /* FLOAT.INLINE_END */;
3305
4133
  }
3306
- return 0 /* NONE */;
4134
+ return 0 /* FLOAT.NONE */;
3307
4135
  }
3308
4136
  };
3309
4137
 
@@ -3311,15 +4139,15 @@ var letterSpacing = {
3311
4139
  name: 'letter-spacing',
3312
4140
  initialValue: '0',
3313
4141
  prefix: false,
3314
- type: 0 /* VALUE */,
4142
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3315
4143
  parse: function (_context, token) {
3316
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'normal') {
4144
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'normal') {
3317
4145
  return 0;
3318
4146
  }
3319
- if (token.type === 17 /* NUMBER_TOKEN */) {
4147
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
3320
4148
  return token.number;
3321
4149
  }
3322
- if (token.type === 15 /* DIMENSION_TOKEN */) {
4150
+ if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
3323
4151
  return token.number;
3324
4152
  }
3325
4153
  return 0;
@@ -3335,7 +4163,7 @@ var lineBreak = {
3335
4163
  name: 'line-break',
3336
4164
  initialValue: 'normal',
3337
4165
  prefix: false,
3338
- type: 2 /* IDENT_VALUE */,
4166
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3339
4167
  parse: function (_context, lineBreak) {
3340
4168
  switch (lineBreak) {
3341
4169
  case 'strict':
@@ -3351,13 +4179,13 @@ var lineHeight = {
3351
4179
  name: 'line-height',
3352
4180
  initialValue: 'normal',
3353
4181
  prefix: false,
3354
- type: 4 /* TOKEN_VALUE */
4182
+ type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
3355
4183
  };
3356
4184
  var computeLineHeight = function (token, fontSize) {
3357
4185
  if (isIdentToken(token) && token.value === 'normal') {
3358
4186
  return 1.2 * fontSize;
3359
4187
  }
3360
- else if (token.type === 17 /* NUMBER_TOKEN */) {
4188
+ else if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
3361
4189
  return fontSize * token.number;
3362
4190
  }
3363
4191
  else if (isLengthPercentage(token)) {
@@ -3369,10 +4197,10 @@ var computeLineHeight = function (token, fontSize) {
3369
4197
  var listStyleImage = {
3370
4198
  name: 'list-style-image',
3371
4199
  initialValue: 'none',
3372
- type: 0 /* VALUE */,
4200
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3373
4201
  prefix: false,
3374
4202
  parse: function (context, token) {
3375
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
4203
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
3376
4204
  return null;
3377
4205
  }
3378
4206
  return image.parse(context, token);
@@ -3383,14 +4211,14 @@ var listStylePosition = {
3383
4211
  name: 'list-style-position',
3384
4212
  initialValue: 'outside',
3385
4213
  prefix: false,
3386
- type: 2 /* IDENT_VALUE */,
4214
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3387
4215
  parse: function (_context, position) {
3388
4216
  switch (position) {
3389
4217
  case 'inside':
3390
- return 0 /* INSIDE */;
4218
+ return 0 /* LIST_STYLE_POSITION.INSIDE */;
3391
4219
  case 'outside':
3392
4220
  default:
3393
- return 1 /* OUTSIDE */;
4221
+ return 1 /* LIST_STYLE_POSITION.OUTSIDE */;
3394
4222
  }
3395
4223
  }
3396
4224
  };
@@ -3399,127 +4227,127 @@ var listStyleType = {
3399
4227
  name: 'list-style-type',
3400
4228
  initialValue: 'none',
3401
4229
  prefix: false,
3402
- type: 2 /* IDENT_VALUE */,
4230
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3403
4231
  parse: function (_context, type) {
3404
4232
  switch (type) {
3405
4233
  case 'disc':
3406
- return 0 /* DISC */;
4234
+ return 0 /* LIST_STYLE_TYPE.DISC */;
3407
4235
  case 'circle':
3408
- return 1 /* CIRCLE */;
4236
+ return 1 /* LIST_STYLE_TYPE.CIRCLE */;
3409
4237
  case 'square':
3410
- return 2 /* SQUARE */;
4238
+ return 2 /* LIST_STYLE_TYPE.SQUARE */;
3411
4239
  case 'decimal':
3412
- return 3 /* DECIMAL */;
4240
+ return 3 /* LIST_STYLE_TYPE.DECIMAL */;
3413
4241
  case 'cjk-decimal':
3414
- return 4 /* CJK_DECIMAL */;
4242
+ return 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */;
3415
4243
  case 'decimal-leading-zero':
3416
- return 5 /* DECIMAL_LEADING_ZERO */;
4244
+ return 5 /* LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO */;
3417
4245
  case 'lower-roman':
3418
- return 6 /* LOWER_ROMAN */;
4246
+ return 6 /* LIST_STYLE_TYPE.LOWER_ROMAN */;
3419
4247
  case 'upper-roman':
3420
- return 7 /* UPPER_ROMAN */;
4248
+ return 7 /* LIST_STYLE_TYPE.UPPER_ROMAN */;
3421
4249
  case 'lower-greek':
3422
- return 8 /* LOWER_GREEK */;
4250
+ return 8 /* LIST_STYLE_TYPE.LOWER_GREEK */;
3423
4251
  case 'lower-alpha':
3424
- return 9 /* LOWER_ALPHA */;
4252
+ return 9 /* LIST_STYLE_TYPE.LOWER_ALPHA */;
3425
4253
  case 'upper-alpha':
3426
- return 10 /* UPPER_ALPHA */;
4254
+ return 10 /* LIST_STYLE_TYPE.UPPER_ALPHA */;
3427
4255
  case 'arabic-indic':
3428
- return 11 /* ARABIC_INDIC */;
4256
+ return 11 /* LIST_STYLE_TYPE.ARABIC_INDIC */;
3429
4257
  case 'armenian':
3430
- return 12 /* ARMENIAN */;
4258
+ return 12 /* LIST_STYLE_TYPE.ARMENIAN */;
3431
4259
  case 'bengali':
3432
- return 13 /* BENGALI */;
4260
+ return 13 /* LIST_STYLE_TYPE.BENGALI */;
3433
4261
  case 'cambodian':
3434
- return 14 /* CAMBODIAN */;
4262
+ return 14 /* LIST_STYLE_TYPE.CAMBODIAN */;
3435
4263
  case 'cjk-earthly-branch':
3436
- return 15 /* CJK_EARTHLY_BRANCH */;
4264
+ return 15 /* LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH */;
3437
4265
  case 'cjk-heavenly-stem':
3438
- return 16 /* CJK_HEAVENLY_STEM */;
4266
+ return 16 /* LIST_STYLE_TYPE.CJK_HEAVENLY_STEM */;
3439
4267
  case 'cjk-ideographic':
3440
- return 17 /* CJK_IDEOGRAPHIC */;
4268
+ return 17 /* LIST_STYLE_TYPE.CJK_IDEOGRAPHIC */;
3441
4269
  case 'devanagari':
3442
- return 18 /* DEVANAGARI */;
4270
+ return 18 /* LIST_STYLE_TYPE.DEVANAGARI */;
3443
4271
  case 'ethiopic-numeric':
3444
- return 19 /* ETHIOPIC_NUMERIC */;
4272
+ return 19 /* LIST_STYLE_TYPE.ETHIOPIC_NUMERIC */;
3445
4273
  case 'georgian':
3446
- return 20 /* GEORGIAN */;
4274
+ return 20 /* LIST_STYLE_TYPE.GEORGIAN */;
3447
4275
  case 'gujarati':
3448
- return 21 /* GUJARATI */;
4276
+ return 21 /* LIST_STYLE_TYPE.GUJARATI */;
3449
4277
  case 'gurmukhi':
3450
- return 22 /* GURMUKHI */;
4278
+ return 22 /* LIST_STYLE_TYPE.GURMUKHI */;
3451
4279
  case 'hebrew':
3452
- return 22 /* HEBREW */;
4280
+ return 52 /* LIST_STYLE_TYPE.HEBREW */;
3453
4281
  case 'hiragana':
3454
- return 23 /* HIRAGANA */;
4282
+ return 23 /* LIST_STYLE_TYPE.HIRAGANA */;
3455
4283
  case 'hiragana-iroha':
3456
- return 24 /* HIRAGANA_IROHA */;
4284
+ return 24 /* LIST_STYLE_TYPE.HIRAGANA_IROHA */;
3457
4285
  case 'japanese-formal':
3458
- return 25 /* JAPANESE_FORMAL */;
4286
+ return 25 /* LIST_STYLE_TYPE.JAPANESE_FORMAL */;
3459
4287
  case 'japanese-informal':
3460
- return 26 /* JAPANESE_INFORMAL */;
4288
+ return 26 /* LIST_STYLE_TYPE.JAPANESE_INFORMAL */;
3461
4289
  case 'kannada':
3462
- return 27 /* KANNADA */;
4290
+ return 27 /* LIST_STYLE_TYPE.KANNADA */;
3463
4291
  case 'katakana':
3464
- return 28 /* KATAKANA */;
4292
+ return 28 /* LIST_STYLE_TYPE.KATAKANA */;
3465
4293
  case 'katakana-iroha':
3466
- return 29 /* KATAKANA_IROHA */;
4294
+ return 29 /* LIST_STYLE_TYPE.KATAKANA_IROHA */;
3467
4295
  case 'khmer':
3468
- return 30 /* KHMER */;
4296
+ return 30 /* LIST_STYLE_TYPE.KHMER */;
3469
4297
  case 'korean-hangul-formal':
3470
- return 31 /* KOREAN_HANGUL_FORMAL */;
4298
+ return 31 /* LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL */;
3471
4299
  case 'korean-hanja-formal':
3472
- return 32 /* KOREAN_HANJA_FORMAL */;
4300
+ return 32 /* LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL */;
3473
4301
  case 'korean-hanja-informal':
3474
- return 33 /* KOREAN_HANJA_INFORMAL */;
4302
+ return 33 /* LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL */;
3475
4303
  case 'lao':
3476
- return 34 /* LAO */;
4304
+ return 34 /* LIST_STYLE_TYPE.LAO */;
3477
4305
  case 'lower-armenian':
3478
- return 35 /* LOWER_ARMENIAN */;
4306
+ return 35 /* LIST_STYLE_TYPE.LOWER_ARMENIAN */;
3479
4307
  case 'malayalam':
3480
- return 36 /* MALAYALAM */;
4308
+ return 36 /* LIST_STYLE_TYPE.MALAYALAM */;
3481
4309
  case 'mongolian':
3482
- return 37 /* MONGOLIAN */;
4310
+ return 37 /* LIST_STYLE_TYPE.MONGOLIAN */;
3483
4311
  case 'myanmar':
3484
- return 38 /* MYANMAR */;
4312
+ return 38 /* LIST_STYLE_TYPE.MYANMAR */;
3485
4313
  case 'oriya':
3486
- return 39 /* ORIYA */;
4314
+ return 39 /* LIST_STYLE_TYPE.ORIYA */;
3487
4315
  case 'persian':
3488
- return 40 /* PERSIAN */;
4316
+ return 40 /* LIST_STYLE_TYPE.PERSIAN */;
3489
4317
  case 'simp-chinese-formal':
3490
- return 41 /* SIMP_CHINESE_FORMAL */;
4318
+ return 41 /* LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL */;
3491
4319
  case 'simp-chinese-informal':
3492
- return 42 /* SIMP_CHINESE_INFORMAL */;
4320
+ return 42 /* LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL */;
3493
4321
  case 'tamil':
3494
- return 43 /* TAMIL */;
4322
+ return 43 /* LIST_STYLE_TYPE.TAMIL */;
3495
4323
  case 'telugu':
3496
- return 44 /* TELUGU */;
4324
+ return 44 /* LIST_STYLE_TYPE.TELUGU */;
3497
4325
  case 'thai':
3498
- return 45 /* THAI */;
4326
+ return 45 /* LIST_STYLE_TYPE.THAI */;
3499
4327
  case 'tibetan':
3500
- return 46 /* TIBETAN */;
4328
+ return 46 /* LIST_STYLE_TYPE.TIBETAN */;
3501
4329
  case 'trad-chinese-formal':
3502
- return 47 /* TRAD_CHINESE_FORMAL */;
4330
+ return 47 /* LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL */;
3503
4331
  case 'trad-chinese-informal':
3504
- return 48 /* TRAD_CHINESE_INFORMAL */;
4332
+ return 48 /* LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL */;
3505
4333
  case 'upper-armenian':
3506
- return 49 /* UPPER_ARMENIAN */;
4334
+ return 49 /* LIST_STYLE_TYPE.UPPER_ARMENIAN */;
3507
4335
  case 'disclosure-open':
3508
- return 50 /* DISCLOSURE_OPEN */;
4336
+ return 50 /* LIST_STYLE_TYPE.DISCLOSURE_OPEN */;
3509
4337
  case 'disclosure-closed':
3510
- return 51 /* DISCLOSURE_CLOSED */;
4338
+ return 51 /* LIST_STYLE_TYPE.DISCLOSURE_CLOSED */;
3511
4339
  case 'none':
3512
4340
  default:
3513
- return -1 /* NONE */;
4341
+ return -1 /* LIST_STYLE_TYPE.NONE */;
3514
4342
  }
3515
4343
  }
3516
4344
  };
3517
4345
 
3518
4346
  var marginForSide = function (side) { return ({
3519
- name: "margin-" + side,
4347
+ name: "margin-".concat(side),
3520
4348
  initialValue: '0',
3521
4349
  prefix: false,
3522
- type: 4 /* TOKEN_VALUE */
4350
+ type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
3523
4351
  }); };
3524
4352
  var marginTop = marginForSide('top');
3525
4353
  var marginRight = marginForSide('right');
@@ -3530,21 +4358,21 @@ var overflow = {
3530
4358
  name: 'overflow',
3531
4359
  initialValue: 'visible',
3532
4360
  prefix: false,
3533
- type: 1 /* LIST */,
4361
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3534
4362
  parse: function (_context, tokens) {
3535
4363
  return tokens.filter(isIdentToken).map(function (overflow) {
3536
4364
  switch (overflow.value) {
3537
4365
  case 'hidden':
3538
- return 1 /* HIDDEN */;
4366
+ return 1 /* OVERFLOW.HIDDEN */;
3539
4367
  case 'scroll':
3540
- return 2 /* SCROLL */;
4368
+ return 2 /* OVERFLOW.SCROLL */;
3541
4369
  case 'clip':
3542
- return 3 /* CLIP */;
4370
+ return 3 /* OVERFLOW.CLIP */;
3543
4371
  case 'auto':
3544
- return 4 /* AUTO */;
4372
+ return 4 /* OVERFLOW.AUTO */;
3545
4373
  case 'visible':
3546
4374
  default:
3547
- return 0 /* VISIBLE */;
4375
+ return 0 /* OVERFLOW.VISIBLE */;
3548
4376
  }
3549
4377
  });
3550
4378
  }
@@ -3554,23 +4382,23 @@ var overflowWrap = {
3554
4382
  name: 'overflow-wrap',
3555
4383
  initialValue: 'normal',
3556
4384
  prefix: false,
3557
- type: 2 /* IDENT_VALUE */,
4385
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3558
4386
  parse: function (_context, overflow) {
3559
4387
  switch (overflow) {
3560
4388
  case 'break-word':
3561
- return "break-word" /* BREAK_WORD */;
4389
+ return "break-word" /* OVERFLOW_WRAP.BREAK_WORD */;
3562
4390
  case 'normal':
3563
4391
  default:
3564
- return "normal" /* NORMAL */;
4392
+ return "normal" /* OVERFLOW_WRAP.NORMAL */;
3565
4393
  }
3566
4394
  }
3567
4395
  };
3568
4396
 
3569
4397
  var paddingForSide = function (side) { return ({
3570
- name: "padding-" + side,
4398
+ name: "padding-".concat(side),
3571
4399
  initialValue: '0',
3572
4400
  prefix: false,
3573
- type: 3 /* TYPE_VALUE */,
4401
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3574
4402
  format: 'length-percentage'
3575
4403
  }); };
3576
4404
  var paddingTop = paddingForSide('top');
@@ -3582,17 +4410,17 @@ var textAlign = {
3582
4410
  name: 'text-align',
3583
4411
  initialValue: 'left',
3584
4412
  prefix: false,
3585
- type: 2 /* IDENT_VALUE */,
4413
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3586
4414
  parse: function (_context, textAlign) {
3587
4415
  switch (textAlign) {
3588
4416
  case 'right':
3589
- return 2 /* RIGHT */;
4417
+ return 2 /* TEXT_ALIGN.RIGHT */;
3590
4418
  case 'center':
3591
4419
  case 'justify':
3592
- return 1 /* CENTER */;
4420
+ return 1 /* TEXT_ALIGN.CENTER */;
3593
4421
  case 'left':
3594
4422
  default:
3595
- return 0 /* LEFT */;
4423
+ return 0 /* TEXT_ALIGN.LEFT */;
3596
4424
  }
3597
4425
  }
3598
4426
  };
@@ -3601,26 +4429,26 @@ var position = {
3601
4429
  name: 'position',
3602
4430
  initialValue: 'static',
3603
4431
  prefix: false,
3604
- type: 2 /* IDENT_VALUE */,
4432
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3605
4433
  parse: function (_context, position) {
3606
4434
  switch (position) {
3607
4435
  case 'relative':
3608
- return 1 /* RELATIVE */;
4436
+ return 1 /* POSITION.RELATIVE */;
3609
4437
  case 'absolute':
3610
- return 2 /* ABSOLUTE */;
4438
+ return 2 /* POSITION.ABSOLUTE */;
3611
4439
  case 'fixed':
3612
- return 3 /* FIXED */;
4440
+ return 3 /* POSITION.FIXED */;
3613
4441
  case 'sticky':
3614
- return 4 /* STICKY */;
4442
+ return 4 /* POSITION.STICKY */;
3615
4443
  }
3616
- return 0 /* STATIC */;
4444
+ return 0 /* POSITION.STATIC */;
3617
4445
  }
3618
4446
  };
3619
4447
 
3620
4448
  var textShadow = {
3621
4449
  name: 'text-shadow',
3622
4450
  initialValue: 'none',
3623
- type: 1 /* LIST */,
4451
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3624
4452
  prefix: false,
3625
4453
  parse: function (context, tokens) {
3626
4454
  if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
@@ -3661,17 +4489,17 @@ var textTransform = {
3661
4489
  name: 'text-transform',
3662
4490
  initialValue: 'none',
3663
4491
  prefix: false,
3664
- type: 2 /* IDENT_VALUE */,
4492
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3665
4493
  parse: function (_context, textTransform) {
3666
4494
  switch (textTransform) {
3667
4495
  case 'uppercase':
3668
- return 2 /* UPPERCASE */;
4496
+ return 2 /* TEXT_TRANSFORM.UPPERCASE */;
3669
4497
  case 'lowercase':
3670
- return 1 /* LOWERCASE */;
4498
+ return 1 /* TEXT_TRANSFORM.LOWERCASE */;
3671
4499
  case 'capitalize':
3672
- return 3 /* CAPITALIZE */;
4500
+ return 3 /* TEXT_TRANSFORM.CAPITALIZE */;
3673
4501
  }
3674
- return 0 /* NONE */;
4502
+ return 0 /* TEXT_TRANSFORM.NONE */;
3675
4503
  }
3676
4504
  };
3677
4505
 
@@ -3679,38 +4507,58 @@ var transform$1 = {
3679
4507
  name: 'transform',
3680
4508
  initialValue: 'none',
3681
4509
  prefix: true,
3682
- type: 0 /* VALUE */,
4510
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3683
4511
  parse: function (_context, token) {
3684
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
4512
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
3685
4513
  return null;
3686
4514
  }
3687
- if (token.type === 18 /* FUNCTION */) {
4515
+ if (token.type === 18 /* TokenType.FUNCTION */) {
3688
4516
  var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
3689
4517
  if (typeof transformFunction === 'undefined') {
3690
- throw new Error("Attempting to parse an unsupported transform function \"" + token.name + "\"");
4518
+ throw new Error("Attempting to parse an unsupported transform function \"".concat(token.name, "\""));
3691
4519
  }
3692
- return transformFunction(token.values);
4520
+ return transformFunction(_context, token.values);
3693
4521
  }
3694
4522
  return null;
3695
4523
  }
3696
4524
  };
3697
- var matrix = function (args) {
3698
- var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
4525
+ var matrix = function (_context, args) {
4526
+ var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
3699
4527
  return values.length === 6 ? values : null;
3700
4528
  };
3701
4529
  // doesn't support 3D transforms at the moment
3702
- var matrix3d = function (args) {
3703
- var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
4530
+ var matrix3d = function (_context, args) {
4531
+ var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
3704
4532
  var a1 = values[0], b1 = values[1]; values[2]; values[3]; var a2 = values[4], b2 = values[5]; values[6]; values[7]; values[8]; values[9]; values[10]; values[11]; var a4 = values[12], b4 = values[13]; values[14]; values[15];
3705
4533
  return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
3706
4534
  };
4535
+ var rotate$1 = function (context, args) {
4536
+ if (args.length !== 1) {
4537
+ return null;
4538
+ }
4539
+ var arg = args[0];
4540
+ var radians = 0;
4541
+ if (arg.type === 17 /* TokenType.NUMBER_TOKEN */ && arg.number === 0) {
4542
+ radians = 0;
4543
+ }
4544
+ else if (arg.type === 15 /* TokenType.DIMENSION_TOKEN */) {
4545
+ radians = angle.parse(context, arg);
4546
+ }
4547
+ else {
4548
+ return null;
4549
+ }
4550
+ var cos = Math.cos(radians);
4551
+ var sin = Math.sin(radians);
4552
+ return [cos, sin, -sin, cos, 0, 0];
4553
+ };
3707
4554
  var SUPPORTED_TRANSFORM_FUNCTIONS = {
3708
4555
  matrix: matrix,
3709
- matrix3d: matrix3d
4556
+ matrix3d: matrix3d,
4557
+ rotate: rotate$1
3710
4558
  };
3711
4559
 
3712
4560
  var DEFAULT_VALUE = {
3713
- type: 16 /* PERCENTAGE_TOKEN */,
4561
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
3714
4562
  number: 50,
3715
4563
  flags: FLAG_INTEGER
3716
4564
  };
@@ -3719,7 +4567,7 @@ var transformOrigin = {
3719
4567
  name: 'transform-origin',
3720
4568
  initialValue: '50% 50%',
3721
4569
  prefix: true,
3722
- type: 1 /* LIST */,
4570
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3723
4571
  parse: function (_context, tokens) {
3724
4572
  var origins = tokens.filter(isLengthPercentage);
3725
4573
  if (origins.length !== 2) {
@@ -3729,20 +4577,44 @@ var transformOrigin = {
3729
4577
  }
3730
4578
  };
3731
4579
 
4580
+ var rotate = {
4581
+ name: 'rotate',
4582
+ initialValue: 'none',
4583
+ prefix: false,
4584
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
4585
+ parse: function (_context, token) {
4586
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
4587
+ return null;
4588
+ }
4589
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
4590
+ if (token.number === 0) {
4591
+ return 0;
4592
+ }
4593
+ }
4594
+ if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
4595
+ // Parse angle and convert to degrees for storage
4596
+ var radians = angle.parse(_context, token);
4597
+ // Store as degrees for consistency
4598
+ return (radians * 180) / Math.PI;
4599
+ }
4600
+ return null;
4601
+ }
4602
+ };
4603
+
3732
4604
  var visibility = {
3733
4605
  name: 'visible',
3734
4606
  initialValue: 'none',
3735
4607
  prefix: false,
3736
- type: 2 /* IDENT_VALUE */,
4608
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3737
4609
  parse: function (_context, visibility) {
3738
4610
  switch (visibility) {
3739
4611
  case 'hidden':
3740
- return 1 /* HIDDEN */;
4612
+ return 1 /* VISIBILITY.HIDDEN */;
3741
4613
  case 'collapse':
3742
- return 2 /* COLLAPSE */;
4614
+ return 2 /* VISIBILITY.COLLAPSE */;
3743
4615
  case 'visible':
3744
4616
  default:
3745
- return 0 /* VISIBLE */;
4617
+ return 0 /* VISIBILITY.VISIBLE */;
3746
4618
  }
3747
4619
  }
3748
4620
  };
@@ -3757,7 +4629,7 @@ var wordBreak = {
3757
4629
  name: 'word-break',
3758
4630
  initialValue: 'normal',
3759
4631
  prefix: false,
3760
- type: 2 /* IDENT_VALUE */,
4632
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3761
4633
  parse: function (_context, wordBreak) {
3762
4634
  switch (wordBreak) {
3763
4635
  case 'break-all':
@@ -3775,9 +4647,9 @@ var zIndex = {
3775
4647
  name: 'z-index',
3776
4648
  initialValue: 'auto',
3777
4649
  prefix: false,
3778
- type: 0 /* VALUE */,
4650
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3779
4651
  parse: function (_context, token) {
3780
- if (token.type === 20 /* IDENT_TOKEN */) {
4652
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
3781
4653
  return { auto: true, order: 0 };
3782
4654
  }
3783
4655
  if (isNumberToken(token)) {
@@ -3790,7 +4662,7 @@ var zIndex = {
3790
4662
  var time = {
3791
4663
  name: 'time',
3792
4664
  parse: function (_context, value) {
3793
- if (value.type === 15 /* DIMENSION_TOKEN */) {
4665
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
3794
4666
  switch (value.unit.toLowerCase()) {
3795
4667
  case 's':
3796
4668
  return 1000 * value.number;
@@ -3805,7 +4677,7 @@ var time = {
3805
4677
  var opacity = {
3806
4678
  name: 'opacity',
3807
4679
  initialValue: '1',
3808
- type: 0 /* VALUE */,
4680
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3809
4681
  prefix: false,
3810
4682
  parse: function (_context, token) {
3811
4683
  if (isNumberToken(token)) {
@@ -3819,7 +4691,7 @@ var textDecorationColor = {
3819
4691
  name: "text-decoration-color",
3820
4692
  initialValue: 'transparent',
3821
4693
  prefix: false,
3822
- type: 3 /* TYPE_VALUE */,
4694
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3823
4695
  format: 'color'
3824
4696
  };
3825
4697
 
@@ -3827,24 +4699,24 @@ var textDecorationLine = {
3827
4699
  name: 'text-decoration-line',
3828
4700
  initialValue: 'none',
3829
4701
  prefix: false,
3830
- type: 1 /* LIST */,
4702
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3831
4703
  parse: function (_context, tokens) {
3832
4704
  return tokens
3833
4705
  .filter(isIdentToken)
3834
4706
  .map(function (token) {
3835
4707
  switch (token.value) {
3836
4708
  case 'underline':
3837
- return 1 /* UNDERLINE */;
4709
+ return 1 /* TEXT_DECORATION_LINE.UNDERLINE */;
3838
4710
  case 'overline':
3839
- return 2 /* OVERLINE */;
4711
+ return 2 /* TEXT_DECORATION_LINE.OVERLINE */;
3840
4712
  case 'line-through':
3841
- return 3 /* LINE_THROUGH */;
4713
+ return 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */;
3842
4714
  case 'none':
3843
- return 4 /* BLINK */;
4715
+ return 4 /* TEXT_DECORATION_LINE.BLINK */;
3844
4716
  }
3845
- return 0 /* NONE */;
4717
+ return 0 /* TEXT_DECORATION_LINE.NONE */;
3846
4718
  })
3847
- .filter(function (line) { return line !== 0 /* NONE */; });
4719
+ .filter(function (line) { return line !== 0 /* TEXT_DECORATION_LINE.NONE */; });
3848
4720
  }
3849
4721
  };
3850
4722
 
@@ -3852,20 +4724,20 @@ var fontFamily = {
3852
4724
  name: "font-family",
3853
4725
  initialValue: '',
3854
4726
  prefix: false,
3855
- type: 1 /* LIST */,
4727
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3856
4728
  parse: function (_context, tokens) {
3857
4729
  var accumulator = [];
3858
4730
  var results = [];
3859
4731
  tokens.forEach(function (token) {
3860
4732
  switch (token.type) {
3861
- case 20 /* IDENT_TOKEN */:
3862
- case 0 /* STRING_TOKEN */:
4733
+ case 20 /* TokenType.IDENT_TOKEN */:
4734
+ case 0 /* TokenType.STRING_TOKEN */:
3863
4735
  accumulator.push(token.value);
3864
4736
  break;
3865
- case 17 /* NUMBER_TOKEN */:
4737
+ case 17 /* TokenType.NUMBER_TOKEN */:
3866
4738
  accumulator.push(token.number.toString());
3867
4739
  break;
3868
- case 4 /* COMMA_TOKEN */:
4740
+ case 4 /* TokenType.COMMA_TOKEN */:
3869
4741
  results.push(accumulator.join(' '));
3870
4742
  accumulator.length = 0;
3871
4743
  break;
@@ -3874,7 +4746,7 @@ var fontFamily = {
3874
4746
  if (accumulator.length) {
3875
4747
  results.push(accumulator.join(' '));
3876
4748
  }
3877
- return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'" + result + "'"); });
4749
+ return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'".concat(result, "'")); });
3878
4750
  }
3879
4751
  };
3880
4752
 
@@ -3882,14 +4754,14 @@ var fontSize = {
3882
4754
  name: "font-size",
3883
4755
  initialValue: '0',
3884
4756
  prefix: false,
3885
- type: 3 /* TYPE_VALUE */,
4757
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3886
4758
  format: 'length'
3887
4759
  };
3888
4760
 
3889
4761
  var fontWeight = {
3890
4762
  name: 'font-weight',
3891
4763
  initialValue: 'normal',
3892
- type: 0 /* VALUE */,
4764
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3893
4765
  prefix: false,
3894
4766
  parse: function (_context, token) {
3895
4767
  if (isNumberToken(token)) {
@@ -3911,7 +4783,7 @@ var fontWeight = {
3911
4783
  var fontVariant = {
3912
4784
  name: 'font-variant',
3913
4785
  initialValue: 'none',
3914
- type: 1 /* LIST */,
4786
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3915
4787
  prefix: false,
3916
4788
  parse: function (_context, tokens) {
3917
4789
  return tokens.filter(isIdentToken).map(function (token) { return token.value; });
@@ -3922,16 +4794,16 @@ var fontStyle = {
3922
4794
  name: 'font-style',
3923
4795
  initialValue: 'normal',
3924
4796
  prefix: false,
3925
- type: 2 /* IDENT_VALUE */,
4797
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3926
4798
  parse: function (_context, overflow) {
3927
4799
  switch (overflow) {
3928
4800
  case 'oblique':
3929
- return "oblique" /* OBLIQUE */;
4801
+ return "oblique" /* FONT_STYLE.OBLIQUE */;
3930
4802
  case 'italic':
3931
- return "italic" /* ITALIC */;
4803
+ return "italic" /* FONT_STYLE.ITALIC */;
3932
4804
  case 'normal':
3933
4805
  default:
3934
- return "normal" /* NORMAL */;
4806
+ return "normal" /* FONT_STYLE.NORMAL */;
3935
4807
  }
3936
4808
  }
3937
4809
  };
@@ -3941,14 +4813,14 @@ var contains = function (bit, value) { return (bit & value) !== 0; };
3941
4813
  var content = {
3942
4814
  name: 'content',
3943
4815
  initialValue: 'none',
3944
- type: 1 /* LIST */,
4816
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3945
4817
  prefix: false,
3946
4818
  parse: function (_context, tokens) {
3947
4819
  if (tokens.length === 0) {
3948
4820
  return [];
3949
4821
  }
3950
4822
  var first = tokens[0];
3951
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4823
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3952
4824
  return [];
3953
4825
  }
3954
4826
  return tokens;
@@ -3959,13 +4831,13 @@ var counterIncrement = {
3959
4831
  name: 'counter-increment',
3960
4832
  initialValue: 'none',
3961
4833
  prefix: true,
3962
- type: 1 /* LIST */,
4834
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3963
4835
  parse: function (_context, tokens) {
3964
4836
  if (tokens.length === 0) {
3965
4837
  return null;
3966
4838
  }
3967
4839
  var first = tokens[0];
3968
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4840
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3969
4841
  return null;
3970
4842
  }
3971
4843
  var increments = [];
@@ -3973,7 +4845,7 @@ var counterIncrement = {
3973
4845
  for (var i = 0; i < filtered.length; i++) {
3974
4846
  var counter = filtered[i];
3975
4847
  var next = filtered[i + 1];
3976
- if (counter.type === 20 /* IDENT_TOKEN */) {
4848
+ if (counter.type === 20 /* TokenType.IDENT_TOKEN */) {
3977
4849
  var increment = next && isNumberToken(next) ? next.number : 1;
3978
4850
  increments.push({ counter: counter.value, increment: increment });
3979
4851
  }
@@ -3986,7 +4858,7 @@ var counterReset = {
3986
4858
  name: 'counter-reset',
3987
4859
  initialValue: 'none',
3988
4860
  prefix: true,
3989
- type: 1 /* LIST */,
4861
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3990
4862
  parse: function (_context, tokens) {
3991
4863
  if (tokens.length === 0) {
3992
4864
  return [];
@@ -4009,7 +4881,7 @@ var duration = {
4009
4881
  name: 'duration',
4010
4882
  initialValue: '0s',
4011
4883
  prefix: false,
4012
- type: 1 /* LIST */,
4884
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4013
4885
  parse: function (context, tokens) {
4014
4886
  return tokens.filter(isDimensionToken).map(function (token) { return time.parse(context, token); });
4015
4887
  }
@@ -4019,13 +4891,13 @@ var quotes = {
4019
4891
  name: 'quotes',
4020
4892
  initialValue: 'none',
4021
4893
  prefix: true,
4022
- type: 1 /* LIST */,
4894
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4023
4895
  parse: function (_context, tokens) {
4024
4896
  if (tokens.length === 0) {
4025
4897
  return null;
4026
4898
  }
4027
4899
  var first = tokens[0];
4028
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4900
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
4029
4901
  return null;
4030
4902
  }
4031
4903
  var quotes = [];
@@ -4055,7 +4927,7 @@ var getQuote = function (quotes, depth, open) {
4055
4927
  var boxShadow = {
4056
4928
  name: 'box-shadow',
4057
4929
  initialValue: 'none',
4058
- type: 1 /* LIST */,
4930
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4059
4931
  prefix: false,
4060
4932
  parse: function (context, tokens) {
4061
4933
  if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
@@ -4104,20 +4976,20 @@ var paintOrder = {
4104
4976
  name: 'paint-order',
4105
4977
  initialValue: 'normal',
4106
4978
  prefix: false,
4107
- type: 1 /* LIST */,
4979
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4108
4980
  parse: function (_context, tokens) {
4109
- var DEFAULT_VALUE = [0 /* FILL */, 1 /* STROKE */, 2 /* MARKERS */];
4981
+ var DEFAULT_VALUE = [0 /* PAINT_ORDER_LAYER.FILL */, 1 /* PAINT_ORDER_LAYER.STROKE */, 2 /* PAINT_ORDER_LAYER.MARKERS */];
4110
4982
  var layers = [];
4111
4983
  tokens.filter(isIdentToken).forEach(function (token) {
4112
4984
  switch (token.value) {
4113
4985
  case 'stroke':
4114
- layers.push(1 /* STROKE */);
4986
+ layers.push(1 /* PAINT_ORDER_LAYER.STROKE */);
4115
4987
  break;
4116
4988
  case 'fill':
4117
- layers.push(0 /* FILL */);
4989
+ layers.push(0 /* PAINT_ORDER_LAYER.FILL */);
4118
4990
  break;
4119
4991
  case 'markers':
4120
- layers.push(2 /* MARKERS */);
4992
+ layers.push(2 /* PAINT_ORDER_LAYER.MARKERS */);
4121
4993
  break;
4122
4994
  }
4123
4995
  });
@@ -4134,14 +5006,14 @@ var webkitTextStrokeColor = {
4134
5006
  name: "-webkit-text-stroke-color",
4135
5007
  initialValue: 'currentcolor',
4136
5008
  prefix: false,
4137
- type: 3 /* TYPE_VALUE */,
5009
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
4138
5010
  format: 'color'
4139
5011
  };
4140
5012
 
4141
5013
  var webkitTextStrokeWidth = {
4142
5014
  name: "-webkit-text-stroke-width",
4143
5015
  initialValue: '0',
4144
- type: 0 /* VALUE */,
5016
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
4145
5017
  prefix: false,
4146
5018
  parse: function (_context, token) {
4147
5019
  if (isDimensionToken(token)) {
@@ -4151,6 +5023,31 @@ var webkitTextStrokeWidth = {
4151
5023
  }
4152
5024
  };
4153
5025
 
5026
+ var objectFit = {
5027
+ name: 'objectFit',
5028
+ initialValue: 'fill',
5029
+ prefix: false,
5030
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
5031
+ parse: function (_context, tokens) {
5032
+ return tokens.filter(isIdentToken).reduce(function (bit, token) {
5033
+ return bit | parseDisplayValue(token.value);
5034
+ }, 0 /* OBJECT_FIT.FILL */);
5035
+ }
5036
+ };
5037
+ var parseDisplayValue = function (display) {
5038
+ switch (display) {
5039
+ case 'contain':
5040
+ return 2 /* OBJECT_FIT.CONTAIN */;
5041
+ case 'cover':
5042
+ return 4 /* OBJECT_FIT.COVER */;
5043
+ case 'none':
5044
+ return 8 /* OBJECT_FIT.NONE */;
5045
+ case 'scale-down':
5046
+ return 16 /* OBJECT_FIT.SCALE_DOWN */;
5047
+ }
5048
+ return 0 /* OBJECT_FIT.FILL */;
5049
+ };
5050
+
4154
5051
  var CSSParsedDeclaration = /** @class */ (function () {
4155
5052
  function CSSParsedDeclaration(context, declaration) {
4156
5053
  var _a, _b;
@@ -4216,37 +5113,39 @@ var CSSParsedDeclaration = /** @class */ (function () {
4216
5113
  this.textTransform = parse(context, textTransform, declaration.textTransform);
4217
5114
  this.transform = parse(context, transform$1, declaration.transform);
4218
5115
  this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
5116
+ this.rotate = parse(context, rotate, declaration.rotate);
4219
5117
  this.visibility = parse(context, visibility, declaration.visibility);
4220
5118
  this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
4221
5119
  this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
4222
5120
  this.wordBreak = parse(context, wordBreak, declaration.wordBreak);
4223
5121
  this.zIndex = parse(context, zIndex, declaration.zIndex);
5122
+ this.objectFit = parse(context, objectFit, declaration.objectFit);
4224
5123
  }
4225
5124
  CSSParsedDeclaration.prototype.isVisible = function () {
4226
- return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBLE */;
5125
+ return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBILITY.VISIBLE */;
4227
5126
  };
4228
5127
  CSSParsedDeclaration.prototype.isTransparent = function () {
4229
5128
  return isTransparent(this.backgroundColor);
4230
5129
  };
4231
5130
  CSSParsedDeclaration.prototype.isTransformed = function () {
4232
- return this.transform !== null;
5131
+ return this.transform !== null || this.rotate !== null;
4233
5132
  };
4234
5133
  CSSParsedDeclaration.prototype.isPositioned = function () {
4235
- return this.position !== 0 /* STATIC */;
5134
+ return this.position !== 0 /* POSITION.STATIC */;
4236
5135
  };
4237
5136
  CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {
4238
5137
  return this.isPositioned() && !this.zIndex.auto;
4239
5138
  };
4240
5139
  CSSParsedDeclaration.prototype.isFloating = function () {
4241
- return this.float !== 0 /* NONE */;
5140
+ return this.float !== 0 /* FLOAT.NONE */;
4242
5141
  };
4243
5142
  CSSParsedDeclaration.prototype.isInlineLevel = function () {
4244
- return (contains(this.display, 4 /* INLINE */) ||
4245
- contains(this.display, 33554432 /* INLINE_BLOCK */) ||
4246
- contains(this.display, 268435456 /* INLINE_FLEX */) ||
4247
- contains(this.display, 536870912 /* INLINE_GRID */) ||
4248
- contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||
4249
- contains(this.display, 134217728 /* INLINE_TABLE */));
5143
+ return (contains(this.display, 4 /* DISPLAY.INLINE */) ||
5144
+ contains(this.display, 33554432 /* DISPLAY.INLINE_BLOCK */) ||
5145
+ contains(this.display, 268435456 /* DISPLAY.INLINE_FLEX */) ||
5146
+ contains(this.display, 536870912 /* DISPLAY.INLINE_GRID */) ||
5147
+ contains(this.display, 67108864 /* DISPLAY.INLINE_LIST_ITEM */) ||
5148
+ contains(this.display, 134217728 /* DISPLAY.INLINE_TABLE */));
4250
5149
  };
4251
5150
  return CSSParsedDeclaration;
4252
5151
  }());
@@ -4271,16 +5170,16 @@ var parse = function (context, descriptor, style) {
4271
5170
  tokenizer.write(value);
4272
5171
  var parser = new Parser(tokenizer.read());
4273
5172
  switch (descriptor.type) {
4274
- case 2 /* IDENT_VALUE */:
5173
+ case 2 /* PropertyDescriptorParsingType.IDENT_VALUE */:
4275
5174
  var token = parser.parseComponentValue();
4276
5175
  return descriptor.parse(context, isIdentToken(token) ? token.value : descriptor.initialValue);
4277
- case 0 /* VALUE */:
5176
+ case 0 /* PropertyDescriptorParsingType.VALUE */:
4278
5177
  return descriptor.parse(context, parser.parseComponentValue());
4279
- case 1 /* LIST */:
5178
+ case 1 /* PropertyDescriptorParsingType.LIST */:
4280
5179
  return descriptor.parse(context, parser.parseComponentValues());
4281
- case 4 /* TOKEN_VALUE */:
5180
+ case 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */:
4282
5181
  return parser.parseComponentValue();
4283
- case 3 /* TYPE_VALUE */:
5182
+ case 3 /* PropertyDescriptorParsingType.TYPE_VALUE */:
4284
5183
  switch (descriptor.format) {
4285
5184
  case 'angle':
4286
5185
  return angle.parse(context, parser.parseComponentValue());
@@ -4306,20 +5205,20 @@ var getElementDebugType = function (element) {
4306
5205
  var attribute = element.getAttribute(elementDebuggerAttribute);
4307
5206
  switch (attribute) {
4308
5207
  case 'all':
4309
- return 1 /* ALL */;
5208
+ return 1 /* DebuggerType.ALL */;
4310
5209
  case 'clone':
4311
- return 2 /* CLONE */;
5210
+ return 2 /* DebuggerType.CLONE */;
4312
5211
  case 'parse':
4313
- return 3 /* PARSE */;
5212
+ return 3 /* DebuggerType.PARSE */;
4314
5213
  case 'render':
4315
- return 4 /* RENDER */;
5214
+ return 4 /* DebuggerType.RENDER */;
4316
5215
  default:
4317
- return 0 /* NONE */;
5216
+ return 0 /* DebuggerType.NONE */;
4318
5217
  }
4319
5218
  };
4320
5219
  var isDebugging = function (element, type) {
4321
5220
  var elementType = getElementDebugType(element);
4322
- return elementType === 1 /* ALL */ || type === elementType;
5221
+ return elementType === 1 /* DebuggerType.ALL */ || type === elementType;
4323
5222
  };
4324
5223
 
4325
5224
  var ElementContainer = /** @class */ (function () {
@@ -4328,7 +5227,7 @@ var ElementContainer = /** @class */ (function () {
4328
5227
  this.textNodes = [];
4329
5228
  this.elements = [];
4330
5229
  this.flags = 0;
4331
- if (isDebugging(element, 3 /* PARSE */)) {
5230
+ if (isDebugging(element, 3 /* DebuggerType.PARSE */)) {
4332
5231
  debugger;
4333
5232
  }
4334
5233
  this.styles = new CSSParsedDeclaration(context, window.getComputedStyle(element, null));
@@ -4340,10 +5239,14 @@ var ElementContainer = /** @class */ (function () {
4340
5239
  // getBoundingClientRect takes transforms into account
4341
5240
  element.style.transform = 'none';
4342
5241
  }
5242
+ if (this.styles.rotate !== null) {
5243
+ // Handle rotate property similarly to transform
5244
+ element.style.rotate = 'none';
5245
+ }
4343
5246
  }
4344
5247
  this.bounds = parseBounds(this.context, element);
4345
- if (isDebugging(element, 4 /* RENDER */)) {
4346
- this.flags |= 16 /* DEBUG_RENDER */;
5248
+ if (isDebugging(element, 4 /* DebuggerType.RENDER */)) {
5249
+ this.flags |= 16 /* FLAGS.DEBUG_RENDER */;
4347
5250
  }
4348
5251
  }
4349
5252
  return ElementContainer;
@@ -4737,7 +5640,7 @@ var testRangeBounds = function (document) {
4737
5640
  var range = document.createRange();
4738
5641
  if (range.getBoundingClientRect) {
4739
5642
  var testElement = document.createElement('boundtest');
4740
- testElement.style.height = TEST_HEIGHT + "px";
5643
+ testElement.style.height = "".concat(TEST_HEIGHT, "px");
4741
5644
  testElement.style.display = 'block';
4742
5645
  document.body.appendChild(testElement);
4743
5646
  range.selectNode(testElement);
@@ -4827,8 +5730,8 @@ var testForeignObject = function (document) {
4827
5730
  ctx.fillStyle = 'red';
4828
5731
  ctx.fillRect(0, 0, size, size);
4829
5732
  var node = document.createElement('div');
4830
- node.style.backgroundImage = "url(" + greenImageSrc + ")";
4831
- node.style.height = size + "px";
5733
+ node.style.backgroundImage = "url(".concat(greenImageSrc, ")");
5734
+ node.style.height = "".concat(size, "px");
4832
5735
  // Firefox 55 does not render inline <img /> tags
4833
5736
  return isGreenPixel(data)
4834
5737
  ? loadSerializedSVG$1(createForeignObjectSVG(size, size, 0, 0, node))
@@ -4861,7 +5764,7 @@ var loadSerializedSVG$1 = function (svg) {
4861
5764
  var img = new Image();
4862
5765
  img.onload = function () { return resolve(img); };
4863
5766
  img.onerror = reject;
4864
- img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
5767
+ img.src = "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svg)));
4865
5768
  });
4866
5769
  };
4867
5770
  var FEATURES = {
@@ -5005,7 +5908,7 @@ var wordSeparators = [0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091];
5005
5908
  var breakWords = function (str, styles) {
5006
5909
  var breaker = LineBreaker(str, {
5007
5910
  lineBreak: styles.lineBreak,
5008
- wordBreak: styles.overflowWrap === "break-word" /* BREAK_WORD */ ? 'break-word' : styles.wordBreak
5911
+ wordBreak: styles.overflowWrap === "break-word" /* OVERFLOW_WRAP.BREAK_WORD */ ? 'break-word' : styles.wordBreak
5009
5912
  });
5010
5913
  var words = [];
5011
5914
  var bk;
@@ -5046,11 +5949,11 @@ var TextContainer = /** @class */ (function () {
5046
5949
  }());
5047
5950
  var transform = function (text, transform) {
5048
5951
  switch (transform) {
5049
- case 1 /* LOWERCASE */:
5952
+ case 1 /* TEXT_TRANSFORM.LOWERCASE */:
5050
5953
  return text.toLowerCase();
5051
- case 3 /* CAPITALIZE */:
5954
+ case 3 /* TEXT_TRANSFORM.CAPITALIZE */:
5052
5955
  return text.replace(CAPITALIZE, capitalize);
5053
- case 2 /* UPPERCASE */:
5956
+ case 2 /* TEXT_TRANSFORM.UPPERCASE */:
5054
5957
  return text.toUpperCase();
5055
5958
  default:
5056
5959
  return text;
@@ -5095,9 +5998,9 @@ var SVGElementContainer = /** @class */ (function (_super) {
5095
5998
  var _this = _super.call(this, context, img) || this;
5096
5999
  var s = new XMLSerializer();
5097
6000
  var bounds = parseBounds(context, img);
5098
- img.setAttribute('width', bounds.width + "px");
5099
- img.setAttribute('height', bounds.height + "px");
5100
- _this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img));
6001
+ img.setAttribute('width', "".concat(bounds.width, "px"));
6002
+ img.setAttribute('height', "".concat(bounds.height, "px"));
6003
+ _this.svg = "data:image/svg+xml,".concat(encodeURIComponent(s.serializeToString(img)));
5101
6004
  _this.intrinsicWidth = img.width.baseVal.value;
5102
6005
  _this.intrinsicHeight = img.height.baseVal.value;
5103
6006
  _this.context.cache.addImage(_this.svg);
@@ -5129,7 +6032,7 @@ var OLElementContainer = /** @class */ (function (_super) {
5129
6032
 
5130
6033
  var CHECKBOX_BORDER_RADIUS = [
5131
6034
  {
5132
- type: 15 /* DIMENSION_TOKEN */,
6035
+ type: 15 /* TokenType.DIMENSION_TOKEN */,
5133
6036
  flags: 0,
5134
6037
  unit: 'px',
5135
6038
  number: 3
@@ -5137,7 +6040,7 @@ var CHECKBOX_BORDER_RADIUS = [
5137
6040
  ];
5138
6041
  var RADIO_BORDER_RADIUS = [
5139
6042
  {
5140
- type: 16 /* PERCENTAGE_TOKEN */,
6043
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
5141
6044
  flags: 0,
5142
6045
  number: 50
5143
6046
  }
@@ -5182,9 +6085,9 @@ var InputElementContainer = /** @class */ (function (_super) {
5182
6085
  _this.styles.borderRightStyle =
5183
6086
  _this.styles.borderBottomStyle =
5184
6087
  _this.styles.borderLeftStyle =
5185
- 1 /* SOLID */;
5186
- _this.styles.backgroundClip = [0 /* BORDER_BOX */];
5187
- _this.styles.backgroundOrigin = [0 /* BORDER_BOX */];
6088
+ 1 /* BORDER_STYLE.SOLID */;
6089
+ _this.styles.backgroundClip = [0 /* BACKGROUND_CLIP.BORDER_BOX */];
6090
+ _this.styles.backgroundOrigin = [0 /* BACKGROUND_ORIGIN.BORDER_BOX */];
5188
6091
  _this.bounds = reformatInputBounds(_this.bounds);
5189
6092
  }
5190
6093
  switch (_this.type) {
@@ -5266,7 +6169,8 @@ var LIST_OWNERS = ['OL', 'UL', 'MENU'];
5266
6169
  var parseNodeTree = function (context, node, parent, root) {
5267
6170
  for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
5268
6171
  nextNode = childNode.nextSibling;
5269
- if (isTextNode(childNode) && childNode.data.trim().length > 0) {
6172
+ // Fixes #2238 #1624 - Fix the issue of TextNode content being overlooked in rendering due to being perceived as blank by trim().
6173
+ if (isTextNode(childNode) && childNode.data.length > 0) {
5270
6174
  parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
5271
6175
  }
5272
6176
  else if (isElementNode(childNode)) {
@@ -5277,13 +6181,13 @@ var parseNodeTree = function (context, node, parent, root) {
5277
6181
  var container = createContainer(context, childNode);
5278
6182
  if (container.styles.isVisible()) {
5279
6183
  if (createsRealStackingContext(childNode, container, root)) {
5280
- container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
6184
+ container.flags |= 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */;
5281
6185
  }
5282
6186
  else if (createsStackingContext(container.styles)) {
5283
- container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
6187
+ container.flags |= 2 /* FLAGS.CREATES_STACKING_CONTEXT */;
5284
6188
  }
5285
6189
  if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
5286
- container.flags |= 8 /* IS_LIST_OWNER */;
6190
+ container.flags |= 8 /* FLAGS.IS_LIST_OWNER */;
5287
6191
  }
5288
6192
  parent.elements.push(container);
5289
6193
  childNode.slot;
@@ -5332,7 +6236,7 @@ var createContainer = function (context, element) {
5332
6236
  };
5333
6237
  var parseTree = function (context, element) {
5334
6238
  var container = createContainer(context, element);
5335
- container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
6239
+ container.flags |= 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */;
5336
6240
  parseNodeTree(context, element, container, container);
5337
6241
  return container;
5338
6242
  };
@@ -5600,7 +6504,7 @@ var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;
5600
6504
  var CJK_HUNDRED_COEFFICIENTS = 1 << 3;
5601
6505
  var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {
5602
6506
  if (value < -9999 || value > 9999) {
5603
- return createCounterText(value, 4 /* CJK_DECIMAL */, suffix.length > 0);
6507
+ return createCounterText(value, 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */, suffix.length > 0);
5604
6508
  }
5605
6509
  var tmp = Math.abs(value);
5606
6510
  var string = suffix;
@@ -5636,101 +6540,101 @@ var createCounterText = function (value, type, appendSuffix) {
5636
6540
  var koreanSuffix = appendSuffix ? ', ' : '';
5637
6541
  var spaceSuffix = appendSuffix ? ' ' : '';
5638
6542
  switch (type) {
5639
- case 0 /* DISC */:
6543
+ case 0 /* LIST_STYLE_TYPE.DISC */:
5640
6544
  return '•' + spaceSuffix;
5641
- case 1 /* CIRCLE */:
6545
+ case 1 /* LIST_STYLE_TYPE.CIRCLE */:
5642
6546
  return '◦' + spaceSuffix;
5643
- case 2 /* SQUARE */:
6547
+ case 2 /* LIST_STYLE_TYPE.SQUARE */:
5644
6548
  return '◾' + spaceSuffix;
5645
- case 5 /* DECIMAL_LEADING_ZERO */:
6549
+ case 5 /* LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO */:
5646
6550
  var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
5647
- return string.length < 4 ? "0" + string : string;
5648
- case 4 /* CJK_DECIMAL */:
6551
+ return string.length < 4 ? "0".concat(string) : string;
6552
+ case 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */:
5649
6553
  return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);
5650
- case 6 /* LOWER_ROMAN */:
5651
- return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
5652
- case 7 /* UPPER_ROMAN */:
5653
- return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix);
5654
- case 8 /* LOWER_GREEK */:
6554
+ case 6 /* LIST_STYLE_TYPE.LOWER_ROMAN */:
6555
+ return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix).toLowerCase();
6556
+ case 7 /* LIST_STYLE_TYPE.UPPER_ROMAN */:
6557
+ return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6558
+ case 8 /* LIST_STYLE_TYPE.LOWER_GREEK */:
5655
6559
  return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);
5656
- case 9 /* LOWER_ALPHA */:
6560
+ case 9 /* LIST_STYLE_TYPE.LOWER_ALPHA */:
5657
6561
  return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);
5658
- case 10 /* UPPER_ALPHA */:
6562
+ case 10 /* LIST_STYLE_TYPE.UPPER_ALPHA */:
5659
6563
  return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);
5660
- case 11 /* ARABIC_INDIC */:
6564
+ case 11 /* LIST_STYLE_TYPE.ARABIC_INDIC */:
5661
6565
  return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);
5662
- case 12 /* ARMENIAN */:
5663
- case 49 /* UPPER_ARMENIAN */:
5664
- return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix);
5665
- case 35 /* LOWER_ARMENIAN */:
5666
- return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
5667
- case 13 /* BENGALI */:
6566
+ case 12 /* LIST_STYLE_TYPE.ARMENIAN */:
6567
+ case 49 /* LIST_STYLE_TYPE.UPPER_ARMENIAN */:
6568
+ return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6569
+ case 35 /* LIST_STYLE_TYPE.LOWER_ARMENIAN */:
6570
+ return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix).toLowerCase();
6571
+ case 13 /* LIST_STYLE_TYPE.BENGALI */:
5668
6572
  return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);
5669
- case 14 /* CAMBODIAN */:
5670
- case 30 /* KHMER */:
6573
+ case 14 /* LIST_STYLE_TYPE.CAMBODIAN */:
6574
+ case 30 /* LIST_STYLE_TYPE.KHMER */:
5671
6575
  return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);
5672
- case 15 /* CJK_EARTHLY_BRANCH */:
6576
+ case 15 /* LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH */:
5673
6577
  return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);
5674
- case 16 /* CJK_HEAVENLY_STEM */:
6578
+ case 16 /* LIST_STYLE_TYPE.CJK_HEAVENLY_STEM */:
5675
6579
  return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);
5676
- case 17 /* CJK_IDEOGRAPHIC */:
5677
- case 48 /* TRAD_CHINESE_INFORMAL */:
6580
+ case 17 /* LIST_STYLE_TYPE.CJK_IDEOGRAPHIC */:
6581
+ case 48 /* LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL */:
5678
6582
  return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5679
- case 47 /* TRAD_CHINESE_FORMAL */:
6583
+ case 47 /* LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL */:
5680
6584
  return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5681
- case 42 /* SIMP_CHINESE_INFORMAL */:
6585
+ case 42 /* LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL */:
5682
6586
  return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5683
- case 41 /* SIMP_CHINESE_FORMAL */:
6587
+ case 41 /* LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL */:
5684
6588
  return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5685
- case 26 /* JAPANESE_INFORMAL */:
6589
+ case 26 /* LIST_STYLE_TYPE.JAPANESE_INFORMAL */:
5686
6590
  return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);
5687
- case 25 /* JAPANESE_FORMAL */:
6591
+ case 25 /* LIST_STYLE_TYPE.JAPANESE_FORMAL */:
5688
6592
  return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5689
- case 31 /* KOREAN_HANGUL_FORMAL */:
6593
+ case 31 /* LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL */:
5690
6594
  return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5691
- case 33 /* KOREAN_HANJA_INFORMAL */:
6595
+ case 33 /* LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL */:
5692
6596
  return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);
5693
- case 32 /* KOREAN_HANJA_FORMAL */:
6597
+ case 32 /* LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL */:
5694
6598
  return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5695
- case 18 /* DEVANAGARI */:
6599
+ case 18 /* LIST_STYLE_TYPE.DEVANAGARI */:
5696
6600
  return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);
5697
- case 20 /* GEORGIAN */:
5698
- return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3 /* DECIMAL */, defaultSuffix);
5699
- case 21 /* GUJARATI */:
6601
+ case 20 /* LIST_STYLE_TYPE.GEORGIAN */:
6602
+ return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6603
+ case 21 /* LIST_STYLE_TYPE.GUJARATI */:
5700
6604
  return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);
5701
- case 22 /* GURMUKHI */:
6605
+ case 22 /* LIST_STYLE_TYPE.GURMUKHI */:
5702
6606
  return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);
5703
- case 22 /* HEBREW */:
5704
- return createAdditiveCounter(value, 1, 10999, HEBREW, 3 /* DECIMAL */, defaultSuffix);
5705
- case 23 /* HIRAGANA */:
6607
+ case 52 /* LIST_STYLE_TYPE.HEBREW */:
6608
+ return createAdditiveCounter(value, 1, 10999, HEBREW, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6609
+ case 23 /* LIST_STYLE_TYPE.HIRAGANA */:
5706
6610
  return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');
5707
- case 24 /* HIRAGANA_IROHA */:
6611
+ case 24 /* LIST_STYLE_TYPE.HIRAGANA_IROHA */:
5708
6612
  return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');
5709
- case 27 /* KANNADA */:
6613
+ case 27 /* LIST_STYLE_TYPE.KANNADA */:
5710
6614
  return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);
5711
- case 28 /* KATAKANA */:
6615
+ case 28 /* LIST_STYLE_TYPE.KATAKANA */:
5712
6616
  return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);
5713
- case 29 /* KATAKANA_IROHA */:
6617
+ case 29 /* LIST_STYLE_TYPE.KATAKANA_IROHA */:
5714
6618
  return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);
5715
- case 34 /* LAO */:
6619
+ case 34 /* LIST_STYLE_TYPE.LAO */:
5716
6620
  return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);
5717
- case 37 /* MONGOLIAN */:
6621
+ case 37 /* LIST_STYLE_TYPE.MONGOLIAN */:
5718
6622
  return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);
5719
- case 38 /* MYANMAR */:
6623
+ case 38 /* LIST_STYLE_TYPE.MYANMAR */:
5720
6624
  return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);
5721
- case 39 /* ORIYA */:
6625
+ case 39 /* LIST_STYLE_TYPE.ORIYA */:
5722
6626
  return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);
5723
- case 40 /* PERSIAN */:
6627
+ case 40 /* LIST_STYLE_TYPE.PERSIAN */:
5724
6628
  return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);
5725
- case 43 /* TAMIL */:
6629
+ case 43 /* LIST_STYLE_TYPE.TAMIL */:
5726
6630
  return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);
5727
- case 44 /* TELUGU */:
6631
+ case 44 /* LIST_STYLE_TYPE.TELUGU */:
5728
6632
  return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);
5729
- case 45 /* THAI */:
6633
+ case 45 /* LIST_STYLE_TYPE.THAI */:
5730
6634
  return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);
5731
- case 46 /* TIBETAN */:
6635
+ case 46 /* LIST_STYLE_TYPE.TIBETAN */:
5732
6636
  return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);
5733
- case 3 /* DECIMAL */:
6637
+ case 3 /* LIST_STYLE_TYPE.DECIMAL */:
5734
6638
  default:
5735
6639
  return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
5736
6640
  }
@@ -5780,7 +6684,7 @@ var DocumentCloner = /** @class */ (function () {
5780
6684
  onclone = this.options.onclone;
5781
6685
  referenceElement = this.clonedReferenceElement;
5782
6686
  if (typeof referenceElement === 'undefined') {
5783
- return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
6687
+ return [2 /*return*/, Promise.reject("Error finding the ".concat(this.referenceElement.nodeName, " in the cloned document"))];
5784
6688
  }
5785
6689
  if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
5786
6690
  return [4 /*yield*/, documentClone.fonts.ready];
@@ -5803,16 +6707,33 @@ var DocumentCloner = /** @class */ (function () {
5803
6707
  }
5804
6708
  });
5805
6709
  }); });
6710
+ /**
6711
+ * The baseURI of the document will be lost after documentClone.open().
6712
+ * We save it before open() to preserve the original base URI for resource resolution.
6713
+ * */
6714
+ var baseUri = documentClone.baseURI;
5806
6715
  documentClone.open();
5807
- documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
6716
+ documentClone.write("".concat(serializeDoctype(document.doctype), "<html></html>"));
5808
6717
  // Chrome scrolls the parent document for some reason after the write to the cloned window???
5809
6718
  restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
5810
- documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
6719
+ /**
6720
+ * Note: adoptNode() should be called AFTER documentClone.open() and close()
6721
+ *
6722
+ * In Chrome, calling adoptNode() before or during open/write may cause
6723
+ * styles with uppercase characters in class names (e.g. ".MyClass") to not apply correctly.
6724
+ *
6725
+ * Fix:
6726
+ * - Make sure adoptNode() is called after documentClone.open() and close()
6727
+ * - This allows Chrome to properly match and apply all CSS rules including mixed-case class selectors.
6728
+ * */
6729
+ var adoptedNode = documentClone.adoptNode(this.documentElement);
6730
+ addBase(adoptedNode, baseUri);
6731
+ documentClone.replaceChild(adoptedNode, documentClone.documentElement);
5811
6732
  documentClone.close();
5812
6733
  return iframeLoad;
5813
6734
  };
5814
6735
  DocumentCloner.prototype.createElementClone = function (node) {
5815
- if (isDebugging(node, 2 /* CLONE */)) {
6736
+ if (isDebugging(node, 2 /* DebuggerType.CLONE */)) {
5816
6737
  debugger;
5817
6738
  }
5818
6739
  if (isCanvasElement(node)) {
@@ -5885,7 +6806,7 @@ var DocumentCloner = /** @class */ (function () {
5885
6806
  clonedCanvas.width = canvas.width;
5886
6807
  clonedCanvas.height = canvas.height;
5887
6808
  var ctx = canvas.getContext('2d');
5888
- var clonedCtx = clonedCanvas.getContext('2d');
6809
+ var clonedCtx = clonedCanvas.getContext('2d', { willReadFrequently: true });
5889
6810
  if (clonedCtx) {
5890
6811
  if (!this.options.allowTaint && ctx) {
5891
6812
  clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
@@ -6020,16 +6941,16 @@ var DocumentCloner = /** @class */ (function () {
6020
6941
  var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
6021
6942
  copyCSSStyles(style, anonymousReplacedElement);
6022
6943
  declaration.content.forEach(function (token) {
6023
- if (token.type === 0 /* STRING_TOKEN */) {
6944
+ if (token.type === 0 /* TokenType.STRING_TOKEN */) {
6024
6945
  anonymousReplacedElement.appendChild(document.createTextNode(token.value));
6025
6946
  }
6026
- else if (token.type === 22 /* URL_TOKEN */) {
6947
+ else if (token.type === 22 /* TokenType.URL_TOKEN */) {
6027
6948
  var img = document.createElement('img');
6028
6949
  img.src = token.value;
6029
6950
  img.style.opacity = '1';
6030
6951
  anonymousReplacedElement.appendChild(img);
6031
6952
  }
6032
- else if (token.type === 18 /* FUNCTION */) {
6953
+ else if (token.type === 18 /* TokenType.FUNCTION */) {
6033
6954
  if (token.name === 'attr') {
6034
6955
  var attr = token.values.filter(isIdentToken);
6035
6956
  if (attr.length) {
@@ -6042,7 +6963,7 @@ var DocumentCloner = /** @class */ (function () {
6042
6963
  var counterState = _this.counters.getCounterValue(counter.value);
6043
6964
  var counterType = counterStyle && isIdentToken(counterStyle)
6044
6965
  ? listStyleType.parse(_this.context, counterStyle.value)
6045
- : 3 /* DECIMAL */;
6966
+ : 3 /* LIST_STYLE_TYPE.DECIMAL */;
6046
6967
  anonymousReplacedElement.appendChild(document.createTextNode(createCounterText(counterState, counterType, false)));
6047
6968
  }
6048
6969
  }
@@ -6052,8 +6973,8 @@ var DocumentCloner = /** @class */ (function () {
6052
6973
  var counterStates = _this.counters.getCounterValues(counter.value);
6053
6974
  var counterType_1 = counterStyle && isIdentToken(counterStyle)
6054
6975
  ? listStyleType.parse(_this.context, counterStyle.value)
6055
- : 3 /* DECIMAL */;
6056
- var separator = delim && delim.type === 0 /* STRING_TOKEN */ ? delim.value : '';
6976
+ : 3 /* LIST_STYLE_TYPE.DECIMAL */;
6977
+ var separator = delim && delim.type === 0 /* TokenType.STRING_TOKEN */ ? delim.value : '';
6057
6978
  var text = counterStates
6058
6979
  .map(function (value) { return createCounterText(value, counterType_1, false); })
6059
6980
  .join(separator);
@@ -6062,7 +6983,7 @@ var DocumentCloner = /** @class */ (function () {
6062
6983
  }
6063
6984
  else ;
6064
6985
  }
6065
- else if (token.type === 20 /* IDENT_TOKEN */) {
6986
+ else if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
6066
6987
  switch (token.value) {
6067
6988
  case 'open-quote':
6068
6989
  anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, _this.quoteDepth++, true)));
@@ -6076,10 +6997,10 @@ var DocumentCloner = /** @class */ (function () {
6076
6997
  }
6077
6998
  }
6078
6999
  });
6079
- anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
7000
+ anonymousReplacedElement.className = "".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE, " ").concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER);
6080
7001
  var newClassName = pseudoElt === PseudoElementType.BEFORE
6081
- ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
6082
- : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
7002
+ ? " ".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE)
7003
+ : " ".concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER);
6083
7004
  if (isSVGElementNode(clone)) {
6084
7005
  clone.className.baseValue += newClassName;
6085
7006
  }
@@ -6153,8 +7074,8 @@ var iframeLoader = function (iframe) {
6153
7074
  });
6154
7075
  };
6155
7076
  var ignoredStyleProperties = [
6156
- 'all',
6157
- 'd',
7077
+ 'all', // #2476
7078
+ 'd', // #2483
6158
7079
  'content' // Safari shows pseudoelements if content is set
6159
7080
  ];
6160
7081
  var copyCSSStyles = function (style, target) {
@@ -6178,10 +7099,10 @@ var serializeDoctype = function (doctype) {
6178
7099
  str += doctype.internalSubset;
6179
7100
  }
6180
7101
  if (doctype.publicId) {
6181
- str += "\"" + doctype.publicId + "\"";
7102
+ str += "\"".concat(doctype.publicId, "\"");
6182
7103
  }
6183
7104
  if (doctype.systemId) {
6184
- str += "\"" + doctype.systemId + "\"";
7105
+ str += "\"".concat(doctype.systemId, "\"");
6185
7106
  }
6186
7107
  str += '>';
6187
7108
  }
@@ -6205,7 +7126,7 @@ var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
6205
7126
  var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
6206
7127
  var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
6207
7128
  var createPseudoHideStyles = function (body) {
6208
- createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE);
7129
+ createStyles(body, ".".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE).concat(PSEUDO_BEFORE).concat(PSEUDO_HIDE_ELEMENT_STYLE, "\n .").concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER).concat(PSEUDO_AFTER).concat(PSEUDO_HIDE_ELEMENT_STYLE));
6209
7130
  };
6210
7131
  var createStyles = function (body, styles) {
6211
7132
  var document = body.ownerDocument;
@@ -6215,6 +7136,13 @@ var createStyles = function (body, styles) {
6215
7136
  body.appendChild(style);
6216
7137
  }
6217
7138
  };
7139
+ var addBase = function (targetELement, baseUri) {
7140
+ var _a;
7141
+ var baseNode = targetELement.ownerDocument.createElement('base');
7142
+ baseNode.href = baseUri;
7143
+ var headEle = targetELement.getElementsByTagName('head').item(0);
7144
+ headEle === null || headEle === void 0 ? void 0 : headEle.insertBefore(baseNode, (_a = headEle === null || headEle === void 0 ? void 0 : headEle.firstChild) !== null && _a !== void 0 ? _a : null);
7145
+ };
6218
7146
 
6219
7147
  var CacheStorage = /** @class */ (function () {
6220
7148
  function CacheStorage() {
@@ -6264,12 +7192,21 @@ var Cache = /** @class */ (function () {
6264
7192
  };
6265
7193
  Cache.prototype.loadImage = function (key) {
6266
7194
  return __awaiter(this, void 0, void 0, function () {
6267
- var isSameOrigin, useCORS, useProxy, src;
7195
+ var isSameOrigin, _a, useCORS, useProxy, src;
6268
7196
  var _this = this;
6269
- return __generator(this, function (_a) {
6270
- switch (_a.label) {
7197
+ return __generator(this, function (_b) {
7198
+ switch (_b.label) {
6271
7199
  case 0:
6272
- isSameOrigin = CacheStorage.isSameOrigin(key);
7200
+ if (!(typeof this._options.customIsSameOrigin === 'function')) return [3 /*break*/, 2];
7201
+ return [4 /*yield*/, this._options.customIsSameOrigin(key, CacheStorage.isSameOrigin)];
7202
+ case 1:
7203
+ _a = _b.sent();
7204
+ return [3 /*break*/, 3];
7205
+ case 2:
7206
+ _a = CacheStorage.isSameOrigin(key);
7207
+ _b.label = 3;
7208
+ case 3:
7209
+ isSameOrigin = _a;
6273
7210
  useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
6274
7211
  useProxy = !isInlineImage(key) &&
6275
7212
  !isSameOrigin &&
@@ -6286,13 +7223,13 @@ var Cache = /** @class */ (function () {
6286
7223
  return [2 /*return*/];
6287
7224
  }
6288
7225
  src = key;
6289
- if (!useProxy) return [3 /*break*/, 2];
7226
+ if (!useProxy) return [3 /*break*/, 5];
6290
7227
  return [4 /*yield*/, this.proxy(src)];
6291
- case 1:
6292
- src = _a.sent();
6293
- _a.label = 2;
6294
- case 2:
6295
- this.context.logger.debug("Added image " + key.substring(0, 256));
7228
+ case 4:
7229
+ src = _b.sent();
7230
+ _b.label = 5;
7231
+ case 5:
7232
+ this.context.logger.debug("Added image ".concat(key.substring(0, 256)));
6296
7233
  return [4 /*yield*/, new Promise(function (resolve, reject) {
6297
7234
  var img = new Image();
6298
7235
  img.onload = function () { return resolve(img); };
@@ -6307,10 +7244,10 @@ var Cache = /** @class */ (function () {
6307
7244
  setTimeout(function () { return resolve(img); }, 500);
6308
7245
  }
6309
7246
  if (_this._options.imageTimeout > 0) {
6310
- setTimeout(function () { return reject("Timed out (" + _this._options.imageTimeout + "ms) loading image"); }, _this._options.imageTimeout);
7247
+ setTimeout(function () { return reject("Timed out (".concat(_this._options.imageTimeout, "ms) loading image")); }, _this._options.imageTimeout);
6311
7248
  }
6312
7249
  })];
6313
- case 3: return [2 /*return*/, _a.sent()];
7250
+ case 6: return [2 /*return*/, _b.sent()];
6314
7251
  }
6315
7252
  });
6316
7253
  });
@@ -6344,19 +7281,19 @@ var Cache = /** @class */ (function () {
6344
7281
  }
6345
7282
  }
6346
7283
  else {
6347
- reject("Failed to proxy resource " + key + " with status code " + xhr.status);
7284
+ reject("Failed to proxy resource ".concat(key, " with status code ").concat(xhr.status));
6348
7285
  }
6349
7286
  };
6350
7287
  xhr.onerror = reject;
6351
7288
  var queryString = proxy.indexOf('?') > -1 ? '&' : '?';
6352
- xhr.open('GET', "" + proxy + queryString + "url=" + encodeURIComponent(src) + "&responseType=" + responseType);
7289
+ xhr.open('GET', "".concat(proxy).concat(queryString, "url=").concat(encodeURIComponent(src), "&responseType=").concat(responseType));
6353
7290
  if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
6354
7291
  xhr.responseType = responseType;
6355
7292
  }
6356
7293
  if (_this._options.imageTimeout) {
6357
7294
  var timeout_1 = _this._options.imageTimeout;
6358
7295
  xhr.timeout = timeout_1;
6359
- xhr.ontimeout = function () { return reject("Timed out (" + timeout_1 + "ms) proxying " + key); };
7296
+ xhr.ontimeout = function () { return reject("Timed out (".concat(timeout_1, "ms) proxying ").concat(key)); };
6360
7297
  }
6361
7298
  xhr.send();
6362
7299
  });
@@ -6374,7 +7311,7 @@ var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || IN
6374
7311
 
6375
7312
  var Vector = /** @class */ (function () {
6376
7313
  function Vector(x, y) {
6377
- this.type = 0 /* VECTOR */;
7314
+ this.type = 0 /* PathType.VECTOR */;
6378
7315
  this.x = x;
6379
7316
  this.y = y;
6380
7317
  }
@@ -6389,7 +7326,7 @@ var lerp = function (a, b, t) {
6389
7326
  };
6390
7327
  var BezierCurve = /** @class */ (function () {
6391
7328
  function BezierCurve(start, startControl, endControl, end) {
6392
- this.type = 1 /* BEZIER_CURVE */;
7329
+ this.type = 1 /* PathType.BEZIER_CURVE */;
6393
7330
  this.start = start;
6394
7331
  this.startControl = startControl;
6395
7332
  this.endControl = endControl;
@@ -6412,7 +7349,7 @@ var BezierCurve = /** @class */ (function () {
6412
7349
  };
6413
7350
  return BezierCurve;
6414
7351
  }());
6415
- var isBezierCurve = function (path) { return path.type === 1 /* BEZIER_CURVE */; };
7352
+ var isBezierCurve = function (path) { return path.type === 1 /* PathType.BEZIER_CURVE */; };
6416
7353
 
6417
7354
  var BoundCurves = /** @class */ (function () {
6418
7355
  function BoundCurves(element) {
@@ -6599,8 +7536,8 @@ var TransformEffect = /** @class */ (function () {
6599
7536
  this.offsetX = offsetX;
6600
7537
  this.offsetY = offsetY;
6601
7538
  this.matrix = matrix;
6602
- this.type = 0 /* TRANSFORM */;
6603
- this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
7539
+ this.type = 0 /* EffectType.TRANSFORM */;
7540
+ this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
6604
7541
  }
6605
7542
  return TransformEffect;
6606
7543
  }());
@@ -6608,23 +7545,23 @@ var ClipEffect = /** @class */ (function () {
6608
7545
  function ClipEffect(path, target) {
6609
7546
  this.path = path;
6610
7547
  this.target = target;
6611
- this.type = 1 /* CLIP */;
7548
+ this.type = 1 /* EffectType.CLIP */;
6612
7549
  }
6613
7550
  return ClipEffect;
6614
7551
  }());
6615
7552
  var OpacityEffect = /** @class */ (function () {
6616
7553
  function OpacityEffect(opacity) {
6617
7554
  this.opacity = opacity;
6618
- this.type = 2 /* OPACITY */;
6619
- this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
7555
+ this.type = 2 /* EffectType.OPACITY */;
7556
+ this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
6620
7557
  }
6621
7558
  return OpacityEffect;
6622
7559
  }());
6623
7560
  var isTransformEffect = function (effect) {
6624
- return effect.type === 0 /* TRANSFORM */;
7561
+ return effect.type === 0 /* EffectType.TRANSFORM */;
6625
7562
  };
6626
- var isClipEffect = function (effect) { return effect.type === 1 /* CLIP */; };
6627
- var isOpacityEffect = function (effect) { return effect.type === 2 /* OPACITY */; };
7563
+ var isClipEffect = function (effect) { return effect.type === 1 /* EffectType.CLIP */; };
7564
+ var isOpacityEffect = function (effect) { return effect.type === 2 /* EffectType.OPACITY */; };
6628
7565
 
6629
7566
  var equalPath = function (a, b) {
6630
7567
  if (a.length === b.length) {
@@ -6670,40 +7607,51 @@ var ElementPaint = /** @class */ (function () {
6670
7607
  if (this.container.styles.opacity < 1) {
6671
7608
  this.effects.push(new OpacityEffect(this.container.styles.opacity));
6672
7609
  }
7610
+ if (this.container.styles.rotate !== null) {
7611
+ var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
7612
+ var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
7613
+ // Apply rotate property if present
7614
+ var angle = this.container.styles.rotate;
7615
+ var rad = (angle * Math.PI) / 180;
7616
+ var cos = Math.cos(rad);
7617
+ var sin = Math.sin(rad);
7618
+ var rotateMatrix = [cos, sin, -sin, cos, 0, 0];
7619
+ this.effects.push(new TransformEffect(offsetX, offsetY, rotateMatrix));
7620
+ }
6673
7621
  if (this.container.styles.transform !== null) {
6674
7622
  var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
6675
7623
  var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
6676
7624
  var matrix = this.container.styles.transform;
6677
7625
  this.effects.push(new TransformEffect(offsetX, offsetY, matrix));
6678
7626
  }
6679
- if (this.container.styles.overflowX !== 0 /* VISIBLE */) {
7627
+ if (this.container.styles.overflowX !== 0 /* OVERFLOW.VISIBLE */) {
6680
7628
  var borderBox = calculateBorderBoxPath(this.curves);
6681
7629
  var paddingBox = calculatePaddingBoxPath(this.curves);
6682
7630
  if (equalPath(borderBox, paddingBox)) {
6683
- this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
7631
+ this.effects.push(new ClipEffect(borderBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
6684
7632
  }
6685
7633
  else {
6686
- this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */));
6687
- this.effects.push(new ClipEffect(paddingBox, 4 /* CONTENT */));
7634
+ this.effects.push(new ClipEffect(borderBox, 2 /* EffectTarget.BACKGROUND_BORDERS */));
7635
+ this.effects.push(new ClipEffect(paddingBox, 4 /* EffectTarget.CONTENT */));
6688
7636
  }
6689
7637
  }
6690
7638
  }
6691
7639
  ElementPaint.prototype.getEffects = function (target) {
6692
- var inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(this.container.styles.position) === -1;
7640
+ var inFlow = [2 /* POSITION.ABSOLUTE */, 3 /* POSITION.FIXED */].indexOf(this.container.styles.position) === -1;
6693
7641
  var parent = this.parent;
6694
7642
  var effects = this.effects.slice(0);
6695
7643
  while (parent) {
6696
7644
  var croplessEffects = parent.effects.filter(function (effect) { return !isClipEffect(effect); });
6697
- if (inFlow || parent.container.styles.position !== 0 /* STATIC */ || !parent.parent) {
6698
- effects.unshift.apply(effects, croplessEffects);
6699
- inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(parent.container.styles.position) === -1;
6700
- if (parent.container.styles.overflowX !== 0 /* VISIBLE */) {
7645
+ if (inFlow || parent.container.styles.position !== 0 /* POSITION.STATIC */ || !parent.parent) {
7646
+ inFlow = [2 /* POSITION.ABSOLUTE */, 3 /* POSITION.FIXED */].indexOf(parent.container.styles.position) === -1;
7647
+ if (parent.container.styles.overflowX !== 0 /* OVERFLOW.VISIBLE */) {
6701
7648
  var borderBox = calculateBorderBoxPath(parent.curves);
6702
7649
  var paddingBox = calculatePaddingBoxPath(parent.curves);
6703
7650
  if (!equalPath(borderBox, paddingBox)) {
6704
- effects.unshift(new ClipEffect(paddingBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
7651
+ effects.unshift(new ClipEffect(paddingBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
6705
7652
  }
6706
7653
  }
7654
+ effects.unshift.apply(effects, croplessEffects);
6707
7655
  }
6708
7656
  else {
6709
7657
  effects.unshift.apply(effects, croplessEffects);
@@ -6716,13 +7664,13 @@ var ElementPaint = /** @class */ (function () {
6716
7664
  }());
6717
7665
  var parseStackTree = function (parent, stackingContext, realStackingContext, listItems) {
6718
7666
  parent.container.elements.forEach(function (child) {
6719
- var treatAsRealStackingContext = contains(child.flags, 4 /* CREATES_REAL_STACKING_CONTEXT */);
6720
- var createsStackingContext = contains(child.flags, 2 /* CREATES_STACKING_CONTEXT */);
7667
+ var treatAsRealStackingContext = contains(child.flags, 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */);
7668
+ var createsStackingContext = contains(child.flags, 2 /* FLAGS.CREATES_STACKING_CONTEXT */);
6721
7669
  var paintContainer = new ElementPaint(child, parent);
6722
- if (contains(child.styles.display, 2048 /* LIST_ITEM */)) {
7670
+ if (contains(child.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) {
6723
7671
  listItems.push(paintContainer);
6724
7672
  }
6725
- var listOwnerItems = contains(child.flags, 8 /* IS_LIST_OWNER */) ? [] : listItems;
7673
+ var listOwnerItems = contains(child.flags, 8 /* FLAGS.IS_LIST_OWNER */) ? [] : listItems;
6726
7674
  if (treatAsRealStackingContext || createsStackingContext) {
6727
7675
  var parentStack = treatAsRealStackingContext || child.styles.isPositioned() ? realStackingContext : stackingContext;
6728
7676
  var stack = new StackingContext(paintContainer);
@@ -6779,7 +7727,7 @@ var parseStackTree = function (parent, stackingContext, realStackingContext, lis
6779
7727
  }
6780
7728
  parseStackTree(paintContainer, stackingContext, realStackingContext, listOwnerItems);
6781
7729
  }
6782
- if (contains(child.flags, 8 /* IS_LIST_OWNER */)) {
7730
+ if (contains(child.flags, 8 /* FLAGS.IS_LIST_OWNER */)) {
6783
7731
  processListItems(child, listOwnerItems);
6784
7732
  }
6785
7733
  });
@@ -6920,19 +7868,19 @@ var contentBox = function (element) {
6920
7868
  };
6921
7869
 
6922
7870
  var calculateBackgroundPositioningArea = function (backgroundOrigin, element) {
6923
- if (backgroundOrigin === 0 /* BORDER_BOX */) {
7871
+ if (backgroundOrigin === 0 /* BACKGROUND_ORIGIN.BORDER_BOX */) {
6924
7872
  return element.bounds;
6925
7873
  }
6926
- if (backgroundOrigin === 2 /* CONTENT_BOX */) {
7874
+ if (backgroundOrigin === 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */) {
6927
7875
  return contentBox(element);
6928
7876
  }
6929
7877
  return paddingBox(element);
6930
7878
  };
6931
7879
  var calculateBackgroundPaintingArea = function (backgroundClip, element) {
6932
- if (backgroundClip === 0 /* BORDER_BOX */) {
7880
+ if (backgroundClip === 0 /* BACKGROUND_CLIP.BORDER_BOX */) {
6933
7881
  return element.bounds;
6934
7882
  }
6935
- if (backgroundClip === 2 /* CONTENT_BOX */) {
7883
+ if (backgroundClip === 2 /* BACKGROUND_CLIP.CONTENT_BOX */) {
6936
7884
  return contentBox(element);
6937
7885
  }
6938
7886
  return paddingBox(element);
@@ -6946,6 +7894,8 @@ var calculateBackgroundRendering = function (container, index, intrinsicSize) {
6946
7894
  var path = calculateBackgroundRepeatPath(getBackgroundValueForIndex(container.styles.backgroundRepeat, index), position, backgroundImageSize, backgroundPositioningArea, backgroundPaintingArea);
6947
7895
  var offsetX = Math.round(backgroundPositioningArea.left + position[0]);
6948
7896
  var offsetY = Math.round(backgroundPositioningArea.top + position[1]);
7897
+ sizeWidth = Math.max(1, sizeWidth);
7898
+ sizeHeight = Math.max(1, sizeHeight);
6949
7899
  return [path, offsetX, offsetY, sizeWidth, sizeHeight];
6950
7900
  };
6951
7901
  var isAuto = function (token) { return isIdentToken(token) && token.value === BACKGROUND_SIZE.AUTO; };
@@ -7060,21 +8010,21 @@ var calculateBackgroundRepeatPath = function (repeat, _a, _b, backgroundPosition
7060
8010
  var x = _a[0], y = _a[1];
7061
8011
  var width = _b[0], height = _b[1];
7062
8012
  switch (repeat) {
7063
- case 2 /* REPEAT_X */:
8013
+ case 2 /* BACKGROUND_REPEAT.REPEAT_X */:
7064
8014
  return [
7065
8015
  new Vector(Math.round(backgroundPositioningArea.left), Math.round(backgroundPositioningArea.top + y)),
7066
8016
  new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(backgroundPositioningArea.top + y)),
7067
8017
  new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(height + backgroundPositioningArea.top + y)),
7068
8018
  new Vector(Math.round(backgroundPositioningArea.left), Math.round(height + backgroundPositioningArea.top + y))
7069
8019
  ];
7070
- case 3 /* REPEAT_Y */:
8020
+ case 3 /* BACKGROUND_REPEAT.REPEAT_Y */:
7071
8021
  return [
7072
8022
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top)),
7073
8023
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top)),
7074
8024
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top)),
7075
8025
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top))
7076
8026
  ];
7077
- case 1 /* NO_REPEAT */:
8027
+ case 1 /* BACKGROUND_REPEAT.NO_REPEAT */:
7078
8028
  return [
7079
8029
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y)),
7080
8030
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y)),
@@ -7134,7 +8084,7 @@ var FontMetrics = /** @class */ (function () {
7134
8084
  return { baseline: baseline, middle: middle };
7135
8085
  };
7136
8086
  FontMetrics.prototype.getMetrics = function (fontFamily, fontSize) {
7137
- var key = fontFamily + " " + fontSize;
8087
+ var key = "".concat(fontFamily, " ").concat(fontSize);
7138
8088
  if (typeof this._data[key] === 'undefined') {
7139
8089
  this._data[key] = this.parseMetrics(fontFamily, fontSize);
7140
8090
  }
@@ -7162,15 +8112,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
7162
8112
  if (!options.canvas) {
7163
8113
  _this.canvas.width = Math.floor(options.width * options.scale);
7164
8114
  _this.canvas.height = Math.floor(options.height * options.scale);
7165
- _this.canvas.style.width = options.width + "px";
7166
- _this.canvas.style.height = options.height + "px";
8115
+ _this.canvas.style.width = "".concat(options.width, "px");
8116
+ _this.canvas.style.height = "".concat(options.height, "px");
7167
8117
  }
7168
8118
  _this.fontMetrics = new FontMetrics(document);
7169
8119
  _this.ctx.scale(_this.options.scale, _this.options.scale);
7170
8120
  _this.ctx.translate(-options.x, -options.y);
7171
8121
  _this.ctx.textBaseline = 'bottom';
7172
8122
  _this._activeEffects = [];
7173
- _this.context.logger.debug("Canvas renderer initialized (" + options.width + "x" + options.height + ") with scale " + options.scale);
8123
+ _this.context.logger.debug("Canvas renderer initialized (".concat(options.width, "x").concat(options.height, ") with scale ").concat(options.scale));
7174
8124
  return _this;
7175
8125
  }
7176
8126
  CanvasRenderer.prototype.applyEffects = function (effects) {
@@ -7222,7 +8172,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7222
8172
  return __generator(this, function (_a) {
7223
8173
  switch (_a.label) {
7224
8174
  case 0:
7225
- if (contains(paint.container.flags, 16 /* DEBUG_RENDER */)) {
8175
+ if (contains(paint.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
7226
8176
  debugger;
7227
8177
  }
7228
8178
  if (!paint.container.styles.isVisible()) return [3 /*break*/, 3];
@@ -7241,7 +8191,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
7241
8191
  CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing, baseline) {
7242
8192
  var _this = this;
7243
8193
  if (letterSpacing === 0) {
7244
- this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
8194
+ // Fixed an issue with characters moving up in non-Firefox.
8195
+ // https://github.com/niklasvh/html2canvas/issues/2107#issuecomment-692462900
8196
+ if (navigator.userAgent.indexOf('Firefox') === -1) {
8197
+ this.ctx.textBaseline = 'ideographic';
8198
+ this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
8199
+ }
8200
+ else {
8201
+ this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
8202
+ }
7245
8203
  }
7246
8204
  else {
7247
8205
  var letters = segmentGraphemes(text.text);
@@ -7257,8 +8215,8 @@ var CanvasRenderer = /** @class */ (function (_super) {
7257
8215
  .join('');
7258
8216
  var fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', ');
7259
8217
  var fontSize = isDimensionToken(styles.fontSize)
7260
- ? "" + styles.fontSize.number + styles.fontSize.unit
7261
- : styles.fontSize.number + "px";
8218
+ ? "".concat(styles.fontSize.number).concat(styles.fontSize.unit)
8219
+ : "".concat(styles.fontSize.number, "px");
7262
8220
  return [
7263
8221
  [styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
7264
8222
  fontFamily,
@@ -7267,22 +8225,21 @@ var CanvasRenderer = /** @class */ (function (_super) {
7267
8225
  };
7268
8226
  CanvasRenderer.prototype.renderTextNode = function (text, styles) {
7269
8227
  return __awaiter(this, void 0, void 0, function () {
7270
- var _a, font, fontFamily, fontSize, _b, baseline, middle, paintOrder;
8228
+ var font, paintOrder;
7271
8229
  var _this = this;
7272
- return __generator(this, function (_c) {
7273
- _a = this.createFontStyle(styles), font = _a[0], fontFamily = _a[1], fontSize = _a[2];
8230
+ return __generator(this, function (_a) {
8231
+ font = this.createFontStyle(styles)[0];
7274
8232
  this.ctx.font = font;
7275
- this.ctx.direction = styles.direction === 1 /* RTL */ ? 'rtl' : 'ltr';
8233
+ this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
7276
8234
  this.ctx.textAlign = 'left';
7277
8235
  this.ctx.textBaseline = 'alphabetic';
7278
- _b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
7279
8236
  paintOrder = styles.paintOrder;
7280
8237
  text.textBounds.forEach(function (text) {
7281
8238
  paintOrder.forEach(function (paintOrderLayer) {
7282
8239
  switch (paintOrderLayer) {
7283
- case 0 /* FILL */:
8240
+ case 0 /* PAINT_ORDER_LAYER.FILL */:
7284
8241
  _this.ctx.fillStyle = asString(styles.color);
7285
- _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
8242
+ _this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
7286
8243
  var textShadows = styles.textShadow;
7287
8244
  if (textShadows.length && text.text.trim().length) {
7288
8245
  textShadows
@@ -7293,7 +8250,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7293
8250
  _this.ctx.shadowOffsetX = textShadow.offsetX.number * _this.options.scale;
7294
8251
  _this.ctx.shadowOffsetY = textShadow.offsetY.number * _this.options.scale;
7295
8252
  _this.ctx.shadowBlur = textShadow.blur.number;
7296
- _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
8253
+ _this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
7297
8254
  });
7298
8255
  _this.ctx.shadowColor = '';
7299
8256
  _this.ctx.shadowOffsetX = 0;
@@ -7302,32 +8259,30 @@ var CanvasRenderer = /** @class */ (function (_super) {
7302
8259
  }
7303
8260
  if (styles.textDecorationLine.length) {
7304
8261
  _this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
8262
+ var decorationLineHeight_1 = 1;
7305
8263
  styles.textDecorationLine.forEach(function (textDecorationLine) {
8264
+ // Fix the issue where textDecorationLine exhibits x-axis positioning errors on high-resolution devices due to varying devicePixelRatio, corrected by using relative values of element heights.
7306
8265
  switch (textDecorationLine) {
7307
- case 1 /* UNDERLINE */:
7308
- // Draws a line at the baseline of the font
7309
- // TODO As some browsers display the line as more than 1px if the font-size is big,
7310
- // need to take that into account both in position and size
7311
- _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
8266
+ case 1 /* TEXT_DECORATION_LINE.UNDERLINE */:
8267
+ _this.ctx.fillRect(text.bounds.left, text.bounds.top + text.bounds.height - decorationLineHeight_1, text.bounds.width, decorationLineHeight_1);
7312
8268
  break;
7313
- case 2 /* OVERLINE */:
7314
- _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top), text.bounds.width, 1);
8269
+ case 2 /* TEXT_DECORATION_LINE.OVERLINE */:
8270
+ _this.ctx.fillRect(text.bounds.left, text.bounds.top, text.bounds.width, decorationLineHeight_1);
7315
8271
  break;
7316
- case 3 /* LINE_THROUGH */:
7317
- // TODO try and find exact position for line-through
7318
- _this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
8272
+ case 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */:
8273
+ _this.ctx.fillRect(text.bounds.left, text.bounds.top + (text.bounds.height / 2 - decorationLineHeight_1 / 2), text.bounds.width, decorationLineHeight_1);
7319
8274
  break;
7320
8275
  }
7321
8276
  });
7322
8277
  }
7323
8278
  break;
7324
- case 1 /* STROKE */:
8279
+ case 1 /* PAINT_ORDER_LAYER.STROKE */:
7325
8280
  if (styles.webkitTextStrokeWidth && text.text.trim().length) {
7326
8281
  _this.ctx.strokeStyle = asString(styles.webkitTextStrokeColor);
7327
8282
  _this.ctx.lineWidth = styles.webkitTextStrokeWidth;
7328
8283
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7329
8284
  _this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
7330
- _this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + baseline);
8285
+ _this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
7331
8286
  }
7332
8287
  _this.ctx.strokeStyle = '';
7333
8288
  _this.ctx.lineWidth = 0;
@@ -7341,23 +8296,99 @@ var CanvasRenderer = /** @class */ (function (_super) {
7341
8296
  });
7342
8297
  };
7343
8298
  CanvasRenderer.prototype.renderReplacedElement = function (container, curves, image) {
7344
- if (image && container.intrinsicWidth > 0 && container.intrinsicHeight > 0) {
8299
+ var intrinsicWidth = image.naturalWidth || container.intrinsicWidth;
8300
+ var intrinsicHeight = image.naturalHeight || container.intrinsicHeight;
8301
+ if (image && intrinsicWidth > 0 && intrinsicHeight > 0) {
7345
8302
  var box = contentBox(container);
7346
8303
  var path = calculatePaddingBoxPath(curves);
7347
8304
  this.path(path);
7348
8305
  this.ctx.save();
7349
8306
  this.ctx.clip();
7350
- this.ctx.drawImage(image, 0, 0, container.intrinsicWidth, container.intrinsicHeight, box.left, box.top, box.width, box.height);
8307
+ var sx = 0, sy = 0, sw = intrinsicWidth, sh = intrinsicHeight, dx = box.left, dy = box.top, dw = box.width, dh = box.height;
8308
+ var objectFit = container.styles.objectFit;
8309
+ var boxRatio = dw / dh;
8310
+ var imgRatio = sw / sh;
8311
+ if (objectFit === 2 /* OBJECT_FIT.CONTAIN */) {
8312
+ if (imgRatio > boxRatio) {
8313
+ dh = dw / imgRatio;
8314
+ dy += (box.height - dh) / 2;
8315
+ }
8316
+ else {
8317
+ dw = dh * imgRatio;
8318
+ dx += (box.width - dw) / 2;
8319
+ }
8320
+ }
8321
+ else if (objectFit === 4 /* OBJECT_FIT.COVER */) {
8322
+ if (imgRatio > boxRatio) {
8323
+ sw = sh * boxRatio;
8324
+ sx += (intrinsicWidth - sw) / 2;
8325
+ }
8326
+ else {
8327
+ sh = sw / boxRatio;
8328
+ sy += (intrinsicHeight - sh) / 2;
8329
+ }
8330
+ }
8331
+ else if (objectFit === 8 /* OBJECT_FIT.NONE */) {
8332
+ if (sw > dw) {
8333
+ sx += (sw - dw) / 2;
8334
+ sw = dw;
8335
+ }
8336
+ else {
8337
+ dx += (dw - sw) / 2;
8338
+ dw = sw;
8339
+ }
8340
+ if (sh > dh) {
8341
+ sy += (sh - dh) / 2;
8342
+ sh = dh;
8343
+ }
8344
+ else {
8345
+ dy += (dh - sh) / 2;
8346
+ dh = sh;
8347
+ }
8348
+ }
8349
+ else if (objectFit === 16 /* OBJECT_FIT.SCALE_DOWN */) {
8350
+ var containW = imgRatio > boxRatio ? dw : dh * imgRatio;
8351
+ var noneW = sw > dw ? sw : dw;
8352
+ if (containW < noneW) {
8353
+ if (imgRatio > boxRatio) {
8354
+ dh = dw / imgRatio;
8355
+ dy += (box.height - dh) / 2;
8356
+ }
8357
+ else {
8358
+ dw = dh * imgRatio;
8359
+ dx += (box.width - dw) / 2;
8360
+ }
8361
+ }
8362
+ else {
8363
+ if (sw > dw) {
8364
+ sx += (sw - dw) / 2;
8365
+ sw = dw;
8366
+ }
8367
+ else {
8368
+ dx += (dw - sw) / 2;
8369
+ dw = sw;
8370
+ }
8371
+ if (sh > dh) {
8372
+ sy += (sh - dh) / 2;
8373
+ sh = dh;
8374
+ }
8375
+ else {
8376
+ dy += (dh - sh) / 2;
8377
+ dh = sh;
8378
+ }
8379
+ }
8380
+ }
8381
+ this.ctx.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
7351
8382
  this.ctx.restore();
7352
8383
  }
7353
8384
  };
7354
8385
  CanvasRenderer.prototype.renderNodeContent = function (paint) {
7355
8386
  return __awaiter(this, void 0, void 0, function () {
7356
- var container, curves, styles, _i, _a, child, image, image, iframeRenderer, canvas, size, _b, fontFamily, fontSize, baseline, bounds, x, textBounds, img, image, url, fontFamily, bounds;
8387
+ var container, curves, styles, _i, _a, child, image, image, iframeRenderer, canvas, size, _b, font, fontFamily, fontSize, baseline, bounds, x, textBounds, img, image, url, font, bounds;
7357
8388
  return __generator(this, function (_c) {
7358
8389
  switch (_c.label) {
7359
8390
  case 0:
7360
- this.applyEffects(paint.getEffects(4 /* CONTENT */));
8391
+ this.applyEffects(paint.getEffects(4 /* EffectTarget.CONTENT */));
7361
8392
  container = paint.container;
7362
8393
  curves = paint.curves;
7363
8394
  styles = container.styles;
@@ -7385,7 +8416,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7385
8416
  return [3 /*break*/, 8];
7386
8417
  case 7:
7387
8418
  _c.sent();
7388
- this.context.logger.error("Error loading image " + container.src);
8419
+ this.context.logger.error("Error loading image ".concat(container.src));
7389
8420
  return [3 /*break*/, 8];
7390
8421
  case 8:
7391
8422
  if (container instanceof CanvasElementContainer) {
@@ -7402,7 +8433,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7402
8433
  return [3 /*break*/, 12];
7403
8434
  case 11:
7404
8435
  _c.sent();
7405
- this.context.logger.error("Error loading svg " + container.svg.substring(0, 255));
8436
+ this.context.logger.error("Error loading svg ".concat(container.svg.substring(0, 255)));
7406
8437
  return [3 /*break*/, 12];
7407
8438
  case 12:
7408
8439
  if (!(container instanceof IFrameElementContainer && container.tree)) return [3 /*break*/, 14];
@@ -7453,19 +8484,19 @@ var CanvasRenderer = /** @class */ (function (_super) {
7453
8484
  }
7454
8485
  }
7455
8486
  if (isTextInputElement(container) && container.value.length) {
7456
- _b = this.createFontStyle(styles), fontFamily = _b[0], fontSize = _b[1];
8487
+ _b = this.createFontStyle(styles), font = _b[0], fontFamily = _b[1], fontSize = _b[2];
7457
8488
  baseline = this.fontMetrics.getMetrics(fontFamily, fontSize).baseline;
7458
- this.ctx.font = fontFamily;
8489
+ this.ctx.font = font;
7459
8490
  this.ctx.fillStyle = asString(styles.color);
7460
8491
  this.ctx.textBaseline = 'alphabetic';
7461
8492
  this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
7462
8493
  bounds = contentBox(container);
7463
8494
  x = 0;
7464
8495
  switch (container.styles.textAlign) {
7465
- case 1 /* CENTER */:
8496
+ case 1 /* TEXT_ALIGN.CENTER */:
7466
8497
  x += bounds.width / 2;
7467
8498
  break;
7468
- case 2 /* RIGHT */:
8499
+ case 2 /* TEXT_ALIGN.RIGHT */:
7469
8500
  x += bounds.width;
7470
8501
  break;
7471
8502
  }
@@ -7483,10 +8514,10 @@ var CanvasRenderer = /** @class */ (function (_super) {
7483
8514
  this.ctx.textBaseline = 'alphabetic';
7484
8515
  this.ctx.textAlign = 'left';
7485
8516
  }
7486
- if (!contains(container.styles.display, 2048 /* LIST_ITEM */)) return [3 /*break*/, 20];
8517
+ if (!contains(container.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) return [3 /*break*/, 20];
7487
8518
  if (!(container.styles.listStyleImage !== null)) return [3 /*break*/, 19];
7488
8519
  img = container.styles.listStyleImage;
7489
- if (!(img.type === 0 /* URL */)) return [3 /*break*/, 18];
8520
+ if (!(img.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 18];
7490
8521
  image = void 0;
7491
8522
  url = img.url;
7492
8523
  _c.label = 15;
@@ -7499,13 +8530,13 @@ var CanvasRenderer = /** @class */ (function (_super) {
7499
8530
  return [3 /*break*/, 18];
7500
8531
  case 17:
7501
8532
  _c.sent();
7502
- this.context.logger.error("Error loading list-style-image " + url);
8533
+ this.context.logger.error("Error loading list-style-image ".concat(url));
7503
8534
  return [3 /*break*/, 18];
7504
8535
  case 18: return [3 /*break*/, 20];
7505
8536
  case 19:
7506
- if (paint.listValue && container.styles.listStyleType !== -1 /* NONE */) {
7507
- fontFamily = this.createFontStyle(styles)[0];
7508
- this.ctx.font = fontFamily;
8537
+ if (paint.listValue && container.styles.listStyleType !== -1 /* LIST_STYLE_TYPE.NONE */) {
8538
+ font = this.createFontStyle(styles)[0];
8539
+ this.ctx.font = font;
7509
8540
  this.ctx.fillStyle = asString(styles.color);
7510
8541
  this.ctx.textBaseline = 'middle';
7511
8542
  this.ctx.textAlign = 'right';
@@ -7526,7 +8557,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7526
8557
  return __generator(this, function (_p) {
7527
8558
  switch (_p.label) {
7528
8559
  case 0:
7529
- if (contains(stack.element.container.flags, 16 /* DEBUG_RENDER */)) {
8560
+ if (contains(stack.element.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
7530
8561
  debugger;
7531
8562
  }
7532
8563
  // https://www.w3.org/TR/css-position-3/#painting-order
@@ -7674,10 +8705,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
7674
8705
  this.ctx.translate(-offsetX, -offsetY);
7675
8706
  };
7676
8707
  CanvasRenderer.prototype.resizeImage = function (image, width, height) {
8708
+ // https://github.com/niklasvh/html2canvas/pull/2911
8709
+ // if (image.width === width && image.height === height) {
8710
+ // return image;
8711
+ // }
7677
8712
  var _a;
7678
- if (image.width === width && image.height === height) {
7679
- return image;
7680
- }
7681
8713
  var ownerDocument = (_a = this.canvas.ownerDocument) !== null && _a !== void 0 ? _a : document;
7682
8714
  var canvas = ownerDocument.createElement('canvas');
7683
8715
  canvas.width = Math.max(1, width);
@@ -7694,11 +8726,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
7694
8726
  case 0:
7695
8727
  index = container.styles.backgroundImage.length - 1;
7696
8728
  _loop_1 = function (backgroundImage) {
7697
- var image, url, _c, path, x, y, width, height, pattern, _d, path, x, y, width, height, _e, lineLength, x0, x1, y0, y1, canvas, ctx, gradient_1, pattern, _f, path, left, top_1, width, height, position, x, y, _g, rx, ry, radialGradient_1, midX, midY, f, invF;
8729
+ var image, url, imageWidth, imageHeight, _c, path, x, y, width, height, pattern, _d, path, x, y, width, height, _e, lineLength, x0, x1, y0, y1, canvas, ctx, gradient_1, pattern, _f, path, left, top_1, width, height, position, x, y, _g, rx, ry, radialGradient_1, midX, midY, f, invF;
7698
8730
  return __generator(this, function (_h) {
7699
8731
  switch (_h.label) {
7700
8732
  case 0:
7701
- if (!(backgroundImage.type === 0 /* URL */)) return [3 /*break*/, 5];
8733
+ if (!(backgroundImage.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 5];
7702
8734
  image = void 0;
7703
8735
  url = backgroundImage.url;
7704
8736
  _h.label = 1;
@@ -7710,14 +8742,16 @@ var CanvasRenderer = /** @class */ (function (_super) {
7710
8742
  return [3 /*break*/, 4];
7711
8743
  case 3:
7712
8744
  _h.sent();
7713
- this_1.context.logger.error("Error loading background-image " + url);
8745
+ this_1.context.logger.error("Error loading background-image ".concat(url));
7714
8746
  return [3 /*break*/, 4];
7715
8747
  case 4:
7716
8748
  if (image) {
8749
+ imageWidth = isNaN(image.width) || image.width === 0 ? 1 : image.width;
8750
+ imageHeight = isNaN(image.height) || image.height === 0 ? 1 : image.height;
7717
8751
  _c = calculateBackgroundRendering(container, index, [
7718
- image.width,
7719
- image.height,
7720
- image.width / image.height
8752
+ imageWidth,
8753
+ imageHeight,
8754
+ imageWidth / imageHeight
7721
8755
  ]), path = _c[0], x = _c[1], y = _c[2], width = _c[3], height = _c[4];
7722
8756
  pattern = this_1.ctx.createPattern(this_1.resizeImage(image, width, height), 'repeat');
7723
8757
  this_1.renderRepeat(path, pattern, x, y);
@@ -7732,7 +8766,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7732
8766
  canvas.height = height;
7733
8767
  ctx = canvas.getContext('2d');
7734
8768
  gradient_1 = ctx.createLinearGradient(x0, y0, x1, y1);
7735
- processColorStops(backgroundImage.stops, lineLength).forEach(function (colorStop) {
8769
+ processColorStops(backgroundImage.stops, lineLength || 1).forEach(function (colorStop) {
7736
8770
  return gradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
7737
8771
  });
7738
8772
  ctx.fillStyle = gradient_1;
@@ -7842,7 +8876,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7842
8876
  return __generator(this, function (_a) {
7843
8877
  switch (_a.label) {
7844
8878
  case 0:
7845
- this.applyEffects(paint.getEffects(2 /* BACKGROUND_BORDERS */));
8879
+ this.applyEffects(paint.getEffects(2 /* EffectTarget.BACKGROUND_BORDERS */));
7846
8880
  styles = paint.container.styles;
7847
8881
  hasBackground = !isTransparent(styles.backgroundColor) || styles.backgroundImage.length;
7848
8882
  borders = [
@@ -7898,20 +8932,20 @@ var CanvasRenderer = /** @class */ (function (_super) {
7898
8932
  case 3:
7899
8933
  if (!(_i < borders_1.length)) return [3 /*break*/, 13];
7900
8934
  border = borders_1[_i];
7901
- if (!(border.style !== 0 /* NONE */ && !isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
7902
- if (!(border.style === 2 /* DASHED */)) return [3 /*break*/, 5];
7903
- return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* DASHED */)];
8935
+ if (!(border.style !== 0 /* BORDER_STYLE.NONE */ && !isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
8936
+ if (!(border.style === 2 /* BORDER_STYLE.DASHED */)) return [3 /*break*/, 5];
8937
+ return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* BORDER_STYLE.DASHED */)];
7904
8938
  case 4:
7905
8939
  _a.sent();
7906
8940
  return [3 /*break*/, 11];
7907
8941
  case 5:
7908
- if (!(border.style === 3 /* DOTTED */)) return [3 /*break*/, 7];
7909
- return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* DOTTED */)];
8942
+ if (!(border.style === 3 /* BORDER_STYLE.DOTTED */)) return [3 /*break*/, 7];
8943
+ return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* BORDER_STYLE.DOTTED */)];
7910
8944
  case 6:
7911
8945
  _a.sent();
7912
8946
  return [3 /*break*/, 11];
7913
8947
  case 7:
7914
- if (!(border.style === 4 /* DOUBLE */)) return [3 /*break*/, 9];
8948
+ if (!(border.style === 4 /* BORDER_STYLE.DOUBLE */)) return [3 /*break*/, 9];
7915
8949
  return [4 /*yield*/, this.renderDoubleBorder(border.color, border.width, side, paint.curves)];
7916
8950
  case 8:
7917
8951
  _a.sent();
@@ -7938,7 +8972,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7938
8972
  this.ctx.save();
7939
8973
  strokePaths = parsePathForBorderStroke(curvePoints, side);
7940
8974
  boxPaths = parsePathForBorder(curvePoints, side);
7941
- if (style === 2 /* DASHED */) {
8975
+ if (style === 2 /* BORDER_STYLE.DASHED */) {
7942
8976
  this.path(boxPaths);
7943
8977
  this.ctx.clip();
7944
8978
  }
@@ -7965,7 +8999,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7965
8999
  length = Math.abs(startY - endY);
7966
9000
  }
7967
9001
  this.ctx.beginPath();
7968
- if (style === 3 /* DOTTED */) {
9002
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7969
9003
  this.formatPath(strokePaths);
7970
9004
  }
7971
9005
  else {
@@ -7973,7 +9007,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7973
9007
  }
7974
9008
  dashLength = width < 3 ? width * 3 : width * 2;
7975
9009
  spaceLength = width < 3 ? width * 2 : width;
7976
- if (style === 3 /* DOTTED */) {
9010
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7977
9011
  dashLength = width;
7978
9012
  spaceLength = width;
7979
9013
  }
@@ -7996,14 +9030,14 @@ var CanvasRenderer = /** @class */ (function (_super) {
7996
9030
  : maxSpace;
7997
9031
  }
7998
9032
  if (useLineDash) {
7999
- if (style === 3 /* DOTTED */) {
9033
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
8000
9034
  this.ctx.setLineDash([0, dashLength + spaceLength]);
8001
9035
  }
8002
9036
  else {
8003
9037
  this.ctx.setLineDash([dashLength, spaceLength]);
8004
9038
  }
8005
9039
  }
8006
- if (style === 3 /* DOTTED */) {
9040
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
8007
9041
  this.ctx.lineCap = 'round';
8008
9042
  this.ctx.lineWidth = width;
8009
9043
  }
@@ -8014,7 +9048,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
8014
9048
  this.ctx.stroke();
8015
9049
  this.ctx.setLineDash([]);
8016
9050
  // dashed round edge gap
8017
- if (style === 2 /* DASHED */) {
9051
+ if (style === 2 /* BORDER_STYLE.DASHED */) {
8018
9052
  if (isBezierCurve(boxPaths[0])) {
8019
9053
  path1 = boxPaths[3];
8020
9054
  path2 = boxPaths[0];
@@ -8071,22 +9105,22 @@ var isTextInputElement = function (container) {
8071
9105
  };
8072
9106
  var calculateBackgroundCurvedPaintingArea = function (clip, curves) {
8073
9107
  switch (clip) {
8074
- case 0 /* BORDER_BOX */:
9108
+ case 0 /* BACKGROUND_CLIP.BORDER_BOX */:
8075
9109
  return calculateBorderBoxPath(curves);
8076
- case 2 /* CONTENT_BOX */:
9110
+ case 2 /* BACKGROUND_CLIP.CONTENT_BOX */:
8077
9111
  return calculateContentBoxPath(curves);
8078
- case 1 /* PADDING_BOX */:
9112
+ case 1 /* BACKGROUND_CLIP.PADDING_BOX */:
8079
9113
  default:
8080
9114
  return calculatePaddingBoxPath(curves);
8081
9115
  }
8082
9116
  };
8083
9117
  var canvasTextAlign = function (textAlign) {
8084
9118
  switch (textAlign) {
8085
- case 1 /* CENTER */:
9119
+ case 1 /* TEXT_ALIGN.CENTER */:
8086
9120
  return 'center';
8087
- case 2 /* RIGHT */:
9121
+ case 2 /* TEXT_ALIGN.RIGHT */:
8088
9122
  return 'right';
8089
- case 0 /* LEFT */:
9123
+ case 0 /* TEXT_ALIGN.LEFT */:
8090
9124
  default:
8091
9125
  return 'left';
8092
9126
  }
@@ -8108,11 +9142,11 @@ var ForeignObjectRenderer = /** @class */ (function (_super) {
8108
9142
  _this.options = options;
8109
9143
  _this.canvas.width = Math.floor(options.width * options.scale);
8110
9144
  _this.canvas.height = Math.floor(options.height * options.scale);
8111
- _this.canvas.style.width = options.width + "px";
8112
- _this.canvas.style.height = options.height + "px";
9145
+ _this.canvas.style.width = "".concat(options.width, "px");
9146
+ _this.canvas.style.height = "".concat(options.height, "px");
8113
9147
  _this.ctx.scale(_this.options.scale, _this.options.scale);
8114
9148
  _this.ctx.translate(-options.x, -options.y);
8115
- _this.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + options.width + "x" + options.height + " at " + options.x + "," + options.y + ") with scale " + options.scale);
9149
+ _this.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (".concat(options.width, "x").concat(options.height, " at ").concat(options.x, ",").concat(options.y, ") with scale ").concat(options.scale));
8116
9150
  return _this;
8117
9151
  }
8118
9152
  ForeignObjectRenderer.prototype.render = function (element) {
@@ -8144,7 +9178,7 @@ var loadSerializedSVG = function (svg) {
8144
9178
  resolve(img);
8145
9179
  };
8146
9180
  img.onerror = reject;
8147
- img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
9181
+ img.src = "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svg)));
8148
9182
  });
8149
9183
  };
8150
9184
 
@@ -8165,7 +9199,7 @@ var Logger = /** @class */ (function () {
8165
9199
  // eslint-disable-next-line no-console
8166
9200
  if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {
8167
9201
  // eslint-disable-next-line no-console
8168
- console.debug.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9202
+ console.debug.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8169
9203
  }
8170
9204
  else {
8171
9205
  this.info.apply(this, args);
@@ -8185,7 +9219,7 @@ var Logger = /** @class */ (function () {
8185
9219
  // eslint-disable-next-line no-console
8186
9220
  if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {
8187
9221
  // eslint-disable-next-line no-console
8188
- console.info.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9222
+ console.info.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8189
9223
  }
8190
9224
  }
8191
9225
  };
@@ -8199,7 +9233,7 @@ var Logger = /** @class */ (function () {
8199
9233
  // eslint-disable-next-line no-console
8200
9234
  if (typeof window !== 'undefined' && window.console && typeof console.warn === 'function') {
8201
9235
  // eslint-disable-next-line no-console
8202
- console.warn.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9236
+ console.warn.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8203
9237
  }
8204
9238
  else {
8205
9239
  this.info.apply(this, args);
@@ -8216,7 +9250,7 @@ var Logger = /** @class */ (function () {
8216
9250
  // eslint-disable-next-line no-console
8217
9251
  if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {
8218
9252
  // eslint-disable-next-line no-console
8219
- console.error.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9253
+ console.error.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8220
9254
  }
8221
9255
  else {
8222
9256
  this.info.apply(this, args);
@@ -8231,7 +9265,7 @@ var Context = /** @class */ (function () {
8231
9265
  function Context(options, windowBounds) {
8232
9266
  var _a;
8233
9267
  this.windowBounds = windowBounds;
8234
- this.instanceName = "#" + Context.instanceCount++;
9268
+ this.instanceName = "#".concat(Context.instanceCount++);
8235
9269
  this.logger = new Logger({ id: this.instanceName, enabled: options.logging });
8236
9270
  this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new Cache(this, options);
8237
9271
  }
@@ -8267,7 +9301,8 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8267
9301
  allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false,
8268
9302
  imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15000,
8269
9303
  proxy: opts.proxy,
8270
- useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false
9304
+ useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false,
9305
+ customIsSameOrigin: opts.customIsSameOrigin
8271
9306
  };
8272
9307
  contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions);
8273
9308
  windowOptions = {
@@ -8286,7 +9321,7 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8286
9321
  inlineImages: foreignObjectRendering,
8287
9322
  copyStyles: foreignObjectRendering
8288
9323
  };
8289
- context.logger.debug("Starting document clone with size " + windowBounds.width + "x" + windowBounds.height + " scrolled to " + -windowBounds.left + "," + -windowBounds.top);
9324
+ context.logger.debug("Starting document clone with size ".concat(windowBounds.width, "x").concat(windowBounds.height, " scrolled to ").concat(-windowBounds.left, ",").concat(-windowBounds.top));
8290
9325
  documentCloner = new DocumentCloner(context, element, cloneOptions);
8291
9326
  clonedElement = documentCloner.clonedReferenceElement;
8292
9327
  if (!clonedElement) {
@@ -8316,13 +9351,13 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8316
9351
  canvas = _u.sent();
8317
9352
  return [3 /*break*/, 5];
8318
9353
  case 3:
8319
- context.logger.debug("Document cloned, element located at " + left + "," + top + " with size " + width + "x" + height + " using computed rendering");
9354
+ context.logger.debug("Document cloned, element located at ".concat(left, ",").concat(top, " with size ").concat(width, "x").concat(height, " using computed rendering"));
8320
9355
  context.logger.debug("Starting DOM parsing");
8321
9356
  root = parseTree(context, clonedElement);
8322
9357
  if (backgroundColor === root.styles.backgroundColor) {
8323
9358
  root.styles.backgroundColor = COLORS.TRANSPARENT;
8324
9359
  }
8325
- context.logger.debug("Starting renderer for element at " + renderOptions.x + "," + renderOptions.y + " with size " + renderOptions.width + "x" + renderOptions.height);
9360
+ context.logger.debug("Starting renderer for element at ".concat(renderOptions.x, ",").concat(renderOptions.y, " with size ").concat(renderOptions.width, "x").concat(renderOptions.height));
8326
9361
  renderer = new CanvasRenderer(context, renderOptions);
8327
9362
  return [4 /*yield*/, renderer.render(root)];
8328
9363
  case 4:
@@ -8383,38 +9418,38 @@ class Screenshot {
8383
9418
  useCORS: true,
8384
9419
  logging: false,
8385
9420
  width: fullPageWidth,
8386
- height: fullPageHeight
9421
+ height: fullPageHeight,
8387
9422
  });
8388
9423
  // Restore scroll position
8389
9424
  window.scrollTo(0, originalScrollY);
8390
9425
  // Show UXbert UI elements again
8391
9426
  this.showUXbertElements();
8392
9427
  // Convert to base64
8393
- this.currentScreenshot = canvas.toDataURL('image/png');
9428
+ this.currentScreenshot = canvas.toDataURL("image/png");
8394
9429
  return this.currentScreenshot;
8395
9430
  }
8396
9431
  catch (error) {
8397
- console.error('Screenshot capture failed:', error);
9432
+ console.error("Screenshot capture failed:", error);
8398
9433
  this.showUXbertElements();
8399
9434
  throw error;
8400
9435
  }
8401
9436
  }
8402
9437
  hideUXbertElements() {
8403
9438
  const elements = document.querySelectorAll('[class*="uxbert-"]');
8404
- elements.forEach(el => {
9439
+ elements.forEach((el) => {
8405
9440
  const element = el;
8406
- element.setAttribute('data-uxbert-display', element.style.display || '');
8407
- element.style.display = 'none';
9441
+ element.setAttribute("data-uxbert-display", element.style.display || "");
9442
+ element.style.display = "none";
8408
9443
  });
8409
9444
  }
8410
9445
  showUXbertElements() {
8411
9446
  const elements = document.querySelectorAll('[class*="uxbert-"]');
8412
- elements.forEach(el => {
9447
+ elements.forEach((el) => {
8413
9448
  const element = el;
8414
- const originalDisplay = element.getAttribute('data-uxbert-display');
9449
+ const originalDisplay = element.getAttribute("data-uxbert-display");
8415
9450
  if (originalDisplay !== null) {
8416
9451
  element.style.display = originalDisplay;
8417
- element.removeAttribute('data-uxbert-display');
9452
+ element.removeAttribute("data-uxbert-display");
8418
9453
  }
8419
9454
  });
8420
9455
  }