@uxbertlabs/reportly 1.0.3 → 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.
@@ -22,6 +22,10 @@ class Config {
22
22
  };
23
23
  }
24
24
  loadFromStorage() {
25
+ // Check if we're in a browser environment
26
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
27
+ return;
28
+ }
25
29
  try {
26
30
  const saved = localStorage.getItem('uxbert-config');
27
31
  if (saved) {
@@ -34,6 +38,10 @@ class Config {
34
38
  }
35
39
  }
36
40
  save() {
41
+ // Check if we're in a browser environment
42
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
43
+ return;
44
+ }
37
45
  try {
38
46
  localStorage.setItem('uxbert-config', JSON.stringify(this.config));
39
47
  }
@@ -338,24 +346,26 @@ class Modal {
338
346
  }
339
347
 
340
348
  class Toolbar {
349
+ // private currentTool: AnnotationTool;
350
+ // private currentColor: string;
341
351
  constructor(callbacks) {
342
352
  this.callbacks = callbacks;
343
353
  this.toolbar = null;
344
354
  this.toggleButton = null;
345
355
  this.isToolbarExpanded = false;
346
- this.currentTool = 'pen';
347
- this.currentColor = '#ef4444';
356
+ // this.currentTool = "pen";
357
+ // this.currentColor = "#ef4444";
348
358
  }
349
359
  create() {
350
360
  // Create toggle button
351
- this.toggleButton = document.createElement('button');
352
- this.toggleButton.className = 'uxbert-toolbar-toggle';
353
- this.toggleButton.innerHTML = '🛠️';
354
- 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";
355
365
  document.body.appendChild(this.toggleButton);
356
366
  // Create toolbar
357
- this.toolbar = document.createElement('div');
358
- this.toolbar.className = 'uxbert-toolbar';
367
+ this.toolbar = document.createElement("div");
368
+ this.toolbar.className = "uxbert-toolbar";
359
369
  this.toolbar.innerHTML = `
360
370
  <div class="uxbert-toolbar-header">
361
371
  <div class="uxbert-toolbar-title">Annotation Tools</div>
@@ -395,19 +405,19 @@ class Toolbar {
395
405
  if (!this.toolbar || !this.toggleButton)
396
406
  return;
397
407
  // Toggle button
398
- this.toggleButton.addEventListener('click', () => {
408
+ this.toggleButton.addEventListener("click", () => {
399
409
  this.toggleToolbar();
400
410
  });
401
411
  // Minimize button
402
- const minimizeBtn = this.toolbar.querySelector('#uxbert-minimize-btn');
403
- minimizeBtn.addEventListener('click', () => {
412
+ const minimizeBtn = this.toolbar.querySelector("#uxbert-minimize-btn");
413
+ minimizeBtn.addEventListener("click", () => {
404
414
  this.toggleToolbar();
405
415
  });
406
416
  // Tool buttons
407
- const toolBtns = this.toolbar.querySelectorAll('[data-tool]');
408
- toolBtns.forEach(btn => {
409
- btn.addEventListener('click', () => {
410
- 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");
411
421
  this.setTool(tool);
412
422
  if (this.callbacks.onToolChange) {
413
423
  this.callbacks.onToolChange(tool);
@@ -415,10 +425,10 @@ class Toolbar {
415
425
  });
416
426
  });
417
427
  // Color buttons
418
- const colorBtns = this.toolbar.querySelectorAll('[data-color]');
419
- colorBtns.forEach(btn => {
420
- btn.addEventListener('click', () => {
421
- 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");
422
432
  this.setColor(color);
423
433
  if (this.callbacks.onColorChange) {
424
434
  this.callbacks.onColorChange(color);
@@ -426,57 +436,57 @@ class Toolbar {
426
436
  });
427
437
  });
428
438
  // Action buttons
429
- const undoBtn = this.toolbar.querySelector('#uxbert-undo-btn');
430
- undoBtn.addEventListener('click', () => {
439
+ const undoBtn = this.toolbar.querySelector("#uxbert-undo-btn");
440
+ undoBtn.addEventListener("click", () => {
431
441
  if (this.callbacks.onUndo) {
432
442
  this.callbacks.onUndo();
433
443
  }
434
444
  });
435
- const clearBtn = this.toolbar.querySelector('#uxbert-clear-btn');
436
- clearBtn.addEventListener('click', () => {
445
+ const clearBtn = this.toolbar.querySelector("#uxbert-clear-btn");
446
+ clearBtn.addEventListener("click", () => {
437
447
  if (this.callbacks.onClear) {
438
448
  this.callbacks.onClear();
439
449
  }
440
450
  });
441
- const doneBtn = this.toolbar.querySelector('#uxbert-done-btn');
442
- doneBtn.addEventListener('click', () => {
451
+ const doneBtn = this.toolbar.querySelector("#uxbert-done-btn");
452
+ doneBtn.addEventListener("click", () => {
443
453
  if (this.callbacks.onDone) {
444
454
  this.callbacks.onDone();
445
455
  }
446
456
  });
447
457
  // Exit button
448
- const exitBtn = this.toolbar.querySelector('#uxbert-exit-btn');
449
- exitBtn.addEventListener('click', () => {
458
+ const exitBtn = this.toolbar.querySelector("#uxbert-exit-btn");
459
+ exitBtn.addEventListener("click", () => {
450
460
  if (this.callbacks.onExit) {
451
461
  this.callbacks.onExit();
452
462
  }
453
463
  });
454
464
  }
455
465
  setTool(tool) {
456
- this.currentTool = tool;
466
+ // this.currentTool = tool;
457
467
  if (!this.toolbar)
458
468
  return;
459
- const toolBtns = this.toolbar.querySelectorAll('[data-tool]');
460
- toolBtns.forEach(btn => {
461
- if (btn.getAttribute('data-tool') === tool) {
462
- 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");
463
473
  }
464
474
  else {
465
- btn.classList.remove('active');
475
+ btn.classList.remove("active");
466
476
  }
467
477
  });
468
478
  }
469
479
  setColor(color) {
470
- this.currentColor = color;
480
+ // this.currentColor = color;
471
481
  if (!this.toolbar)
472
482
  return;
473
- const colorBtns = this.toolbar.querySelectorAll('[data-color]');
474
- colorBtns.forEach(btn => {
475
- if (btn.getAttribute('data-color') === color) {
476
- 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");
477
487
  }
478
488
  else {
479
- btn.classList.remove('active');
489
+ btn.classList.remove("active");
480
490
  }
481
491
  });
482
492
  }
@@ -485,40 +495,40 @@ class Toolbar {
485
495
  return;
486
496
  this.isToolbarExpanded = !this.isToolbarExpanded;
487
497
  if (this.isToolbarExpanded) {
488
- this.toolbar.classList.add('expanded');
489
- this.toggleButton.classList.add('hidden');
498
+ this.toolbar.classList.add("expanded");
499
+ this.toggleButton.classList.add("hidden");
490
500
  }
491
501
  else {
492
- this.toolbar.classList.remove('expanded');
493
- this.toggleButton.classList.remove('hidden');
502
+ this.toolbar.classList.remove("expanded");
503
+ this.toggleButton.classList.remove("hidden");
494
504
  }
495
505
  }
496
506
  show() {
497
507
  if (this.toolbar && this.toggleButton) {
498
- this.toolbar.classList.add('active');
499
- this.toggleButton.classList.add('active');
508
+ this.toolbar.classList.add("active");
509
+ this.toggleButton.classList.add("active");
500
510
  // Use setTimeout to ensure DOM is ready before checking width and applying classes
501
511
  setTimeout(() => {
502
512
  // Auto-expand on desktop, collapsed on mobile
503
513
  if (window.innerWidth > 768) {
504
514
  this.isToolbarExpanded = true;
505
- this.toolbar.classList.add('expanded');
506
- this.toggleButton.classList.add('hidden');
515
+ this.toolbar.classList.add("expanded");
516
+ this.toggleButton.classList.add("hidden");
507
517
  }
508
518
  else {
509
519
  this.isToolbarExpanded = false;
510
- this.toolbar.classList.remove('expanded');
511
- this.toggleButton.classList.remove('hidden');
520
+ this.toolbar.classList.remove("expanded");
521
+ this.toggleButton.classList.remove("hidden");
512
522
  }
513
523
  }, 50);
514
524
  }
515
525
  }
516
526
  hide() {
517
527
  if (this.toolbar && this.toggleButton) {
518
- this.toolbar.classList.remove('active');
519
- this.toolbar.classList.remove('expanded');
520
- this.toggleButton.classList.remove('active');
521
- 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");
522
532
  this.isToolbarExpanded = false;
523
533
  }
524
534
  }
@@ -535,11 +545,11 @@ class Toolbar {
535
545
  }
536
546
 
537
547
  /*!
538
- * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
539
- * 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
540
550
  * Released under MIT License
541
551
  */
542
- /*! *****************************************************************************
552
+ /******************************************************************************
543
553
  Copyright (c) Microsoft Corporation.
544
554
 
545
555
  Permission to use, copy, modify, and/or distribute this software for any
@@ -553,7 +563,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
553
563
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
554
564
  PERFORMANCE OF THIS SOFTWARE.
555
565
  ***************************************************************************** */
556
- /* global Reflect, Promise */
566
+ /* global Reflect, Promise, SuppressedError, Symbol */
557
567
 
558
568
  var extendStatics = function(d, b) {
559
569
  extendStatics = Object.setPrototypeOf ||
@@ -597,7 +607,7 @@ function __generator(thisArg, body) {
597
607
  function verb(n) { return function (v) { return step([n, v]); }; }
598
608
  function step(op) {
599
609
  if (f) throw new TypeError("Generator is already executing.");
600
- while (_) try {
610
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
601
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;
602
612
  if (y = 0, t) op = [op[0] & 2, t.value];
603
613
  switch (op[0]) {
@@ -626,8 +636,13 @@ function __spreadArray(to, from, pack) {
626
636
  ar[i] = from[i];
627
637
  }
628
638
  }
629
- return to.concat(ar || from);
630
- }
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
+ };
631
646
 
632
647
  var Bounds = /** @class */ (function () {
633
648
  function Bounds(left, top, width, height) {
@@ -1522,38 +1537,38 @@ var stringToNumber = function (codePoints) {
1522
1537
  return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);
1523
1538
  };
1524
1539
  var LEFT_PARENTHESIS_TOKEN = {
1525
- type: 2 /* LEFT_PARENTHESIS_TOKEN */
1540
+ type: 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */
1526
1541
  };
1527
1542
  var RIGHT_PARENTHESIS_TOKEN = {
1528
- type: 3 /* RIGHT_PARENTHESIS_TOKEN */
1529
- };
1530
- var COMMA_TOKEN = { type: 4 /* COMMA_TOKEN */ };
1531
- var SUFFIX_MATCH_TOKEN = { type: 13 /* SUFFIX_MATCH_TOKEN */ };
1532
- var PREFIX_MATCH_TOKEN = { type: 8 /* PREFIX_MATCH_TOKEN */ };
1533
- var COLUMN_TOKEN = { type: 21 /* COLUMN_TOKEN */ };
1534
- var DASH_MATCH_TOKEN = { type: 9 /* DASH_MATCH_TOKEN */ };
1535
- 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 */ };
1536
1551
  var LEFT_CURLY_BRACKET_TOKEN = {
1537
- type: 11 /* LEFT_CURLY_BRACKET_TOKEN */
1552
+ type: 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */
1538
1553
  };
1539
1554
  var RIGHT_CURLY_BRACKET_TOKEN = {
1540
- type: 12 /* RIGHT_CURLY_BRACKET_TOKEN */
1541
- };
1542
- var SUBSTRING_MATCH_TOKEN = { type: 14 /* SUBSTRING_MATCH_TOKEN */ };
1543
- var BAD_URL_TOKEN = { type: 23 /* BAD_URL_TOKEN */ };
1544
- var BAD_STRING_TOKEN = { type: 1 /* BAD_STRING_TOKEN */ };
1545
- var CDO_TOKEN = { type: 25 /* CDO_TOKEN */ };
1546
- var CDC_TOKEN = { type: 24 /* CDC_TOKEN */ };
1547
- var COLON_TOKEN = { type: 26 /* COLON_TOKEN */ };
1548
- 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 */ };
1549
1564
  var LEFT_SQUARE_BRACKET_TOKEN = {
1550
- type: 28 /* LEFT_SQUARE_BRACKET_TOKEN */
1565
+ type: 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */
1551
1566
  };
1552
1567
  var RIGHT_SQUARE_BRACKET_TOKEN = {
1553
- type: 29 /* RIGHT_SQUARE_BRACKET_TOKEN */
1568
+ type: 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */
1554
1569
  };
1555
- var WHITESPACE_TOKEN = { type: 31 /* WHITESPACE_TOKEN */ };
1556
- 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 */ };
1557
1572
  var Tokenizer = /** @class */ (function () {
1558
1573
  function Tokenizer() {
1559
1574
  this._value = [];
@@ -1582,7 +1597,7 @@ var Tokenizer = /** @class */ (function () {
1582
1597
  if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {
1583
1598
  var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;
1584
1599
  var value = this.consumeName();
1585
- return { type: 5 /* HASH_TOKEN */, value: value, flags: flags };
1600
+ return { type: 5 /* TokenType.HASH_TOKEN */, value: value, flags: flags };
1586
1601
  }
1587
1602
  break;
1588
1603
  case DOLLAR_SIGN:
@@ -1671,7 +1686,7 @@ var Tokenizer = /** @class */ (function () {
1671
1686
  var a3 = this.peekCodePoint(2);
1672
1687
  if (isIdentifierStart(a1, a2, a3)) {
1673
1688
  var value = this.consumeName();
1674
- return { type: 7 /* AT_KEYWORD_TOKEN */, value: value };
1689
+ return { type: 7 /* TokenType.AT_KEYWORD_TOKEN */, value: value };
1675
1690
  }
1676
1691
  break;
1677
1692
  case LEFT_SQUARE_BRACKET:
@@ -1735,7 +1750,7 @@ var Tokenizer = /** @class */ (function () {
1735
1750
  this.reconsumeCodePoint(codePoint);
1736
1751
  return this.consumeIdentLikeToken();
1737
1752
  }
1738
- return { type: 6 /* DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
1753
+ return { type: 6 /* TokenType.DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
1739
1754
  };
1740
1755
  Tokenizer.prototype.consumeCodePoint = function () {
1741
1756
  var value = this._value.shift();
@@ -1766,7 +1781,7 @@ var Tokenizer = /** @class */ (function () {
1766
1781
  if (questionMarks) {
1767
1782
  var start_1 = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);
1768
1783
  var end = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);
1769
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start_1, end: end };
1784
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start_1, end: end };
1770
1785
  }
1771
1786
  var start = parseInt(fromCodePoint$1.apply(void 0, digits), 16);
1772
1787
  if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {
@@ -1778,10 +1793,10 @@ var Tokenizer = /** @class */ (function () {
1778
1793
  codePoint = this.consumeCodePoint();
1779
1794
  }
1780
1795
  var end = parseInt(fromCodePoint$1.apply(void 0, endDigits), 16);
1781
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: end };
1796
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start, end: end };
1782
1797
  }
1783
1798
  else {
1784
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: start };
1799
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start, end: start };
1785
1800
  }
1786
1801
  };
1787
1802
  Tokenizer.prototype.consumeIdentLikeToken = function () {
@@ -1792,24 +1807,24 @@ var Tokenizer = /** @class */ (function () {
1792
1807
  }
1793
1808
  else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {
1794
1809
  this.consumeCodePoint();
1795
- return { type: 19 /* FUNCTION_TOKEN */, value: value };
1810
+ return { type: 19 /* TokenType.FUNCTION_TOKEN */, value: value };
1796
1811
  }
1797
- return { type: 20 /* IDENT_TOKEN */, value: value };
1812
+ return { type: 20 /* TokenType.IDENT_TOKEN */, value: value };
1798
1813
  };
1799
1814
  Tokenizer.prototype.consumeUrlToken = function () {
1800
1815
  var value = [];
1801
1816
  this.consumeWhiteSpace();
1802
1817
  if (this.peekCodePoint(0) === EOF) {
1803
- return { type: 22 /* URL_TOKEN */, value: '' };
1818
+ return { type: 22 /* TokenType.URL_TOKEN */, value: '' };
1804
1819
  }
1805
1820
  var next = this.peekCodePoint(0);
1806
1821
  if (next === APOSTROPHE || next === QUOTATION_MARK) {
1807
1822
  var stringToken = this.consumeStringToken(this.consumeCodePoint());
1808
- if (stringToken.type === 0 /* STRING_TOKEN */) {
1823
+ if (stringToken.type === 0 /* TokenType.STRING_TOKEN */) {
1809
1824
  this.consumeWhiteSpace();
1810
1825
  if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
1811
1826
  this.consumeCodePoint();
1812
- return { type: 22 /* URL_TOKEN */, value: stringToken.value };
1827
+ return { type: 22 /* TokenType.URL_TOKEN */, value: stringToken.value };
1813
1828
  }
1814
1829
  }
1815
1830
  this.consumeBadUrlRemnants();
@@ -1818,13 +1833,13 @@ var Tokenizer = /** @class */ (function () {
1818
1833
  while (true) {
1819
1834
  var codePoint = this.consumeCodePoint();
1820
1835
  if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {
1821
- 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) };
1822
1837
  }
1823
1838
  else if (isWhiteSpace(codePoint)) {
1824
1839
  this.consumeWhiteSpace();
1825
1840
  if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
1826
1841
  this.consumeCodePoint();
1827
- 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) };
1828
1843
  }
1829
1844
  this.consumeBadUrlRemnants();
1830
1845
  return BAD_URL_TOKEN;
@@ -1884,7 +1899,7 @@ var Tokenizer = /** @class */ (function () {
1884
1899
  var codePoint = this._value[i];
1885
1900
  if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {
1886
1901
  value += this.consumeStringSlice(i);
1887
- return { type: 0 /* STRING_TOKEN */, value: value };
1902
+ return { type: 0 /* TokenType.STRING_TOKEN */, value: value };
1888
1903
  }
1889
1904
  if (codePoint === LINE_FEED) {
1890
1905
  this._value.splice(0, i);
@@ -1946,13 +1961,13 @@ var Tokenizer = /** @class */ (function () {
1946
1961
  var c3 = this.peekCodePoint(2);
1947
1962
  if (isIdentifierStart(c1, c2, c3)) {
1948
1963
  var unit = this.consumeName();
1949
- return { type: 15 /* DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
1964
+ return { type: 15 /* TokenType.DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
1950
1965
  }
1951
1966
  if (c1 === PERCENTAGE_SIGN) {
1952
1967
  this.consumeCodePoint();
1953
- return { type: 16 /* PERCENTAGE_TOKEN */, number: number, flags: flags };
1968
+ return { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number: number, flags: flags };
1954
1969
  }
1955
- return { type: 17 /* NUMBER_TOKEN */, number: number, flags: flags };
1970
+ return { type: 17 /* TokenType.NUMBER_TOKEN */, number: number, flags: flags };
1956
1971
  };
1957
1972
  Tokenizer.prototype.consumeEscapedCodePoint = function () {
1958
1973
  var codePoint = this.consumeCodePoint();
@@ -2011,18 +2026,18 @@ var Parser = /** @class */ (function () {
2011
2026
  };
2012
2027
  Parser.prototype.parseComponentValue = function () {
2013
2028
  var token = this.consumeToken();
2014
- while (token.type === 31 /* WHITESPACE_TOKEN */) {
2029
+ while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */) {
2015
2030
  token = this.consumeToken();
2016
2031
  }
2017
- if (token.type === 32 /* EOF_TOKEN */) {
2032
+ if (token.type === 32 /* TokenType.EOF_TOKEN */) {
2018
2033
  throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
2019
2034
  }
2020
2035
  this.reconsumeToken(token);
2021
2036
  var value = this.consumeComponentValue();
2022
2037
  do {
2023
2038
  token = this.consumeToken();
2024
- } while (token.type === 31 /* WHITESPACE_TOKEN */);
2025
- if (token.type === 32 /* EOF_TOKEN */) {
2039
+ } while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */);
2040
+ if (token.type === 32 /* TokenType.EOF_TOKEN */) {
2026
2041
  return value;
2027
2042
  }
2028
2043
  throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
@@ -2031,7 +2046,7 @@ var Parser = /** @class */ (function () {
2031
2046
  var values = [];
2032
2047
  while (true) {
2033
2048
  var value = this.consumeComponentValue();
2034
- if (value.type === 32 /* EOF_TOKEN */) {
2049
+ if (value.type === 32 /* TokenType.EOF_TOKEN */) {
2035
2050
  return values;
2036
2051
  }
2037
2052
  values.push(value);
@@ -2041,11 +2056,11 @@ var Parser = /** @class */ (function () {
2041
2056
  Parser.prototype.consumeComponentValue = function () {
2042
2057
  var token = this.consumeToken();
2043
2058
  switch (token.type) {
2044
- case 11 /* LEFT_CURLY_BRACKET_TOKEN */:
2045
- case 28 /* LEFT_SQUARE_BRACKET_TOKEN */:
2046
- 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 */:
2047
2062
  return this.consumeSimpleBlock(token.type);
2048
- case 19 /* FUNCTION_TOKEN */:
2063
+ case 19 /* TokenType.FUNCTION_TOKEN */:
2049
2064
  return this.consumeFunction(token);
2050
2065
  }
2051
2066
  return token;
@@ -2054,7 +2069,7 @@ var Parser = /** @class */ (function () {
2054
2069
  var block = { type: type, values: [] };
2055
2070
  var token = this.consumeToken();
2056
2071
  while (true) {
2057
- if (token.type === 32 /* EOF_TOKEN */ || isEndingTokenFor(token, type)) {
2072
+ if (token.type === 32 /* TokenType.EOF_TOKEN */ || isEndingTokenFor(token, type)) {
2058
2073
  return block;
2059
2074
  }
2060
2075
  this.reconsumeToken(token);
@@ -2066,11 +2081,11 @@ var Parser = /** @class */ (function () {
2066
2081
  var cssFunction = {
2067
2082
  name: functionToken.value,
2068
2083
  values: [],
2069
- type: 18 /* FUNCTION */
2084
+ type: 18 /* TokenType.FUNCTION */
2070
2085
  };
2071
2086
  while (true) {
2072
2087
  var token = this.consumeToken();
2073
- 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 */) {
2074
2089
  return cssFunction;
2075
2090
  }
2076
2091
  this.reconsumeToken(token);
@@ -2086,22 +2101,22 @@ var Parser = /** @class */ (function () {
2086
2101
  };
2087
2102
  return Parser;
2088
2103
  }());
2089
- var isDimensionToken = function (token) { return token.type === 15 /* DIMENSION_TOKEN */; };
2090
- var isNumberToken = function (token) { return token.type === 17 /* NUMBER_TOKEN */; };
2091
- var isIdentToken = function (token) { return token.type === 20 /* IDENT_TOKEN */; };
2092
- 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 */; };
2093
2108
  var isIdentWithValue = function (token, value) {
2094
2109
  return isIdentToken(token) && token.value === value;
2095
2110
  };
2096
- var nonWhiteSpace = function (token) { return token.type !== 31 /* WHITESPACE_TOKEN */; };
2111
+ var nonWhiteSpace = function (token) { return token.type !== 31 /* TokenType.WHITESPACE_TOKEN */; };
2097
2112
  var nonFunctionArgSeparator = function (token) {
2098
- 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 */;
2099
2114
  };
2100
2115
  var parseFunctionArgs = function (tokens) {
2101
2116
  var args = [];
2102
2117
  var arg = [];
2103
2118
  tokens.forEach(function (token) {
2104
- if (token.type === 4 /* COMMA_TOKEN */) {
2119
+ if (token.type === 4 /* TokenType.COMMA_TOKEN */) {
2105
2120
  if (arg.length === 0) {
2106
2121
  throw new Error("Error parsing function args, zero tokens for arg");
2107
2122
  }
@@ -2109,7 +2124,7 @@ var parseFunctionArgs = function (tokens) {
2109
2124
  arg = [];
2110
2125
  return;
2111
2126
  }
2112
- if (token.type !== 31 /* WHITESPACE_TOKEN */) {
2127
+ if (token.type !== 31 /* TokenType.WHITESPACE_TOKEN */) {
2113
2128
  arg.push(token);
2114
2129
  }
2115
2130
  });
@@ -2119,37 +2134,37 @@ var parseFunctionArgs = function (tokens) {
2119
2134
  return args;
2120
2135
  };
2121
2136
  var isEndingTokenFor = function (token, type) {
2122
- 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 */) {
2123
2138
  return true;
2124
2139
  }
2125
- 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 */) {
2126
2141
  return true;
2127
2142
  }
2128
- 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 */;
2129
2144
  };
2130
2145
 
2131
2146
  var isLength = function (token) {
2132
- 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 */;
2133
2148
  };
2134
2149
 
2135
2150
  var isLengthPercentage = function (token) {
2136
- return token.type === 16 /* PERCENTAGE_TOKEN */ || isLength(token);
2151
+ return token.type === 16 /* TokenType.PERCENTAGE_TOKEN */ || isLength(token);
2137
2152
  };
2138
2153
  var parseLengthPercentageTuple = function (tokens) {
2139
2154
  return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];
2140
2155
  };
2141
2156
  var ZERO_LENGTH = {
2142
- type: 17 /* NUMBER_TOKEN */,
2157
+ type: 17 /* TokenType.NUMBER_TOKEN */,
2143
2158
  number: 0,
2144
2159
  flags: FLAG_INTEGER
2145
2160
  };
2146
2161
  var FIFTY_PERCENT = {
2147
- type: 16 /* PERCENTAGE_TOKEN */,
2162
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
2148
2163
  number: 50,
2149
2164
  flags: FLAG_INTEGER
2150
2165
  };
2151
2166
  var HUNDRED_PERCENT = {
2152
- type: 16 /* PERCENTAGE_TOKEN */,
2167
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
2153
2168
  number: 100,
2154
2169
  flags: FLAG_INTEGER
2155
2170
  };
@@ -2158,7 +2173,7 @@ var getAbsoluteValueForTuple = function (tuple, width, height) {
2158
2173
  return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];
2159
2174
  };
2160
2175
  var getAbsoluteValue = function (token, parent) {
2161
- if (token.type === 16 /* PERCENTAGE_TOKEN */) {
2176
+ if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
2162
2177
  return (token.number / 100) * parent;
2163
2178
  }
2164
2179
  if (isDimensionToken(token)) {
@@ -2181,7 +2196,7 @@ var TURN = 'turn';
2181
2196
  var angle = {
2182
2197
  name: 'angle',
2183
2198
  parse: function (_context, value) {
2184
- if (value.type === 15 /* DIMENSION_TOKEN */) {
2199
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
2185
2200
  switch (value.unit) {
2186
2201
  case DEG:
2187
2202
  return (Math.PI * value.number) / 180;
@@ -2197,7 +2212,7 @@ var angle = {
2197
2212
  }
2198
2213
  };
2199
2214
  var isAngle = function (value) {
2200
- if (value.type === 15 /* DIMENSION_TOKEN */) {
2215
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
2201
2216
  if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {
2202
2217
  return true;
2203
2218
  }
@@ -2247,87 +2262,154 @@ var parseNamedSide = function (tokens) {
2247
2262
  };
2248
2263
  var deg = function (deg) { return (Math.PI * deg) / 180; };
2249
2264
 
2250
- var color$1 = {
2251
- name: 'color',
2252
- parse: function (context, value) {
2253
- if (value.type === 18 /* FUNCTION */) {
2254
- var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
2255
- if (typeof colorFunction === 'undefined') {
2256
- throw new Error("Attempting to parse an unsupported color function \"" + value.name + "\"");
2257
- }
2258
- return colorFunction(context, value.values);
2259
- }
2260
- if (value.type === 5 /* HASH_TOKEN */) {
2261
- if (value.value.length === 3) {
2262
- var r = value.value.substring(0, 1);
2263
- var g = value.value.substring(1, 2);
2264
- var b = value.value.substring(2, 3);
2265
- return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);
2266
- }
2267
- if (value.value.length === 4) {
2268
- var r = value.value.substring(0, 1);
2269
- var g = value.value.substring(1, 2);
2270
- var b = value.value.substring(2, 3);
2271
- var a = value.value.substring(3, 4);
2272
- return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);
2273
- }
2274
- if (value.value.length === 6) {
2275
- var r = value.value.substring(0, 2);
2276
- var g = value.value.substring(2, 4);
2277
- var b = value.value.substring(4, 6);
2278
- return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);
2279
- }
2280
- if (value.value.length === 8) {
2281
- var r = value.value.substring(0, 2);
2282
- var g = value.value.substring(2, 4);
2283
- var b = value.value.substring(4, 6);
2284
- var a = value.value.substring(6, 8);
2285
- return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);
2286
- }
2287
- }
2288
- if (value.type === 20 /* IDENT_TOKEN */) {
2289
- var namedColor = COLORS[value.value.toUpperCase()];
2290
- if (typeof namedColor !== 'undefined') {
2291
- return namedColor;
2292
- }
2293
- }
2294
- return COLORS.TRANSPARENT;
2295
- }
2296
- };
2297
2265
  var isTransparent = function (color) { return (0xff & color) === 0; };
2298
2266
  var asString = function (color) {
2299
2267
  var alpha = 0xff & color;
2300
2268
  var blue = 0xff & (color >> 8);
2301
2269
  var green = 0xff & (color >> 16);
2302
2270
  var red = 0xff & (color >> 24);
2303
- 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, ")");
2304
2272
  };
2305
2273
  var pack = function (r, g, b, a) {
2306
2274
  return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;
2307
2275
  };
2308
2276
  var getTokenColorValue = function (token, i) {
2309
- if (token.type === 17 /* NUMBER_TOKEN */) {
2277
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
2310
2278
  return token.number;
2311
2279
  }
2312
- if (token.type === 16 /* PERCENTAGE_TOKEN */) {
2280
+ if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
2313
2281
  var max = i === 3 ? 1 : 255;
2314
2282
  return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);
2315
2283
  }
2316
2284
  return 0;
2317
2285
  };
2318
- var rgb = function (_context, args) {
2319
- var tokens = args.filter(nonFunctionArgSeparator);
2320
- if (tokens.length === 3) {
2321
- var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
2322
- return pack(r, g, b, 1);
2323
- }
2324
- if (tokens.length === 4) {
2325
- var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
2326
- return pack(r, g, b, a);
2327
- }
2328
- 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);
2329
2291
  };
2330
- function hue2rgb(t1, t2, hue) {
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
+ ];
2298
+ };
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) {
2331
2413
  if (hue < 0) {
2332
2414
  hue += 1;
2333
2415
  }
@@ -2346,29 +2428,783 @@ function hue2rgb(t1, t2, hue) {
2346
2428
  else {
2347
2429
  return t1;
2348
2430
  }
2349
- }
2350
- var hsl = function (context, args) {
2351
- var tokens = args.filter(nonFunctionArgSeparator);
2352
- var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];
2353
- var h = (hue.type === 17 /* NUMBER_TOKEN */ ? deg(hue.number) : angle.parse(context, hue)) / (Math.PI * 2);
2354
- var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;
2355
- var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;
2356
- 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];
2357
2434
  if (s === 0) {
2358
- return pack(l * 255, l * 255, l * 255, 1);
2435
+ return [l * 255, l * 255, l * 255];
2436
+ }
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);
2359
3044
  }
2360
- var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
2361
- var t1 = l * 2 - t2;
2362
- var r = hue2rgb(t1, t2, h + 1 / 3);
2363
- var g = hue2rgb(t1, t2, h);
2364
- var b = hue2rgb(t1, t2, h - 1 / 3);
2365
- return pack(r * 255, g * 255, b * 255, a);
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
2366
3197
  };
2367
3198
  var SUPPORTED_COLOR_FUNCTIONS = {
2368
- hsl: hsl,
2369
- hsla: hsl,
3199
+ hsl: packHSL,
3200
+ hsla: packHSL,
2370
3201
  rgb: rgb,
2371
- rgba: rgb
3202
+ rgba: rgb,
3203
+ lch: packLch,
3204
+ oklch: packOkLch,
3205
+ oklab: packOkLab,
3206
+ lab: packLab,
3207
+ color: _color
2372
3208
  };
2373
3209
  var parseColor = function (context, value) {
2374
3210
  return color$1.parse(context, Parser.create(value).parseComponentValue());
@@ -2529,18 +3365,18 @@ var backgroundClip = {
2529
3365
  name: 'background-clip',
2530
3366
  initialValue: 'border-box',
2531
3367
  prefix: false,
2532
- type: 1 /* LIST */,
3368
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
2533
3369
  parse: function (_context, tokens) {
2534
3370
  return tokens.map(function (token) {
2535
3371
  if (isIdentToken(token)) {
2536
3372
  switch (token.value) {
2537
3373
  case 'padding-box':
2538
- return 1 /* PADDING_BOX */;
3374
+ return 1 /* BACKGROUND_CLIP.PADDING_BOX */;
2539
3375
  case 'content-box':
2540
- return 2 /* CONTENT_BOX */;
3376
+ return 2 /* BACKGROUND_CLIP.CONTENT_BOX */;
2541
3377
  }
2542
3378
  }
2543
- return 0 /* BORDER_BOX */;
3379
+ return 0 /* BACKGROUND_CLIP.BORDER_BOX */;
2544
3380
  });
2545
3381
  }
2546
3382
  };
@@ -2549,7 +3385,7 @@ var backgroundColor = {
2549
3385
  name: "background-color",
2550
3386
  initialValue: 'transparent',
2551
3387
  prefix: false,
2552
- type: 3 /* TYPE_VALUE */,
3388
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
2553
3389
  format: 'color'
2554
3390
  };
2555
3391
 
@@ -2652,24 +3488,24 @@ var calculateRadius = function (gradient, x, y, width, height) {
2652
3488
  var rx = 0;
2653
3489
  var ry = 0;
2654
3490
  switch (gradient.size) {
2655
- case 0 /* CLOSEST_SIDE */:
3491
+ case 0 /* CSSRadialExtent.CLOSEST_SIDE */:
2656
3492
  // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.
2657
3493
  // If the shape is an ellipse, it exactly meets the closest side in each dimension.
2658
- if (gradient.shape === 0 /* CIRCLE */) {
3494
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2659
3495
  rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
2660
3496
  }
2661
- else if (gradient.shape === 1 /* ELLIPSE */) {
3497
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2662
3498
  rx = Math.min(Math.abs(x), Math.abs(x - width));
2663
3499
  ry = Math.min(Math.abs(y), Math.abs(y - height));
2664
3500
  }
2665
3501
  break;
2666
- case 2 /* CLOSEST_CORNER */:
3502
+ case 2 /* CSSRadialExtent.CLOSEST_CORNER */:
2667
3503
  // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.
2668
3504
  // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.
2669
- if (gradient.shape === 0 /* CIRCLE */) {
3505
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2670
3506
  rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
2671
3507
  }
2672
- else if (gradient.shape === 1 /* ELLIPSE */) {
3508
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2673
3509
  // Compute the ratio ry/rx (which is to be the same as for "closest-side")
2674
3510
  var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));
2675
3511
  var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];
@@ -2677,23 +3513,23 @@ var calculateRadius = function (gradient, x, y, width, height) {
2677
3513
  ry = c * rx;
2678
3514
  }
2679
3515
  break;
2680
- case 1 /* FARTHEST_SIDE */:
3516
+ case 1 /* CSSRadialExtent.FARTHEST_SIDE */:
2681
3517
  // Same as closest-side, except the ending shape is sized based on the farthest side(s)
2682
- if (gradient.shape === 0 /* CIRCLE */) {
3518
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2683
3519
  rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
2684
3520
  }
2685
- else if (gradient.shape === 1 /* ELLIPSE */) {
3521
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2686
3522
  rx = Math.max(Math.abs(x), Math.abs(x - width));
2687
3523
  ry = Math.max(Math.abs(y), Math.abs(y - height));
2688
3524
  }
2689
3525
  break;
2690
- case 3 /* FARTHEST_CORNER */:
3526
+ case 3 /* CSSRadialExtent.FARTHEST_CORNER */:
2691
3527
  // Same as closest-corner, except the ending shape is sized based on the farthest corner.
2692
3528
  // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.
2693
- if (gradient.shape === 0 /* CIRCLE */) {
3529
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2694
3530
  rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
2695
3531
  }
2696
- else if (gradient.shape === 1 /* ELLIPSE */) {
3532
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2697
3533
  // Compute the ratio ry/rx (which is to be the same as for "farthest-side")
2698
3534
  var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));
2699
3535
  var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];
@@ -2715,7 +3551,7 @@ var linearGradient = function (context, tokens) {
2715
3551
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2716
3552
  if (i === 0) {
2717
3553
  var firstToken = arg[0];
2718
- if (firstToken.type === 20 /* IDENT_TOKEN */ && firstToken.value === 'to') {
3554
+ if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ && firstToken.value === 'to') {
2719
3555
  angle$1 = parseNamedSide(arg);
2720
3556
  return;
2721
3557
  }
@@ -2727,7 +3563,7 @@ var linearGradient = function (context, tokens) {
2727
3563
  var colorStop = parseColorStop(context, arg);
2728
3564
  stops.push(colorStop);
2729
3565
  });
2730
- return { angle: angle$1, stops: stops, type: 1 /* LINEAR_GRADIENT */ };
3566
+ return { angle: angle$1, stops: stops, type: 1 /* CSSImageType.LINEAR_GRADIENT */ };
2731
3567
  };
2732
3568
 
2733
3569
  var prefixLinearGradient = function (context, tokens) {
@@ -2736,7 +3572,7 @@ var prefixLinearGradient = function (context, tokens) {
2736
3572
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2737
3573
  if (i === 0) {
2738
3574
  var firstToken = arg[0];
2739
- if (firstToken.type === 20 /* IDENT_TOKEN */ &&
3575
+ if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ &&
2740
3576
  ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {
2741
3577
  angle$1 = parseNamedSide(arg);
2742
3578
  return;
@@ -2752,30 +3588,30 @@ var prefixLinearGradient = function (context, tokens) {
2752
3588
  return {
2753
3589
  angle: angle$1,
2754
3590
  stops: stops,
2755
- type: 1 /* LINEAR_GRADIENT */
3591
+ type: 1 /* CSSImageType.LINEAR_GRADIENT */
2756
3592
  };
2757
3593
  };
2758
3594
 
2759
3595
  var webkitGradient = function (context, tokens) {
2760
3596
  var angle = deg(180);
2761
3597
  var stops = [];
2762
- var type = 1 /* LINEAR_GRADIENT */;
2763
- var shape = 0 /* CIRCLE */;
2764
- 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 */;
2765
3601
  var position = [];
2766
3602
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2767
3603
  var firstToken = arg[0];
2768
3604
  if (i === 0) {
2769
3605
  if (isIdentToken(firstToken) && firstToken.value === 'linear') {
2770
- type = 1 /* LINEAR_GRADIENT */;
3606
+ type = 1 /* CSSImageType.LINEAR_GRADIENT */;
2771
3607
  return;
2772
3608
  }
2773
3609
  else if (isIdentToken(firstToken) && firstToken.value === 'radial') {
2774
- type = 2 /* RADIAL_GRADIENT */;
3610
+ type = 2 /* CSSImageType.RADIAL_GRADIENT */;
2775
3611
  return;
2776
3612
  }
2777
3613
  }
2778
- if (firstToken.type === 18 /* FUNCTION */) {
3614
+ if (firstToken.type === 18 /* TokenType.FUNCTION */) {
2779
3615
  if (firstToken.name === 'from') {
2780
3616
  var color = color$1.parse(context, firstToken.values[0]);
2781
3617
  stops.push({ stop: ZERO_LENGTH, color: color });
@@ -2791,7 +3627,7 @@ var webkitGradient = function (context, tokens) {
2791
3627
  var stop_1 = values[0];
2792
3628
  if (isNumberToken(stop_1)) {
2793
3629
  stops.push({
2794
- 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 },
2795
3631
  color: color
2796
3632
  });
2797
3633
  }
@@ -2799,7 +3635,7 @@ var webkitGradient = function (context, tokens) {
2799
3635
  }
2800
3636
  }
2801
3637
  });
2802
- return type === 1 /* LINEAR_GRADIENT */
3638
+ return type === 1 /* CSSImageType.LINEAR_GRADIENT */
2803
3639
  ? {
2804
3640
  angle: (angle + deg(180)) % deg(360),
2805
3641
  stops: stops,
@@ -2817,8 +3653,8 @@ var ELLIPSE = 'ellipse';
2817
3653
  var COVER = 'cover';
2818
3654
  var CONTAIN = 'contain';
2819
3655
  var radialGradient = function (context, tokens) {
2820
- var shape = 0 /* CIRCLE */;
2821
- var size = 3 /* FARTHEST_CORNER */;
3656
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3657
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2822
3658
  var stops = [];
2823
3659
  var position = [];
2824
3660
  parseFunctionArgs(tokens).forEach(function (arg, i) {
@@ -2849,27 +3685,27 @@ var radialGradient = function (context, tokens) {
2849
3685
  else if (isIdentToken(token)) {
2850
3686
  switch (token.value) {
2851
3687
  case CIRCLE:
2852
- shape = 0 /* CIRCLE */;
3688
+ shape = 0 /* CSSRadialShape.CIRCLE */;
2853
3689
  return false;
2854
3690
  case ELLIPSE:
2855
- shape = 1 /* ELLIPSE */;
3691
+ shape = 1 /* CSSRadialShape.ELLIPSE */;
2856
3692
  return false;
2857
3693
  case 'at':
2858
3694
  isAtPosition_1 = true;
2859
3695
  return false;
2860
3696
  case CLOSEST_SIDE:
2861
- size = 0 /* CLOSEST_SIDE */;
3697
+ size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
2862
3698
  return false;
2863
3699
  case COVER:
2864
3700
  case FARTHEST_SIDE:
2865
- size = 1 /* FARTHEST_SIDE */;
3701
+ size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
2866
3702
  return false;
2867
3703
  case CONTAIN:
2868
3704
  case CLOSEST_CORNER:
2869
- size = 2 /* CLOSEST_CORNER */;
3705
+ size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
2870
3706
  return false;
2871
3707
  case FARTHEST_CORNER:
2872
- size = 3 /* FARTHEST_CORNER */;
3708
+ size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2873
3709
  return false;
2874
3710
  }
2875
3711
  }
@@ -2888,12 +3724,12 @@ var radialGradient = function (context, tokens) {
2888
3724
  stops.push(colorStop);
2889
3725
  }
2890
3726
  });
2891
- 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 */ };
2892
3728
  };
2893
3729
 
2894
3730
  var prefixRadialGradient = function (context, tokens) {
2895
- var shape = 0 /* CIRCLE */;
2896
- var size = 3 /* FARTHEST_CORNER */;
3731
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3732
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2897
3733
  var stops = [];
2898
3734
  var position = [];
2899
3735
  parseFunctionArgs(tokens).forEach(function (arg, i) {
@@ -2927,24 +3763,24 @@ var prefixRadialGradient = function (context, tokens) {
2927
3763
  if (isIdentToken(token)) {
2928
3764
  switch (token.value) {
2929
3765
  case CIRCLE:
2930
- shape = 0 /* CIRCLE */;
3766
+ shape = 0 /* CSSRadialShape.CIRCLE */;
2931
3767
  return false;
2932
3768
  case ELLIPSE:
2933
- shape = 1 /* ELLIPSE */;
3769
+ shape = 1 /* CSSRadialShape.ELLIPSE */;
2934
3770
  return false;
2935
3771
  case CONTAIN:
2936
3772
  case CLOSEST_SIDE:
2937
- size = 0 /* CLOSEST_SIDE */;
3773
+ size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
2938
3774
  return false;
2939
3775
  case FARTHEST_SIDE:
2940
- size = 1 /* FARTHEST_SIDE */;
3776
+ size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
2941
3777
  return false;
2942
3778
  case CLOSEST_CORNER:
2943
- size = 2 /* CLOSEST_CORNER */;
3779
+ size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
2944
3780
  return false;
2945
3781
  case COVER:
2946
3782
  case FARTHEST_CORNER:
2947
- size = 3 /* FARTHEST_CORNER */;
3783
+ size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2948
3784
  return false;
2949
3785
  }
2950
3786
  }
@@ -2963,36 +3799,36 @@ var prefixRadialGradient = function (context, tokens) {
2963
3799
  stops.push(colorStop);
2964
3800
  }
2965
3801
  });
2966
- 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 */ };
2967
3803
  };
2968
3804
 
2969
3805
  var isLinearGradient = function (background) {
2970
- return background.type === 1 /* LINEAR_GRADIENT */;
3806
+ return background.type === 1 /* CSSImageType.LINEAR_GRADIENT */;
2971
3807
  };
2972
3808
  var isRadialGradient = function (background) {
2973
- return background.type === 2 /* RADIAL_GRADIENT */;
3809
+ return background.type === 2 /* CSSImageType.RADIAL_GRADIENT */;
2974
3810
  };
2975
3811
  var image = {
2976
3812
  name: 'image',
2977
3813
  parse: function (context, value) {
2978
- if (value.type === 22 /* URL_TOKEN */) {
2979
- 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 */ };
2980
3816
  context.cache.addImage(value.value);
2981
3817
  return image_1;
2982
3818
  }
2983
- if (value.type === 18 /* FUNCTION */) {
3819
+ if (value.type === 18 /* TokenType.FUNCTION */) {
2984
3820
  var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];
2985
3821
  if (typeof imageFunction === 'undefined') {
2986
- 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, "\""));
2987
3823
  }
2988
3824
  return imageFunction(context, value.values);
2989
3825
  }
2990
- throw new Error("Unsupported image type " + value.type);
3826
+ throw new Error("Unsupported image type ".concat(value.type));
2991
3827
  }
2992
3828
  };
2993
3829
  function isSupportedImage(value) {
2994
- return (!(value.type === 20 /* IDENT_TOKEN */ && value.value === 'none') &&
2995
- (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]));
2996
3832
  }
2997
3833
  var SUPPORTED_IMAGE_FUNCTIONS = {
2998
3834
  'linear-gradient': linearGradient,
@@ -3011,14 +3847,14 @@ var SUPPORTED_IMAGE_FUNCTIONS = {
3011
3847
  var backgroundImage = {
3012
3848
  name: 'background-image',
3013
3849
  initialValue: 'none',
3014
- type: 1 /* LIST */,
3850
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3015
3851
  prefix: false,
3016
3852
  parse: function (context, tokens) {
3017
3853
  if (tokens.length === 0) {
3018
3854
  return [];
3019
3855
  }
3020
3856
  var first = tokens[0];
3021
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
3857
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3022
3858
  return [];
3023
3859
  }
3024
3860
  return tokens
@@ -3031,18 +3867,18 @@ var backgroundOrigin = {
3031
3867
  name: 'background-origin',
3032
3868
  initialValue: 'border-box',
3033
3869
  prefix: false,
3034
- type: 1 /* LIST */,
3870
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3035
3871
  parse: function (_context, tokens) {
3036
3872
  return tokens.map(function (token) {
3037
3873
  if (isIdentToken(token)) {
3038
3874
  switch (token.value) {
3039
3875
  case 'padding-box':
3040
- return 1 /* PADDING_BOX */;
3876
+ return 1 /* BACKGROUND_ORIGIN.PADDING_BOX */;
3041
3877
  case 'content-box':
3042
- return 2 /* CONTENT_BOX */;
3878
+ return 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */;
3043
3879
  }
3044
3880
  }
3045
- return 0 /* BORDER_BOX */;
3881
+ return 0 /* BACKGROUND_ORIGIN.BORDER_BOX */;
3046
3882
  });
3047
3883
  }
3048
3884
  };
@@ -3050,7 +3886,7 @@ var backgroundOrigin = {
3050
3886
  var backgroundPosition = {
3051
3887
  name: 'background-position',
3052
3888
  initialValue: '0% 0%',
3053
- type: 1 /* LIST */,
3889
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3054
3890
  prefix: false,
3055
3891
  parse: function (_context, tokens) {
3056
3892
  return parseFunctionArgs(tokens)
@@ -3063,7 +3899,7 @@ var backgroundRepeat = {
3063
3899
  name: 'background-repeat',
3064
3900
  initialValue: 'repeat',
3065
3901
  prefix: false,
3066
- type: 1 /* LIST */,
3902
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3067
3903
  parse: function (_context, tokens) {
3068
3904
  return parseFunctionArgs(tokens)
3069
3905
  .map(function (values) {
@@ -3078,16 +3914,16 @@ var backgroundRepeat = {
3078
3914
  var parseBackgroundRepeat = function (value) {
3079
3915
  switch (value) {
3080
3916
  case 'no-repeat':
3081
- return 1 /* NO_REPEAT */;
3917
+ return 1 /* BACKGROUND_REPEAT.NO_REPEAT */;
3082
3918
  case 'repeat-x':
3083
3919
  case 'repeat no-repeat':
3084
- return 2 /* REPEAT_X */;
3920
+ return 2 /* BACKGROUND_REPEAT.REPEAT_X */;
3085
3921
  case 'repeat-y':
3086
3922
  case 'no-repeat repeat':
3087
- return 3 /* REPEAT_Y */;
3923
+ return 3 /* BACKGROUND_REPEAT.REPEAT_Y */;
3088
3924
  case 'repeat':
3089
3925
  default:
3090
- return 0 /* REPEAT */;
3926
+ return 0 /* BACKGROUND_REPEAT.REPEAT */;
3091
3927
  }
3092
3928
  };
3093
3929
 
@@ -3101,7 +3937,7 @@ var backgroundSize = {
3101
3937
  name: 'background-size',
3102
3938
  initialValue: '0',
3103
3939
  prefix: false,
3104
- type: 1 /* LIST */,
3940
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3105
3941
  parse: function (_context, tokens) {
3106
3942
  return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });
3107
3943
  }
@@ -3111,10 +3947,10 @@ var isBackgroundSizeInfoToken = function (value) {
3111
3947
  };
3112
3948
 
3113
3949
  var borderColorForSide = function (side) { return ({
3114
- name: "border-" + side + "-color",
3950
+ name: "border-".concat(side, "-color"),
3115
3951
  initialValue: 'transparent',
3116
3952
  prefix: false,
3117
- type: 3 /* TYPE_VALUE */,
3953
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3118
3954
  format: 'color'
3119
3955
  }); };
3120
3956
  var borderTopColor = borderColorForSide('top');
@@ -3123,10 +3959,10 @@ var borderBottomColor = borderColorForSide('bottom');
3123
3959
  var borderLeftColor = borderColorForSide('left');
3124
3960
 
3125
3961
  var borderRadiusForSide = function (side) { return ({
3126
- name: "border-radius-" + side,
3962
+ name: "border-radius-".concat(side),
3127
3963
  initialValue: '0 0',
3128
3964
  prefix: false,
3129
- type: 1 /* LIST */,
3965
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3130
3966
  parse: function (_context, tokens) {
3131
3967
  return parseLengthPercentageTuple(tokens.filter(isLengthPercentage));
3132
3968
  }
@@ -3137,22 +3973,22 @@ var borderBottomRightRadius = borderRadiusForSide('bottom-right');
3137
3973
  var borderBottomLeftRadius = borderRadiusForSide('bottom-left');
3138
3974
 
3139
3975
  var borderStyleForSide = function (side) { return ({
3140
- name: "border-" + side + "-style",
3976
+ name: "border-".concat(side, "-style"),
3141
3977
  initialValue: 'solid',
3142
3978
  prefix: false,
3143
- type: 2 /* IDENT_VALUE */,
3979
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3144
3980
  parse: function (_context, style) {
3145
3981
  switch (style) {
3146
3982
  case 'none':
3147
- return 0 /* NONE */;
3983
+ return 0 /* BORDER_STYLE.NONE */;
3148
3984
  case 'dashed':
3149
- return 2 /* DASHED */;
3985
+ return 2 /* BORDER_STYLE.DASHED */;
3150
3986
  case 'dotted':
3151
- return 3 /* DOTTED */;
3987
+ return 3 /* BORDER_STYLE.DOTTED */;
3152
3988
  case 'double':
3153
- return 4 /* DOUBLE */;
3989
+ return 4 /* BORDER_STYLE.DOUBLE */;
3154
3990
  }
3155
- return 1 /* SOLID */;
3991
+ return 1 /* BORDER_STYLE.SOLID */;
3156
3992
  }
3157
3993
  }); };
3158
3994
  var borderTopStyle = borderStyleForSide('top');
@@ -3161,9 +3997,9 @@ var borderBottomStyle = borderStyleForSide('bottom');
3161
3997
  var borderLeftStyle = borderStyleForSide('left');
3162
3998
 
3163
3999
  var borderWidthForSide = function (side) { return ({
3164
- name: "border-" + side + "-width",
4000
+ name: "border-".concat(side, "-width"),
3165
4001
  initialValue: '0',
3166
- type: 0 /* VALUE */,
4002
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3167
4003
  prefix: false,
3168
4004
  parse: function (_context, token) {
3169
4005
  if (isDimensionToken(token)) {
@@ -3181,7 +4017,7 @@ var color = {
3181
4017
  name: "color",
3182
4018
  initialValue: 'transparent',
3183
4019
  prefix: false,
3184
- type: 3 /* TYPE_VALUE */,
4020
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3185
4021
  format: 'color'
3186
4022
  };
3187
4023
 
@@ -3189,14 +4025,14 @@ var direction = {
3189
4025
  name: 'direction',
3190
4026
  initialValue: 'ltr',
3191
4027
  prefix: false,
3192
- type: 2 /* IDENT_VALUE */,
4028
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3193
4029
  parse: function (_context, direction) {
3194
4030
  switch (direction) {
3195
4031
  case 'rtl':
3196
- return 1 /* RTL */;
4032
+ return 1 /* DIRECTION.RTL */;
3197
4033
  case 'ltr':
3198
4034
  default:
3199
- return 0 /* LTR */;
4035
+ return 0 /* DIRECTION.LTR */;
3200
4036
  }
3201
4037
  }
3202
4038
  };
@@ -3205,97 +4041,97 @@ var display = {
3205
4041
  name: 'display',
3206
4042
  initialValue: 'inline-block',
3207
4043
  prefix: false,
3208
- type: 1 /* LIST */,
4044
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3209
4045
  parse: function (_context, tokens) {
3210
4046
  return tokens.filter(isIdentToken).reduce(function (bit, token) {
3211
- return bit | parseDisplayValue(token.value);
3212
- }, 0 /* NONE */);
4047
+ return bit | parseDisplayValue$1(token.value);
4048
+ }, 0 /* DISPLAY.NONE */);
3213
4049
  }
3214
4050
  };
3215
- var parseDisplayValue = function (display) {
4051
+ var parseDisplayValue$1 = function (display) {
3216
4052
  switch (display) {
3217
4053
  case 'block':
3218
4054
  case '-webkit-box':
3219
- return 2 /* BLOCK */;
4055
+ return 2 /* DISPLAY.BLOCK */;
3220
4056
  case 'inline':
3221
- return 4 /* INLINE */;
4057
+ return 4 /* DISPLAY.INLINE */;
3222
4058
  case 'run-in':
3223
- return 8 /* RUN_IN */;
4059
+ return 8 /* DISPLAY.RUN_IN */;
3224
4060
  case 'flow':
3225
- return 16 /* FLOW */;
4061
+ return 16 /* DISPLAY.FLOW */;
3226
4062
  case 'flow-root':
3227
- return 32 /* FLOW_ROOT */;
4063
+ return 32 /* DISPLAY.FLOW_ROOT */;
3228
4064
  case 'table':
3229
- return 64 /* TABLE */;
4065
+ return 64 /* DISPLAY.TABLE */;
3230
4066
  case 'flex':
3231
4067
  case '-webkit-flex':
3232
- return 128 /* FLEX */;
4068
+ return 128 /* DISPLAY.FLEX */;
3233
4069
  case 'grid':
3234
4070
  case '-ms-grid':
3235
- return 256 /* GRID */;
4071
+ return 256 /* DISPLAY.GRID */;
3236
4072
  case 'ruby':
3237
- return 512 /* RUBY */;
4073
+ return 512 /* DISPLAY.RUBY */;
3238
4074
  case 'subgrid':
3239
- return 1024 /* SUBGRID */;
4075
+ return 1024 /* DISPLAY.SUBGRID */;
3240
4076
  case 'list-item':
3241
- return 2048 /* LIST_ITEM */;
4077
+ return 2048 /* DISPLAY.LIST_ITEM */;
3242
4078
  case 'table-row-group':
3243
- return 4096 /* TABLE_ROW_GROUP */;
4079
+ return 4096 /* DISPLAY.TABLE_ROW_GROUP */;
3244
4080
  case 'table-header-group':
3245
- return 8192 /* TABLE_HEADER_GROUP */;
4081
+ return 8192 /* DISPLAY.TABLE_HEADER_GROUP */;
3246
4082
  case 'table-footer-group':
3247
- return 16384 /* TABLE_FOOTER_GROUP */;
4083
+ return 16384 /* DISPLAY.TABLE_FOOTER_GROUP */;
3248
4084
  case 'table-row':
3249
- return 32768 /* TABLE_ROW */;
4085
+ return 32768 /* DISPLAY.TABLE_ROW */;
3250
4086
  case 'table-cell':
3251
- return 65536 /* TABLE_CELL */;
4087
+ return 65536 /* DISPLAY.TABLE_CELL */;
3252
4088
  case 'table-column-group':
3253
- return 131072 /* TABLE_COLUMN_GROUP */;
4089
+ return 131072 /* DISPLAY.TABLE_COLUMN_GROUP */;
3254
4090
  case 'table-column':
3255
- return 262144 /* TABLE_COLUMN */;
4091
+ return 262144 /* DISPLAY.TABLE_COLUMN */;
3256
4092
  case 'table-caption':
3257
- return 524288 /* TABLE_CAPTION */;
4093
+ return 524288 /* DISPLAY.TABLE_CAPTION */;
3258
4094
  case 'ruby-base':
3259
- return 1048576 /* RUBY_BASE */;
4095
+ return 1048576 /* DISPLAY.RUBY_BASE */;
3260
4096
  case 'ruby-text':
3261
- return 2097152 /* RUBY_TEXT */;
4097
+ return 2097152 /* DISPLAY.RUBY_TEXT */;
3262
4098
  case 'ruby-base-container':
3263
- return 4194304 /* RUBY_BASE_CONTAINER */;
4099
+ return 4194304 /* DISPLAY.RUBY_BASE_CONTAINER */;
3264
4100
  case 'ruby-text-container':
3265
- return 8388608 /* RUBY_TEXT_CONTAINER */;
4101
+ return 8388608 /* DISPLAY.RUBY_TEXT_CONTAINER */;
3266
4102
  case 'contents':
3267
- return 16777216 /* CONTENTS */;
4103
+ return 16777216 /* DISPLAY.CONTENTS */;
3268
4104
  case 'inline-block':
3269
- return 33554432 /* INLINE_BLOCK */;
4105
+ return 33554432 /* DISPLAY.INLINE_BLOCK */;
3270
4106
  case 'inline-list-item':
3271
- return 67108864 /* INLINE_LIST_ITEM */;
4107
+ return 67108864 /* DISPLAY.INLINE_LIST_ITEM */;
3272
4108
  case 'inline-table':
3273
- return 134217728 /* INLINE_TABLE */;
4109
+ return 134217728 /* DISPLAY.INLINE_TABLE */;
3274
4110
  case 'inline-flex':
3275
- return 268435456 /* INLINE_FLEX */;
4111
+ return 268435456 /* DISPLAY.INLINE_FLEX */;
3276
4112
  case 'inline-grid':
3277
- return 536870912 /* INLINE_GRID */;
4113
+ return 536870912 /* DISPLAY.INLINE_GRID */;
3278
4114
  }
3279
- return 0 /* NONE */;
4115
+ return 0 /* DISPLAY.NONE */;
3280
4116
  };
3281
4117
 
3282
4118
  var float = {
3283
4119
  name: 'float',
3284
4120
  initialValue: 'none',
3285
4121
  prefix: false,
3286
- type: 2 /* IDENT_VALUE */,
4122
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3287
4123
  parse: function (_context, float) {
3288
4124
  switch (float) {
3289
4125
  case 'left':
3290
- return 1 /* LEFT */;
4126
+ return 1 /* FLOAT.LEFT */;
3291
4127
  case 'right':
3292
- return 2 /* RIGHT */;
4128
+ return 2 /* FLOAT.RIGHT */;
3293
4129
  case 'inline-start':
3294
- return 3 /* INLINE_START */;
4130
+ return 3 /* FLOAT.INLINE_START */;
3295
4131
  case 'inline-end':
3296
- return 4 /* INLINE_END */;
4132
+ return 4 /* FLOAT.INLINE_END */;
3297
4133
  }
3298
- return 0 /* NONE */;
4134
+ return 0 /* FLOAT.NONE */;
3299
4135
  }
3300
4136
  };
3301
4137
 
@@ -3303,15 +4139,15 @@ var letterSpacing = {
3303
4139
  name: 'letter-spacing',
3304
4140
  initialValue: '0',
3305
4141
  prefix: false,
3306
- type: 0 /* VALUE */,
4142
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3307
4143
  parse: function (_context, token) {
3308
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'normal') {
4144
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'normal') {
3309
4145
  return 0;
3310
4146
  }
3311
- if (token.type === 17 /* NUMBER_TOKEN */) {
4147
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
3312
4148
  return token.number;
3313
4149
  }
3314
- if (token.type === 15 /* DIMENSION_TOKEN */) {
4150
+ if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
3315
4151
  return token.number;
3316
4152
  }
3317
4153
  return 0;
@@ -3327,7 +4163,7 @@ var lineBreak = {
3327
4163
  name: 'line-break',
3328
4164
  initialValue: 'normal',
3329
4165
  prefix: false,
3330
- type: 2 /* IDENT_VALUE */,
4166
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3331
4167
  parse: function (_context, lineBreak) {
3332
4168
  switch (lineBreak) {
3333
4169
  case 'strict':
@@ -3343,13 +4179,13 @@ var lineHeight = {
3343
4179
  name: 'line-height',
3344
4180
  initialValue: 'normal',
3345
4181
  prefix: false,
3346
- type: 4 /* TOKEN_VALUE */
4182
+ type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
3347
4183
  };
3348
4184
  var computeLineHeight = function (token, fontSize) {
3349
4185
  if (isIdentToken(token) && token.value === 'normal') {
3350
4186
  return 1.2 * fontSize;
3351
4187
  }
3352
- else if (token.type === 17 /* NUMBER_TOKEN */) {
4188
+ else if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
3353
4189
  return fontSize * token.number;
3354
4190
  }
3355
4191
  else if (isLengthPercentage(token)) {
@@ -3361,10 +4197,10 @@ var computeLineHeight = function (token, fontSize) {
3361
4197
  var listStyleImage = {
3362
4198
  name: 'list-style-image',
3363
4199
  initialValue: 'none',
3364
- type: 0 /* VALUE */,
4200
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3365
4201
  prefix: false,
3366
4202
  parse: function (context, token) {
3367
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
4203
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
3368
4204
  return null;
3369
4205
  }
3370
4206
  return image.parse(context, token);
@@ -3375,14 +4211,14 @@ var listStylePosition = {
3375
4211
  name: 'list-style-position',
3376
4212
  initialValue: 'outside',
3377
4213
  prefix: false,
3378
- type: 2 /* IDENT_VALUE */,
4214
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3379
4215
  parse: function (_context, position) {
3380
4216
  switch (position) {
3381
4217
  case 'inside':
3382
- return 0 /* INSIDE */;
4218
+ return 0 /* LIST_STYLE_POSITION.INSIDE */;
3383
4219
  case 'outside':
3384
4220
  default:
3385
- return 1 /* OUTSIDE */;
4221
+ return 1 /* LIST_STYLE_POSITION.OUTSIDE */;
3386
4222
  }
3387
4223
  }
3388
4224
  };
@@ -3391,127 +4227,127 @@ var listStyleType = {
3391
4227
  name: 'list-style-type',
3392
4228
  initialValue: 'none',
3393
4229
  prefix: false,
3394
- type: 2 /* IDENT_VALUE */,
4230
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3395
4231
  parse: function (_context, type) {
3396
4232
  switch (type) {
3397
4233
  case 'disc':
3398
- return 0 /* DISC */;
4234
+ return 0 /* LIST_STYLE_TYPE.DISC */;
3399
4235
  case 'circle':
3400
- return 1 /* CIRCLE */;
4236
+ return 1 /* LIST_STYLE_TYPE.CIRCLE */;
3401
4237
  case 'square':
3402
- return 2 /* SQUARE */;
4238
+ return 2 /* LIST_STYLE_TYPE.SQUARE */;
3403
4239
  case 'decimal':
3404
- return 3 /* DECIMAL */;
4240
+ return 3 /* LIST_STYLE_TYPE.DECIMAL */;
3405
4241
  case 'cjk-decimal':
3406
- return 4 /* CJK_DECIMAL */;
4242
+ return 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */;
3407
4243
  case 'decimal-leading-zero':
3408
- return 5 /* DECIMAL_LEADING_ZERO */;
4244
+ return 5 /* LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO */;
3409
4245
  case 'lower-roman':
3410
- return 6 /* LOWER_ROMAN */;
4246
+ return 6 /* LIST_STYLE_TYPE.LOWER_ROMAN */;
3411
4247
  case 'upper-roman':
3412
- return 7 /* UPPER_ROMAN */;
4248
+ return 7 /* LIST_STYLE_TYPE.UPPER_ROMAN */;
3413
4249
  case 'lower-greek':
3414
- return 8 /* LOWER_GREEK */;
4250
+ return 8 /* LIST_STYLE_TYPE.LOWER_GREEK */;
3415
4251
  case 'lower-alpha':
3416
- return 9 /* LOWER_ALPHA */;
4252
+ return 9 /* LIST_STYLE_TYPE.LOWER_ALPHA */;
3417
4253
  case 'upper-alpha':
3418
- return 10 /* UPPER_ALPHA */;
4254
+ return 10 /* LIST_STYLE_TYPE.UPPER_ALPHA */;
3419
4255
  case 'arabic-indic':
3420
- return 11 /* ARABIC_INDIC */;
4256
+ return 11 /* LIST_STYLE_TYPE.ARABIC_INDIC */;
3421
4257
  case 'armenian':
3422
- return 12 /* ARMENIAN */;
4258
+ return 12 /* LIST_STYLE_TYPE.ARMENIAN */;
3423
4259
  case 'bengali':
3424
- return 13 /* BENGALI */;
4260
+ return 13 /* LIST_STYLE_TYPE.BENGALI */;
3425
4261
  case 'cambodian':
3426
- return 14 /* CAMBODIAN */;
4262
+ return 14 /* LIST_STYLE_TYPE.CAMBODIAN */;
3427
4263
  case 'cjk-earthly-branch':
3428
- return 15 /* CJK_EARTHLY_BRANCH */;
4264
+ return 15 /* LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH */;
3429
4265
  case 'cjk-heavenly-stem':
3430
- return 16 /* CJK_HEAVENLY_STEM */;
4266
+ return 16 /* LIST_STYLE_TYPE.CJK_HEAVENLY_STEM */;
3431
4267
  case 'cjk-ideographic':
3432
- return 17 /* CJK_IDEOGRAPHIC */;
4268
+ return 17 /* LIST_STYLE_TYPE.CJK_IDEOGRAPHIC */;
3433
4269
  case 'devanagari':
3434
- return 18 /* DEVANAGARI */;
4270
+ return 18 /* LIST_STYLE_TYPE.DEVANAGARI */;
3435
4271
  case 'ethiopic-numeric':
3436
- return 19 /* ETHIOPIC_NUMERIC */;
4272
+ return 19 /* LIST_STYLE_TYPE.ETHIOPIC_NUMERIC */;
3437
4273
  case 'georgian':
3438
- return 20 /* GEORGIAN */;
4274
+ return 20 /* LIST_STYLE_TYPE.GEORGIAN */;
3439
4275
  case 'gujarati':
3440
- return 21 /* GUJARATI */;
4276
+ return 21 /* LIST_STYLE_TYPE.GUJARATI */;
3441
4277
  case 'gurmukhi':
3442
- return 22 /* GURMUKHI */;
4278
+ return 22 /* LIST_STYLE_TYPE.GURMUKHI */;
3443
4279
  case 'hebrew':
3444
- return 22 /* HEBREW */;
4280
+ return 52 /* LIST_STYLE_TYPE.HEBREW */;
3445
4281
  case 'hiragana':
3446
- return 23 /* HIRAGANA */;
4282
+ return 23 /* LIST_STYLE_TYPE.HIRAGANA */;
3447
4283
  case 'hiragana-iroha':
3448
- return 24 /* HIRAGANA_IROHA */;
4284
+ return 24 /* LIST_STYLE_TYPE.HIRAGANA_IROHA */;
3449
4285
  case 'japanese-formal':
3450
- return 25 /* JAPANESE_FORMAL */;
4286
+ return 25 /* LIST_STYLE_TYPE.JAPANESE_FORMAL */;
3451
4287
  case 'japanese-informal':
3452
- return 26 /* JAPANESE_INFORMAL */;
4288
+ return 26 /* LIST_STYLE_TYPE.JAPANESE_INFORMAL */;
3453
4289
  case 'kannada':
3454
- return 27 /* KANNADA */;
4290
+ return 27 /* LIST_STYLE_TYPE.KANNADA */;
3455
4291
  case 'katakana':
3456
- return 28 /* KATAKANA */;
4292
+ return 28 /* LIST_STYLE_TYPE.KATAKANA */;
3457
4293
  case 'katakana-iroha':
3458
- return 29 /* KATAKANA_IROHA */;
4294
+ return 29 /* LIST_STYLE_TYPE.KATAKANA_IROHA */;
3459
4295
  case 'khmer':
3460
- return 30 /* KHMER */;
4296
+ return 30 /* LIST_STYLE_TYPE.KHMER */;
3461
4297
  case 'korean-hangul-formal':
3462
- return 31 /* KOREAN_HANGUL_FORMAL */;
4298
+ return 31 /* LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL */;
3463
4299
  case 'korean-hanja-formal':
3464
- return 32 /* KOREAN_HANJA_FORMAL */;
4300
+ return 32 /* LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL */;
3465
4301
  case 'korean-hanja-informal':
3466
- return 33 /* KOREAN_HANJA_INFORMAL */;
4302
+ return 33 /* LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL */;
3467
4303
  case 'lao':
3468
- return 34 /* LAO */;
4304
+ return 34 /* LIST_STYLE_TYPE.LAO */;
3469
4305
  case 'lower-armenian':
3470
- return 35 /* LOWER_ARMENIAN */;
4306
+ return 35 /* LIST_STYLE_TYPE.LOWER_ARMENIAN */;
3471
4307
  case 'malayalam':
3472
- return 36 /* MALAYALAM */;
4308
+ return 36 /* LIST_STYLE_TYPE.MALAYALAM */;
3473
4309
  case 'mongolian':
3474
- return 37 /* MONGOLIAN */;
4310
+ return 37 /* LIST_STYLE_TYPE.MONGOLIAN */;
3475
4311
  case 'myanmar':
3476
- return 38 /* MYANMAR */;
4312
+ return 38 /* LIST_STYLE_TYPE.MYANMAR */;
3477
4313
  case 'oriya':
3478
- return 39 /* ORIYA */;
4314
+ return 39 /* LIST_STYLE_TYPE.ORIYA */;
3479
4315
  case 'persian':
3480
- return 40 /* PERSIAN */;
4316
+ return 40 /* LIST_STYLE_TYPE.PERSIAN */;
3481
4317
  case 'simp-chinese-formal':
3482
- return 41 /* SIMP_CHINESE_FORMAL */;
4318
+ return 41 /* LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL */;
3483
4319
  case 'simp-chinese-informal':
3484
- return 42 /* SIMP_CHINESE_INFORMAL */;
4320
+ return 42 /* LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL */;
3485
4321
  case 'tamil':
3486
- return 43 /* TAMIL */;
4322
+ return 43 /* LIST_STYLE_TYPE.TAMIL */;
3487
4323
  case 'telugu':
3488
- return 44 /* TELUGU */;
4324
+ return 44 /* LIST_STYLE_TYPE.TELUGU */;
3489
4325
  case 'thai':
3490
- return 45 /* THAI */;
4326
+ return 45 /* LIST_STYLE_TYPE.THAI */;
3491
4327
  case 'tibetan':
3492
- return 46 /* TIBETAN */;
4328
+ return 46 /* LIST_STYLE_TYPE.TIBETAN */;
3493
4329
  case 'trad-chinese-formal':
3494
- return 47 /* TRAD_CHINESE_FORMAL */;
4330
+ return 47 /* LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL */;
3495
4331
  case 'trad-chinese-informal':
3496
- return 48 /* TRAD_CHINESE_INFORMAL */;
4332
+ return 48 /* LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL */;
3497
4333
  case 'upper-armenian':
3498
- return 49 /* UPPER_ARMENIAN */;
4334
+ return 49 /* LIST_STYLE_TYPE.UPPER_ARMENIAN */;
3499
4335
  case 'disclosure-open':
3500
- return 50 /* DISCLOSURE_OPEN */;
4336
+ return 50 /* LIST_STYLE_TYPE.DISCLOSURE_OPEN */;
3501
4337
  case 'disclosure-closed':
3502
- return 51 /* DISCLOSURE_CLOSED */;
4338
+ return 51 /* LIST_STYLE_TYPE.DISCLOSURE_CLOSED */;
3503
4339
  case 'none':
3504
4340
  default:
3505
- return -1 /* NONE */;
4341
+ return -1 /* LIST_STYLE_TYPE.NONE */;
3506
4342
  }
3507
4343
  }
3508
4344
  };
3509
4345
 
3510
4346
  var marginForSide = function (side) { return ({
3511
- name: "margin-" + side,
4347
+ name: "margin-".concat(side),
3512
4348
  initialValue: '0',
3513
4349
  prefix: false,
3514
- type: 4 /* TOKEN_VALUE */
4350
+ type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
3515
4351
  }); };
3516
4352
  var marginTop = marginForSide('top');
3517
4353
  var marginRight = marginForSide('right');
@@ -3522,21 +4358,21 @@ var overflow = {
3522
4358
  name: 'overflow',
3523
4359
  initialValue: 'visible',
3524
4360
  prefix: false,
3525
- type: 1 /* LIST */,
4361
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3526
4362
  parse: function (_context, tokens) {
3527
4363
  return tokens.filter(isIdentToken).map(function (overflow) {
3528
4364
  switch (overflow.value) {
3529
4365
  case 'hidden':
3530
- return 1 /* HIDDEN */;
4366
+ return 1 /* OVERFLOW.HIDDEN */;
3531
4367
  case 'scroll':
3532
- return 2 /* SCROLL */;
4368
+ return 2 /* OVERFLOW.SCROLL */;
3533
4369
  case 'clip':
3534
- return 3 /* CLIP */;
4370
+ return 3 /* OVERFLOW.CLIP */;
3535
4371
  case 'auto':
3536
- return 4 /* AUTO */;
4372
+ return 4 /* OVERFLOW.AUTO */;
3537
4373
  case 'visible':
3538
4374
  default:
3539
- return 0 /* VISIBLE */;
4375
+ return 0 /* OVERFLOW.VISIBLE */;
3540
4376
  }
3541
4377
  });
3542
4378
  }
@@ -3546,23 +4382,23 @@ var overflowWrap = {
3546
4382
  name: 'overflow-wrap',
3547
4383
  initialValue: 'normal',
3548
4384
  prefix: false,
3549
- type: 2 /* IDENT_VALUE */,
4385
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3550
4386
  parse: function (_context, overflow) {
3551
4387
  switch (overflow) {
3552
4388
  case 'break-word':
3553
- return "break-word" /* BREAK_WORD */;
4389
+ return "break-word" /* OVERFLOW_WRAP.BREAK_WORD */;
3554
4390
  case 'normal':
3555
4391
  default:
3556
- return "normal" /* NORMAL */;
4392
+ return "normal" /* OVERFLOW_WRAP.NORMAL */;
3557
4393
  }
3558
4394
  }
3559
4395
  };
3560
4396
 
3561
4397
  var paddingForSide = function (side) { return ({
3562
- name: "padding-" + side,
4398
+ name: "padding-".concat(side),
3563
4399
  initialValue: '0',
3564
4400
  prefix: false,
3565
- type: 3 /* TYPE_VALUE */,
4401
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3566
4402
  format: 'length-percentage'
3567
4403
  }); };
3568
4404
  var paddingTop = paddingForSide('top');
@@ -3574,17 +4410,17 @@ var textAlign = {
3574
4410
  name: 'text-align',
3575
4411
  initialValue: 'left',
3576
4412
  prefix: false,
3577
- type: 2 /* IDENT_VALUE */,
4413
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3578
4414
  parse: function (_context, textAlign) {
3579
4415
  switch (textAlign) {
3580
4416
  case 'right':
3581
- return 2 /* RIGHT */;
4417
+ return 2 /* TEXT_ALIGN.RIGHT */;
3582
4418
  case 'center':
3583
4419
  case 'justify':
3584
- return 1 /* CENTER */;
4420
+ return 1 /* TEXT_ALIGN.CENTER */;
3585
4421
  case 'left':
3586
4422
  default:
3587
- return 0 /* LEFT */;
4423
+ return 0 /* TEXT_ALIGN.LEFT */;
3588
4424
  }
3589
4425
  }
3590
4426
  };
@@ -3593,26 +4429,26 @@ var position = {
3593
4429
  name: 'position',
3594
4430
  initialValue: 'static',
3595
4431
  prefix: false,
3596
- type: 2 /* IDENT_VALUE */,
4432
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3597
4433
  parse: function (_context, position) {
3598
4434
  switch (position) {
3599
4435
  case 'relative':
3600
- return 1 /* RELATIVE */;
4436
+ return 1 /* POSITION.RELATIVE */;
3601
4437
  case 'absolute':
3602
- return 2 /* ABSOLUTE */;
4438
+ return 2 /* POSITION.ABSOLUTE */;
3603
4439
  case 'fixed':
3604
- return 3 /* FIXED */;
4440
+ return 3 /* POSITION.FIXED */;
3605
4441
  case 'sticky':
3606
- return 4 /* STICKY */;
4442
+ return 4 /* POSITION.STICKY */;
3607
4443
  }
3608
- return 0 /* STATIC */;
4444
+ return 0 /* POSITION.STATIC */;
3609
4445
  }
3610
4446
  };
3611
4447
 
3612
4448
  var textShadow = {
3613
4449
  name: 'text-shadow',
3614
4450
  initialValue: 'none',
3615
- type: 1 /* LIST */,
4451
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3616
4452
  prefix: false,
3617
4453
  parse: function (context, tokens) {
3618
4454
  if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
@@ -3653,17 +4489,17 @@ var textTransform = {
3653
4489
  name: 'text-transform',
3654
4490
  initialValue: 'none',
3655
4491
  prefix: false,
3656
- type: 2 /* IDENT_VALUE */,
4492
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3657
4493
  parse: function (_context, textTransform) {
3658
4494
  switch (textTransform) {
3659
4495
  case 'uppercase':
3660
- return 2 /* UPPERCASE */;
4496
+ return 2 /* TEXT_TRANSFORM.UPPERCASE */;
3661
4497
  case 'lowercase':
3662
- return 1 /* LOWERCASE */;
4498
+ return 1 /* TEXT_TRANSFORM.LOWERCASE */;
3663
4499
  case 'capitalize':
3664
- return 3 /* CAPITALIZE */;
4500
+ return 3 /* TEXT_TRANSFORM.CAPITALIZE */;
3665
4501
  }
3666
- return 0 /* NONE */;
4502
+ return 0 /* TEXT_TRANSFORM.NONE */;
3667
4503
  }
3668
4504
  };
3669
4505
 
@@ -3671,38 +4507,58 @@ var transform$1 = {
3671
4507
  name: 'transform',
3672
4508
  initialValue: 'none',
3673
4509
  prefix: true,
3674
- type: 0 /* VALUE */,
4510
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3675
4511
  parse: function (_context, token) {
3676
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
4512
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
3677
4513
  return null;
3678
4514
  }
3679
- if (token.type === 18 /* FUNCTION */) {
4515
+ if (token.type === 18 /* TokenType.FUNCTION */) {
3680
4516
  var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
3681
4517
  if (typeof transformFunction === 'undefined') {
3682
- 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, "\""));
3683
4519
  }
3684
- return transformFunction(token.values);
4520
+ return transformFunction(_context, token.values);
3685
4521
  }
3686
4522
  return null;
3687
4523
  }
3688
4524
  };
3689
- var matrix = function (args) {
3690
- 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; });
3691
4527
  return values.length === 6 ? values : null;
3692
4528
  };
3693
4529
  // doesn't support 3D transforms at the moment
3694
- var matrix3d = function (args) {
3695
- 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; });
3696
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];
3697
4533
  return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
3698
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
+ };
3699
4554
  var SUPPORTED_TRANSFORM_FUNCTIONS = {
3700
4555
  matrix: matrix,
3701
- matrix3d: matrix3d
4556
+ matrix3d: matrix3d,
4557
+ rotate: rotate$1
3702
4558
  };
3703
4559
 
3704
4560
  var DEFAULT_VALUE = {
3705
- type: 16 /* PERCENTAGE_TOKEN */,
4561
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
3706
4562
  number: 50,
3707
4563
  flags: FLAG_INTEGER
3708
4564
  };
@@ -3711,7 +4567,7 @@ var transformOrigin = {
3711
4567
  name: 'transform-origin',
3712
4568
  initialValue: '50% 50%',
3713
4569
  prefix: true,
3714
- type: 1 /* LIST */,
4570
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3715
4571
  parse: function (_context, tokens) {
3716
4572
  var origins = tokens.filter(isLengthPercentage);
3717
4573
  if (origins.length !== 2) {
@@ -3721,20 +4577,44 @@ var transformOrigin = {
3721
4577
  }
3722
4578
  };
3723
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
+
3724
4604
  var visibility = {
3725
4605
  name: 'visible',
3726
4606
  initialValue: 'none',
3727
4607
  prefix: false,
3728
- type: 2 /* IDENT_VALUE */,
4608
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3729
4609
  parse: function (_context, visibility) {
3730
4610
  switch (visibility) {
3731
4611
  case 'hidden':
3732
- return 1 /* HIDDEN */;
4612
+ return 1 /* VISIBILITY.HIDDEN */;
3733
4613
  case 'collapse':
3734
- return 2 /* COLLAPSE */;
4614
+ return 2 /* VISIBILITY.COLLAPSE */;
3735
4615
  case 'visible':
3736
4616
  default:
3737
- return 0 /* VISIBLE */;
4617
+ return 0 /* VISIBILITY.VISIBLE */;
3738
4618
  }
3739
4619
  }
3740
4620
  };
@@ -3749,7 +4629,7 @@ var wordBreak = {
3749
4629
  name: 'word-break',
3750
4630
  initialValue: 'normal',
3751
4631
  prefix: false,
3752
- type: 2 /* IDENT_VALUE */,
4632
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3753
4633
  parse: function (_context, wordBreak) {
3754
4634
  switch (wordBreak) {
3755
4635
  case 'break-all':
@@ -3767,9 +4647,9 @@ var zIndex = {
3767
4647
  name: 'z-index',
3768
4648
  initialValue: 'auto',
3769
4649
  prefix: false,
3770
- type: 0 /* VALUE */,
4650
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3771
4651
  parse: function (_context, token) {
3772
- if (token.type === 20 /* IDENT_TOKEN */) {
4652
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
3773
4653
  return { auto: true, order: 0 };
3774
4654
  }
3775
4655
  if (isNumberToken(token)) {
@@ -3782,7 +4662,7 @@ var zIndex = {
3782
4662
  var time = {
3783
4663
  name: 'time',
3784
4664
  parse: function (_context, value) {
3785
- if (value.type === 15 /* DIMENSION_TOKEN */) {
4665
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
3786
4666
  switch (value.unit.toLowerCase()) {
3787
4667
  case 's':
3788
4668
  return 1000 * value.number;
@@ -3797,7 +4677,7 @@ var time = {
3797
4677
  var opacity = {
3798
4678
  name: 'opacity',
3799
4679
  initialValue: '1',
3800
- type: 0 /* VALUE */,
4680
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3801
4681
  prefix: false,
3802
4682
  parse: function (_context, token) {
3803
4683
  if (isNumberToken(token)) {
@@ -3811,7 +4691,7 @@ var textDecorationColor = {
3811
4691
  name: "text-decoration-color",
3812
4692
  initialValue: 'transparent',
3813
4693
  prefix: false,
3814
- type: 3 /* TYPE_VALUE */,
4694
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3815
4695
  format: 'color'
3816
4696
  };
3817
4697
 
@@ -3819,24 +4699,24 @@ var textDecorationLine = {
3819
4699
  name: 'text-decoration-line',
3820
4700
  initialValue: 'none',
3821
4701
  prefix: false,
3822
- type: 1 /* LIST */,
4702
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3823
4703
  parse: function (_context, tokens) {
3824
4704
  return tokens
3825
4705
  .filter(isIdentToken)
3826
4706
  .map(function (token) {
3827
4707
  switch (token.value) {
3828
4708
  case 'underline':
3829
- return 1 /* UNDERLINE */;
4709
+ return 1 /* TEXT_DECORATION_LINE.UNDERLINE */;
3830
4710
  case 'overline':
3831
- return 2 /* OVERLINE */;
4711
+ return 2 /* TEXT_DECORATION_LINE.OVERLINE */;
3832
4712
  case 'line-through':
3833
- return 3 /* LINE_THROUGH */;
4713
+ return 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */;
3834
4714
  case 'none':
3835
- return 4 /* BLINK */;
4715
+ return 4 /* TEXT_DECORATION_LINE.BLINK */;
3836
4716
  }
3837
- return 0 /* NONE */;
4717
+ return 0 /* TEXT_DECORATION_LINE.NONE */;
3838
4718
  })
3839
- .filter(function (line) { return line !== 0 /* NONE */; });
4719
+ .filter(function (line) { return line !== 0 /* TEXT_DECORATION_LINE.NONE */; });
3840
4720
  }
3841
4721
  };
3842
4722
 
@@ -3844,20 +4724,20 @@ var fontFamily = {
3844
4724
  name: "font-family",
3845
4725
  initialValue: '',
3846
4726
  prefix: false,
3847
- type: 1 /* LIST */,
4727
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3848
4728
  parse: function (_context, tokens) {
3849
4729
  var accumulator = [];
3850
4730
  var results = [];
3851
4731
  tokens.forEach(function (token) {
3852
4732
  switch (token.type) {
3853
- case 20 /* IDENT_TOKEN */:
3854
- case 0 /* STRING_TOKEN */:
4733
+ case 20 /* TokenType.IDENT_TOKEN */:
4734
+ case 0 /* TokenType.STRING_TOKEN */:
3855
4735
  accumulator.push(token.value);
3856
4736
  break;
3857
- case 17 /* NUMBER_TOKEN */:
4737
+ case 17 /* TokenType.NUMBER_TOKEN */:
3858
4738
  accumulator.push(token.number.toString());
3859
4739
  break;
3860
- case 4 /* COMMA_TOKEN */:
4740
+ case 4 /* TokenType.COMMA_TOKEN */:
3861
4741
  results.push(accumulator.join(' '));
3862
4742
  accumulator.length = 0;
3863
4743
  break;
@@ -3866,7 +4746,7 @@ var fontFamily = {
3866
4746
  if (accumulator.length) {
3867
4747
  results.push(accumulator.join(' '));
3868
4748
  }
3869
- return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'" + result + "'"); });
4749
+ return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'".concat(result, "'")); });
3870
4750
  }
3871
4751
  };
3872
4752
 
@@ -3874,14 +4754,14 @@ var fontSize = {
3874
4754
  name: "font-size",
3875
4755
  initialValue: '0',
3876
4756
  prefix: false,
3877
- type: 3 /* TYPE_VALUE */,
4757
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3878
4758
  format: 'length'
3879
4759
  };
3880
4760
 
3881
4761
  var fontWeight = {
3882
4762
  name: 'font-weight',
3883
4763
  initialValue: 'normal',
3884
- type: 0 /* VALUE */,
4764
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3885
4765
  prefix: false,
3886
4766
  parse: function (_context, token) {
3887
4767
  if (isNumberToken(token)) {
@@ -3903,7 +4783,7 @@ var fontWeight = {
3903
4783
  var fontVariant = {
3904
4784
  name: 'font-variant',
3905
4785
  initialValue: 'none',
3906
- type: 1 /* LIST */,
4786
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3907
4787
  prefix: false,
3908
4788
  parse: function (_context, tokens) {
3909
4789
  return tokens.filter(isIdentToken).map(function (token) { return token.value; });
@@ -3914,16 +4794,16 @@ var fontStyle = {
3914
4794
  name: 'font-style',
3915
4795
  initialValue: 'normal',
3916
4796
  prefix: false,
3917
- type: 2 /* IDENT_VALUE */,
4797
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3918
4798
  parse: function (_context, overflow) {
3919
4799
  switch (overflow) {
3920
4800
  case 'oblique':
3921
- return "oblique" /* OBLIQUE */;
4801
+ return "oblique" /* FONT_STYLE.OBLIQUE */;
3922
4802
  case 'italic':
3923
- return "italic" /* ITALIC */;
4803
+ return "italic" /* FONT_STYLE.ITALIC */;
3924
4804
  case 'normal':
3925
4805
  default:
3926
- return "normal" /* NORMAL */;
4806
+ return "normal" /* FONT_STYLE.NORMAL */;
3927
4807
  }
3928
4808
  }
3929
4809
  };
@@ -3933,14 +4813,14 @@ var contains = function (bit, value) { return (bit & value) !== 0; };
3933
4813
  var content = {
3934
4814
  name: 'content',
3935
4815
  initialValue: 'none',
3936
- type: 1 /* LIST */,
4816
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3937
4817
  prefix: false,
3938
4818
  parse: function (_context, tokens) {
3939
4819
  if (tokens.length === 0) {
3940
4820
  return [];
3941
4821
  }
3942
4822
  var first = tokens[0];
3943
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4823
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3944
4824
  return [];
3945
4825
  }
3946
4826
  return tokens;
@@ -3951,13 +4831,13 @@ var counterIncrement = {
3951
4831
  name: 'counter-increment',
3952
4832
  initialValue: 'none',
3953
4833
  prefix: true,
3954
- type: 1 /* LIST */,
4834
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3955
4835
  parse: function (_context, tokens) {
3956
4836
  if (tokens.length === 0) {
3957
4837
  return null;
3958
4838
  }
3959
4839
  var first = tokens[0];
3960
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4840
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3961
4841
  return null;
3962
4842
  }
3963
4843
  var increments = [];
@@ -3965,7 +4845,7 @@ var counterIncrement = {
3965
4845
  for (var i = 0; i < filtered.length; i++) {
3966
4846
  var counter = filtered[i];
3967
4847
  var next = filtered[i + 1];
3968
- if (counter.type === 20 /* IDENT_TOKEN */) {
4848
+ if (counter.type === 20 /* TokenType.IDENT_TOKEN */) {
3969
4849
  var increment = next && isNumberToken(next) ? next.number : 1;
3970
4850
  increments.push({ counter: counter.value, increment: increment });
3971
4851
  }
@@ -3978,7 +4858,7 @@ var counterReset = {
3978
4858
  name: 'counter-reset',
3979
4859
  initialValue: 'none',
3980
4860
  prefix: true,
3981
- type: 1 /* LIST */,
4861
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3982
4862
  parse: function (_context, tokens) {
3983
4863
  if (tokens.length === 0) {
3984
4864
  return [];
@@ -4001,7 +4881,7 @@ var duration = {
4001
4881
  name: 'duration',
4002
4882
  initialValue: '0s',
4003
4883
  prefix: false,
4004
- type: 1 /* LIST */,
4884
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4005
4885
  parse: function (context, tokens) {
4006
4886
  return tokens.filter(isDimensionToken).map(function (token) { return time.parse(context, token); });
4007
4887
  }
@@ -4011,13 +4891,13 @@ var quotes = {
4011
4891
  name: 'quotes',
4012
4892
  initialValue: 'none',
4013
4893
  prefix: true,
4014
- type: 1 /* LIST */,
4894
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4015
4895
  parse: function (_context, tokens) {
4016
4896
  if (tokens.length === 0) {
4017
4897
  return null;
4018
4898
  }
4019
4899
  var first = tokens[0];
4020
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4900
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
4021
4901
  return null;
4022
4902
  }
4023
4903
  var quotes = [];
@@ -4047,7 +4927,7 @@ var getQuote = function (quotes, depth, open) {
4047
4927
  var boxShadow = {
4048
4928
  name: 'box-shadow',
4049
4929
  initialValue: 'none',
4050
- type: 1 /* LIST */,
4930
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4051
4931
  prefix: false,
4052
4932
  parse: function (context, tokens) {
4053
4933
  if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
@@ -4096,20 +4976,20 @@ var paintOrder = {
4096
4976
  name: 'paint-order',
4097
4977
  initialValue: 'normal',
4098
4978
  prefix: false,
4099
- type: 1 /* LIST */,
4979
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4100
4980
  parse: function (_context, tokens) {
4101
- 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 */];
4102
4982
  var layers = [];
4103
4983
  tokens.filter(isIdentToken).forEach(function (token) {
4104
4984
  switch (token.value) {
4105
4985
  case 'stroke':
4106
- layers.push(1 /* STROKE */);
4986
+ layers.push(1 /* PAINT_ORDER_LAYER.STROKE */);
4107
4987
  break;
4108
4988
  case 'fill':
4109
- layers.push(0 /* FILL */);
4989
+ layers.push(0 /* PAINT_ORDER_LAYER.FILL */);
4110
4990
  break;
4111
4991
  case 'markers':
4112
- layers.push(2 /* MARKERS */);
4992
+ layers.push(2 /* PAINT_ORDER_LAYER.MARKERS */);
4113
4993
  break;
4114
4994
  }
4115
4995
  });
@@ -4126,14 +5006,14 @@ var webkitTextStrokeColor = {
4126
5006
  name: "-webkit-text-stroke-color",
4127
5007
  initialValue: 'currentcolor',
4128
5008
  prefix: false,
4129
- type: 3 /* TYPE_VALUE */,
5009
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
4130
5010
  format: 'color'
4131
5011
  };
4132
5012
 
4133
5013
  var webkitTextStrokeWidth = {
4134
5014
  name: "-webkit-text-stroke-width",
4135
5015
  initialValue: '0',
4136
- type: 0 /* VALUE */,
5016
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
4137
5017
  prefix: false,
4138
5018
  parse: function (_context, token) {
4139
5019
  if (isDimensionToken(token)) {
@@ -4143,6 +5023,31 @@ var webkitTextStrokeWidth = {
4143
5023
  }
4144
5024
  };
4145
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
+
4146
5051
  var CSSParsedDeclaration = /** @class */ (function () {
4147
5052
  function CSSParsedDeclaration(context, declaration) {
4148
5053
  var _a, _b;
@@ -4208,37 +5113,39 @@ var CSSParsedDeclaration = /** @class */ (function () {
4208
5113
  this.textTransform = parse(context, textTransform, declaration.textTransform);
4209
5114
  this.transform = parse(context, transform$1, declaration.transform);
4210
5115
  this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
5116
+ this.rotate = parse(context, rotate, declaration.rotate);
4211
5117
  this.visibility = parse(context, visibility, declaration.visibility);
4212
5118
  this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
4213
5119
  this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
4214
5120
  this.wordBreak = parse(context, wordBreak, declaration.wordBreak);
4215
5121
  this.zIndex = parse(context, zIndex, declaration.zIndex);
5122
+ this.objectFit = parse(context, objectFit, declaration.objectFit);
4216
5123
  }
4217
5124
  CSSParsedDeclaration.prototype.isVisible = function () {
4218
- return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBLE */;
5125
+ return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBILITY.VISIBLE */;
4219
5126
  };
4220
5127
  CSSParsedDeclaration.prototype.isTransparent = function () {
4221
5128
  return isTransparent(this.backgroundColor);
4222
5129
  };
4223
5130
  CSSParsedDeclaration.prototype.isTransformed = function () {
4224
- return this.transform !== null;
5131
+ return this.transform !== null || this.rotate !== null;
4225
5132
  };
4226
5133
  CSSParsedDeclaration.prototype.isPositioned = function () {
4227
- return this.position !== 0 /* STATIC */;
5134
+ return this.position !== 0 /* POSITION.STATIC */;
4228
5135
  };
4229
5136
  CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {
4230
5137
  return this.isPositioned() && !this.zIndex.auto;
4231
5138
  };
4232
5139
  CSSParsedDeclaration.prototype.isFloating = function () {
4233
- return this.float !== 0 /* NONE */;
5140
+ return this.float !== 0 /* FLOAT.NONE */;
4234
5141
  };
4235
5142
  CSSParsedDeclaration.prototype.isInlineLevel = function () {
4236
- return (contains(this.display, 4 /* INLINE */) ||
4237
- contains(this.display, 33554432 /* INLINE_BLOCK */) ||
4238
- contains(this.display, 268435456 /* INLINE_FLEX */) ||
4239
- contains(this.display, 536870912 /* INLINE_GRID */) ||
4240
- contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||
4241
- 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 */));
4242
5149
  };
4243
5150
  return CSSParsedDeclaration;
4244
5151
  }());
@@ -4263,16 +5170,16 @@ var parse = function (context, descriptor, style) {
4263
5170
  tokenizer.write(value);
4264
5171
  var parser = new Parser(tokenizer.read());
4265
5172
  switch (descriptor.type) {
4266
- case 2 /* IDENT_VALUE */:
5173
+ case 2 /* PropertyDescriptorParsingType.IDENT_VALUE */:
4267
5174
  var token = parser.parseComponentValue();
4268
5175
  return descriptor.parse(context, isIdentToken(token) ? token.value : descriptor.initialValue);
4269
- case 0 /* VALUE */:
5176
+ case 0 /* PropertyDescriptorParsingType.VALUE */:
4270
5177
  return descriptor.parse(context, parser.parseComponentValue());
4271
- case 1 /* LIST */:
5178
+ case 1 /* PropertyDescriptorParsingType.LIST */:
4272
5179
  return descriptor.parse(context, parser.parseComponentValues());
4273
- case 4 /* TOKEN_VALUE */:
5180
+ case 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */:
4274
5181
  return parser.parseComponentValue();
4275
- case 3 /* TYPE_VALUE */:
5182
+ case 3 /* PropertyDescriptorParsingType.TYPE_VALUE */:
4276
5183
  switch (descriptor.format) {
4277
5184
  case 'angle':
4278
5185
  return angle.parse(context, parser.parseComponentValue());
@@ -4298,20 +5205,20 @@ var getElementDebugType = function (element) {
4298
5205
  var attribute = element.getAttribute(elementDebuggerAttribute);
4299
5206
  switch (attribute) {
4300
5207
  case 'all':
4301
- return 1 /* ALL */;
5208
+ return 1 /* DebuggerType.ALL */;
4302
5209
  case 'clone':
4303
- return 2 /* CLONE */;
5210
+ return 2 /* DebuggerType.CLONE */;
4304
5211
  case 'parse':
4305
- return 3 /* PARSE */;
5212
+ return 3 /* DebuggerType.PARSE */;
4306
5213
  case 'render':
4307
- return 4 /* RENDER */;
5214
+ return 4 /* DebuggerType.RENDER */;
4308
5215
  default:
4309
- return 0 /* NONE */;
5216
+ return 0 /* DebuggerType.NONE */;
4310
5217
  }
4311
5218
  };
4312
5219
  var isDebugging = function (element, type) {
4313
5220
  var elementType = getElementDebugType(element);
4314
- return elementType === 1 /* ALL */ || type === elementType;
5221
+ return elementType === 1 /* DebuggerType.ALL */ || type === elementType;
4315
5222
  };
4316
5223
 
4317
5224
  var ElementContainer = /** @class */ (function () {
@@ -4320,7 +5227,7 @@ var ElementContainer = /** @class */ (function () {
4320
5227
  this.textNodes = [];
4321
5228
  this.elements = [];
4322
5229
  this.flags = 0;
4323
- if (isDebugging(element, 3 /* PARSE */)) {
5230
+ if (isDebugging(element, 3 /* DebuggerType.PARSE */)) {
4324
5231
  debugger;
4325
5232
  }
4326
5233
  this.styles = new CSSParsedDeclaration(context, window.getComputedStyle(element, null));
@@ -4332,10 +5239,14 @@ var ElementContainer = /** @class */ (function () {
4332
5239
  // getBoundingClientRect takes transforms into account
4333
5240
  element.style.transform = 'none';
4334
5241
  }
5242
+ if (this.styles.rotate !== null) {
5243
+ // Handle rotate property similarly to transform
5244
+ element.style.rotate = 'none';
5245
+ }
4335
5246
  }
4336
5247
  this.bounds = parseBounds(this.context, element);
4337
- if (isDebugging(element, 4 /* RENDER */)) {
4338
- this.flags |= 16 /* DEBUG_RENDER */;
5248
+ if (isDebugging(element, 4 /* DebuggerType.RENDER */)) {
5249
+ this.flags |= 16 /* FLAGS.DEBUG_RENDER */;
4339
5250
  }
4340
5251
  }
4341
5252
  return ElementContainer;
@@ -4729,7 +5640,7 @@ var testRangeBounds = function (document) {
4729
5640
  var range = document.createRange();
4730
5641
  if (range.getBoundingClientRect) {
4731
5642
  var testElement = document.createElement('boundtest');
4732
- testElement.style.height = TEST_HEIGHT + "px";
5643
+ testElement.style.height = "".concat(TEST_HEIGHT, "px");
4733
5644
  testElement.style.display = 'block';
4734
5645
  document.body.appendChild(testElement);
4735
5646
  range.selectNode(testElement);
@@ -4819,8 +5730,8 @@ var testForeignObject = function (document) {
4819
5730
  ctx.fillStyle = 'red';
4820
5731
  ctx.fillRect(0, 0, size, size);
4821
5732
  var node = document.createElement('div');
4822
- node.style.backgroundImage = "url(" + greenImageSrc + ")";
4823
- node.style.height = size + "px";
5733
+ node.style.backgroundImage = "url(".concat(greenImageSrc, ")");
5734
+ node.style.height = "".concat(size, "px");
4824
5735
  // Firefox 55 does not render inline <img /> tags
4825
5736
  return isGreenPixel(data)
4826
5737
  ? loadSerializedSVG$1(createForeignObjectSVG(size, size, 0, 0, node))
@@ -4853,7 +5764,7 @@ var loadSerializedSVG$1 = function (svg) {
4853
5764
  var img = new Image();
4854
5765
  img.onload = function () { return resolve(img); };
4855
5766
  img.onerror = reject;
4856
- 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)));
4857
5768
  });
4858
5769
  };
4859
5770
  var FEATURES = {
@@ -4997,7 +5908,7 @@ var wordSeparators = [0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091];
4997
5908
  var breakWords = function (str, styles) {
4998
5909
  var breaker = LineBreaker(str, {
4999
5910
  lineBreak: styles.lineBreak,
5000
- 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
5001
5912
  });
5002
5913
  var words = [];
5003
5914
  var bk;
@@ -5038,11 +5949,11 @@ var TextContainer = /** @class */ (function () {
5038
5949
  }());
5039
5950
  var transform = function (text, transform) {
5040
5951
  switch (transform) {
5041
- case 1 /* LOWERCASE */:
5952
+ case 1 /* TEXT_TRANSFORM.LOWERCASE */:
5042
5953
  return text.toLowerCase();
5043
- case 3 /* CAPITALIZE */:
5954
+ case 3 /* TEXT_TRANSFORM.CAPITALIZE */:
5044
5955
  return text.replace(CAPITALIZE, capitalize);
5045
- case 2 /* UPPERCASE */:
5956
+ case 2 /* TEXT_TRANSFORM.UPPERCASE */:
5046
5957
  return text.toUpperCase();
5047
5958
  default:
5048
5959
  return text;
@@ -5087,9 +5998,9 @@ var SVGElementContainer = /** @class */ (function (_super) {
5087
5998
  var _this = _super.call(this, context, img) || this;
5088
5999
  var s = new XMLSerializer();
5089
6000
  var bounds = parseBounds(context, img);
5090
- img.setAttribute('width', bounds.width + "px");
5091
- img.setAttribute('height', bounds.height + "px");
5092
- _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)));
5093
6004
  _this.intrinsicWidth = img.width.baseVal.value;
5094
6005
  _this.intrinsicHeight = img.height.baseVal.value;
5095
6006
  _this.context.cache.addImage(_this.svg);
@@ -5121,7 +6032,7 @@ var OLElementContainer = /** @class */ (function (_super) {
5121
6032
 
5122
6033
  var CHECKBOX_BORDER_RADIUS = [
5123
6034
  {
5124
- type: 15 /* DIMENSION_TOKEN */,
6035
+ type: 15 /* TokenType.DIMENSION_TOKEN */,
5125
6036
  flags: 0,
5126
6037
  unit: 'px',
5127
6038
  number: 3
@@ -5129,7 +6040,7 @@ var CHECKBOX_BORDER_RADIUS = [
5129
6040
  ];
5130
6041
  var RADIO_BORDER_RADIUS = [
5131
6042
  {
5132
- type: 16 /* PERCENTAGE_TOKEN */,
6043
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
5133
6044
  flags: 0,
5134
6045
  number: 50
5135
6046
  }
@@ -5174,9 +6085,9 @@ var InputElementContainer = /** @class */ (function (_super) {
5174
6085
  _this.styles.borderRightStyle =
5175
6086
  _this.styles.borderBottomStyle =
5176
6087
  _this.styles.borderLeftStyle =
5177
- 1 /* SOLID */;
5178
- _this.styles.backgroundClip = [0 /* BORDER_BOX */];
5179
- _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 */];
5180
6091
  _this.bounds = reformatInputBounds(_this.bounds);
5181
6092
  }
5182
6093
  switch (_this.type) {
@@ -5258,7 +6169,8 @@ var LIST_OWNERS = ['OL', 'UL', 'MENU'];
5258
6169
  var parseNodeTree = function (context, node, parent, root) {
5259
6170
  for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
5260
6171
  nextNode = childNode.nextSibling;
5261
- 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) {
5262
6174
  parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
5263
6175
  }
5264
6176
  else if (isElementNode(childNode)) {
@@ -5269,13 +6181,13 @@ var parseNodeTree = function (context, node, parent, root) {
5269
6181
  var container = createContainer(context, childNode);
5270
6182
  if (container.styles.isVisible()) {
5271
6183
  if (createsRealStackingContext(childNode, container, root)) {
5272
- container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
6184
+ container.flags |= 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */;
5273
6185
  }
5274
6186
  else if (createsStackingContext(container.styles)) {
5275
- container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
6187
+ container.flags |= 2 /* FLAGS.CREATES_STACKING_CONTEXT */;
5276
6188
  }
5277
6189
  if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
5278
- container.flags |= 8 /* IS_LIST_OWNER */;
6190
+ container.flags |= 8 /* FLAGS.IS_LIST_OWNER */;
5279
6191
  }
5280
6192
  parent.elements.push(container);
5281
6193
  childNode.slot;
@@ -5324,7 +6236,7 @@ var createContainer = function (context, element) {
5324
6236
  };
5325
6237
  var parseTree = function (context, element) {
5326
6238
  var container = createContainer(context, element);
5327
- container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
6239
+ container.flags |= 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */;
5328
6240
  parseNodeTree(context, element, container, container);
5329
6241
  return container;
5330
6242
  };
@@ -5592,7 +6504,7 @@ var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;
5592
6504
  var CJK_HUNDRED_COEFFICIENTS = 1 << 3;
5593
6505
  var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {
5594
6506
  if (value < -9999 || value > 9999) {
5595
- return createCounterText(value, 4 /* CJK_DECIMAL */, suffix.length > 0);
6507
+ return createCounterText(value, 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */, suffix.length > 0);
5596
6508
  }
5597
6509
  var tmp = Math.abs(value);
5598
6510
  var string = suffix;
@@ -5628,101 +6540,101 @@ var createCounterText = function (value, type, appendSuffix) {
5628
6540
  var koreanSuffix = appendSuffix ? ', ' : '';
5629
6541
  var spaceSuffix = appendSuffix ? ' ' : '';
5630
6542
  switch (type) {
5631
- case 0 /* DISC */:
6543
+ case 0 /* LIST_STYLE_TYPE.DISC */:
5632
6544
  return '•' + spaceSuffix;
5633
- case 1 /* CIRCLE */:
6545
+ case 1 /* LIST_STYLE_TYPE.CIRCLE */:
5634
6546
  return '◦' + spaceSuffix;
5635
- case 2 /* SQUARE */:
6547
+ case 2 /* LIST_STYLE_TYPE.SQUARE */:
5636
6548
  return '◾' + spaceSuffix;
5637
- case 5 /* DECIMAL_LEADING_ZERO */:
6549
+ case 5 /* LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO */:
5638
6550
  var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
5639
- return string.length < 4 ? "0" + string : string;
5640
- case 4 /* CJK_DECIMAL */:
6551
+ return string.length < 4 ? "0".concat(string) : string;
6552
+ case 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */:
5641
6553
  return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);
5642
- case 6 /* LOWER_ROMAN */:
5643
- return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
5644
- case 7 /* UPPER_ROMAN */:
5645
- return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix);
5646
- 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 */:
5647
6559
  return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);
5648
- case 9 /* LOWER_ALPHA */:
6560
+ case 9 /* LIST_STYLE_TYPE.LOWER_ALPHA */:
5649
6561
  return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);
5650
- case 10 /* UPPER_ALPHA */:
6562
+ case 10 /* LIST_STYLE_TYPE.UPPER_ALPHA */:
5651
6563
  return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);
5652
- case 11 /* ARABIC_INDIC */:
6564
+ case 11 /* LIST_STYLE_TYPE.ARABIC_INDIC */:
5653
6565
  return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);
5654
- case 12 /* ARMENIAN */:
5655
- case 49 /* UPPER_ARMENIAN */:
5656
- return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix);
5657
- case 35 /* LOWER_ARMENIAN */:
5658
- return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
5659
- 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 */:
5660
6572
  return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);
5661
- case 14 /* CAMBODIAN */:
5662
- case 30 /* KHMER */:
6573
+ case 14 /* LIST_STYLE_TYPE.CAMBODIAN */:
6574
+ case 30 /* LIST_STYLE_TYPE.KHMER */:
5663
6575
  return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);
5664
- case 15 /* CJK_EARTHLY_BRANCH */:
6576
+ case 15 /* LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH */:
5665
6577
  return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);
5666
- case 16 /* CJK_HEAVENLY_STEM */:
6578
+ case 16 /* LIST_STYLE_TYPE.CJK_HEAVENLY_STEM */:
5667
6579
  return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);
5668
- case 17 /* CJK_IDEOGRAPHIC */:
5669
- case 48 /* TRAD_CHINESE_INFORMAL */:
6580
+ case 17 /* LIST_STYLE_TYPE.CJK_IDEOGRAPHIC */:
6581
+ case 48 /* LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL */:
5670
6582
  return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5671
- case 47 /* TRAD_CHINESE_FORMAL */:
6583
+ case 47 /* LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL */:
5672
6584
  return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5673
- case 42 /* SIMP_CHINESE_INFORMAL */:
6585
+ case 42 /* LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL */:
5674
6586
  return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5675
- case 41 /* SIMP_CHINESE_FORMAL */:
6587
+ case 41 /* LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL */:
5676
6588
  return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5677
- case 26 /* JAPANESE_INFORMAL */:
6589
+ case 26 /* LIST_STYLE_TYPE.JAPANESE_INFORMAL */:
5678
6590
  return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);
5679
- case 25 /* JAPANESE_FORMAL */:
6591
+ case 25 /* LIST_STYLE_TYPE.JAPANESE_FORMAL */:
5680
6592
  return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5681
- case 31 /* KOREAN_HANGUL_FORMAL */:
6593
+ case 31 /* LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL */:
5682
6594
  return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5683
- case 33 /* KOREAN_HANJA_INFORMAL */:
6595
+ case 33 /* LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL */:
5684
6596
  return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);
5685
- case 32 /* KOREAN_HANJA_FORMAL */:
6597
+ case 32 /* LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL */:
5686
6598
  return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5687
- case 18 /* DEVANAGARI */:
6599
+ case 18 /* LIST_STYLE_TYPE.DEVANAGARI */:
5688
6600
  return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);
5689
- case 20 /* GEORGIAN */:
5690
- return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3 /* DECIMAL */, defaultSuffix);
5691
- 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 */:
5692
6604
  return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);
5693
- case 22 /* GURMUKHI */:
6605
+ case 22 /* LIST_STYLE_TYPE.GURMUKHI */:
5694
6606
  return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);
5695
- case 22 /* HEBREW */:
5696
- return createAdditiveCounter(value, 1, 10999, HEBREW, 3 /* DECIMAL */, defaultSuffix);
5697
- 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 */:
5698
6610
  return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');
5699
- case 24 /* HIRAGANA_IROHA */:
6611
+ case 24 /* LIST_STYLE_TYPE.HIRAGANA_IROHA */:
5700
6612
  return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');
5701
- case 27 /* KANNADA */:
6613
+ case 27 /* LIST_STYLE_TYPE.KANNADA */:
5702
6614
  return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);
5703
- case 28 /* KATAKANA */:
6615
+ case 28 /* LIST_STYLE_TYPE.KATAKANA */:
5704
6616
  return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);
5705
- case 29 /* KATAKANA_IROHA */:
6617
+ case 29 /* LIST_STYLE_TYPE.KATAKANA_IROHA */:
5706
6618
  return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);
5707
- case 34 /* LAO */:
6619
+ case 34 /* LIST_STYLE_TYPE.LAO */:
5708
6620
  return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);
5709
- case 37 /* MONGOLIAN */:
6621
+ case 37 /* LIST_STYLE_TYPE.MONGOLIAN */:
5710
6622
  return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);
5711
- case 38 /* MYANMAR */:
6623
+ case 38 /* LIST_STYLE_TYPE.MYANMAR */:
5712
6624
  return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);
5713
- case 39 /* ORIYA */:
6625
+ case 39 /* LIST_STYLE_TYPE.ORIYA */:
5714
6626
  return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);
5715
- case 40 /* PERSIAN */:
6627
+ case 40 /* LIST_STYLE_TYPE.PERSIAN */:
5716
6628
  return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);
5717
- case 43 /* TAMIL */:
6629
+ case 43 /* LIST_STYLE_TYPE.TAMIL */:
5718
6630
  return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);
5719
- case 44 /* TELUGU */:
6631
+ case 44 /* LIST_STYLE_TYPE.TELUGU */:
5720
6632
  return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);
5721
- case 45 /* THAI */:
6633
+ case 45 /* LIST_STYLE_TYPE.THAI */:
5722
6634
  return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);
5723
- case 46 /* TIBETAN */:
6635
+ case 46 /* LIST_STYLE_TYPE.TIBETAN */:
5724
6636
  return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);
5725
- case 3 /* DECIMAL */:
6637
+ case 3 /* LIST_STYLE_TYPE.DECIMAL */:
5726
6638
  default:
5727
6639
  return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
5728
6640
  }
@@ -5772,7 +6684,7 @@ var DocumentCloner = /** @class */ (function () {
5772
6684
  onclone = this.options.onclone;
5773
6685
  referenceElement = this.clonedReferenceElement;
5774
6686
  if (typeof referenceElement === 'undefined') {
5775
- 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"))];
5776
6688
  }
5777
6689
  if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
5778
6690
  return [4 /*yield*/, documentClone.fonts.ready];
@@ -5795,16 +6707,33 @@ var DocumentCloner = /** @class */ (function () {
5795
6707
  }
5796
6708
  });
5797
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;
5798
6715
  documentClone.open();
5799
- documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
6716
+ documentClone.write("".concat(serializeDoctype(document.doctype), "<html></html>"));
5800
6717
  // Chrome scrolls the parent document for some reason after the write to the cloned window???
5801
6718
  restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
5802
- 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);
5803
6732
  documentClone.close();
5804
6733
  return iframeLoad;
5805
6734
  };
5806
6735
  DocumentCloner.prototype.createElementClone = function (node) {
5807
- if (isDebugging(node, 2 /* CLONE */)) {
6736
+ if (isDebugging(node, 2 /* DebuggerType.CLONE */)) {
5808
6737
  debugger;
5809
6738
  }
5810
6739
  if (isCanvasElement(node)) {
@@ -5877,7 +6806,7 @@ var DocumentCloner = /** @class */ (function () {
5877
6806
  clonedCanvas.width = canvas.width;
5878
6807
  clonedCanvas.height = canvas.height;
5879
6808
  var ctx = canvas.getContext('2d');
5880
- var clonedCtx = clonedCanvas.getContext('2d');
6809
+ var clonedCtx = clonedCanvas.getContext('2d', { willReadFrequently: true });
5881
6810
  if (clonedCtx) {
5882
6811
  if (!this.options.allowTaint && ctx) {
5883
6812
  clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
@@ -6012,16 +6941,16 @@ var DocumentCloner = /** @class */ (function () {
6012
6941
  var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
6013
6942
  copyCSSStyles(style, anonymousReplacedElement);
6014
6943
  declaration.content.forEach(function (token) {
6015
- if (token.type === 0 /* STRING_TOKEN */) {
6944
+ if (token.type === 0 /* TokenType.STRING_TOKEN */) {
6016
6945
  anonymousReplacedElement.appendChild(document.createTextNode(token.value));
6017
6946
  }
6018
- else if (token.type === 22 /* URL_TOKEN */) {
6947
+ else if (token.type === 22 /* TokenType.URL_TOKEN */) {
6019
6948
  var img = document.createElement('img');
6020
6949
  img.src = token.value;
6021
6950
  img.style.opacity = '1';
6022
6951
  anonymousReplacedElement.appendChild(img);
6023
6952
  }
6024
- else if (token.type === 18 /* FUNCTION */) {
6953
+ else if (token.type === 18 /* TokenType.FUNCTION */) {
6025
6954
  if (token.name === 'attr') {
6026
6955
  var attr = token.values.filter(isIdentToken);
6027
6956
  if (attr.length) {
@@ -6034,7 +6963,7 @@ var DocumentCloner = /** @class */ (function () {
6034
6963
  var counterState = _this.counters.getCounterValue(counter.value);
6035
6964
  var counterType = counterStyle && isIdentToken(counterStyle)
6036
6965
  ? listStyleType.parse(_this.context, counterStyle.value)
6037
- : 3 /* DECIMAL */;
6966
+ : 3 /* LIST_STYLE_TYPE.DECIMAL */;
6038
6967
  anonymousReplacedElement.appendChild(document.createTextNode(createCounterText(counterState, counterType, false)));
6039
6968
  }
6040
6969
  }
@@ -6044,8 +6973,8 @@ var DocumentCloner = /** @class */ (function () {
6044
6973
  var counterStates = _this.counters.getCounterValues(counter.value);
6045
6974
  var counterType_1 = counterStyle && isIdentToken(counterStyle)
6046
6975
  ? listStyleType.parse(_this.context, counterStyle.value)
6047
- : 3 /* DECIMAL */;
6048
- 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 : '';
6049
6978
  var text = counterStates
6050
6979
  .map(function (value) { return createCounterText(value, counterType_1, false); })
6051
6980
  .join(separator);
@@ -6054,7 +6983,7 @@ var DocumentCloner = /** @class */ (function () {
6054
6983
  }
6055
6984
  else ;
6056
6985
  }
6057
- else if (token.type === 20 /* IDENT_TOKEN */) {
6986
+ else if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
6058
6987
  switch (token.value) {
6059
6988
  case 'open-quote':
6060
6989
  anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, _this.quoteDepth++, true)));
@@ -6068,10 +6997,10 @@ var DocumentCloner = /** @class */ (function () {
6068
6997
  }
6069
6998
  }
6070
6999
  });
6071
- 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);
6072
7001
  var newClassName = pseudoElt === PseudoElementType.BEFORE
6073
- ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
6074
- : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
7002
+ ? " ".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE)
7003
+ : " ".concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER);
6075
7004
  if (isSVGElementNode(clone)) {
6076
7005
  clone.className.baseValue += newClassName;
6077
7006
  }
@@ -6145,8 +7074,8 @@ var iframeLoader = function (iframe) {
6145
7074
  });
6146
7075
  };
6147
7076
  var ignoredStyleProperties = [
6148
- 'all',
6149
- 'd',
7077
+ 'all', // #2476
7078
+ 'd', // #2483
6150
7079
  'content' // Safari shows pseudoelements if content is set
6151
7080
  ];
6152
7081
  var copyCSSStyles = function (style, target) {
@@ -6170,10 +7099,10 @@ var serializeDoctype = function (doctype) {
6170
7099
  str += doctype.internalSubset;
6171
7100
  }
6172
7101
  if (doctype.publicId) {
6173
- str += "\"" + doctype.publicId + "\"";
7102
+ str += "\"".concat(doctype.publicId, "\"");
6174
7103
  }
6175
7104
  if (doctype.systemId) {
6176
- str += "\"" + doctype.systemId + "\"";
7105
+ str += "\"".concat(doctype.systemId, "\"");
6177
7106
  }
6178
7107
  str += '>';
6179
7108
  }
@@ -6197,7 +7126,7 @@ var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
6197
7126
  var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
6198
7127
  var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
6199
7128
  var createPseudoHideStyles = function (body) {
6200
- 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));
6201
7130
  };
6202
7131
  var createStyles = function (body, styles) {
6203
7132
  var document = body.ownerDocument;
@@ -6207,6 +7136,13 @@ var createStyles = function (body, styles) {
6207
7136
  body.appendChild(style);
6208
7137
  }
6209
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
+ };
6210
7146
 
6211
7147
  var CacheStorage = /** @class */ (function () {
6212
7148
  function CacheStorage() {
@@ -6256,12 +7192,21 @@ var Cache = /** @class */ (function () {
6256
7192
  };
6257
7193
  Cache.prototype.loadImage = function (key) {
6258
7194
  return __awaiter(this, void 0, void 0, function () {
6259
- var isSameOrigin, useCORS, useProxy, src;
7195
+ var isSameOrigin, _a, useCORS, useProxy, src;
6260
7196
  var _this = this;
6261
- return __generator(this, function (_a) {
6262
- switch (_a.label) {
7197
+ return __generator(this, function (_b) {
7198
+ switch (_b.label) {
6263
7199
  case 0:
6264
- 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;
6265
7210
  useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
6266
7211
  useProxy = !isInlineImage(key) &&
6267
7212
  !isSameOrigin &&
@@ -6278,13 +7223,13 @@ var Cache = /** @class */ (function () {
6278
7223
  return [2 /*return*/];
6279
7224
  }
6280
7225
  src = key;
6281
- if (!useProxy) return [3 /*break*/, 2];
7226
+ if (!useProxy) return [3 /*break*/, 5];
6282
7227
  return [4 /*yield*/, this.proxy(src)];
6283
- case 1:
6284
- src = _a.sent();
6285
- _a.label = 2;
6286
- case 2:
6287
- 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)));
6288
7233
  return [4 /*yield*/, new Promise(function (resolve, reject) {
6289
7234
  var img = new Image();
6290
7235
  img.onload = function () { return resolve(img); };
@@ -6299,10 +7244,10 @@ var Cache = /** @class */ (function () {
6299
7244
  setTimeout(function () { return resolve(img); }, 500);
6300
7245
  }
6301
7246
  if (_this._options.imageTimeout > 0) {
6302
- 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);
6303
7248
  }
6304
7249
  })];
6305
- case 3: return [2 /*return*/, _a.sent()];
7250
+ case 6: return [2 /*return*/, _b.sent()];
6306
7251
  }
6307
7252
  });
6308
7253
  });
@@ -6336,19 +7281,19 @@ var Cache = /** @class */ (function () {
6336
7281
  }
6337
7282
  }
6338
7283
  else {
6339
- 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));
6340
7285
  }
6341
7286
  };
6342
7287
  xhr.onerror = reject;
6343
7288
  var queryString = proxy.indexOf('?') > -1 ? '&' : '?';
6344
- 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));
6345
7290
  if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
6346
7291
  xhr.responseType = responseType;
6347
7292
  }
6348
7293
  if (_this._options.imageTimeout) {
6349
7294
  var timeout_1 = _this._options.imageTimeout;
6350
7295
  xhr.timeout = timeout_1;
6351
- 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)); };
6352
7297
  }
6353
7298
  xhr.send();
6354
7299
  });
@@ -6366,7 +7311,7 @@ var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || IN
6366
7311
 
6367
7312
  var Vector = /** @class */ (function () {
6368
7313
  function Vector(x, y) {
6369
- this.type = 0 /* VECTOR */;
7314
+ this.type = 0 /* PathType.VECTOR */;
6370
7315
  this.x = x;
6371
7316
  this.y = y;
6372
7317
  }
@@ -6381,7 +7326,7 @@ var lerp = function (a, b, t) {
6381
7326
  };
6382
7327
  var BezierCurve = /** @class */ (function () {
6383
7328
  function BezierCurve(start, startControl, endControl, end) {
6384
- this.type = 1 /* BEZIER_CURVE */;
7329
+ this.type = 1 /* PathType.BEZIER_CURVE */;
6385
7330
  this.start = start;
6386
7331
  this.startControl = startControl;
6387
7332
  this.endControl = endControl;
@@ -6404,7 +7349,7 @@ var BezierCurve = /** @class */ (function () {
6404
7349
  };
6405
7350
  return BezierCurve;
6406
7351
  }());
6407
- var isBezierCurve = function (path) { return path.type === 1 /* BEZIER_CURVE */; };
7352
+ var isBezierCurve = function (path) { return path.type === 1 /* PathType.BEZIER_CURVE */; };
6408
7353
 
6409
7354
  var BoundCurves = /** @class */ (function () {
6410
7355
  function BoundCurves(element) {
@@ -6591,8 +7536,8 @@ var TransformEffect = /** @class */ (function () {
6591
7536
  this.offsetX = offsetX;
6592
7537
  this.offsetY = offsetY;
6593
7538
  this.matrix = matrix;
6594
- this.type = 0 /* TRANSFORM */;
6595
- this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
7539
+ this.type = 0 /* EffectType.TRANSFORM */;
7540
+ this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
6596
7541
  }
6597
7542
  return TransformEffect;
6598
7543
  }());
@@ -6600,23 +7545,23 @@ var ClipEffect = /** @class */ (function () {
6600
7545
  function ClipEffect(path, target) {
6601
7546
  this.path = path;
6602
7547
  this.target = target;
6603
- this.type = 1 /* CLIP */;
7548
+ this.type = 1 /* EffectType.CLIP */;
6604
7549
  }
6605
7550
  return ClipEffect;
6606
7551
  }());
6607
7552
  var OpacityEffect = /** @class */ (function () {
6608
7553
  function OpacityEffect(opacity) {
6609
7554
  this.opacity = opacity;
6610
- this.type = 2 /* OPACITY */;
6611
- this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
7555
+ this.type = 2 /* EffectType.OPACITY */;
7556
+ this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
6612
7557
  }
6613
7558
  return OpacityEffect;
6614
7559
  }());
6615
7560
  var isTransformEffect = function (effect) {
6616
- return effect.type === 0 /* TRANSFORM */;
7561
+ return effect.type === 0 /* EffectType.TRANSFORM */;
6617
7562
  };
6618
- var isClipEffect = function (effect) { return effect.type === 1 /* CLIP */; };
6619
- 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 */; };
6620
7565
 
6621
7566
  var equalPath = function (a, b) {
6622
7567
  if (a.length === b.length) {
@@ -6662,40 +7607,51 @@ var ElementPaint = /** @class */ (function () {
6662
7607
  if (this.container.styles.opacity < 1) {
6663
7608
  this.effects.push(new OpacityEffect(this.container.styles.opacity));
6664
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
+ }
6665
7621
  if (this.container.styles.transform !== null) {
6666
7622
  var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
6667
7623
  var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
6668
7624
  var matrix = this.container.styles.transform;
6669
7625
  this.effects.push(new TransformEffect(offsetX, offsetY, matrix));
6670
7626
  }
6671
- if (this.container.styles.overflowX !== 0 /* VISIBLE */) {
7627
+ if (this.container.styles.overflowX !== 0 /* OVERFLOW.VISIBLE */) {
6672
7628
  var borderBox = calculateBorderBoxPath(this.curves);
6673
7629
  var paddingBox = calculatePaddingBoxPath(this.curves);
6674
7630
  if (equalPath(borderBox, paddingBox)) {
6675
- 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 */));
6676
7632
  }
6677
7633
  else {
6678
- this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */));
6679
- 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 */));
6680
7636
  }
6681
7637
  }
6682
7638
  }
6683
7639
  ElementPaint.prototype.getEffects = function (target) {
6684
- 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;
6685
7641
  var parent = this.parent;
6686
7642
  var effects = this.effects.slice(0);
6687
7643
  while (parent) {
6688
7644
  var croplessEffects = parent.effects.filter(function (effect) { return !isClipEffect(effect); });
6689
- if (inFlow || parent.container.styles.position !== 0 /* STATIC */ || !parent.parent) {
6690
- effects.unshift.apply(effects, croplessEffects);
6691
- inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(parent.container.styles.position) === -1;
6692
- 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 */) {
6693
7648
  var borderBox = calculateBorderBoxPath(parent.curves);
6694
7649
  var paddingBox = calculatePaddingBoxPath(parent.curves);
6695
7650
  if (!equalPath(borderBox, paddingBox)) {
6696
- effects.unshift(new ClipEffect(paddingBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
7651
+ effects.unshift(new ClipEffect(paddingBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
6697
7652
  }
6698
7653
  }
7654
+ effects.unshift.apply(effects, croplessEffects);
6699
7655
  }
6700
7656
  else {
6701
7657
  effects.unshift.apply(effects, croplessEffects);
@@ -6708,13 +7664,13 @@ var ElementPaint = /** @class */ (function () {
6708
7664
  }());
6709
7665
  var parseStackTree = function (parent, stackingContext, realStackingContext, listItems) {
6710
7666
  parent.container.elements.forEach(function (child) {
6711
- var treatAsRealStackingContext = contains(child.flags, 4 /* CREATES_REAL_STACKING_CONTEXT */);
6712
- 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 */);
6713
7669
  var paintContainer = new ElementPaint(child, parent);
6714
- if (contains(child.styles.display, 2048 /* LIST_ITEM */)) {
7670
+ if (contains(child.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) {
6715
7671
  listItems.push(paintContainer);
6716
7672
  }
6717
- var listOwnerItems = contains(child.flags, 8 /* IS_LIST_OWNER */) ? [] : listItems;
7673
+ var listOwnerItems = contains(child.flags, 8 /* FLAGS.IS_LIST_OWNER */) ? [] : listItems;
6718
7674
  if (treatAsRealStackingContext || createsStackingContext) {
6719
7675
  var parentStack = treatAsRealStackingContext || child.styles.isPositioned() ? realStackingContext : stackingContext;
6720
7676
  var stack = new StackingContext(paintContainer);
@@ -6771,7 +7727,7 @@ var parseStackTree = function (parent, stackingContext, realStackingContext, lis
6771
7727
  }
6772
7728
  parseStackTree(paintContainer, stackingContext, realStackingContext, listOwnerItems);
6773
7729
  }
6774
- if (contains(child.flags, 8 /* IS_LIST_OWNER */)) {
7730
+ if (contains(child.flags, 8 /* FLAGS.IS_LIST_OWNER */)) {
6775
7731
  processListItems(child, listOwnerItems);
6776
7732
  }
6777
7733
  });
@@ -6912,19 +7868,19 @@ var contentBox = function (element) {
6912
7868
  };
6913
7869
 
6914
7870
  var calculateBackgroundPositioningArea = function (backgroundOrigin, element) {
6915
- if (backgroundOrigin === 0 /* BORDER_BOX */) {
7871
+ if (backgroundOrigin === 0 /* BACKGROUND_ORIGIN.BORDER_BOX */) {
6916
7872
  return element.bounds;
6917
7873
  }
6918
- if (backgroundOrigin === 2 /* CONTENT_BOX */) {
7874
+ if (backgroundOrigin === 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */) {
6919
7875
  return contentBox(element);
6920
7876
  }
6921
7877
  return paddingBox(element);
6922
7878
  };
6923
7879
  var calculateBackgroundPaintingArea = function (backgroundClip, element) {
6924
- if (backgroundClip === 0 /* BORDER_BOX */) {
7880
+ if (backgroundClip === 0 /* BACKGROUND_CLIP.BORDER_BOX */) {
6925
7881
  return element.bounds;
6926
7882
  }
6927
- if (backgroundClip === 2 /* CONTENT_BOX */) {
7883
+ if (backgroundClip === 2 /* BACKGROUND_CLIP.CONTENT_BOX */) {
6928
7884
  return contentBox(element);
6929
7885
  }
6930
7886
  return paddingBox(element);
@@ -6938,6 +7894,8 @@ var calculateBackgroundRendering = function (container, index, intrinsicSize) {
6938
7894
  var path = calculateBackgroundRepeatPath(getBackgroundValueForIndex(container.styles.backgroundRepeat, index), position, backgroundImageSize, backgroundPositioningArea, backgroundPaintingArea);
6939
7895
  var offsetX = Math.round(backgroundPositioningArea.left + position[0]);
6940
7896
  var offsetY = Math.round(backgroundPositioningArea.top + position[1]);
7897
+ sizeWidth = Math.max(1, sizeWidth);
7898
+ sizeHeight = Math.max(1, sizeHeight);
6941
7899
  return [path, offsetX, offsetY, sizeWidth, sizeHeight];
6942
7900
  };
6943
7901
  var isAuto = function (token) { return isIdentToken(token) && token.value === BACKGROUND_SIZE.AUTO; };
@@ -7052,21 +8010,21 @@ var calculateBackgroundRepeatPath = function (repeat, _a, _b, backgroundPosition
7052
8010
  var x = _a[0], y = _a[1];
7053
8011
  var width = _b[0], height = _b[1];
7054
8012
  switch (repeat) {
7055
- case 2 /* REPEAT_X */:
8013
+ case 2 /* BACKGROUND_REPEAT.REPEAT_X */:
7056
8014
  return [
7057
8015
  new Vector(Math.round(backgroundPositioningArea.left), Math.round(backgroundPositioningArea.top + y)),
7058
8016
  new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(backgroundPositioningArea.top + y)),
7059
8017
  new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(height + backgroundPositioningArea.top + y)),
7060
8018
  new Vector(Math.round(backgroundPositioningArea.left), Math.round(height + backgroundPositioningArea.top + y))
7061
8019
  ];
7062
- case 3 /* REPEAT_Y */:
8020
+ case 3 /* BACKGROUND_REPEAT.REPEAT_Y */:
7063
8021
  return [
7064
8022
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top)),
7065
8023
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top)),
7066
8024
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top)),
7067
8025
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top))
7068
8026
  ];
7069
- case 1 /* NO_REPEAT */:
8027
+ case 1 /* BACKGROUND_REPEAT.NO_REPEAT */:
7070
8028
  return [
7071
8029
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y)),
7072
8030
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y)),
@@ -7126,7 +8084,7 @@ var FontMetrics = /** @class */ (function () {
7126
8084
  return { baseline: baseline, middle: middle };
7127
8085
  };
7128
8086
  FontMetrics.prototype.getMetrics = function (fontFamily, fontSize) {
7129
- var key = fontFamily + " " + fontSize;
8087
+ var key = "".concat(fontFamily, " ").concat(fontSize);
7130
8088
  if (typeof this._data[key] === 'undefined') {
7131
8089
  this._data[key] = this.parseMetrics(fontFamily, fontSize);
7132
8090
  }
@@ -7154,15 +8112,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
7154
8112
  if (!options.canvas) {
7155
8113
  _this.canvas.width = Math.floor(options.width * options.scale);
7156
8114
  _this.canvas.height = Math.floor(options.height * options.scale);
7157
- _this.canvas.style.width = options.width + "px";
7158
- _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");
7159
8117
  }
7160
8118
  _this.fontMetrics = new FontMetrics(document);
7161
8119
  _this.ctx.scale(_this.options.scale, _this.options.scale);
7162
8120
  _this.ctx.translate(-options.x, -options.y);
7163
8121
  _this.ctx.textBaseline = 'bottom';
7164
8122
  _this._activeEffects = [];
7165
- _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));
7166
8124
  return _this;
7167
8125
  }
7168
8126
  CanvasRenderer.prototype.applyEffects = function (effects) {
@@ -7214,7 +8172,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7214
8172
  return __generator(this, function (_a) {
7215
8173
  switch (_a.label) {
7216
8174
  case 0:
7217
- if (contains(paint.container.flags, 16 /* DEBUG_RENDER */)) {
8175
+ if (contains(paint.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
7218
8176
  debugger;
7219
8177
  }
7220
8178
  if (!paint.container.styles.isVisible()) return [3 /*break*/, 3];
@@ -7233,7 +8191,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
7233
8191
  CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing, baseline) {
7234
8192
  var _this = this;
7235
8193
  if (letterSpacing === 0) {
7236
- 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
+ }
7237
8203
  }
7238
8204
  else {
7239
8205
  var letters = segmentGraphemes(text.text);
@@ -7249,8 +8215,8 @@ var CanvasRenderer = /** @class */ (function (_super) {
7249
8215
  .join('');
7250
8216
  var fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', ');
7251
8217
  var fontSize = isDimensionToken(styles.fontSize)
7252
- ? "" + styles.fontSize.number + styles.fontSize.unit
7253
- : styles.fontSize.number + "px";
8218
+ ? "".concat(styles.fontSize.number).concat(styles.fontSize.unit)
8219
+ : "".concat(styles.fontSize.number, "px");
7254
8220
  return [
7255
8221
  [styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
7256
8222
  fontFamily,
@@ -7259,22 +8225,21 @@ var CanvasRenderer = /** @class */ (function (_super) {
7259
8225
  };
7260
8226
  CanvasRenderer.prototype.renderTextNode = function (text, styles) {
7261
8227
  return __awaiter(this, void 0, void 0, function () {
7262
- var _a, font, fontFamily, fontSize, _b, baseline, middle, paintOrder;
8228
+ var font, paintOrder;
7263
8229
  var _this = this;
7264
- return __generator(this, function (_c) {
7265
- _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];
7266
8232
  this.ctx.font = font;
7267
- this.ctx.direction = styles.direction === 1 /* RTL */ ? 'rtl' : 'ltr';
8233
+ this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
7268
8234
  this.ctx.textAlign = 'left';
7269
8235
  this.ctx.textBaseline = 'alphabetic';
7270
- _b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
7271
8236
  paintOrder = styles.paintOrder;
7272
8237
  text.textBounds.forEach(function (text) {
7273
8238
  paintOrder.forEach(function (paintOrderLayer) {
7274
8239
  switch (paintOrderLayer) {
7275
- case 0 /* FILL */:
8240
+ case 0 /* PAINT_ORDER_LAYER.FILL */:
7276
8241
  _this.ctx.fillStyle = asString(styles.color);
7277
- _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
8242
+ _this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
7278
8243
  var textShadows = styles.textShadow;
7279
8244
  if (textShadows.length && text.text.trim().length) {
7280
8245
  textShadows
@@ -7285,7 +8250,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7285
8250
  _this.ctx.shadowOffsetX = textShadow.offsetX.number * _this.options.scale;
7286
8251
  _this.ctx.shadowOffsetY = textShadow.offsetY.number * _this.options.scale;
7287
8252
  _this.ctx.shadowBlur = textShadow.blur.number;
7288
- _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
8253
+ _this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
7289
8254
  });
7290
8255
  _this.ctx.shadowColor = '';
7291
8256
  _this.ctx.shadowOffsetX = 0;
@@ -7294,32 +8259,30 @@ var CanvasRenderer = /** @class */ (function (_super) {
7294
8259
  }
7295
8260
  if (styles.textDecorationLine.length) {
7296
8261
  _this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
8262
+ var decorationLineHeight_1 = 1;
7297
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.
7298
8265
  switch (textDecorationLine) {
7299
- case 1 /* UNDERLINE */:
7300
- // Draws a line at the baseline of the font
7301
- // TODO As some browsers display the line as more than 1px if the font-size is big,
7302
- // need to take that into account both in position and size
7303
- _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);
7304
8268
  break;
7305
- case 2 /* OVERLINE */:
7306
- _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);
7307
8271
  break;
7308
- case 3 /* LINE_THROUGH */:
7309
- // TODO try and find exact position for line-through
7310
- _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);
7311
8274
  break;
7312
8275
  }
7313
8276
  });
7314
8277
  }
7315
8278
  break;
7316
- case 1 /* STROKE */:
8279
+ case 1 /* PAINT_ORDER_LAYER.STROKE */:
7317
8280
  if (styles.webkitTextStrokeWidth && text.text.trim().length) {
7318
8281
  _this.ctx.strokeStyle = asString(styles.webkitTextStrokeColor);
7319
8282
  _this.ctx.lineWidth = styles.webkitTextStrokeWidth;
7320
8283
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7321
8284
  _this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
7322
- _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);
7323
8286
  }
7324
8287
  _this.ctx.strokeStyle = '';
7325
8288
  _this.ctx.lineWidth = 0;
@@ -7333,23 +8296,99 @@ var CanvasRenderer = /** @class */ (function (_super) {
7333
8296
  });
7334
8297
  };
7335
8298
  CanvasRenderer.prototype.renderReplacedElement = function (container, curves, image) {
7336
- 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) {
7337
8302
  var box = contentBox(container);
7338
8303
  var path = calculatePaddingBoxPath(curves);
7339
8304
  this.path(path);
7340
8305
  this.ctx.save();
7341
8306
  this.ctx.clip();
7342
- 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);
7343
8382
  this.ctx.restore();
7344
8383
  }
7345
8384
  };
7346
8385
  CanvasRenderer.prototype.renderNodeContent = function (paint) {
7347
8386
  return __awaiter(this, void 0, void 0, function () {
7348
- 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;
7349
8388
  return __generator(this, function (_c) {
7350
8389
  switch (_c.label) {
7351
8390
  case 0:
7352
- this.applyEffects(paint.getEffects(4 /* CONTENT */));
8391
+ this.applyEffects(paint.getEffects(4 /* EffectTarget.CONTENT */));
7353
8392
  container = paint.container;
7354
8393
  curves = paint.curves;
7355
8394
  styles = container.styles;
@@ -7377,7 +8416,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7377
8416
  return [3 /*break*/, 8];
7378
8417
  case 7:
7379
8418
  _c.sent();
7380
- this.context.logger.error("Error loading image " + container.src);
8419
+ this.context.logger.error("Error loading image ".concat(container.src));
7381
8420
  return [3 /*break*/, 8];
7382
8421
  case 8:
7383
8422
  if (container instanceof CanvasElementContainer) {
@@ -7394,7 +8433,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7394
8433
  return [3 /*break*/, 12];
7395
8434
  case 11:
7396
8435
  _c.sent();
7397
- 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)));
7398
8437
  return [3 /*break*/, 12];
7399
8438
  case 12:
7400
8439
  if (!(container instanceof IFrameElementContainer && container.tree)) return [3 /*break*/, 14];
@@ -7445,19 +8484,19 @@ var CanvasRenderer = /** @class */ (function (_super) {
7445
8484
  }
7446
8485
  }
7447
8486
  if (isTextInputElement(container) && container.value.length) {
7448
- _b = this.createFontStyle(styles), fontFamily = _b[0], fontSize = _b[1];
8487
+ _b = this.createFontStyle(styles), font = _b[0], fontFamily = _b[1], fontSize = _b[2];
7449
8488
  baseline = this.fontMetrics.getMetrics(fontFamily, fontSize).baseline;
7450
- this.ctx.font = fontFamily;
8489
+ this.ctx.font = font;
7451
8490
  this.ctx.fillStyle = asString(styles.color);
7452
8491
  this.ctx.textBaseline = 'alphabetic';
7453
8492
  this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
7454
8493
  bounds = contentBox(container);
7455
8494
  x = 0;
7456
8495
  switch (container.styles.textAlign) {
7457
- case 1 /* CENTER */:
8496
+ case 1 /* TEXT_ALIGN.CENTER */:
7458
8497
  x += bounds.width / 2;
7459
8498
  break;
7460
- case 2 /* RIGHT */:
8499
+ case 2 /* TEXT_ALIGN.RIGHT */:
7461
8500
  x += bounds.width;
7462
8501
  break;
7463
8502
  }
@@ -7475,10 +8514,10 @@ var CanvasRenderer = /** @class */ (function (_super) {
7475
8514
  this.ctx.textBaseline = 'alphabetic';
7476
8515
  this.ctx.textAlign = 'left';
7477
8516
  }
7478
- 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];
7479
8518
  if (!(container.styles.listStyleImage !== null)) return [3 /*break*/, 19];
7480
8519
  img = container.styles.listStyleImage;
7481
- if (!(img.type === 0 /* URL */)) return [3 /*break*/, 18];
8520
+ if (!(img.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 18];
7482
8521
  image = void 0;
7483
8522
  url = img.url;
7484
8523
  _c.label = 15;
@@ -7491,13 +8530,13 @@ var CanvasRenderer = /** @class */ (function (_super) {
7491
8530
  return [3 /*break*/, 18];
7492
8531
  case 17:
7493
8532
  _c.sent();
7494
- this.context.logger.error("Error loading list-style-image " + url);
8533
+ this.context.logger.error("Error loading list-style-image ".concat(url));
7495
8534
  return [3 /*break*/, 18];
7496
8535
  case 18: return [3 /*break*/, 20];
7497
8536
  case 19:
7498
- if (paint.listValue && container.styles.listStyleType !== -1 /* NONE */) {
7499
- fontFamily = this.createFontStyle(styles)[0];
7500
- 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;
7501
8540
  this.ctx.fillStyle = asString(styles.color);
7502
8541
  this.ctx.textBaseline = 'middle';
7503
8542
  this.ctx.textAlign = 'right';
@@ -7518,7 +8557,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7518
8557
  return __generator(this, function (_p) {
7519
8558
  switch (_p.label) {
7520
8559
  case 0:
7521
- if (contains(stack.element.container.flags, 16 /* DEBUG_RENDER */)) {
8560
+ if (contains(stack.element.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
7522
8561
  debugger;
7523
8562
  }
7524
8563
  // https://www.w3.org/TR/css-position-3/#painting-order
@@ -7666,10 +8705,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
7666
8705
  this.ctx.translate(-offsetX, -offsetY);
7667
8706
  };
7668
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
+ // }
7669
8712
  var _a;
7670
- if (image.width === width && image.height === height) {
7671
- return image;
7672
- }
7673
8713
  var ownerDocument = (_a = this.canvas.ownerDocument) !== null && _a !== void 0 ? _a : document;
7674
8714
  var canvas = ownerDocument.createElement('canvas');
7675
8715
  canvas.width = Math.max(1, width);
@@ -7686,11 +8726,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
7686
8726
  case 0:
7687
8727
  index = container.styles.backgroundImage.length - 1;
7688
8728
  _loop_1 = function (backgroundImage) {
7689
- 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;
7690
8730
  return __generator(this, function (_h) {
7691
8731
  switch (_h.label) {
7692
8732
  case 0:
7693
- if (!(backgroundImage.type === 0 /* URL */)) return [3 /*break*/, 5];
8733
+ if (!(backgroundImage.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 5];
7694
8734
  image = void 0;
7695
8735
  url = backgroundImage.url;
7696
8736
  _h.label = 1;
@@ -7702,14 +8742,16 @@ var CanvasRenderer = /** @class */ (function (_super) {
7702
8742
  return [3 /*break*/, 4];
7703
8743
  case 3:
7704
8744
  _h.sent();
7705
- this_1.context.logger.error("Error loading background-image " + url);
8745
+ this_1.context.logger.error("Error loading background-image ".concat(url));
7706
8746
  return [3 /*break*/, 4];
7707
8747
  case 4:
7708
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;
7709
8751
  _c = calculateBackgroundRendering(container, index, [
7710
- image.width,
7711
- image.height,
7712
- image.width / image.height
8752
+ imageWidth,
8753
+ imageHeight,
8754
+ imageWidth / imageHeight
7713
8755
  ]), path = _c[0], x = _c[1], y = _c[2], width = _c[3], height = _c[4];
7714
8756
  pattern = this_1.ctx.createPattern(this_1.resizeImage(image, width, height), 'repeat');
7715
8757
  this_1.renderRepeat(path, pattern, x, y);
@@ -7724,7 +8766,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7724
8766
  canvas.height = height;
7725
8767
  ctx = canvas.getContext('2d');
7726
8768
  gradient_1 = ctx.createLinearGradient(x0, y0, x1, y1);
7727
- processColorStops(backgroundImage.stops, lineLength).forEach(function (colorStop) {
8769
+ processColorStops(backgroundImage.stops, lineLength || 1).forEach(function (colorStop) {
7728
8770
  return gradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
7729
8771
  });
7730
8772
  ctx.fillStyle = gradient_1;
@@ -7834,7 +8876,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7834
8876
  return __generator(this, function (_a) {
7835
8877
  switch (_a.label) {
7836
8878
  case 0:
7837
- this.applyEffects(paint.getEffects(2 /* BACKGROUND_BORDERS */));
8879
+ this.applyEffects(paint.getEffects(2 /* EffectTarget.BACKGROUND_BORDERS */));
7838
8880
  styles = paint.container.styles;
7839
8881
  hasBackground = !isTransparent(styles.backgroundColor) || styles.backgroundImage.length;
7840
8882
  borders = [
@@ -7890,20 +8932,20 @@ var CanvasRenderer = /** @class */ (function (_super) {
7890
8932
  case 3:
7891
8933
  if (!(_i < borders_1.length)) return [3 /*break*/, 13];
7892
8934
  border = borders_1[_i];
7893
- if (!(border.style !== 0 /* NONE */ && !isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
7894
- if (!(border.style === 2 /* DASHED */)) return [3 /*break*/, 5];
7895
- 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 */)];
7896
8938
  case 4:
7897
8939
  _a.sent();
7898
8940
  return [3 /*break*/, 11];
7899
8941
  case 5:
7900
- if (!(border.style === 3 /* DOTTED */)) return [3 /*break*/, 7];
7901
- 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 */)];
7902
8944
  case 6:
7903
8945
  _a.sent();
7904
8946
  return [3 /*break*/, 11];
7905
8947
  case 7:
7906
- if (!(border.style === 4 /* DOUBLE */)) return [3 /*break*/, 9];
8948
+ if (!(border.style === 4 /* BORDER_STYLE.DOUBLE */)) return [3 /*break*/, 9];
7907
8949
  return [4 /*yield*/, this.renderDoubleBorder(border.color, border.width, side, paint.curves)];
7908
8950
  case 8:
7909
8951
  _a.sent();
@@ -7930,7 +8972,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7930
8972
  this.ctx.save();
7931
8973
  strokePaths = parsePathForBorderStroke(curvePoints, side);
7932
8974
  boxPaths = parsePathForBorder(curvePoints, side);
7933
- if (style === 2 /* DASHED */) {
8975
+ if (style === 2 /* BORDER_STYLE.DASHED */) {
7934
8976
  this.path(boxPaths);
7935
8977
  this.ctx.clip();
7936
8978
  }
@@ -7957,7 +8999,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7957
8999
  length = Math.abs(startY - endY);
7958
9000
  }
7959
9001
  this.ctx.beginPath();
7960
- if (style === 3 /* DOTTED */) {
9002
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7961
9003
  this.formatPath(strokePaths);
7962
9004
  }
7963
9005
  else {
@@ -7965,7 +9007,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7965
9007
  }
7966
9008
  dashLength = width < 3 ? width * 3 : width * 2;
7967
9009
  spaceLength = width < 3 ? width * 2 : width;
7968
- if (style === 3 /* DOTTED */) {
9010
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7969
9011
  dashLength = width;
7970
9012
  spaceLength = width;
7971
9013
  }
@@ -7988,14 +9030,14 @@ var CanvasRenderer = /** @class */ (function (_super) {
7988
9030
  : maxSpace;
7989
9031
  }
7990
9032
  if (useLineDash) {
7991
- if (style === 3 /* DOTTED */) {
9033
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7992
9034
  this.ctx.setLineDash([0, dashLength + spaceLength]);
7993
9035
  }
7994
9036
  else {
7995
9037
  this.ctx.setLineDash([dashLength, spaceLength]);
7996
9038
  }
7997
9039
  }
7998
- if (style === 3 /* DOTTED */) {
9040
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7999
9041
  this.ctx.lineCap = 'round';
8000
9042
  this.ctx.lineWidth = width;
8001
9043
  }
@@ -8006,7 +9048,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
8006
9048
  this.ctx.stroke();
8007
9049
  this.ctx.setLineDash([]);
8008
9050
  // dashed round edge gap
8009
- if (style === 2 /* DASHED */) {
9051
+ if (style === 2 /* BORDER_STYLE.DASHED */) {
8010
9052
  if (isBezierCurve(boxPaths[0])) {
8011
9053
  path1 = boxPaths[3];
8012
9054
  path2 = boxPaths[0];
@@ -8063,22 +9105,22 @@ var isTextInputElement = function (container) {
8063
9105
  };
8064
9106
  var calculateBackgroundCurvedPaintingArea = function (clip, curves) {
8065
9107
  switch (clip) {
8066
- case 0 /* BORDER_BOX */:
9108
+ case 0 /* BACKGROUND_CLIP.BORDER_BOX */:
8067
9109
  return calculateBorderBoxPath(curves);
8068
- case 2 /* CONTENT_BOX */:
9110
+ case 2 /* BACKGROUND_CLIP.CONTENT_BOX */:
8069
9111
  return calculateContentBoxPath(curves);
8070
- case 1 /* PADDING_BOX */:
9112
+ case 1 /* BACKGROUND_CLIP.PADDING_BOX */:
8071
9113
  default:
8072
9114
  return calculatePaddingBoxPath(curves);
8073
9115
  }
8074
9116
  };
8075
9117
  var canvasTextAlign = function (textAlign) {
8076
9118
  switch (textAlign) {
8077
- case 1 /* CENTER */:
9119
+ case 1 /* TEXT_ALIGN.CENTER */:
8078
9120
  return 'center';
8079
- case 2 /* RIGHT */:
9121
+ case 2 /* TEXT_ALIGN.RIGHT */:
8080
9122
  return 'right';
8081
- case 0 /* LEFT */:
9123
+ case 0 /* TEXT_ALIGN.LEFT */:
8082
9124
  default:
8083
9125
  return 'left';
8084
9126
  }
@@ -8100,11 +9142,11 @@ var ForeignObjectRenderer = /** @class */ (function (_super) {
8100
9142
  _this.options = options;
8101
9143
  _this.canvas.width = Math.floor(options.width * options.scale);
8102
9144
  _this.canvas.height = Math.floor(options.height * options.scale);
8103
- _this.canvas.style.width = options.width + "px";
8104
- _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");
8105
9147
  _this.ctx.scale(_this.options.scale, _this.options.scale);
8106
9148
  _this.ctx.translate(-options.x, -options.y);
8107
- _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));
8108
9150
  return _this;
8109
9151
  }
8110
9152
  ForeignObjectRenderer.prototype.render = function (element) {
@@ -8136,7 +9178,7 @@ var loadSerializedSVG = function (svg) {
8136
9178
  resolve(img);
8137
9179
  };
8138
9180
  img.onerror = reject;
8139
- 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)));
8140
9182
  });
8141
9183
  };
8142
9184
 
@@ -8157,7 +9199,7 @@ var Logger = /** @class */ (function () {
8157
9199
  // eslint-disable-next-line no-console
8158
9200
  if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {
8159
9201
  // eslint-disable-next-line no-console
8160
- 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));
8161
9203
  }
8162
9204
  else {
8163
9205
  this.info.apply(this, args);
@@ -8177,7 +9219,7 @@ var Logger = /** @class */ (function () {
8177
9219
  // eslint-disable-next-line no-console
8178
9220
  if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {
8179
9221
  // eslint-disable-next-line no-console
8180
- 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));
8181
9223
  }
8182
9224
  }
8183
9225
  };
@@ -8191,7 +9233,7 @@ var Logger = /** @class */ (function () {
8191
9233
  // eslint-disable-next-line no-console
8192
9234
  if (typeof window !== 'undefined' && window.console && typeof console.warn === 'function') {
8193
9235
  // eslint-disable-next-line no-console
8194
- 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));
8195
9237
  }
8196
9238
  else {
8197
9239
  this.info.apply(this, args);
@@ -8208,7 +9250,7 @@ var Logger = /** @class */ (function () {
8208
9250
  // eslint-disable-next-line no-console
8209
9251
  if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {
8210
9252
  // eslint-disable-next-line no-console
8211
- 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));
8212
9254
  }
8213
9255
  else {
8214
9256
  this.info.apply(this, args);
@@ -8223,7 +9265,7 @@ var Context = /** @class */ (function () {
8223
9265
  function Context(options, windowBounds) {
8224
9266
  var _a;
8225
9267
  this.windowBounds = windowBounds;
8226
- this.instanceName = "#" + Context.instanceCount++;
9268
+ this.instanceName = "#".concat(Context.instanceCount++);
8227
9269
  this.logger = new Logger({ id: this.instanceName, enabled: options.logging });
8228
9270
  this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new Cache(this, options);
8229
9271
  }
@@ -8259,7 +9301,8 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8259
9301
  allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false,
8260
9302
  imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15000,
8261
9303
  proxy: opts.proxy,
8262
- 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
8263
9306
  };
8264
9307
  contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions);
8265
9308
  windowOptions = {
@@ -8278,7 +9321,7 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8278
9321
  inlineImages: foreignObjectRendering,
8279
9322
  copyStyles: foreignObjectRendering
8280
9323
  };
8281
- 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));
8282
9325
  documentCloner = new DocumentCloner(context, element, cloneOptions);
8283
9326
  clonedElement = documentCloner.clonedReferenceElement;
8284
9327
  if (!clonedElement) {
@@ -8308,13 +9351,13 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8308
9351
  canvas = _u.sent();
8309
9352
  return [3 /*break*/, 5];
8310
9353
  case 3:
8311
- 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"));
8312
9355
  context.logger.debug("Starting DOM parsing");
8313
9356
  root = parseTree(context, clonedElement);
8314
9357
  if (backgroundColor === root.styles.backgroundColor) {
8315
9358
  root.styles.backgroundColor = COLORS.TRANSPARENT;
8316
9359
  }
8317
- 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));
8318
9361
  renderer = new CanvasRenderer(context, renderOptions);
8319
9362
  return [4 /*yield*/, renderer.render(root)];
8320
9363
  case 4:
@@ -8375,38 +9418,38 @@ class Screenshot {
8375
9418
  useCORS: true,
8376
9419
  logging: false,
8377
9420
  width: fullPageWidth,
8378
- height: fullPageHeight
9421
+ height: fullPageHeight,
8379
9422
  });
8380
9423
  // Restore scroll position
8381
9424
  window.scrollTo(0, originalScrollY);
8382
9425
  // Show UXbert UI elements again
8383
9426
  this.showUXbertElements();
8384
9427
  // Convert to base64
8385
- this.currentScreenshot = canvas.toDataURL('image/png');
9428
+ this.currentScreenshot = canvas.toDataURL("image/png");
8386
9429
  return this.currentScreenshot;
8387
9430
  }
8388
9431
  catch (error) {
8389
- console.error('Screenshot capture failed:', error);
9432
+ console.error("Screenshot capture failed:", error);
8390
9433
  this.showUXbertElements();
8391
9434
  throw error;
8392
9435
  }
8393
9436
  }
8394
9437
  hideUXbertElements() {
8395
9438
  const elements = document.querySelectorAll('[class*="uxbert-"]');
8396
- elements.forEach(el => {
9439
+ elements.forEach((el) => {
8397
9440
  const element = el;
8398
- element.setAttribute('data-uxbert-display', element.style.display || '');
8399
- element.style.display = 'none';
9441
+ element.setAttribute("data-uxbert-display", element.style.display || "");
9442
+ element.style.display = "none";
8400
9443
  });
8401
9444
  }
8402
9445
  showUXbertElements() {
8403
9446
  const elements = document.querySelectorAll('[class*="uxbert-"]');
8404
- elements.forEach(el => {
9447
+ elements.forEach((el) => {
8405
9448
  const element = el;
8406
- const originalDisplay = element.getAttribute('data-uxbert-display');
9449
+ const originalDisplay = element.getAttribute("data-uxbert-display");
8407
9450
  if (originalDisplay !== null) {
8408
9451
  element.style.display = originalDisplay;
8409
- element.removeAttribute('data-uxbert-display');
9452
+ element.removeAttribute("data-uxbert-display");
8410
9453
  }
8411
9454
  });
8412
9455
  }
@@ -8825,6 +9868,22 @@ class DeviceInfo {
8825
9868
  this.info = this.collect();
8826
9869
  }
8827
9870
  collect() {
9871
+ // Check if we're in a browser environment
9872
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
9873
+ return {
9874
+ browser: 'SSR',
9875
+ os: 'SSR',
9876
+ screenResolution: '0x0',
9877
+ viewport: '0x0',
9878
+ url: '',
9879
+ timestamp: new Date().toISOString(),
9880
+ userAgent: 'SSR',
9881
+ language: 'en-US',
9882
+ platform: 'SSR',
9883
+ cookiesEnabled: false,
9884
+ onLine: false
9885
+ };
9886
+ }
8828
9887
  return {
8829
9888
  browser: this.getBrowserInfo(),
8830
9889
  os: this.getOSInfo(),
@@ -9008,6 +10067,11 @@ class Reportly {
9008
10067
  this.isInitialized = false;
9009
10068
  }
9010
10069
  init(userConfig = {}) {
10070
+ // Check if we're in a browser environment
10071
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
10072
+ console.warn("Uxbert Reportly can only be initialized in a browser environment");
10073
+ return;
10074
+ }
9011
10075
  if (this.isInitialized) {
9012
10076
  console.warn("Uxbert Reportly is already initialized");
9013
10077
  return;