@vuu-ui/vuu-utils 0.8.8-debug → 0.8.9-debug

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.
package/esm/index.js CHANGED
@@ -45,7 +45,7 @@ function itemsOrOrderChanged(currentItems, newItems, identityProperty) {
45
45
  );
46
46
  }
47
47
  }
48
- var moveItem = (items, item, moveTo) => {
48
+ var moveItemDeprecated = (items, item, moveTo) => {
49
49
  const fromIndex = items.indexOf(item);
50
50
  if (fromIndex === moveTo) {
51
51
  return items;
@@ -63,6 +63,28 @@ var moveItem = (items, item, moveTo) => {
63
63
  }
64
64
  return newItems;
65
65
  };
66
+ var moveItem = (items, fromIndex, toIndex) => {
67
+ if (fromIndex === toIndex) {
68
+ return items;
69
+ } else {
70
+ const newItems = items.slice();
71
+ const [item] = newItems.splice(fromIndex, 1);
72
+ if (toIndex === -1) {
73
+ return newItems.concat(item);
74
+ } else {
75
+ const offset = toIndex > fromIndex ? 0 : 0;
76
+ newItems.splice(toIndex + offset, 0, item);
77
+ return newItems;
78
+ }
79
+ }
80
+ };
81
+
82
+ // src/box-utils.ts
83
+ function boxContainsPoint(rect, x, y) {
84
+ if (rect) {
85
+ return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom;
86
+ }
87
+ }
66
88
 
67
89
  // src/filter-utils.ts
68
90
  var singleValueFilterOps = /* @__PURE__ */ new Set([
@@ -83,6 +105,7 @@ var isMultiValueFilter = (f) => f !== void 0 && f.op === "in";
83
105
  var isInFilter = (f) => f.op === "in";
84
106
  var isAndFilter = (f) => f.op === "and";
85
107
  var isOrFilter = (f) => f.op === "or";
108
+ var isCompleteFilter = (filter) => isSingleValueFilter(filter) && filter.column !== void 0 && filter.op !== void 0 && filter.value !== void 0;
86
109
  function isMultiClauseFilter(f) {
87
110
  return f !== void 0 && (f.op === "and" || f.op === "or");
88
111
  }
@@ -132,6 +155,10 @@ function mapSortCriteria(sortCriteria, columnMap, metadataOffset = 0) {
132
155
  }
133
156
  });
134
157
  }
158
+ var numericTypes = ["int", "long", "double"];
159
+ var getDefaultAlignment = (serverDataType) => serverDataType === void 0 ? "left" : numericTypes.includes(serverDataType) ? "right" : "left";
160
+ var isValidColumnAlignment = (v) => v === "left" || v === "right";
161
+ var isValidPinLocation = (v) => isValidColumnAlignment(v) || v === "floating";
135
162
  var isKeyedColumn = (column) => {
136
163
  return typeof column.key === "number";
137
164
  };
@@ -176,6 +203,7 @@ var isSimpleColumnType = (value) => typeof value === "string" && ["string", "num
176
203
  var isTypeDescriptor = (type) => typeof type !== "undefined" && typeof type !== "string";
177
204
  var EMPTY_COLUMN_MAP = {};
178
205
  var isColumnTypeRenderer = (renderer) => typeof (renderer == null ? void 0 : renderer.name) !== "undefined";
206
+ var hasValidationRules = (type) => isTypeDescriptor(type) && isColumnTypeRenderer(type.renderer) && Array.isArray(type.renderer.rules) && type.renderer.rules.length > 0;
179
207
  var isMappedValueTypeRenderer = (renderer) => renderer !== void 0 && typeof (renderer == null ? void 0 : renderer.map) !== "undefined";
180
208
  function buildColumnMap(columns) {
181
209
  const start = metadataKeys.count;
@@ -183,7 +211,7 @@ function buildColumnMap(columns) {
183
211
  return columns.reduce((map, column, i) => {
184
212
  if (typeof column === "string") {
185
213
  map[column] = start + i;
186
- } else if (typeof column.key === "number") {
214
+ } else if (isKeyedColumn(column)) {
187
215
  map[column.name] = column.key;
188
216
  } else {
189
217
  map[column.name] = start + i;
@@ -389,7 +417,7 @@ var getColumnStyle = ({
389
417
  }) => pin === "left" ? {
390
418
  left: pinnedOffset,
391
419
  width,
392
- "--pin-width": `${pinnedOffset + width - 5}px`
420
+ "--pin-width": `${pinnedOffset + width - 3}px`
393
421
  } : pin === "right" ? {
394
422
  right: pinnedOffset,
395
423
  width,
@@ -577,6 +605,155 @@ var getGroupValueAndOffset = (columns, row) => {
577
605
  return [value, depth - 1];
578
606
  }
579
607
  };
608
+ var getDefaultColumnType = (serverDataType) => {
609
+ switch (serverDataType) {
610
+ case "int":
611
+ case "long":
612
+ case "double":
613
+ return "number";
614
+ case "boolean":
615
+ return "boolean";
616
+ default:
617
+ return "string";
618
+ }
619
+ };
620
+ var updateColumnType = (column, formatting) => {
621
+ const { serverDataType, type = getDefaultColumnType(serverDataType) } = column;
622
+ if (typeof type === "string" || type === void 0) {
623
+ return {
624
+ ...column,
625
+ type: {
626
+ name: type,
627
+ formatting
628
+ }
629
+ };
630
+ } else {
631
+ return {
632
+ ...column,
633
+ type: {
634
+ ...type,
635
+ formatting
636
+ }
637
+ };
638
+ }
639
+ };
640
+ var updateColumnRenderer = (column, cellRenderer) => {
641
+ const { serverDataType, type } = column;
642
+ if (type === void 0) {
643
+ return {
644
+ ...column,
645
+ type: {
646
+ name: getDefaultColumnType(serverDataType),
647
+ renderer: {
648
+ name: cellRenderer.name
649
+ }
650
+ }
651
+ };
652
+ } else if (isSimpleColumnType(type)) {
653
+ return {
654
+ ...column,
655
+ type: {
656
+ name: type,
657
+ renderer: {
658
+ name: cellRenderer.name
659
+ }
660
+ }
661
+ };
662
+ } else {
663
+ return {
664
+ ...column,
665
+ type: {
666
+ ...type,
667
+ renderer: {
668
+ name: cellRenderer.name
669
+ }
670
+ }
671
+ };
672
+ }
673
+ };
674
+ var NO_TYPE_SETTINGS = {};
675
+ var getTypeSettingsFromColumn = (column) => {
676
+ var _a;
677
+ if (isTypeDescriptor(column.type)) {
678
+ return (_a = column.type.formatting) != null ? _a : NO_TYPE_SETTINGS;
679
+ } else {
680
+ return NO_TYPE_SETTINGS;
681
+ }
682
+ };
683
+ var subscribedOnly = (columnNames) => (column) => columnNames == null ? void 0 : columnNames.includes(column.name);
684
+ var addColumnToSubscribedColumns = (subscribedColumns, availableColumns, columnName) => {
685
+ const byColName = (n = columnName) => (column) => column.name === n;
686
+ if (subscribedColumns.findIndex(byColName()) !== -1) {
687
+ throw Error(
688
+ `column-utils, addColumnToSubscribedColumns column ${columnName} is already subscribed`
689
+ );
690
+ }
691
+ const indexOfAvailableColumn = availableColumns.findIndex(byColName());
692
+ if (indexOfAvailableColumn === -1) {
693
+ throw Error(
694
+ `column-utils, addColumnToSubscribedColumns column ${columnName} is not available`
695
+ );
696
+ }
697
+ const newColumn = {
698
+ ...availableColumns[indexOfAvailableColumn]
699
+ };
700
+ let index = -1;
701
+ for (let i = indexOfAvailableColumn - 1; i >= 0; i--) {
702
+ const { name } = availableColumns[i];
703
+ index = subscribedColumns.findIndex(byColName(name));
704
+ if (index !== -1) {
705
+ break;
706
+ }
707
+ }
708
+ if (index === -1) {
709
+ return [newColumn].concat(subscribedColumns);
710
+ } else {
711
+ const results = [];
712
+ for (let i = 0; i < subscribedColumns.length; i++) {
713
+ results.push(subscribedColumns[i]);
714
+ if (i === index) {
715
+ results.push(newColumn);
716
+ index = Number.MAX_SAFE_INTEGER;
717
+ }
718
+ }
719
+ return results;
720
+ }
721
+ };
722
+ var CalculatedColumnPattern = /.*:.*:.*/;
723
+ var isCalculatedColumn = (columnName) => columnName !== void 0 && CalculatedColumnPattern.test(columnName);
724
+ var getCalculatedColumnDetails = (column) => {
725
+ if (isCalculatedColumn(column.name)) {
726
+ return column.name.split(":");
727
+ } else {
728
+ throw Error(
729
+ `column-utils, getCalculatedColumnDetails column name ${column.name} is not valid calculated column`
730
+ );
731
+ }
732
+ };
733
+ var getCalculatedColumnName = (column) => getCalculatedColumnDetails(column)[0];
734
+ var getCalculatedColumnExpression = (column) => getCalculatedColumnDetails(column)[1];
735
+ var getCalculatedColumnType = (column) => getCalculatedColumnDetails(column)[2];
736
+ var setCalculatedColumnName = (column, name) => {
737
+ const [, expression, type] = column.name.split(":");
738
+ return {
739
+ ...column,
740
+ name: `${name}:${expression}:${type}`
741
+ };
742
+ };
743
+ var setCalculatedColumnExpression = (column, expression) => {
744
+ const [name, , type] = column.name.split(":");
745
+ return {
746
+ ...column,
747
+ name: `${name}:${expression}:${type}`
748
+ };
749
+ };
750
+ var setCalculatedColumnType = (column, type) => {
751
+ const [name, expression] = column.name.split(":");
752
+ return {
753
+ ...column,
754
+ name: `${name}:${expression}:${type}`
755
+ };
756
+ };
580
757
 
581
758
  // src/cookie-utils.ts
582
759
  var getCookieValue = (name) => {
@@ -589,9 +766,10 @@ var getCookieValue = (name) => {
589
766
  // src/component-registry.ts
590
767
  var cellRenderersMap = /* @__PURE__ */ new Map();
591
768
  var cellConfigPanelsMap = /* @__PURE__ */ new Map();
769
+ var editRuleValidatorsMap = /* @__PURE__ */ new Map();
592
770
  var optionsMap = /* @__PURE__ */ new Map();
593
771
  var isTypeCompatible = (rendererType, serverDataType) => {
594
- if (rendererType === void 0) {
772
+ if (rendererType === void 0 || rendererType === "private") {
595
773
  return true;
596
774
  } else if (Array.isArray(rendererType)) {
597
775
  return rendererType.includes(serverDataType);
@@ -601,11 +779,14 @@ var isTypeCompatible = (rendererType, serverDataType) => {
601
779
  };
602
780
  var isCellRenderer = (type, component) => type === "cell-renderer";
603
781
  var isCellConfigPanel = (type, component) => type === "cell-config-panel";
782
+ var isEditRuleValidator = (type, component) => type === "data-edit-validator";
604
783
  function registerComponent(componentName, component, type = "cell-renderer", options) {
605
784
  if (isCellRenderer(type, component)) {
606
785
  cellRenderersMap.set(componentName, component);
607
786
  } else if (isCellConfigPanel(type, component)) {
608
787
  cellConfigPanelsMap.set(componentName, component);
788
+ } else if (isEditRuleValidator(type, component)) {
789
+ editRuleValidatorsMap.set(componentName, component);
609
790
  }
610
791
  if (options) {
611
792
  optionsMap.set(componentName, options);
@@ -633,8 +814,12 @@ function getCellRenderer(renderer) {
633
814
  function getCellConfigPanelRenderer(name) {
634
815
  return cellConfigPanelsMap.get(name);
635
816
  }
817
+ function getEditRuleValidator(name) {
818
+ return editRuleValidatorsMap.get(name);
819
+ }
636
820
 
637
821
  // src/range-utils.ts
822
+ var NULL_RANGE = { from: 0, to: 0 };
638
823
  function getFullRange({ from, to }, bufferSize = 0, rowCount = Number.MAX_SAFE_INTEGER) {
639
824
  if (bufferSize === 0) {
640
825
  if (rowCount < from) {
@@ -786,6 +971,9 @@ var shallowEquals = (o1 = EMPTY, o2 = EMPTY) => {
786
971
  return props1.length === props2.length && props1.every((key) => o1[key] === o2[key]);
787
972
  };
788
973
  function getMovingValueDirection(newValue, direction, prevValue, decimalPlaces) {
974
+ if (newValue === void 0) {
975
+ return "";
976
+ }
789
977
  if (!isFinite(newValue) || prevValue === void 0 || direction === void 0) {
790
978
  return "";
791
979
  } else {
@@ -948,6 +1136,34 @@ var getFocusableElement = (el, tabIndex) => {
948
1136
  }
949
1137
  }
950
1138
  };
1139
+ var getElementDataIndex = (el) => {
1140
+ if (el) {
1141
+ const index = parseInt(el.dataset.index || "");
1142
+ if (!isNaN(index)) {
1143
+ return index;
1144
+ }
1145
+ }
1146
+ return -1;
1147
+ };
1148
+ var getClosest = (el, dataProperty) => el.closest(`[data-${dataProperty}]`);
1149
+ var getClosestIndexItem = (el) => getClosest(el, "index");
1150
+ function getElementByDataIndex(container, index, throwIfNotFound = false) {
1151
+ if (container === null && throwIfNotFound) {
1152
+ throw Error("html-utils getElementByDataIndex, container is null");
1153
+ }
1154
+ const element = container == null ? void 0 : container.querySelector(
1155
+ `[data-index="${index}"]`
1156
+ );
1157
+ if (element) {
1158
+ return element;
1159
+ } else if (throwIfNotFound) {
1160
+ throw Error(
1161
+ "html-utils getElementByDataIndex, Item not found with data-index='${index}'"
1162
+ );
1163
+ } else {
1164
+ return void 0;
1165
+ }
1166
+ }
951
1167
  var focusFirstFocusableElement = (el, tabIndex) => {
952
1168
  requestAnimationFrame(() => {
953
1169
  const focusableElement = getFocusableElement(el, tabIndex);
@@ -956,6 +1172,46 @@ var focusFirstFocusableElement = (el, tabIndex) => {
956
1172
  }
957
1173
  });
958
1174
  };
1175
+ var isSelectableElement = (el) => {
1176
+ const item = el == null ? void 0 : el.closest("[data-index]");
1177
+ if (!item || item.ariaDisabled || item.dataset.selectable === "false" || item.querySelector('[data-selectable="false"],[aria-disabled="true"]')) {
1178
+ return false;
1179
+ } else {
1180
+ return true;
1181
+ }
1182
+ };
1183
+ var size;
1184
+ function getScrollbarSize() {
1185
+ if (size === void 0) {
1186
+ let outer = document.createElement("div");
1187
+ outer.className = "scrollable-content";
1188
+ outer.style.width = "50px";
1189
+ outer.style.height = "50px";
1190
+ outer.style.overflowY = "scroll";
1191
+ outer.style.position = "absolute";
1192
+ outer.style.top = "-200px";
1193
+ outer.style.left = "-200px";
1194
+ const inner = document.createElement("div");
1195
+ inner.style.height = "100px";
1196
+ inner.style.width = "100%";
1197
+ outer.appendChild(inner);
1198
+ document.body.appendChild(outer);
1199
+ const outerWidth = outer.offsetWidth;
1200
+ const innerWidth = inner.offsetWidth;
1201
+ document.body.removeChild(outer);
1202
+ size = outerWidth - innerWidth;
1203
+ outer = null;
1204
+ }
1205
+ return size;
1206
+ }
1207
+ var dispatchMouseEvent = (el, type) => {
1208
+ const evt = new MouseEvent(type, {
1209
+ view: window,
1210
+ bubbles: true,
1211
+ cancelable: true
1212
+ });
1213
+ el.dispatchEvent(evt);
1214
+ };
959
1215
 
960
1216
  // src/event-emitter.ts
961
1217
  function isArrayOfListeners(listeners) {
@@ -1210,47 +1466,7 @@ function addGroupColumn(groupBy, column) {
1210
1466
  }
1211
1467
 
1212
1468
  // src/input-utils.ts
1213
- var actionKeys = {
1214
- Enter: "Enter",
1215
- Delete: "Delete"
1216
- };
1217
- var navigationKeys = {
1218
- Home: "Home",
1219
- End: "End",
1220
- ArrowRight: "ArrowRight",
1221
- ArrowLeft: "ArrowLeft",
1222
- ArrowDown: "ArrowDown",
1223
- ArrowUp: "ArrowUp",
1224
- Tab: "Tab"
1225
- };
1226
- var functionKeys = {
1227
- F1: "F1",
1228
- F2: "F2",
1229
- F3: "F3",
1230
- F4: "F4",
1231
- F5: "F5",
1232
- F6: "F6",
1233
- F7: "F7",
1234
- F8: "F8",
1235
- F9: "F9",
1236
- F10: "F10",
1237
- F11: "F11",
1238
- F12: "F12"
1239
- };
1240
- var specialKeys = {
1241
- ...actionKeys,
1242
- ...navigationKeys,
1243
- ...functionKeys
1244
- };
1245
- var isSpecialKey = (key) => key in specialKeys;
1246
- var isCharacterKey = (evt) => {
1247
- if (isSpecialKey(evt.key)) {
1248
- return false;
1249
- }
1250
- if (typeof evt.which === "number" && evt.which > 0) {
1251
- return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which !== 8;
1252
- }
1253
- };
1469
+ var isCharacterKey = (key) => key.length === 1;
1254
1470
  var isQuoteKey = (evt) => {
1255
1471
  return evt.key === '"' || evt.key === "'";
1256
1472
  };
@@ -1402,9 +1618,9 @@ var KeySet = class {
1402
1618
  this.keys.delete(rowIndex);
1403
1619
  }
1404
1620
  });
1405
- const size = to - from;
1406
- if (this.keys.size + this.free.length > size) {
1407
- this.free.length = Math.max(0, size - this.keys.size);
1621
+ const size2 = to - from;
1622
+ if (this.keys.size + this.free.length > size2) {
1623
+ this.free.length = Math.max(0, size2 - this.keys.size);
1408
1624
  }
1409
1625
  for (let rowIndex = from; rowIndex < to; rowIndex++) {
1410
1626
  if (!this.keys.has(rowIndex)) {
@@ -1436,11 +1652,11 @@ var KeySet = class {
1436
1652
  var isGroupMenuItemDescriptor = (menuItem) => menuItem !== void 0 && "children" in menuItem;
1437
1653
 
1438
1654
  // src/nanoid/index.ts
1439
- var uuid = (size = 21) => {
1655
+ var uuid = (size2 = 21) => {
1440
1656
  let id = "";
1441
- let bytes = crypto.getRandomValues(new Uint8Array(size));
1442
- while (size--) {
1443
- let byte = bytes[size] & 63;
1657
+ let bytes = crypto.getRandomValues(new Uint8Array(size2));
1658
+ while (size2--) {
1659
+ let byte = bytes[size2] & 63;
1444
1660
  if (byte < 36) {
1445
1661
  id += byte.toString(36);
1446
1662
  } else if (byte < 62) {
@@ -1780,6 +1996,12 @@ var lastWord = (text) => {
1780
1996
  return trimmedText.slice(pos + 1);
1781
1997
  }
1782
1998
  };
1999
+ var capitalize = (text) => text.length === 0 ? "" : text[0].toUpperCase() + text.slice(1);
2000
+ var regexp_worfify = /(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])/;
2001
+ var wordify = (text) => {
2002
+ const [firstWord, ...rest] = text.split(regexp_worfify);
2003
+ return `${capitalize(firstWord)} ${rest.join(" ")}`;
2004
+ };
1783
2005
 
1784
2006
  // src/url-utils.ts
1785
2007
  var getUrlParameter = (paramName, defaultValue) => {
@@ -1787,6 +2009,773 @@ var getUrlParameter = (paramName, defaultValue) => {
1787
2009
  return (_a = new URL(document.location.href).searchParams.get(paramName)) != null ? _a : defaultValue;
1788
2010
  };
1789
2011
  var hasUrlParameter = (paramName) => new URL(document.location.href).searchParams.has(paramName);
2012
+
2013
+ // ../../node_modules/html-to-image/es/util.js
2014
+ function resolveUrl(url, baseUrl) {
2015
+ if (url.match(/^[a-z]+:\/\//i)) {
2016
+ return url;
2017
+ }
2018
+ if (url.match(/^\/\//)) {
2019
+ return window.location.protocol + url;
2020
+ }
2021
+ if (url.match(/^[a-z]+:/i)) {
2022
+ return url;
2023
+ }
2024
+ const doc = document.implementation.createHTMLDocument();
2025
+ const base = doc.createElement("base");
2026
+ const a = doc.createElement("a");
2027
+ doc.head.appendChild(base);
2028
+ doc.body.appendChild(a);
2029
+ if (baseUrl) {
2030
+ base.href = baseUrl;
2031
+ }
2032
+ a.href = url;
2033
+ return a.href;
2034
+ }
2035
+ var uuid2 = (() => {
2036
+ let counter = 0;
2037
+ const random = () => (
2038
+ // eslint-disable-next-line no-bitwise
2039
+ `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4)
2040
+ );
2041
+ return () => {
2042
+ counter += 1;
2043
+ return `u${random()}${counter}`;
2044
+ };
2045
+ })();
2046
+ function toArray(arrayLike) {
2047
+ const arr = [];
2048
+ for (let i = 0, l = arrayLike.length; i < l; i++) {
2049
+ arr.push(arrayLike[i]);
2050
+ }
2051
+ return arr;
2052
+ }
2053
+ function px(node, styleProperty) {
2054
+ const win = node.ownerDocument.defaultView || window;
2055
+ const val = win.getComputedStyle(node).getPropertyValue(styleProperty);
2056
+ return val ? parseFloat(val.replace("px", "")) : 0;
2057
+ }
2058
+ function getNodeWidth(node) {
2059
+ const leftBorder = px(node, "border-left-width");
2060
+ const rightBorder = px(node, "border-right-width");
2061
+ return node.clientWidth + leftBorder + rightBorder;
2062
+ }
2063
+ function getNodeHeight(node) {
2064
+ const topBorder = px(node, "border-top-width");
2065
+ const bottomBorder = px(node, "border-bottom-width");
2066
+ return node.clientHeight + topBorder + bottomBorder;
2067
+ }
2068
+ function getImageSize(targetNode, options = {}) {
2069
+ const width = options.width || getNodeWidth(targetNode);
2070
+ const height = options.height || getNodeHeight(targetNode);
2071
+ return { width, height };
2072
+ }
2073
+ function getPixelRatio() {
2074
+ let ratio;
2075
+ let FINAL_PROCESS;
2076
+ try {
2077
+ FINAL_PROCESS = process;
2078
+ } catch (e) {
2079
+ }
2080
+ const val = FINAL_PROCESS && FINAL_PROCESS.env ? FINAL_PROCESS.env.devicePixelRatio : null;
2081
+ if (val) {
2082
+ ratio = parseInt(val, 10);
2083
+ if (Number.isNaN(ratio)) {
2084
+ ratio = 1;
2085
+ }
2086
+ }
2087
+ return ratio || window.devicePixelRatio || 1;
2088
+ }
2089
+ var canvasDimensionLimit = 16384;
2090
+ function checkCanvasDimensions(canvas) {
2091
+ if (canvas.width > canvasDimensionLimit || canvas.height > canvasDimensionLimit) {
2092
+ if (canvas.width > canvasDimensionLimit && canvas.height > canvasDimensionLimit) {
2093
+ if (canvas.width > canvas.height) {
2094
+ canvas.height *= canvasDimensionLimit / canvas.width;
2095
+ canvas.width = canvasDimensionLimit;
2096
+ } else {
2097
+ canvas.width *= canvasDimensionLimit / canvas.height;
2098
+ canvas.height = canvasDimensionLimit;
2099
+ }
2100
+ } else if (canvas.width > canvasDimensionLimit) {
2101
+ canvas.height *= canvasDimensionLimit / canvas.width;
2102
+ canvas.width = canvasDimensionLimit;
2103
+ } else {
2104
+ canvas.width *= canvasDimensionLimit / canvas.height;
2105
+ canvas.height = canvasDimensionLimit;
2106
+ }
2107
+ }
2108
+ }
2109
+ function createImage(url) {
2110
+ return new Promise((resolve, reject) => {
2111
+ const img = new Image();
2112
+ img.decode = () => resolve(img);
2113
+ img.onload = () => resolve(img);
2114
+ img.onerror = reject;
2115
+ img.crossOrigin = "anonymous";
2116
+ img.decoding = "async";
2117
+ img.src = url;
2118
+ });
2119
+ }
2120
+ async function svgToDataURL(svg) {
2121
+ return Promise.resolve().then(() => new XMLSerializer().serializeToString(svg)).then(encodeURIComponent).then((html) => `data:image/svg+xml;charset=utf-8,${html}`);
2122
+ }
2123
+ async function nodeToDataURL(node, width, height) {
2124
+ const xmlns = "http://www.w3.org/2000/svg";
2125
+ const svg = document.createElementNS(xmlns, "svg");
2126
+ const foreignObject = document.createElementNS(xmlns, "foreignObject");
2127
+ svg.setAttribute("width", `${width}`);
2128
+ svg.setAttribute("height", `${height}`);
2129
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
2130
+ foreignObject.setAttribute("width", "100%");
2131
+ foreignObject.setAttribute("height", "100%");
2132
+ foreignObject.setAttribute("x", "0");
2133
+ foreignObject.setAttribute("y", "0");
2134
+ foreignObject.setAttribute("externalResourcesRequired", "true");
2135
+ svg.appendChild(foreignObject);
2136
+ foreignObject.appendChild(node);
2137
+ return svgToDataURL(svg);
2138
+ }
2139
+ var isInstanceOfElement = (node, instance) => {
2140
+ if (node instanceof instance)
2141
+ return true;
2142
+ const nodePrototype = Object.getPrototypeOf(node);
2143
+ if (nodePrototype === null)
2144
+ return false;
2145
+ return nodePrototype.constructor.name === instance.name || isInstanceOfElement(nodePrototype, instance);
2146
+ };
2147
+
2148
+ // ../../node_modules/html-to-image/es/clone-pseudos.js
2149
+ function formatCSSText(style) {
2150
+ const content = style.getPropertyValue("content");
2151
+ return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
2152
+ }
2153
+ function formatCSSProperties(style) {
2154
+ return toArray(style).map((name) => {
2155
+ const value = style.getPropertyValue(name);
2156
+ const priority = style.getPropertyPriority(name);
2157
+ return `${name}: ${value}${priority ? " !important" : ""};`;
2158
+ }).join(" ");
2159
+ }
2160
+ function getPseudoElementStyle(className, pseudo, style) {
2161
+ const selector = `.${className}:${pseudo}`;
2162
+ const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style);
2163
+ return document.createTextNode(`${selector}{${cssText}}`);
2164
+ }
2165
+ function clonePseudoElement(nativeNode, clonedNode, pseudo) {
2166
+ const style = window.getComputedStyle(nativeNode, pseudo);
2167
+ const content = style.getPropertyValue("content");
2168
+ if (content === "" || content === "none") {
2169
+ return;
2170
+ }
2171
+ const className = uuid2();
2172
+ try {
2173
+ clonedNode.className = `${clonedNode.className} ${className}`;
2174
+ } catch (err) {
2175
+ return;
2176
+ }
2177
+ const styleElement = document.createElement("style");
2178
+ styleElement.appendChild(getPseudoElementStyle(className, pseudo, style));
2179
+ clonedNode.appendChild(styleElement);
2180
+ }
2181
+ function clonePseudoElements(nativeNode, clonedNode) {
2182
+ clonePseudoElement(nativeNode, clonedNode, ":before");
2183
+ clonePseudoElement(nativeNode, clonedNode, ":after");
2184
+ }
2185
+
2186
+ // ../../node_modules/html-to-image/es/mimes.js
2187
+ var WOFF = "application/font-woff";
2188
+ var JPEG = "image/jpeg";
2189
+ var mimes = {
2190
+ woff: WOFF,
2191
+ woff2: WOFF,
2192
+ ttf: "application/font-truetype",
2193
+ eot: "application/vnd.ms-fontobject",
2194
+ png: "image/png",
2195
+ jpg: JPEG,
2196
+ jpeg: JPEG,
2197
+ gif: "image/gif",
2198
+ tiff: "image/tiff",
2199
+ svg: "image/svg+xml",
2200
+ webp: "image/webp"
2201
+ };
2202
+ function getExtension(url) {
2203
+ const match = /\.([^./]*?)$/g.exec(url);
2204
+ return match ? match[1] : "";
2205
+ }
2206
+ function getMimeType(url) {
2207
+ const extension = getExtension(url).toLowerCase();
2208
+ return mimes[extension] || "";
2209
+ }
2210
+
2211
+ // ../../node_modules/html-to-image/es/dataurl.js
2212
+ function getContentFromDataUrl(dataURL) {
2213
+ return dataURL.split(/,/)[1];
2214
+ }
2215
+ function isDataUrl(url) {
2216
+ return url.search(/^(data:)/) !== -1;
2217
+ }
2218
+ function makeDataUrl(content, mimeType) {
2219
+ return `data:${mimeType};base64,${content}`;
2220
+ }
2221
+ async function fetchAsDataURL(url, init, process2) {
2222
+ const res = await fetch(url, init);
2223
+ if (res.status === 404) {
2224
+ throw new Error(`Resource "${res.url}" not found`);
2225
+ }
2226
+ const blob = await res.blob();
2227
+ return new Promise((resolve, reject) => {
2228
+ const reader = new FileReader();
2229
+ reader.onerror = reject;
2230
+ reader.onloadend = () => {
2231
+ try {
2232
+ resolve(process2({ res, result: reader.result }));
2233
+ } catch (error) {
2234
+ reject(error);
2235
+ }
2236
+ };
2237
+ reader.readAsDataURL(blob);
2238
+ });
2239
+ }
2240
+ var cache = {};
2241
+ function getCacheKey(url, contentType, includeQueryParams) {
2242
+ let key = url.replace(/\?.*/, "");
2243
+ if (includeQueryParams) {
2244
+ key = url;
2245
+ }
2246
+ if (/ttf|otf|eot|woff2?/i.test(key)) {
2247
+ key = key.replace(/.*\//, "");
2248
+ }
2249
+ return contentType ? `[${contentType}]${key}` : key;
2250
+ }
2251
+ async function resourceToDataURL(resourceUrl, contentType, options) {
2252
+ const cacheKey = getCacheKey(resourceUrl, contentType, options.includeQueryParams);
2253
+ if (cache[cacheKey] != null) {
2254
+ return cache[cacheKey];
2255
+ }
2256
+ if (options.cacheBust) {
2257
+ resourceUrl += (/\?/.test(resourceUrl) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
2258
+ }
2259
+ let dataURL;
2260
+ try {
2261
+ const content = await fetchAsDataURL(resourceUrl, options.fetchRequestInit, ({ res, result }) => {
2262
+ if (!contentType) {
2263
+ contentType = res.headers.get("Content-Type") || "";
2264
+ }
2265
+ return getContentFromDataUrl(result);
2266
+ });
2267
+ dataURL = makeDataUrl(content, contentType);
2268
+ } catch (error) {
2269
+ dataURL = options.imagePlaceholder || "";
2270
+ let msg = `Failed to fetch resource: ${resourceUrl}`;
2271
+ if (error) {
2272
+ msg = typeof error === "string" ? error : error.message;
2273
+ }
2274
+ if (msg) {
2275
+ console.warn(msg);
2276
+ }
2277
+ }
2278
+ cache[cacheKey] = dataURL;
2279
+ return dataURL;
2280
+ }
2281
+
2282
+ // ../../node_modules/html-to-image/es/clone-node.js
2283
+ async function cloneCanvasElement(canvas) {
2284
+ const dataURL = canvas.toDataURL();
2285
+ if (dataURL === "data:,") {
2286
+ return canvas.cloneNode(false);
2287
+ }
2288
+ return createImage(dataURL);
2289
+ }
2290
+ async function cloneVideoElement(video, options) {
2291
+ if (video.currentSrc) {
2292
+ const canvas = document.createElement("canvas");
2293
+ const ctx = canvas.getContext("2d");
2294
+ canvas.width = video.clientWidth;
2295
+ canvas.height = video.clientHeight;
2296
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
2297
+ const dataURL2 = canvas.toDataURL();
2298
+ return createImage(dataURL2);
2299
+ }
2300
+ const poster = video.poster;
2301
+ const contentType = getMimeType(poster);
2302
+ const dataURL = await resourceToDataURL(poster, contentType, options);
2303
+ return createImage(dataURL);
2304
+ }
2305
+ async function cloneIFrameElement(iframe) {
2306
+ var _a;
2307
+ try {
2308
+ if ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.body) {
2309
+ return await cloneNode(iframe.contentDocument.body, {}, true);
2310
+ }
2311
+ } catch (_b) {
2312
+ }
2313
+ return iframe.cloneNode(false);
2314
+ }
2315
+ async function cloneSingleNode(node, options) {
2316
+ if (isInstanceOfElement(node, HTMLCanvasElement)) {
2317
+ return cloneCanvasElement(node);
2318
+ }
2319
+ if (isInstanceOfElement(node, HTMLVideoElement)) {
2320
+ return cloneVideoElement(node, options);
2321
+ }
2322
+ if (isInstanceOfElement(node, HTMLIFrameElement)) {
2323
+ return cloneIFrameElement(node);
2324
+ }
2325
+ return node.cloneNode(false);
2326
+ }
2327
+ var isSlotElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SLOT";
2328
+ async function cloneChildren(nativeNode, clonedNode, options) {
2329
+ var _a, _b;
2330
+ let children = [];
2331
+ if (isSlotElement(nativeNode) && nativeNode.assignedNodes) {
2332
+ children = toArray(nativeNode.assignedNodes());
2333
+ } else if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && ((_a = nativeNode.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
2334
+ children = toArray(nativeNode.contentDocument.body.childNodes);
2335
+ } else {
2336
+ children = toArray(((_b = nativeNode.shadowRoot) !== null && _b !== void 0 ? _b : nativeNode).childNodes);
2337
+ }
2338
+ if (children.length === 0 || isInstanceOfElement(nativeNode, HTMLVideoElement)) {
2339
+ return clonedNode;
2340
+ }
2341
+ await children.reduce((deferred, child) => deferred.then(() => cloneNode(child, options)).then((clonedChild) => {
2342
+ if (clonedChild) {
2343
+ clonedNode.appendChild(clonedChild);
2344
+ }
2345
+ }), Promise.resolve());
2346
+ return clonedNode;
2347
+ }
2348
+ function cloneCSSStyle(nativeNode, clonedNode) {
2349
+ const targetStyle = clonedNode.style;
2350
+ if (!targetStyle) {
2351
+ return;
2352
+ }
2353
+ const sourceStyle = window.getComputedStyle(nativeNode);
2354
+ if (sourceStyle.cssText) {
2355
+ targetStyle.cssText = sourceStyle.cssText;
2356
+ targetStyle.transformOrigin = sourceStyle.transformOrigin;
2357
+ } else {
2358
+ toArray(sourceStyle).forEach((name) => {
2359
+ let value = sourceStyle.getPropertyValue(name);
2360
+ if (name === "font-size" && value.endsWith("px")) {
2361
+ const reducedFont = Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1;
2362
+ value = `${reducedFont}px`;
2363
+ }
2364
+ if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && name === "display" && value === "inline") {
2365
+ value = "block";
2366
+ }
2367
+ if (name === "d" && clonedNode.getAttribute("d")) {
2368
+ value = `path(${clonedNode.getAttribute("d")})`;
2369
+ }
2370
+ targetStyle.setProperty(name, value, sourceStyle.getPropertyPriority(name));
2371
+ });
2372
+ }
2373
+ }
2374
+ function cloneInputValue(nativeNode, clonedNode) {
2375
+ if (isInstanceOfElement(nativeNode, HTMLTextAreaElement)) {
2376
+ clonedNode.innerHTML = nativeNode.value;
2377
+ }
2378
+ if (isInstanceOfElement(nativeNode, HTMLInputElement)) {
2379
+ clonedNode.setAttribute("value", nativeNode.value);
2380
+ }
2381
+ }
2382
+ function cloneSelectValue(nativeNode, clonedNode) {
2383
+ if (isInstanceOfElement(nativeNode, HTMLSelectElement)) {
2384
+ const clonedSelect = clonedNode;
2385
+ const selectedOption = Array.from(clonedSelect.children).find((child) => nativeNode.value === child.getAttribute("value"));
2386
+ if (selectedOption) {
2387
+ selectedOption.setAttribute("selected", "");
2388
+ }
2389
+ }
2390
+ }
2391
+ function decorate(nativeNode, clonedNode) {
2392
+ if (isInstanceOfElement(clonedNode, Element)) {
2393
+ cloneCSSStyle(nativeNode, clonedNode);
2394
+ clonePseudoElements(nativeNode, clonedNode);
2395
+ cloneInputValue(nativeNode, clonedNode);
2396
+ cloneSelectValue(nativeNode, clonedNode);
2397
+ }
2398
+ return clonedNode;
2399
+ }
2400
+ async function ensureSVGSymbols(clone, options) {
2401
+ const uses = clone.querySelectorAll ? clone.querySelectorAll("use") : [];
2402
+ if (uses.length === 0) {
2403
+ return clone;
2404
+ }
2405
+ const processedDefs = {};
2406
+ for (let i = 0; i < uses.length; i++) {
2407
+ const use = uses[i];
2408
+ const id = use.getAttribute("xlink:href");
2409
+ if (id) {
2410
+ const exist = clone.querySelector(id);
2411
+ const definition = document.querySelector(id);
2412
+ if (!exist && definition && !processedDefs[id]) {
2413
+ processedDefs[id] = await cloneNode(definition, options, true);
2414
+ }
2415
+ }
2416
+ }
2417
+ const nodes = Object.values(processedDefs);
2418
+ if (nodes.length) {
2419
+ const ns = "http://www.w3.org/1999/xhtml";
2420
+ const svg = document.createElementNS(ns, "svg");
2421
+ svg.setAttribute("xmlns", ns);
2422
+ svg.style.position = "absolute";
2423
+ svg.style.width = "0";
2424
+ svg.style.height = "0";
2425
+ svg.style.overflow = "hidden";
2426
+ svg.style.display = "none";
2427
+ const defs = document.createElementNS(ns, "defs");
2428
+ svg.appendChild(defs);
2429
+ for (let i = 0; i < nodes.length; i++) {
2430
+ defs.appendChild(nodes[i]);
2431
+ }
2432
+ clone.appendChild(svg);
2433
+ }
2434
+ return clone;
2435
+ }
2436
+ async function cloneNode(node, options, isRoot) {
2437
+ if (!isRoot && options.filter && !options.filter(node)) {
2438
+ return null;
2439
+ }
2440
+ return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
2441
+ }
2442
+
2443
+ // ../../node_modules/html-to-image/es/embed-resources.js
2444
+ var URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
2445
+ var URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
2446
+ var FONT_SRC_REGEX = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
2447
+ function toRegex(url) {
2448
+ const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
2449
+ return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
2450
+ }
2451
+ function parseURLs(cssText) {
2452
+ const urls = [];
2453
+ cssText.replace(URL_REGEX, (raw, quotation, url) => {
2454
+ urls.push(url);
2455
+ return raw;
2456
+ });
2457
+ return urls.filter((url) => !isDataUrl(url));
2458
+ }
2459
+ async function embed(cssText, resourceURL, baseURL, options, getContentFromUrl) {
2460
+ try {
2461
+ const resolvedURL = baseURL ? resolveUrl(resourceURL, baseURL) : resourceURL;
2462
+ const contentType = getMimeType(resourceURL);
2463
+ let dataURL;
2464
+ if (getContentFromUrl) {
2465
+ const content = await getContentFromUrl(resolvedURL);
2466
+ dataURL = makeDataUrl(content, contentType);
2467
+ } else {
2468
+ dataURL = await resourceToDataURL(resolvedURL, contentType, options);
2469
+ }
2470
+ return cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
2471
+ } catch (error) {
2472
+ }
2473
+ return cssText;
2474
+ }
2475
+ function filterPreferredFontFormat(str, { preferredFontFormat }) {
2476
+ return !preferredFontFormat ? str : str.replace(FONT_SRC_REGEX, (match) => {
2477
+ while (true) {
2478
+ const [src, , format] = URL_WITH_FORMAT_REGEX.exec(match) || [];
2479
+ if (!format) {
2480
+ return "";
2481
+ }
2482
+ if (format === preferredFontFormat) {
2483
+ return `src: ${src};`;
2484
+ }
2485
+ }
2486
+ });
2487
+ }
2488
+ function shouldEmbed(url) {
2489
+ return url.search(URL_REGEX) !== -1;
2490
+ }
2491
+ async function embedResources(cssText, baseUrl, options) {
2492
+ if (!shouldEmbed(cssText)) {
2493
+ return cssText;
2494
+ }
2495
+ const filteredCSSText = filterPreferredFontFormat(cssText, options);
2496
+ const urls = parseURLs(filteredCSSText);
2497
+ return urls.reduce((deferred, url) => deferred.then((css) => embed(css, url, baseUrl, options)), Promise.resolve(filteredCSSText));
2498
+ }
2499
+
2500
+ // ../../node_modules/html-to-image/es/embed-images.js
2501
+ async function embedProp(propName, node, options) {
2502
+ var _a;
2503
+ const propValue = (_a = node.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue(propName);
2504
+ if (propValue) {
2505
+ const cssString = await embedResources(propValue, null, options);
2506
+ node.style.setProperty(propName, cssString, node.style.getPropertyPriority(propName));
2507
+ return true;
2508
+ }
2509
+ return false;
2510
+ }
2511
+ async function embedBackground(clonedNode, options) {
2512
+ if (!await embedProp("background", clonedNode, options)) {
2513
+ await embedProp("background-image", clonedNode, options);
2514
+ }
2515
+ if (!await embedProp("mask", clonedNode, options)) {
2516
+ await embedProp("mask-image", clonedNode, options);
2517
+ }
2518
+ }
2519
+ async function embedImageNode(clonedNode, options) {
2520
+ const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
2521
+ if (!(isImageElement && !isDataUrl(clonedNode.src)) && !(isInstanceOfElement(clonedNode, SVGImageElement) && !isDataUrl(clonedNode.href.baseVal))) {
2522
+ return;
2523
+ }
2524
+ const url = isImageElement ? clonedNode.src : clonedNode.href.baseVal;
2525
+ const dataURL = await resourceToDataURL(url, getMimeType(url), options);
2526
+ await new Promise((resolve, reject) => {
2527
+ clonedNode.onload = resolve;
2528
+ clonedNode.onerror = reject;
2529
+ const image = clonedNode;
2530
+ if (image.decode) {
2531
+ image.decode = resolve;
2532
+ }
2533
+ if (image.loading === "lazy") {
2534
+ image.loading = "eager";
2535
+ }
2536
+ if (isImageElement) {
2537
+ clonedNode.srcset = "";
2538
+ clonedNode.src = dataURL;
2539
+ } else {
2540
+ clonedNode.href.baseVal = dataURL;
2541
+ }
2542
+ });
2543
+ }
2544
+ async function embedChildren(clonedNode, options) {
2545
+ const children = toArray(clonedNode.childNodes);
2546
+ const deferreds = children.map((child) => embedImages(child, options));
2547
+ await Promise.all(deferreds).then(() => clonedNode);
2548
+ }
2549
+ async function embedImages(clonedNode, options) {
2550
+ if (isInstanceOfElement(clonedNode, Element)) {
2551
+ await embedBackground(clonedNode, options);
2552
+ await embedImageNode(clonedNode, options);
2553
+ await embedChildren(clonedNode, options);
2554
+ }
2555
+ }
2556
+
2557
+ // ../../node_modules/html-to-image/es/apply-style.js
2558
+ function applyStyle(node, options) {
2559
+ const { style } = node;
2560
+ if (options.backgroundColor) {
2561
+ style.backgroundColor = options.backgroundColor;
2562
+ }
2563
+ if (options.width) {
2564
+ style.width = `${options.width}px`;
2565
+ }
2566
+ if (options.height) {
2567
+ style.height = `${options.height}px`;
2568
+ }
2569
+ const manual = options.style;
2570
+ if (manual != null) {
2571
+ Object.keys(manual).forEach((key) => {
2572
+ style[key] = manual[key];
2573
+ });
2574
+ }
2575
+ return node;
2576
+ }
2577
+
2578
+ // ../../node_modules/html-to-image/es/embed-webfonts.js
2579
+ var cssFetchCache = {};
2580
+ async function fetchCSS(url) {
2581
+ let cache2 = cssFetchCache[url];
2582
+ if (cache2 != null) {
2583
+ return cache2;
2584
+ }
2585
+ const res = await fetch(url);
2586
+ const cssText = await res.text();
2587
+ cache2 = { url, cssText };
2588
+ cssFetchCache[url] = cache2;
2589
+ return cache2;
2590
+ }
2591
+ async function embedFonts(data, options) {
2592
+ let cssText = data.cssText;
2593
+ const regexUrl = /url\(["']?([^"')]+)["']?\)/g;
2594
+ const fontLocs = cssText.match(/url\([^)]+\)/g) || [];
2595
+ const loadFonts = fontLocs.map(async (loc) => {
2596
+ let url = loc.replace(regexUrl, "$1");
2597
+ if (!url.startsWith("https://")) {
2598
+ url = new URL(url, data.url).href;
2599
+ }
2600
+ return fetchAsDataURL(url, options.fetchRequestInit, ({ result }) => {
2601
+ cssText = cssText.replace(loc, `url(${result})`);
2602
+ return [loc, result];
2603
+ });
2604
+ });
2605
+ return Promise.all(loadFonts).then(() => cssText);
2606
+ }
2607
+ function parseCSS(source) {
2608
+ if (source == null) {
2609
+ return [];
2610
+ }
2611
+ const result = [];
2612
+ const commentsRegex = /(\/\*[\s\S]*?\*\/)/gi;
2613
+ let cssText = source.replace(commentsRegex, "");
2614
+ const keyframesRegex = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
2615
+ while (true) {
2616
+ const matches = keyframesRegex.exec(cssText);
2617
+ if (matches === null) {
2618
+ break;
2619
+ }
2620
+ result.push(matches[0]);
2621
+ }
2622
+ cssText = cssText.replace(keyframesRegex, "");
2623
+ const importRegex = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
2624
+ const combinedCSSRegex = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})";
2625
+ const unifiedRegex = new RegExp(combinedCSSRegex, "gi");
2626
+ while (true) {
2627
+ let matches = importRegex.exec(cssText);
2628
+ if (matches === null) {
2629
+ matches = unifiedRegex.exec(cssText);
2630
+ if (matches === null) {
2631
+ break;
2632
+ } else {
2633
+ importRegex.lastIndex = unifiedRegex.lastIndex;
2634
+ }
2635
+ } else {
2636
+ unifiedRegex.lastIndex = importRegex.lastIndex;
2637
+ }
2638
+ result.push(matches[0]);
2639
+ }
2640
+ return result;
2641
+ }
2642
+ async function getCSSRules(styleSheets, options) {
2643
+ const ret = [];
2644
+ const deferreds = [];
2645
+ styleSheets.forEach((sheet) => {
2646
+ if ("cssRules" in sheet) {
2647
+ try {
2648
+ toArray(sheet.cssRules || []).forEach((item, index) => {
2649
+ if (item.type === CSSRule.IMPORT_RULE) {
2650
+ let importIndex = index + 1;
2651
+ const url = item.href;
2652
+ const deferred = fetchCSS(url).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
2653
+ try {
2654
+ sheet.insertRule(rule, rule.startsWith("@import") ? importIndex += 1 : sheet.cssRules.length);
2655
+ } catch (error) {
2656
+ console.error("Error inserting rule from remote css", {
2657
+ rule,
2658
+ error
2659
+ });
2660
+ }
2661
+ })).catch((e) => {
2662
+ console.error("Error loading remote css", e.toString());
2663
+ });
2664
+ deferreds.push(deferred);
2665
+ }
2666
+ });
2667
+ } catch (e) {
2668
+ const inline = styleSheets.find((a) => a.href == null) || document.styleSheets[0];
2669
+ if (sheet.href != null) {
2670
+ deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
2671
+ inline.insertRule(rule, sheet.cssRules.length);
2672
+ })).catch((err) => {
2673
+ console.error("Error loading remote stylesheet", err);
2674
+ }));
2675
+ }
2676
+ console.error("Error inlining remote css file", e);
2677
+ }
2678
+ }
2679
+ });
2680
+ return Promise.all(deferreds).then(() => {
2681
+ styleSheets.forEach((sheet) => {
2682
+ if ("cssRules" in sheet) {
2683
+ try {
2684
+ toArray(sheet.cssRules || []).forEach((item) => {
2685
+ ret.push(item);
2686
+ });
2687
+ } catch (e) {
2688
+ console.error(`Error while reading CSS rules from ${sheet.href}`, e);
2689
+ }
2690
+ }
2691
+ });
2692
+ return ret;
2693
+ });
2694
+ }
2695
+ function getWebFontRules(cssRules) {
2696
+ return cssRules.filter((rule) => rule.type === CSSRule.FONT_FACE_RULE).filter((rule) => shouldEmbed(rule.style.getPropertyValue("src")));
2697
+ }
2698
+ async function parseWebFontRules(node, options) {
2699
+ if (node.ownerDocument == null) {
2700
+ throw new Error("Provided element is not within a Document");
2701
+ }
2702
+ const styleSheets = toArray(node.ownerDocument.styleSheets);
2703
+ const cssRules = await getCSSRules(styleSheets, options);
2704
+ return getWebFontRules(cssRules);
2705
+ }
2706
+ async function getWebFontCSS(node, options) {
2707
+ const rules = await parseWebFontRules(node, options);
2708
+ const cssTexts = await Promise.all(rules.map((rule) => {
2709
+ const baseUrl = rule.parentStyleSheet ? rule.parentStyleSheet.href : null;
2710
+ return embedResources(rule.cssText, baseUrl, options);
2711
+ }));
2712
+ return cssTexts.join("\n");
2713
+ }
2714
+ async function embedWebFonts(clonedNode, options) {
2715
+ const cssText = options.fontEmbedCSS != null ? options.fontEmbedCSS : options.skipFonts ? null : await getWebFontCSS(clonedNode, options);
2716
+ if (cssText) {
2717
+ const styleNode = document.createElement("style");
2718
+ const sytleContent = document.createTextNode(cssText);
2719
+ styleNode.appendChild(sytleContent);
2720
+ if (clonedNode.firstChild) {
2721
+ clonedNode.insertBefore(styleNode, clonedNode.firstChild);
2722
+ } else {
2723
+ clonedNode.appendChild(styleNode);
2724
+ }
2725
+ }
2726
+ }
2727
+
2728
+ // ../../node_modules/html-to-image/es/index.js
2729
+ async function toSvg(node, options = {}) {
2730
+ const { width, height } = getImageSize(node, options);
2731
+ const clonedNode = await cloneNode(node, options, true);
2732
+ await embedWebFonts(clonedNode, options);
2733
+ await embedImages(clonedNode, options);
2734
+ applyStyle(clonedNode, options);
2735
+ const datauri = await nodeToDataURL(clonedNode, width, height);
2736
+ return datauri;
2737
+ }
2738
+ async function toCanvas(node, options = {}) {
2739
+ const { width, height } = getImageSize(node, options);
2740
+ const svg = await toSvg(node, options);
2741
+ const img = await createImage(svg);
2742
+ const canvas = document.createElement("canvas");
2743
+ const context = canvas.getContext("2d");
2744
+ const ratio = options.pixelRatio || getPixelRatio();
2745
+ const canvasWidth = options.canvasWidth || width;
2746
+ const canvasHeight = options.canvasHeight || height;
2747
+ canvas.width = canvasWidth * ratio;
2748
+ canvas.height = canvasHeight * ratio;
2749
+ if (!options.skipAutoScale) {
2750
+ checkCanvasDimensions(canvas);
2751
+ }
2752
+ canvas.style.width = `${canvasWidth}`;
2753
+ canvas.style.height = `${canvasHeight}`;
2754
+ if (options.backgroundColor) {
2755
+ context.fillStyle = options.backgroundColor;
2756
+ context.fillRect(0, 0, canvas.width, canvas.height);
2757
+ }
2758
+ context.drawImage(img, 0, 0, canvas.width, canvas.height);
2759
+ return canvas;
2760
+ }
2761
+ async function toPng(node, options = {}) {
2762
+ const canvas = await toCanvas(node, options);
2763
+ return canvas.toDataURL();
2764
+ }
2765
+
2766
+ // src/screenshot-utils.ts
2767
+ async function takeScreenshot(node) {
2768
+ const screenshot = await toPng(node, { cacheBust: true }).then((dataUrl) => {
2769
+ return dataUrl;
2770
+ }).catch((err) => {
2771
+ console.error("Error taking screenshot", err);
2772
+ return void 0;
2773
+ });
2774
+ if (!screenshot) {
2775
+ return void 0;
2776
+ }
2777
+ return screenshot;
2778
+ }
1790
2779
  export {
1791
2780
  AggregationType,
1792
2781
  ArrowDown,
@@ -1803,6 +2792,7 @@ export {
1803
2792
  Home,
1804
2793
  KeySet,
1805
2794
  MEASURES,
2795
+ NULL_RANGE,
1806
2796
  PageDown,
1807
2797
  PageUp,
1808
2798
  RangeMonitor,
@@ -1813,18 +2803,21 @@ export {
1813
2803
  UP2,
1814
2804
  WindowRange,
1815
2805
  actualRowPositioning,
2806
+ addColumnToSubscribedColumns,
1816
2807
  addGroupColumn,
1817
2808
  addSortColumn,
1818
2809
  applyFilterToColumns,
1819
2810
  applyGroupByToColumns,
1820
2811
  applySort,
1821
2812
  applySortToColumns,
2813
+ boxContainsPoint,
1822
2814
  buildColumnMap,
1823
2815
  createEl,
1824
2816
  dateFormatter,
1825
2817
  debounce,
1826
2818
  defaultValueFormatter,
1827
2819
  deselectItem,
2820
+ dispatchMouseEvent,
1828
2821
  expandSelection,
1829
2822
  extractFilterForColumn,
1830
2823
  extractGroupColumn,
@@ -1834,12 +2827,23 @@ export {
1834
2827
  focusFirstFocusableElement,
1835
2828
  formatDate,
1836
2829
  fromServerDataType,
2830
+ getCalculatedColumnDetails,
2831
+ getCalculatedColumnExpression,
2832
+ getCalculatedColumnName,
2833
+ getCalculatedColumnType,
1837
2834
  getCellConfigPanelRenderer,
1838
2835
  getCellRenderer,
2836
+ getClosest,
2837
+ getClosestIndexItem,
1839
2838
  getColumnName,
1840
2839
  getColumnStyle,
1841
2840
  getColumnsInViewport,
1842
2841
  getCookieValue,
2842
+ getDefaultAlignment,
2843
+ getDefaultColumnType,
2844
+ getEditRuleValidator,
2845
+ getElementByDataIndex,
2846
+ getElementDataIndex,
1843
2847
  getFocusableElement,
1844
2848
  getFullRange,
1845
2849
  getGroupValueAndOffset,
@@ -1847,17 +2851,22 @@ export {
1847
2851
  getMovingValueDirection,
1848
2852
  getRegisteredCellRenderers,
1849
2853
  getRowRecord,
2854
+ getScrollbarSize,
1850
2855
  getSelectionStatus,
1851
2856
  getTableHeadings,
2857
+ getTypeSettingsFromColumn,
1852
2858
  getUniqueId,
1853
2859
  getUrlParameter,
1854
2860
  getValueFormatter,
1855
2861
  hasHeadings,
1856
2862
  hasUrlParameter,
2863
+ hasValidationRules,
1857
2864
  invariant,
1858
2865
  isAndFilter,
2866
+ isCalculatedColumn,
1859
2867
  isCharacterKey,
1860
2868
  isColumnTypeRenderer,
2869
+ isCompleteFilter,
1861
2870
  isDataLoading,
1862
2871
  isDateColumn,
1863
2872
  isDatePattern,
@@ -1882,6 +2891,7 @@ export {
1882
2891
  isQuoteKey,
1883
2892
  isResizing,
1884
2893
  isRowSelected,
2894
+ isSelectableElement,
1885
2895
  isSelected,
1886
2896
  isSimpleColumnType,
1887
2897
  isSingleValueFilter,
@@ -1889,8 +2899,10 @@ export {
1889
2899
  isTimeColumn,
1890
2900
  isTimePattern,
1891
2901
  isTypeDescriptor,
2902
+ isValidColumnAlignment,
1892
2903
  isValidFilterClauseOp,
1893
2904
  isValidNumber,
2905
+ isValidPinLocation,
1894
2906
  itemToString,
1895
2907
  itemsChanged,
1896
2908
  itemsOrOrderChanged,
@@ -1900,6 +2912,7 @@ export {
1900
2912
  mapSortCriteria,
1901
2913
  metadataKeys,
1902
2914
  moveItem,
2915
+ moveItemDeprecated,
1903
2916
  notHidden,
1904
2917
  numericFormatter,
1905
2918
  partition,
@@ -1911,17 +2924,25 @@ export {
1911
2924
  roundDecimal,
1912
2925
  selectItem,
1913
2926
  setAggregations,
2927
+ setCalculatedColumnExpression,
2928
+ setCalculatedColumnName,
2929
+ setCalculatedColumnType,
1914
2930
  setSortColumn,
1915
2931
  shallowEquals,
1916
2932
  sortPinnedColumns,
1917
2933
  stripFilterFromColumns,
2934
+ subscribedOnly,
2935
+ takeScreenshot,
1918
2936
  throttle,
1919
2937
  toColumnDescriptor,
1920
2938
  toDataSourceColumns,
1921
2939
  updateColumn,
2940
+ updateColumnRenderer,
2941
+ updateColumnType,
1922
2942
  uuid,
1923
2943
  virtualRowPositioning,
1924
2944
  visibleColumnAtIndex,
1925
- withinRange
2945
+ withinRange,
2946
+ wordify
1926
2947
  };
1927
2948
  //# sourceMappingURL=index.js.map