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