@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/cjs/index.js CHANGED
@@ -48,6 +48,7 @@ __export(src_exports, {
48
48
  Home: () => Home,
49
49
  KeySet: () => KeySet,
50
50
  MEASURES: () => MEASURES,
51
+ NULL_RANGE: () => NULL_RANGE,
51
52
  PageDown: () => PageDown,
52
53
  PageUp: () => PageUp,
53
54
  RangeMonitor: () => RangeMonitor,
@@ -58,18 +59,21 @@ __export(src_exports, {
58
59
  UP2: () => UP2,
59
60
  WindowRange: () => WindowRange,
60
61
  actualRowPositioning: () => actualRowPositioning,
62
+ addColumnToSubscribedColumns: () => addColumnToSubscribedColumns,
61
63
  addGroupColumn: () => addGroupColumn,
62
64
  addSortColumn: () => addSortColumn,
63
65
  applyFilterToColumns: () => applyFilterToColumns,
64
66
  applyGroupByToColumns: () => applyGroupByToColumns,
65
67
  applySort: () => applySort,
66
68
  applySortToColumns: () => applySortToColumns,
69
+ boxContainsPoint: () => boxContainsPoint,
67
70
  buildColumnMap: () => buildColumnMap,
68
71
  createEl: () => createEl,
69
72
  dateFormatter: () => dateFormatter,
70
73
  debounce: () => debounce,
71
74
  defaultValueFormatter: () => defaultValueFormatter,
72
75
  deselectItem: () => deselectItem,
76
+ dispatchMouseEvent: () => dispatchMouseEvent,
73
77
  expandSelection: () => expandSelection,
74
78
  extractFilterForColumn: () => extractFilterForColumn,
75
79
  extractGroupColumn: () => extractGroupColumn,
@@ -79,12 +83,23 @@ __export(src_exports, {
79
83
  focusFirstFocusableElement: () => focusFirstFocusableElement,
80
84
  formatDate: () => formatDate,
81
85
  fromServerDataType: () => fromServerDataType,
86
+ getCalculatedColumnDetails: () => getCalculatedColumnDetails,
87
+ getCalculatedColumnExpression: () => getCalculatedColumnExpression,
88
+ getCalculatedColumnName: () => getCalculatedColumnName,
89
+ getCalculatedColumnType: () => getCalculatedColumnType,
82
90
  getCellConfigPanelRenderer: () => getCellConfigPanelRenderer,
83
91
  getCellRenderer: () => getCellRenderer,
92
+ getClosest: () => getClosest,
93
+ getClosestIndexItem: () => getClosestIndexItem,
84
94
  getColumnName: () => getColumnName,
85
95
  getColumnStyle: () => getColumnStyle,
86
96
  getColumnsInViewport: () => getColumnsInViewport,
87
97
  getCookieValue: () => getCookieValue,
98
+ getDefaultAlignment: () => getDefaultAlignment,
99
+ getDefaultColumnType: () => getDefaultColumnType,
100
+ getEditRuleValidator: () => getEditRuleValidator,
101
+ getElementByDataIndex: () => getElementByDataIndex,
102
+ getElementDataIndex: () => getElementDataIndex,
88
103
  getFocusableElement: () => getFocusableElement,
89
104
  getFullRange: () => getFullRange,
90
105
  getGroupValueAndOffset: () => getGroupValueAndOffset,
@@ -92,17 +107,22 @@ __export(src_exports, {
92
107
  getMovingValueDirection: () => getMovingValueDirection,
93
108
  getRegisteredCellRenderers: () => getRegisteredCellRenderers,
94
109
  getRowRecord: () => getRowRecord,
110
+ getScrollbarSize: () => getScrollbarSize,
95
111
  getSelectionStatus: () => getSelectionStatus,
96
112
  getTableHeadings: () => getTableHeadings,
113
+ getTypeSettingsFromColumn: () => getTypeSettingsFromColumn,
97
114
  getUniqueId: () => getUniqueId,
98
115
  getUrlParameter: () => getUrlParameter,
99
116
  getValueFormatter: () => getValueFormatter,
100
117
  hasHeadings: () => hasHeadings,
101
118
  hasUrlParameter: () => hasUrlParameter,
119
+ hasValidationRules: () => hasValidationRules,
102
120
  invariant: () => invariant,
103
121
  isAndFilter: () => isAndFilter,
122
+ isCalculatedColumn: () => isCalculatedColumn,
104
123
  isCharacterKey: () => isCharacterKey,
105
124
  isColumnTypeRenderer: () => isColumnTypeRenderer,
125
+ isCompleteFilter: () => isCompleteFilter,
106
126
  isDataLoading: () => isDataLoading,
107
127
  isDateColumn: () => isDateColumn,
108
128
  isDatePattern: () => isDatePattern,
@@ -127,6 +147,7 @@ __export(src_exports, {
127
147
  isQuoteKey: () => isQuoteKey,
128
148
  isResizing: () => isResizing,
129
149
  isRowSelected: () => isRowSelected,
150
+ isSelectableElement: () => isSelectableElement,
130
151
  isSelected: () => isSelected,
131
152
  isSimpleColumnType: () => isSimpleColumnType,
132
153
  isSingleValueFilter: () => isSingleValueFilter,
@@ -134,8 +155,10 @@ __export(src_exports, {
134
155
  isTimeColumn: () => isTimeColumn,
135
156
  isTimePattern: () => isTimePattern,
136
157
  isTypeDescriptor: () => isTypeDescriptor,
158
+ isValidColumnAlignment: () => isValidColumnAlignment,
137
159
  isValidFilterClauseOp: () => isValidFilterClauseOp,
138
160
  isValidNumber: () => isValidNumber,
161
+ isValidPinLocation: () => isValidPinLocation,
139
162
  itemToString: () => itemToString,
140
163
  itemsChanged: () => itemsChanged,
141
164
  itemsOrOrderChanged: () => itemsOrOrderChanged,
@@ -145,6 +168,7 @@ __export(src_exports, {
145
168
  mapSortCriteria: () => mapSortCriteria,
146
169
  metadataKeys: () => metadataKeys,
147
170
  moveItem: () => moveItem,
171
+ moveItemDeprecated: () => moveItemDeprecated,
148
172
  notHidden: () => notHidden,
149
173
  numericFormatter: () => numericFormatter,
150
174
  partition: () => partition,
@@ -156,18 +180,26 @@ __export(src_exports, {
156
180
  roundDecimal: () => roundDecimal,
157
181
  selectItem: () => selectItem,
158
182
  setAggregations: () => setAggregations,
183
+ setCalculatedColumnExpression: () => setCalculatedColumnExpression,
184
+ setCalculatedColumnName: () => setCalculatedColumnName,
185
+ setCalculatedColumnType: () => setCalculatedColumnType,
159
186
  setSortColumn: () => setSortColumn,
160
187
  shallowEquals: () => shallowEquals,
161
188
  sortPinnedColumns: () => sortPinnedColumns,
162
189
  stripFilterFromColumns: () => stripFilterFromColumns,
190
+ subscribedOnly: () => subscribedOnly,
191
+ takeScreenshot: () => takeScreenshot,
163
192
  throttle: () => throttle,
164
193
  toColumnDescriptor: () => toColumnDescriptor,
165
194
  toDataSourceColumns: () => toDataSourceColumns,
166
195
  updateColumn: () => updateColumn,
196
+ updateColumnRenderer: () => updateColumnRenderer,
197
+ updateColumnType: () => updateColumnType,
167
198
  uuid: () => uuid,
168
199
  virtualRowPositioning: () => virtualRowPositioning,
169
200
  visibleColumnAtIndex: () => visibleColumnAtIndex,
170
- withinRange: () => withinRange
201
+ withinRange: () => withinRange,
202
+ wordify: () => wordify
171
203
  });
172
204
  module.exports = __toCommonJS(src_exports);
173
205
 
@@ -204,7 +236,7 @@ function itemsOrOrderChanged(currentItems, newItems, identityProperty) {
204
236
  );
205
237
  }
206
238
  }
207
- var moveItem = (items, item, moveTo) => {
239
+ var moveItemDeprecated = (items, item, moveTo) => {
208
240
  const fromIndex = items.indexOf(item);
209
241
  if (fromIndex === moveTo) {
210
242
  return items;
@@ -222,6 +254,28 @@ var moveItem = (items, item, moveTo) => {
222
254
  }
223
255
  return newItems;
224
256
  };
257
+ var moveItem = (items, fromIndex, toIndex) => {
258
+ if (fromIndex === toIndex) {
259
+ return items;
260
+ } else {
261
+ const newItems = items.slice();
262
+ const [item] = newItems.splice(fromIndex, 1);
263
+ if (toIndex === -1) {
264
+ return newItems.concat(item);
265
+ } else {
266
+ const offset = toIndex > fromIndex ? 0 : 0;
267
+ newItems.splice(toIndex + offset, 0, item);
268
+ return newItems;
269
+ }
270
+ }
271
+ };
272
+
273
+ // src/box-utils.ts
274
+ function boxContainsPoint(rect, x, y) {
275
+ if (rect) {
276
+ return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom;
277
+ }
278
+ }
225
279
 
226
280
  // src/filter-utils.ts
227
281
  var singleValueFilterOps = /* @__PURE__ */ new Set([
@@ -242,6 +296,7 @@ var isMultiValueFilter = (f) => f !== void 0 && f.op === "in";
242
296
  var isInFilter = (f) => f.op === "in";
243
297
  var isAndFilter = (f) => f.op === "and";
244
298
  var isOrFilter = (f) => f.op === "or";
299
+ var isCompleteFilter = (filter) => isSingleValueFilter(filter) && filter.column !== void 0 && filter.op !== void 0 && filter.value !== void 0;
245
300
  function isMultiClauseFilter(f) {
246
301
  return f !== void 0 && (f.op === "and" || f.op === "or");
247
302
  }
@@ -291,6 +346,10 @@ function mapSortCriteria(sortCriteria, columnMap, metadataOffset = 0) {
291
346
  }
292
347
  });
293
348
  }
349
+ var numericTypes = ["int", "long", "double"];
350
+ var getDefaultAlignment = (serverDataType) => serverDataType === void 0 ? "left" : numericTypes.includes(serverDataType) ? "right" : "left";
351
+ var isValidColumnAlignment = (v) => v === "left" || v === "right";
352
+ var isValidPinLocation = (v) => isValidColumnAlignment(v) || v === "floating";
294
353
  var isKeyedColumn = (column) => {
295
354
  return typeof column.key === "number";
296
355
  };
@@ -335,6 +394,7 @@ var isSimpleColumnType = (value) => typeof value === "string" && ["string", "num
335
394
  var isTypeDescriptor = (type) => typeof type !== "undefined" && typeof type !== "string";
336
395
  var EMPTY_COLUMN_MAP = {};
337
396
  var isColumnTypeRenderer = (renderer) => typeof (renderer == null ? void 0 : renderer.name) !== "undefined";
397
+ var hasValidationRules = (type) => isTypeDescriptor(type) && isColumnTypeRenderer(type.renderer) && Array.isArray(type.renderer.rules) && type.renderer.rules.length > 0;
338
398
  var isMappedValueTypeRenderer = (renderer) => renderer !== void 0 && typeof (renderer == null ? void 0 : renderer.map) !== "undefined";
339
399
  function buildColumnMap(columns) {
340
400
  const start = metadataKeys.count;
@@ -342,7 +402,7 @@ function buildColumnMap(columns) {
342
402
  return columns.reduce((map, column, i) => {
343
403
  if (typeof column === "string") {
344
404
  map[column] = start + i;
345
- } else if (typeof column.key === "number") {
405
+ } else if (isKeyedColumn(column)) {
346
406
  map[column.name] = column.key;
347
407
  } else {
348
408
  map[column.name] = start + i;
@@ -548,7 +608,7 @@ var getColumnStyle = ({
548
608
  }) => pin === "left" ? {
549
609
  left: pinnedOffset,
550
610
  width,
551
- "--pin-width": `${pinnedOffset + width - 5}px`
611
+ "--pin-width": `${pinnedOffset + width - 3}px`
552
612
  } : pin === "right" ? {
553
613
  right: pinnedOffset,
554
614
  width,
@@ -736,6 +796,155 @@ var getGroupValueAndOffset = (columns, row) => {
736
796
  return [value, depth - 1];
737
797
  }
738
798
  };
799
+ var getDefaultColumnType = (serverDataType) => {
800
+ switch (serverDataType) {
801
+ case "int":
802
+ case "long":
803
+ case "double":
804
+ return "number";
805
+ case "boolean":
806
+ return "boolean";
807
+ default:
808
+ return "string";
809
+ }
810
+ };
811
+ var updateColumnType = (column, formatting) => {
812
+ const { serverDataType, type = getDefaultColumnType(serverDataType) } = column;
813
+ if (typeof type === "string" || type === void 0) {
814
+ return {
815
+ ...column,
816
+ type: {
817
+ name: type,
818
+ formatting
819
+ }
820
+ };
821
+ } else {
822
+ return {
823
+ ...column,
824
+ type: {
825
+ ...type,
826
+ formatting
827
+ }
828
+ };
829
+ }
830
+ };
831
+ var updateColumnRenderer = (column, cellRenderer) => {
832
+ const { serverDataType, type } = column;
833
+ if (type === void 0) {
834
+ return {
835
+ ...column,
836
+ type: {
837
+ name: getDefaultColumnType(serverDataType),
838
+ renderer: {
839
+ name: cellRenderer.name
840
+ }
841
+ }
842
+ };
843
+ } else if (isSimpleColumnType(type)) {
844
+ return {
845
+ ...column,
846
+ type: {
847
+ name: type,
848
+ renderer: {
849
+ name: cellRenderer.name
850
+ }
851
+ }
852
+ };
853
+ } else {
854
+ return {
855
+ ...column,
856
+ type: {
857
+ ...type,
858
+ renderer: {
859
+ name: cellRenderer.name
860
+ }
861
+ }
862
+ };
863
+ }
864
+ };
865
+ var NO_TYPE_SETTINGS = {};
866
+ var getTypeSettingsFromColumn = (column) => {
867
+ var _a;
868
+ if (isTypeDescriptor(column.type)) {
869
+ return (_a = column.type.formatting) != null ? _a : NO_TYPE_SETTINGS;
870
+ } else {
871
+ return NO_TYPE_SETTINGS;
872
+ }
873
+ };
874
+ var subscribedOnly = (columnNames) => (column) => columnNames == null ? void 0 : columnNames.includes(column.name);
875
+ var addColumnToSubscribedColumns = (subscribedColumns, availableColumns, columnName) => {
876
+ const byColName = (n = columnName) => (column) => column.name === n;
877
+ if (subscribedColumns.findIndex(byColName()) !== -1) {
878
+ throw Error(
879
+ `column-utils, addColumnToSubscribedColumns column ${columnName} is already subscribed`
880
+ );
881
+ }
882
+ const indexOfAvailableColumn = availableColumns.findIndex(byColName());
883
+ if (indexOfAvailableColumn === -1) {
884
+ throw Error(
885
+ `column-utils, addColumnToSubscribedColumns column ${columnName} is not available`
886
+ );
887
+ }
888
+ const newColumn = {
889
+ ...availableColumns[indexOfAvailableColumn]
890
+ };
891
+ let index = -1;
892
+ for (let i = indexOfAvailableColumn - 1; i >= 0; i--) {
893
+ const { name } = availableColumns[i];
894
+ index = subscribedColumns.findIndex(byColName(name));
895
+ if (index !== -1) {
896
+ break;
897
+ }
898
+ }
899
+ if (index === -1) {
900
+ return [newColumn].concat(subscribedColumns);
901
+ } else {
902
+ const results = [];
903
+ for (let i = 0; i < subscribedColumns.length; i++) {
904
+ results.push(subscribedColumns[i]);
905
+ if (i === index) {
906
+ results.push(newColumn);
907
+ index = Number.MAX_SAFE_INTEGER;
908
+ }
909
+ }
910
+ return results;
911
+ }
912
+ };
913
+ var CalculatedColumnPattern = /.*:.*:.*/;
914
+ var isCalculatedColumn = (columnName) => columnName !== void 0 && CalculatedColumnPattern.test(columnName);
915
+ var getCalculatedColumnDetails = (column) => {
916
+ if (isCalculatedColumn(column.name)) {
917
+ return column.name.split(":");
918
+ } else {
919
+ throw Error(
920
+ `column-utils, getCalculatedColumnDetails column name ${column.name} is not valid calculated column`
921
+ );
922
+ }
923
+ };
924
+ var getCalculatedColumnName = (column) => getCalculatedColumnDetails(column)[0];
925
+ var getCalculatedColumnExpression = (column) => getCalculatedColumnDetails(column)[1];
926
+ var getCalculatedColumnType = (column) => getCalculatedColumnDetails(column)[2];
927
+ var setCalculatedColumnName = (column, name) => {
928
+ const [, expression, type] = column.name.split(":");
929
+ return {
930
+ ...column,
931
+ name: `${name}:${expression}:${type}`
932
+ };
933
+ };
934
+ var setCalculatedColumnExpression = (column, expression) => {
935
+ const [name, , type] = column.name.split(":");
936
+ return {
937
+ ...column,
938
+ name: `${name}:${expression}:${type}`
939
+ };
940
+ };
941
+ var setCalculatedColumnType = (column, type) => {
942
+ const [name, expression] = column.name.split(":");
943
+ return {
944
+ ...column,
945
+ name: `${name}:${expression}:${type}`
946
+ };
947
+ };
739
948
 
740
949
  // src/cookie-utils.ts
741
950
  var getCookieValue = (name) => {
@@ -748,9 +957,10 @@ var getCookieValue = (name) => {
748
957
  // src/component-registry.ts
749
958
  var cellRenderersMap = /* @__PURE__ */ new Map();
750
959
  var cellConfigPanelsMap = /* @__PURE__ */ new Map();
960
+ var editRuleValidatorsMap = /* @__PURE__ */ new Map();
751
961
  var optionsMap = /* @__PURE__ */ new Map();
752
962
  var isTypeCompatible = (rendererType, serverDataType) => {
753
- if (rendererType === void 0) {
963
+ if (rendererType === void 0 || rendererType === "private") {
754
964
  return true;
755
965
  } else if (Array.isArray(rendererType)) {
756
966
  return rendererType.includes(serverDataType);
@@ -760,11 +970,14 @@ var isTypeCompatible = (rendererType, serverDataType) => {
760
970
  };
761
971
  var isCellRenderer = (type, component) => type === "cell-renderer";
762
972
  var isCellConfigPanel = (type, component) => type === "cell-config-panel";
973
+ var isEditRuleValidator = (type, component) => type === "data-edit-validator";
763
974
  function registerComponent(componentName, component, type = "cell-renderer", options) {
764
975
  if (isCellRenderer(type, component)) {
765
976
  cellRenderersMap.set(componentName, component);
766
977
  } else if (isCellConfigPanel(type, component)) {
767
978
  cellConfigPanelsMap.set(componentName, component);
979
+ } else if (isEditRuleValidator(type, component)) {
980
+ editRuleValidatorsMap.set(componentName, component);
768
981
  }
769
982
  if (options) {
770
983
  optionsMap.set(componentName, options);
@@ -792,8 +1005,12 @@ function getCellRenderer(renderer) {
792
1005
  function getCellConfigPanelRenderer(name) {
793
1006
  return cellConfigPanelsMap.get(name);
794
1007
  }
1008
+ function getEditRuleValidator(name) {
1009
+ return editRuleValidatorsMap.get(name);
1010
+ }
795
1011
 
796
1012
  // src/range-utils.ts
1013
+ var NULL_RANGE = { from: 0, to: 0 };
797
1014
  function getFullRange({ from, to }, bufferSize = 0, rowCount = Number.MAX_SAFE_INTEGER) {
798
1015
  if (bufferSize === 0) {
799
1016
  if (rowCount < from) {
@@ -945,6 +1162,9 @@ var shallowEquals = (o1 = EMPTY, o2 = EMPTY) => {
945
1162
  return props1.length === props2.length && props1.every((key) => o1[key] === o2[key]);
946
1163
  };
947
1164
  function getMovingValueDirection(newValue, direction, prevValue, decimalPlaces) {
1165
+ if (newValue === void 0) {
1166
+ return "";
1167
+ }
948
1168
  if (!isFinite(newValue) || prevValue === void 0 || direction === void 0) {
949
1169
  return "";
950
1170
  } else {
@@ -1107,6 +1327,34 @@ var getFocusableElement = (el, tabIndex) => {
1107
1327
  }
1108
1328
  }
1109
1329
  };
1330
+ var getElementDataIndex = (el) => {
1331
+ if (el) {
1332
+ const index = parseInt(el.dataset.index || "");
1333
+ if (!isNaN(index)) {
1334
+ return index;
1335
+ }
1336
+ }
1337
+ return -1;
1338
+ };
1339
+ var getClosest = (el, dataProperty) => el.closest(`[data-${dataProperty}]`);
1340
+ var getClosestIndexItem = (el) => getClosest(el, "index");
1341
+ function getElementByDataIndex(container, index, throwIfNotFound = false) {
1342
+ if (container === null && throwIfNotFound) {
1343
+ throw Error("html-utils getElementByDataIndex, container is null");
1344
+ }
1345
+ const element = container == null ? void 0 : container.querySelector(
1346
+ `[data-index="${index}"]`
1347
+ );
1348
+ if (element) {
1349
+ return element;
1350
+ } else if (throwIfNotFound) {
1351
+ throw Error(
1352
+ "html-utils getElementByDataIndex, Item not found with data-index='${index}'"
1353
+ );
1354
+ } else {
1355
+ return void 0;
1356
+ }
1357
+ }
1110
1358
  var focusFirstFocusableElement = (el, tabIndex) => {
1111
1359
  requestAnimationFrame(() => {
1112
1360
  const focusableElement = getFocusableElement(el, tabIndex);
@@ -1115,6 +1363,46 @@ var focusFirstFocusableElement = (el, tabIndex) => {
1115
1363
  }
1116
1364
  });
1117
1365
  };
1366
+ var isSelectableElement = (el) => {
1367
+ const item = el == null ? void 0 : el.closest("[data-index]");
1368
+ if (!item || item.ariaDisabled || item.dataset.selectable === "false" || item.querySelector('[data-selectable="false"],[aria-disabled="true"]')) {
1369
+ return false;
1370
+ } else {
1371
+ return true;
1372
+ }
1373
+ };
1374
+ var size;
1375
+ function getScrollbarSize() {
1376
+ if (size === void 0) {
1377
+ let outer = document.createElement("div");
1378
+ outer.className = "scrollable-content";
1379
+ outer.style.width = "50px";
1380
+ outer.style.height = "50px";
1381
+ outer.style.overflowY = "scroll";
1382
+ outer.style.position = "absolute";
1383
+ outer.style.top = "-200px";
1384
+ outer.style.left = "-200px";
1385
+ const inner = document.createElement("div");
1386
+ inner.style.height = "100px";
1387
+ inner.style.width = "100%";
1388
+ outer.appendChild(inner);
1389
+ document.body.appendChild(outer);
1390
+ const outerWidth = outer.offsetWidth;
1391
+ const innerWidth = inner.offsetWidth;
1392
+ document.body.removeChild(outer);
1393
+ size = outerWidth - innerWidth;
1394
+ outer = null;
1395
+ }
1396
+ return size;
1397
+ }
1398
+ var dispatchMouseEvent = (el, type) => {
1399
+ const evt = new MouseEvent(type, {
1400
+ view: window,
1401
+ bubbles: true,
1402
+ cancelable: true
1403
+ });
1404
+ el.dispatchEvent(evt);
1405
+ };
1118
1406
 
1119
1407
  // src/event-emitter.ts
1120
1408
  function isArrayOfListeners(listeners) {
@@ -1369,47 +1657,7 @@ function addGroupColumn(groupBy, column) {
1369
1657
  }
1370
1658
 
1371
1659
  // src/input-utils.ts
1372
- var actionKeys = {
1373
- Enter: "Enter",
1374
- Delete: "Delete"
1375
- };
1376
- var navigationKeys = {
1377
- Home: "Home",
1378
- End: "End",
1379
- ArrowRight: "ArrowRight",
1380
- ArrowLeft: "ArrowLeft",
1381
- ArrowDown: "ArrowDown",
1382
- ArrowUp: "ArrowUp",
1383
- Tab: "Tab"
1384
- };
1385
- var functionKeys = {
1386
- F1: "F1",
1387
- F2: "F2",
1388
- F3: "F3",
1389
- F4: "F4",
1390
- F5: "F5",
1391
- F6: "F6",
1392
- F7: "F7",
1393
- F8: "F8",
1394
- F9: "F9",
1395
- F10: "F10",
1396
- F11: "F11",
1397
- F12: "F12"
1398
- };
1399
- var specialKeys = {
1400
- ...actionKeys,
1401
- ...navigationKeys,
1402
- ...functionKeys
1403
- };
1404
- var isSpecialKey = (key) => key in specialKeys;
1405
- var isCharacterKey = (evt) => {
1406
- if (isSpecialKey(evt.key)) {
1407
- return false;
1408
- }
1409
- if (typeof evt.which === "number" && evt.which > 0) {
1410
- return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which !== 8;
1411
- }
1412
- };
1660
+ var isCharacterKey = (key) => key.length === 1;
1413
1661
  var isQuoteKey = (evt) => {
1414
1662
  return evt.key === '"' || evt.key === "'";
1415
1663
  };
@@ -1561,9 +1809,9 @@ var KeySet = class {
1561
1809
  this.keys.delete(rowIndex);
1562
1810
  }
1563
1811
  });
1564
- const size = to - from;
1565
- if (this.keys.size + this.free.length > size) {
1566
- this.free.length = Math.max(0, size - this.keys.size);
1812
+ const size2 = to - from;
1813
+ if (this.keys.size + this.free.length > size2) {
1814
+ this.free.length = Math.max(0, size2 - this.keys.size);
1567
1815
  }
1568
1816
  for (let rowIndex = from; rowIndex < to; rowIndex++) {
1569
1817
  if (!this.keys.has(rowIndex)) {
@@ -1595,11 +1843,11 @@ var KeySet = class {
1595
1843
  var isGroupMenuItemDescriptor = (menuItem) => menuItem !== void 0 && "children" in menuItem;
1596
1844
 
1597
1845
  // src/nanoid/index.ts
1598
- var uuid = (size = 21) => {
1846
+ var uuid = (size2 = 21) => {
1599
1847
  let id = "";
1600
- let bytes = crypto.getRandomValues(new Uint8Array(size));
1601
- while (size--) {
1602
- let byte = bytes[size] & 63;
1848
+ let bytes = crypto.getRandomValues(new Uint8Array(size2));
1849
+ while (size2--) {
1850
+ let byte = bytes[size2] & 63;
1603
1851
  if (byte < 36) {
1604
1852
  id += byte.toString(36);
1605
1853
  } else if (byte < 62) {
@@ -1939,6 +2187,12 @@ var lastWord = (text) => {
1939
2187
  return trimmedText.slice(pos + 1);
1940
2188
  }
1941
2189
  };
2190
+ var capitalize = (text) => text.length === 0 ? "" : text[0].toUpperCase() + text.slice(1);
2191
+ var regexp_worfify = /(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])/;
2192
+ var wordify = (text) => {
2193
+ const [firstWord, ...rest] = text.split(regexp_worfify);
2194
+ return `${capitalize(firstWord)} ${rest.join(" ")}`;
2195
+ };
1942
2196
 
1943
2197
  // src/url-utils.ts
1944
2198
  var getUrlParameter = (paramName, defaultValue) => {
@@ -1946,4 +2200,771 @@ var getUrlParameter = (paramName, defaultValue) => {
1946
2200
  return (_a = new URL(document.location.href).searchParams.get(paramName)) != null ? _a : defaultValue;
1947
2201
  };
1948
2202
  var hasUrlParameter = (paramName) => new URL(document.location.href).searchParams.has(paramName);
2203
+
2204
+ // ../../node_modules/html-to-image/es/util.js
2205
+ function resolveUrl(url, baseUrl) {
2206
+ if (url.match(/^[a-z]+:\/\//i)) {
2207
+ return url;
2208
+ }
2209
+ if (url.match(/^\/\//)) {
2210
+ return window.location.protocol + url;
2211
+ }
2212
+ if (url.match(/^[a-z]+:/i)) {
2213
+ return url;
2214
+ }
2215
+ const doc = document.implementation.createHTMLDocument();
2216
+ const base = doc.createElement("base");
2217
+ const a = doc.createElement("a");
2218
+ doc.head.appendChild(base);
2219
+ doc.body.appendChild(a);
2220
+ if (baseUrl) {
2221
+ base.href = baseUrl;
2222
+ }
2223
+ a.href = url;
2224
+ return a.href;
2225
+ }
2226
+ var uuid2 = (() => {
2227
+ let counter = 0;
2228
+ const random = () => (
2229
+ // eslint-disable-next-line no-bitwise
2230
+ `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4)
2231
+ );
2232
+ return () => {
2233
+ counter += 1;
2234
+ return `u${random()}${counter}`;
2235
+ };
2236
+ })();
2237
+ function toArray(arrayLike) {
2238
+ const arr = [];
2239
+ for (let i = 0, l = arrayLike.length; i < l; i++) {
2240
+ arr.push(arrayLike[i]);
2241
+ }
2242
+ return arr;
2243
+ }
2244
+ function px(node, styleProperty) {
2245
+ const win = node.ownerDocument.defaultView || window;
2246
+ const val = win.getComputedStyle(node).getPropertyValue(styleProperty);
2247
+ return val ? parseFloat(val.replace("px", "")) : 0;
2248
+ }
2249
+ function getNodeWidth(node) {
2250
+ const leftBorder = px(node, "border-left-width");
2251
+ const rightBorder = px(node, "border-right-width");
2252
+ return node.clientWidth + leftBorder + rightBorder;
2253
+ }
2254
+ function getNodeHeight(node) {
2255
+ const topBorder = px(node, "border-top-width");
2256
+ const bottomBorder = px(node, "border-bottom-width");
2257
+ return node.clientHeight + topBorder + bottomBorder;
2258
+ }
2259
+ function getImageSize(targetNode, options = {}) {
2260
+ const width = options.width || getNodeWidth(targetNode);
2261
+ const height = options.height || getNodeHeight(targetNode);
2262
+ return { width, height };
2263
+ }
2264
+ function getPixelRatio() {
2265
+ let ratio;
2266
+ let FINAL_PROCESS;
2267
+ try {
2268
+ FINAL_PROCESS = process;
2269
+ } catch (e) {
2270
+ }
2271
+ const val = FINAL_PROCESS && FINAL_PROCESS.env ? FINAL_PROCESS.env.devicePixelRatio : null;
2272
+ if (val) {
2273
+ ratio = parseInt(val, 10);
2274
+ if (Number.isNaN(ratio)) {
2275
+ ratio = 1;
2276
+ }
2277
+ }
2278
+ return ratio || window.devicePixelRatio || 1;
2279
+ }
2280
+ var canvasDimensionLimit = 16384;
2281
+ function checkCanvasDimensions(canvas) {
2282
+ if (canvas.width > canvasDimensionLimit || canvas.height > canvasDimensionLimit) {
2283
+ if (canvas.width > canvasDimensionLimit && canvas.height > canvasDimensionLimit) {
2284
+ if (canvas.width > canvas.height) {
2285
+ canvas.height *= canvasDimensionLimit / canvas.width;
2286
+ canvas.width = canvasDimensionLimit;
2287
+ } else {
2288
+ canvas.width *= canvasDimensionLimit / canvas.height;
2289
+ canvas.height = canvasDimensionLimit;
2290
+ }
2291
+ } else if (canvas.width > canvasDimensionLimit) {
2292
+ canvas.height *= canvasDimensionLimit / canvas.width;
2293
+ canvas.width = canvasDimensionLimit;
2294
+ } else {
2295
+ canvas.width *= canvasDimensionLimit / canvas.height;
2296
+ canvas.height = canvasDimensionLimit;
2297
+ }
2298
+ }
2299
+ }
2300
+ function createImage(url) {
2301
+ return new Promise((resolve, reject) => {
2302
+ const img = new Image();
2303
+ img.decode = () => resolve(img);
2304
+ img.onload = () => resolve(img);
2305
+ img.onerror = reject;
2306
+ img.crossOrigin = "anonymous";
2307
+ img.decoding = "async";
2308
+ img.src = url;
2309
+ });
2310
+ }
2311
+ async function svgToDataURL(svg) {
2312
+ return Promise.resolve().then(() => new XMLSerializer().serializeToString(svg)).then(encodeURIComponent).then((html) => `data:image/svg+xml;charset=utf-8,${html}`);
2313
+ }
2314
+ async function nodeToDataURL(node, width, height) {
2315
+ const xmlns = "http://www.w3.org/2000/svg";
2316
+ const svg = document.createElementNS(xmlns, "svg");
2317
+ const foreignObject = document.createElementNS(xmlns, "foreignObject");
2318
+ svg.setAttribute("width", `${width}`);
2319
+ svg.setAttribute("height", `${height}`);
2320
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
2321
+ foreignObject.setAttribute("width", "100%");
2322
+ foreignObject.setAttribute("height", "100%");
2323
+ foreignObject.setAttribute("x", "0");
2324
+ foreignObject.setAttribute("y", "0");
2325
+ foreignObject.setAttribute("externalResourcesRequired", "true");
2326
+ svg.appendChild(foreignObject);
2327
+ foreignObject.appendChild(node);
2328
+ return svgToDataURL(svg);
2329
+ }
2330
+ var isInstanceOfElement = (node, instance) => {
2331
+ if (node instanceof instance)
2332
+ return true;
2333
+ const nodePrototype = Object.getPrototypeOf(node);
2334
+ if (nodePrototype === null)
2335
+ return false;
2336
+ return nodePrototype.constructor.name === instance.name || isInstanceOfElement(nodePrototype, instance);
2337
+ };
2338
+
2339
+ // ../../node_modules/html-to-image/es/clone-pseudos.js
2340
+ function formatCSSText(style) {
2341
+ const content = style.getPropertyValue("content");
2342
+ return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
2343
+ }
2344
+ function formatCSSProperties(style) {
2345
+ return toArray(style).map((name) => {
2346
+ const value = style.getPropertyValue(name);
2347
+ const priority = style.getPropertyPriority(name);
2348
+ return `${name}: ${value}${priority ? " !important" : ""};`;
2349
+ }).join(" ");
2350
+ }
2351
+ function getPseudoElementStyle(className, pseudo, style) {
2352
+ const selector = `.${className}:${pseudo}`;
2353
+ const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style);
2354
+ return document.createTextNode(`${selector}{${cssText}}`);
2355
+ }
2356
+ function clonePseudoElement(nativeNode, clonedNode, pseudo) {
2357
+ const style = window.getComputedStyle(nativeNode, pseudo);
2358
+ const content = style.getPropertyValue("content");
2359
+ if (content === "" || content === "none") {
2360
+ return;
2361
+ }
2362
+ const className = uuid2();
2363
+ try {
2364
+ clonedNode.className = `${clonedNode.className} ${className}`;
2365
+ } catch (err) {
2366
+ return;
2367
+ }
2368
+ const styleElement = document.createElement("style");
2369
+ styleElement.appendChild(getPseudoElementStyle(className, pseudo, style));
2370
+ clonedNode.appendChild(styleElement);
2371
+ }
2372
+ function clonePseudoElements(nativeNode, clonedNode) {
2373
+ clonePseudoElement(nativeNode, clonedNode, ":before");
2374
+ clonePseudoElement(nativeNode, clonedNode, ":after");
2375
+ }
2376
+
2377
+ // ../../node_modules/html-to-image/es/mimes.js
2378
+ var WOFF = "application/font-woff";
2379
+ var JPEG = "image/jpeg";
2380
+ var mimes = {
2381
+ woff: WOFF,
2382
+ woff2: WOFF,
2383
+ ttf: "application/font-truetype",
2384
+ eot: "application/vnd.ms-fontobject",
2385
+ png: "image/png",
2386
+ jpg: JPEG,
2387
+ jpeg: JPEG,
2388
+ gif: "image/gif",
2389
+ tiff: "image/tiff",
2390
+ svg: "image/svg+xml",
2391
+ webp: "image/webp"
2392
+ };
2393
+ function getExtension(url) {
2394
+ const match = /\.([^./]*?)$/g.exec(url);
2395
+ return match ? match[1] : "";
2396
+ }
2397
+ function getMimeType(url) {
2398
+ const extension = getExtension(url).toLowerCase();
2399
+ return mimes[extension] || "";
2400
+ }
2401
+
2402
+ // ../../node_modules/html-to-image/es/dataurl.js
2403
+ function getContentFromDataUrl(dataURL) {
2404
+ return dataURL.split(/,/)[1];
2405
+ }
2406
+ function isDataUrl(url) {
2407
+ return url.search(/^(data:)/) !== -1;
2408
+ }
2409
+ function makeDataUrl(content, mimeType) {
2410
+ return `data:${mimeType};base64,${content}`;
2411
+ }
2412
+ async function fetchAsDataURL(url, init, process2) {
2413
+ const res = await fetch(url, init);
2414
+ if (res.status === 404) {
2415
+ throw new Error(`Resource "${res.url}" not found`);
2416
+ }
2417
+ const blob = await res.blob();
2418
+ return new Promise((resolve, reject) => {
2419
+ const reader = new FileReader();
2420
+ reader.onerror = reject;
2421
+ reader.onloadend = () => {
2422
+ try {
2423
+ resolve(process2({ res, result: reader.result }));
2424
+ } catch (error) {
2425
+ reject(error);
2426
+ }
2427
+ };
2428
+ reader.readAsDataURL(blob);
2429
+ });
2430
+ }
2431
+ var cache = {};
2432
+ function getCacheKey(url, contentType, includeQueryParams) {
2433
+ let key = url.replace(/\?.*/, "");
2434
+ if (includeQueryParams) {
2435
+ key = url;
2436
+ }
2437
+ if (/ttf|otf|eot|woff2?/i.test(key)) {
2438
+ key = key.replace(/.*\//, "");
2439
+ }
2440
+ return contentType ? `[${contentType}]${key}` : key;
2441
+ }
2442
+ async function resourceToDataURL(resourceUrl, contentType, options) {
2443
+ const cacheKey = getCacheKey(resourceUrl, contentType, options.includeQueryParams);
2444
+ if (cache[cacheKey] != null) {
2445
+ return cache[cacheKey];
2446
+ }
2447
+ if (options.cacheBust) {
2448
+ resourceUrl += (/\?/.test(resourceUrl) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
2449
+ }
2450
+ let dataURL;
2451
+ try {
2452
+ const content = await fetchAsDataURL(resourceUrl, options.fetchRequestInit, ({ res, result }) => {
2453
+ if (!contentType) {
2454
+ contentType = res.headers.get("Content-Type") || "";
2455
+ }
2456
+ return getContentFromDataUrl(result);
2457
+ });
2458
+ dataURL = makeDataUrl(content, contentType);
2459
+ } catch (error) {
2460
+ dataURL = options.imagePlaceholder || "";
2461
+ let msg = `Failed to fetch resource: ${resourceUrl}`;
2462
+ if (error) {
2463
+ msg = typeof error === "string" ? error : error.message;
2464
+ }
2465
+ if (msg) {
2466
+ console.warn(msg);
2467
+ }
2468
+ }
2469
+ cache[cacheKey] = dataURL;
2470
+ return dataURL;
2471
+ }
2472
+
2473
+ // ../../node_modules/html-to-image/es/clone-node.js
2474
+ async function cloneCanvasElement(canvas) {
2475
+ const dataURL = canvas.toDataURL();
2476
+ if (dataURL === "data:,") {
2477
+ return canvas.cloneNode(false);
2478
+ }
2479
+ return createImage(dataURL);
2480
+ }
2481
+ async function cloneVideoElement(video, options) {
2482
+ if (video.currentSrc) {
2483
+ const canvas = document.createElement("canvas");
2484
+ const ctx = canvas.getContext("2d");
2485
+ canvas.width = video.clientWidth;
2486
+ canvas.height = video.clientHeight;
2487
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
2488
+ const dataURL2 = canvas.toDataURL();
2489
+ return createImage(dataURL2);
2490
+ }
2491
+ const poster = video.poster;
2492
+ const contentType = getMimeType(poster);
2493
+ const dataURL = await resourceToDataURL(poster, contentType, options);
2494
+ return createImage(dataURL);
2495
+ }
2496
+ async function cloneIFrameElement(iframe) {
2497
+ var _a;
2498
+ try {
2499
+ if ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.body) {
2500
+ return await cloneNode(iframe.contentDocument.body, {}, true);
2501
+ }
2502
+ } catch (_b) {
2503
+ }
2504
+ return iframe.cloneNode(false);
2505
+ }
2506
+ async function cloneSingleNode(node, options) {
2507
+ if (isInstanceOfElement(node, HTMLCanvasElement)) {
2508
+ return cloneCanvasElement(node);
2509
+ }
2510
+ if (isInstanceOfElement(node, HTMLVideoElement)) {
2511
+ return cloneVideoElement(node, options);
2512
+ }
2513
+ if (isInstanceOfElement(node, HTMLIFrameElement)) {
2514
+ return cloneIFrameElement(node);
2515
+ }
2516
+ return node.cloneNode(false);
2517
+ }
2518
+ var isSlotElement = (node) => node.tagName != null && node.tagName.toUpperCase() === "SLOT";
2519
+ async function cloneChildren(nativeNode, clonedNode, options) {
2520
+ var _a, _b;
2521
+ let children = [];
2522
+ if (isSlotElement(nativeNode) && nativeNode.assignedNodes) {
2523
+ children = toArray(nativeNode.assignedNodes());
2524
+ } else if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && ((_a = nativeNode.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
2525
+ children = toArray(nativeNode.contentDocument.body.childNodes);
2526
+ } else {
2527
+ children = toArray(((_b = nativeNode.shadowRoot) !== null && _b !== void 0 ? _b : nativeNode).childNodes);
2528
+ }
2529
+ if (children.length === 0 || isInstanceOfElement(nativeNode, HTMLVideoElement)) {
2530
+ return clonedNode;
2531
+ }
2532
+ await children.reduce((deferred, child) => deferred.then(() => cloneNode(child, options)).then((clonedChild) => {
2533
+ if (clonedChild) {
2534
+ clonedNode.appendChild(clonedChild);
2535
+ }
2536
+ }), Promise.resolve());
2537
+ return clonedNode;
2538
+ }
2539
+ function cloneCSSStyle(nativeNode, clonedNode) {
2540
+ const targetStyle = clonedNode.style;
2541
+ if (!targetStyle) {
2542
+ return;
2543
+ }
2544
+ const sourceStyle = window.getComputedStyle(nativeNode);
2545
+ if (sourceStyle.cssText) {
2546
+ targetStyle.cssText = sourceStyle.cssText;
2547
+ targetStyle.transformOrigin = sourceStyle.transformOrigin;
2548
+ } else {
2549
+ toArray(sourceStyle).forEach((name) => {
2550
+ let value = sourceStyle.getPropertyValue(name);
2551
+ if (name === "font-size" && value.endsWith("px")) {
2552
+ const reducedFont = Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1;
2553
+ value = `${reducedFont}px`;
2554
+ }
2555
+ if (isInstanceOfElement(nativeNode, HTMLIFrameElement) && name === "display" && value === "inline") {
2556
+ value = "block";
2557
+ }
2558
+ if (name === "d" && clonedNode.getAttribute("d")) {
2559
+ value = `path(${clonedNode.getAttribute("d")})`;
2560
+ }
2561
+ targetStyle.setProperty(name, value, sourceStyle.getPropertyPriority(name));
2562
+ });
2563
+ }
2564
+ }
2565
+ function cloneInputValue(nativeNode, clonedNode) {
2566
+ if (isInstanceOfElement(nativeNode, HTMLTextAreaElement)) {
2567
+ clonedNode.innerHTML = nativeNode.value;
2568
+ }
2569
+ if (isInstanceOfElement(nativeNode, HTMLInputElement)) {
2570
+ clonedNode.setAttribute("value", nativeNode.value);
2571
+ }
2572
+ }
2573
+ function cloneSelectValue(nativeNode, clonedNode) {
2574
+ if (isInstanceOfElement(nativeNode, HTMLSelectElement)) {
2575
+ const clonedSelect = clonedNode;
2576
+ const selectedOption = Array.from(clonedSelect.children).find((child) => nativeNode.value === child.getAttribute("value"));
2577
+ if (selectedOption) {
2578
+ selectedOption.setAttribute("selected", "");
2579
+ }
2580
+ }
2581
+ }
2582
+ function decorate(nativeNode, clonedNode) {
2583
+ if (isInstanceOfElement(clonedNode, Element)) {
2584
+ cloneCSSStyle(nativeNode, clonedNode);
2585
+ clonePseudoElements(nativeNode, clonedNode);
2586
+ cloneInputValue(nativeNode, clonedNode);
2587
+ cloneSelectValue(nativeNode, clonedNode);
2588
+ }
2589
+ return clonedNode;
2590
+ }
2591
+ async function ensureSVGSymbols(clone, options) {
2592
+ const uses = clone.querySelectorAll ? clone.querySelectorAll("use") : [];
2593
+ if (uses.length === 0) {
2594
+ return clone;
2595
+ }
2596
+ const processedDefs = {};
2597
+ for (let i = 0; i < uses.length; i++) {
2598
+ const use = uses[i];
2599
+ const id = use.getAttribute("xlink:href");
2600
+ if (id) {
2601
+ const exist = clone.querySelector(id);
2602
+ const definition = document.querySelector(id);
2603
+ if (!exist && definition && !processedDefs[id]) {
2604
+ processedDefs[id] = await cloneNode(definition, options, true);
2605
+ }
2606
+ }
2607
+ }
2608
+ const nodes = Object.values(processedDefs);
2609
+ if (nodes.length) {
2610
+ const ns = "http://www.w3.org/1999/xhtml";
2611
+ const svg = document.createElementNS(ns, "svg");
2612
+ svg.setAttribute("xmlns", ns);
2613
+ svg.style.position = "absolute";
2614
+ svg.style.width = "0";
2615
+ svg.style.height = "0";
2616
+ svg.style.overflow = "hidden";
2617
+ svg.style.display = "none";
2618
+ const defs = document.createElementNS(ns, "defs");
2619
+ svg.appendChild(defs);
2620
+ for (let i = 0; i < nodes.length; i++) {
2621
+ defs.appendChild(nodes[i]);
2622
+ }
2623
+ clone.appendChild(svg);
2624
+ }
2625
+ return clone;
2626
+ }
2627
+ async function cloneNode(node, options, isRoot) {
2628
+ if (!isRoot && options.filter && !options.filter(node)) {
2629
+ return null;
2630
+ }
2631
+ 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));
2632
+ }
2633
+
2634
+ // ../../node_modules/html-to-image/es/embed-resources.js
2635
+ var URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
2636
+ var URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
2637
+ var FONT_SRC_REGEX = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
2638
+ function toRegex(url) {
2639
+ const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
2640
+ return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
2641
+ }
2642
+ function parseURLs(cssText) {
2643
+ const urls = [];
2644
+ cssText.replace(URL_REGEX, (raw, quotation, url) => {
2645
+ urls.push(url);
2646
+ return raw;
2647
+ });
2648
+ return urls.filter((url) => !isDataUrl(url));
2649
+ }
2650
+ async function embed(cssText, resourceURL, baseURL, options, getContentFromUrl) {
2651
+ try {
2652
+ const resolvedURL = baseURL ? resolveUrl(resourceURL, baseURL) : resourceURL;
2653
+ const contentType = getMimeType(resourceURL);
2654
+ let dataURL;
2655
+ if (getContentFromUrl) {
2656
+ const content = await getContentFromUrl(resolvedURL);
2657
+ dataURL = makeDataUrl(content, contentType);
2658
+ } else {
2659
+ dataURL = await resourceToDataURL(resolvedURL, contentType, options);
2660
+ }
2661
+ return cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
2662
+ } catch (error) {
2663
+ }
2664
+ return cssText;
2665
+ }
2666
+ function filterPreferredFontFormat(str, { preferredFontFormat }) {
2667
+ return !preferredFontFormat ? str : str.replace(FONT_SRC_REGEX, (match) => {
2668
+ while (true) {
2669
+ const [src, , format] = URL_WITH_FORMAT_REGEX.exec(match) || [];
2670
+ if (!format) {
2671
+ return "";
2672
+ }
2673
+ if (format === preferredFontFormat) {
2674
+ return `src: ${src};`;
2675
+ }
2676
+ }
2677
+ });
2678
+ }
2679
+ function shouldEmbed(url) {
2680
+ return url.search(URL_REGEX) !== -1;
2681
+ }
2682
+ async function embedResources(cssText, baseUrl, options) {
2683
+ if (!shouldEmbed(cssText)) {
2684
+ return cssText;
2685
+ }
2686
+ const filteredCSSText = filterPreferredFontFormat(cssText, options);
2687
+ const urls = parseURLs(filteredCSSText);
2688
+ return urls.reduce((deferred, url) => deferred.then((css) => embed(css, url, baseUrl, options)), Promise.resolve(filteredCSSText));
2689
+ }
2690
+
2691
+ // ../../node_modules/html-to-image/es/embed-images.js
2692
+ async function embedProp(propName, node, options) {
2693
+ var _a;
2694
+ const propValue = (_a = node.style) === null || _a === void 0 ? void 0 : _a.getPropertyValue(propName);
2695
+ if (propValue) {
2696
+ const cssString = await embedResources(propValue, null, options);
2697
+ node.style.setProperty(propName, cssString, node.style.getPropertyPriority(propName));
2698
+ return true;
2699
+ }
2700
+ return false;
2701
+ }
2702
+ async function embedBackground(clonedNode, options) {
2703
+ if (!await embedProp("background", clonedNode, options)) {
2704
+ await embedProp("background-image", clonedNode, options);
2705
+ }
2706
+ if (!await embedProp("mask", clonedNode, options)) {
2707
+ await embedProp("mask-image", clonedNode, options);
2708
+ }
2709
+ }
2710
+ async function embedImageNode(clonedNode, options) {
2711
+ const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
2712
+ if (!(isImageElement && !isDataUrl(clonedNode.src)) && !(isInstanceOfElement(clonedNode, SVGImageElement) && !isDataUrl(clonedNode.href.baseVal))) {
2713
+ return;
2714
+ }
2715
+ const url = isImageElement ? clonedNode.src : clonedNode.href.baseVal;
2716
+ const dataURL = await resourceToDataURL(url, getMimeType(url), options);
2717
+ await new Promise((resolve, reject) => {
2718
+ clonedNode.onload = resolve;
2719
+ clonedNode.onerror = reject;
2720
+ const image = clonedNode;
2721
+ if (image.decode) {
2722
+ image.decode = resolve;
2723
+ }
2724
+ if (image.loading === "lazy") {
2725
+ image.loading = "eager";
2726
+ }
2727
+ if (isImageElement) {
2728
+ clonedNode.srcset = "";
2729
+ clonedNode.src = dataURL;
2730
+ } else {
2731
+ clonedNode.href.baseVal = dataURL;
2732
+ }
2733
+ });
2734
+ }
2735
+ async function embedChildren(clonedNode, options) {
2736
+ const children = toArray(clonedNode.childNodes);
2737
+ const deferreds = children.map((child) => embedImages(child, options));
2738
+ await Promise.all(deferreds).then(() => clonedNode);
2739
+ }
2740
+ async function embedImages(clonedNode, options) {
2741
+ if (isInstanceOfElement(clonedNode, Element)) {
2742
+ await embedBackground(clonedNode, options);
2743
+ await embedImageNode(clonedNode, options);
2744
+ await embedChildren(clonedNode, options);
2745
+ }
2746
+ }
2747
+
2748
+ // ../../node_modules/html-to-image/es/apply-style.js
2749
+ function applyStyle(node, options) {
2750
+ const { style } = node;
2751
+ if (options.backgroundColor) {
2752
+ style.backgroundColor = options.backgroundColor;
2753
+ }
2754
+ if (options.width) {
2755
+ style.width = `${options.width}px`;
2756
+ }
2757
+ if (options.height) {
2758
+ style.height = `${options.height}px`;
2759
+ }
2760
+ const manual = options.style;
2761
+ if (manual != null) {
2762
+ Object.keys(manual).forEach((key) => {
2763
+ style[key] = manual[key];
2764
+ });
2765
+ }
2766
+ return node;
2767
+ }
2768
+
2769
+ // ../../node_modules/html-to-image/es/embed-webfonts.js
2770
+ var cssFetchCache = {};
2771
+ async function fetchCSS(url) {
2772
+ let cache2 = cssFetchCache[url];
2773
+ if (cache2 != null) {
2774
+ return cache2;
2775
+ }
2776
+ const res = await fetch(url);
2777
+ const cssText = await res.text();
2778
+ cache2 = { url, cssText };
2779
+ cssFetchCache[url] = cache2;
2780
+ return cache2;
2781
+ }
2782
+ async function embedFonts(data, options) {
2783
+ let cssText = data.cssText;
2784
+ const regexUrl = /url\(["']?([^"')]+)["']?\)/g;
2785
+ const fontLocs = cssText.match(/url\([^)]+\)/g) || [];
2786
+ const loadFonts = fontLocs.map(async (loc) => {
2787
+ let url = loc.replace(regexUrl, "$1");
2788
+ if (!url.startsWith("https://")) {
2789
+ url = new URL(url, data.url).href;
2790
+ }
2791
+ return fetchAsDataURL(url, options.fetchRequestInit, ({ result }) => {
2792
+ cssText = cssText.replace(loc, `url(${result})`);
2793
+ return [loc, result];
2794
+ });
2795
+ });
2796
+ return Promise.all(loadFonts).then(() => cssText);
2797
+ }
2798
+ function parseCSS(source) {
2799
+ if (source == null) {
2800
+ return [];
2801
+ }
2802
+ const result = [];
2803
+ const commentsRegex = /(\/\*[\s\S]*?\*\/)/gi;
2804
+ let cssText = source.replace(commentsRegex, "");
2805
+ const keyframesRegex = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
2806
+ while (true) {
2807
+ const matches = keyframesRegex.exec(cssText);
2808
+ if (matches === null) {
2809
+ break;
2810
+ }
2811
+ result.push(matches[0]);
2812
+ }
2813
+ cssText = cssText.replace(keyframesRegex, "");
2814
+ const importRegex = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
2815
+ const combinedCSSRegex = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})";
2816
+ const unifiedRegex = new RegExp(combinedCSSRegex, "gi");
2817
+ while (true) {
2818
+ let matches = importRegex.exec(cssText);
2819
+ if (matches === null) {
2820
+ matches = unifiedRegex.exec(cssText);
2821
+ if (matches === null) {
2822
+ break;
2823
+ } else {
2824
+ importRegex.lastIndex = unifiedRegex.lastIndex;
2825
+ }
2826
+ } else {
2827
+ unifiedRegex.lastIndex = importRegex.lastIndex;
2828
+ }
2829
+ result.push(matches[0]);
2830
+ }
2831
+ return result;
2832
+ }
2833
+ async function getCSSRules(styleSheets, options) {
2834
+ const ret = [];
2835
+ const deferreds = [];
2836
+ styleSheets.forEach((sheet) => {
2837
+ if ("cssRules" in sheet) {
2838
+ try {
2839
+ toArray(sheet.cssRules || []).forEach((item, index) => {
2840
+ if (item.type === CSSRule.IMPORT_RULE) {
2841
+ let importIndex = index + 1;
2842
+ const url = item.href;
2843
+ const deferred = fetchCSS(url).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
2844
+ try {
2845
+ sheet.insertRule(rule, rule.startsWith("@import") ? importIndex += 1 : sheet.cssRules.length);
2846
+ } catch (error) {
2847
+ console.error("Error inserting rule from remote css", {
2848
+ rule,
2849
+ error
2850
+ });
2851
+ }
2852
+ })).catch((e) => {
2853
+ console.error("Error loading remote css", e.toString());
2854
+ });
2855
+ deferreds.push(deferred);
2856
+ }
2857
+ });
2858
+ } catch (e) {
2859
+ const inline = styleSheets.find((a) => a.href == null) || document.styleSheets[0];
2860
+ if (sheet.href != null) {
2861
+ deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
2862
+ inline.insertRule(rule, sheet.cssRules.length);
2863
+ })).catch((err) => {
2864
+ console.error("Error loading remote stylesheet", err);
2865
+ }));
2866
+ }
2867
+ console.error("Error inlining remote css file", e);
2868
+ }
2869
+ }
2870
+ });
2871
+ return Promise.all(deferreds).then(() => {
2872
+ styleSheets.forEach((sheet) => {
2873
+ if ("cssRules" in sheet) {
2874
+ try {
2875
+ toArray(sheet.cssRules || []).forEach((item) => {
2876
+ ret.push(item);
2877
+ });
2878
+ } catch (e) {
2879
+ console.error(`Error while reading CSS rules from ${sheet.href}`, e);
2880
+ }
2881
+ }
2882
+ });
2883
+ return ret;
2884
+ });
2885
+ }
2886
+ function getWebFontRules(cssRules) {
2887
+ return cssRules.filter((rule) => rule.type === CSSRule.FONT_FACE_RULE).filter((rule) => shouldEmbed(rule.style.getPropertyValue("src")));
2888
+ }
2889
+ async function parseWebFontRules(node, options) {
2890
+ if (node.ownerDocument == null) {
2891
+ throw new Error("Provided element is not within a Document");
2892
+ }
2893
+ const styleSheets = toArray(node.ownerDocument.styleSheets);
2894
+ const cssRules = await getCSSRules(styleSheets, options);
2895
+ return getWebFontRules(cssRules);
2896
+ }
2897
+ async function getWebFontCSS(node, options) {
2898
+ const rules = await parseWebFontRules(node, options);
2899
+ const cssTexts = await Promise.all(rules.map((rule) => {
2900
+ const baseUrl = rule.parentStyleSheet ? rule.parentStyleSheet.href : null;
2901
+ return embedResources(rule.cssText, baseUrl, options);
2902
+ }));
2903
+ return cssTexts.join("\n");
2904
+ }
2905
+ async function embedWebFonts(clonedNode, options) {
2906
+ const cssText = options.fontEmbedCSS != null ? options.fontEmbedCSS : options.skipFonts ? null : await getWebFontCSS(clonedNode, options);
2907
+ if (cssText) {
2908
+ const styleNode = document.createElement("style");
2909
+ const sytleContent = document.createTextNode(cssText);
2910
+ styleNode.appendChild(sytleContent);
2911
+ if (clonedNode.firstChild) {
2912
+ clonedNode.insertBefore(styleNode, clonedNode.firstChild);
2913
+ } else {
2914
+ clonedNode.appendChild(styleNode);
2915
+ }
2916
+ }
2917
+ }
2918
+
2919
+ // ../../node_modules/html-to-image/es/index.js
2920
+ async function toSvg(node, options = {}) {
2921
+ const { width, height } = getImageSize(node, options);
2922
+ const clonedNode = await cloneNode(node, options, true);
2923
+ await embedWebFonts(clonedNode, options);
2924
+ await embedImages(clonedNode, options);
2925
+ applyStyle(clonedNode, options);
2926
+ const datauri = await nodeToDataURL(clonedNode, width, height);
2927
+ return datauri;
2928
+ }
2929
+ async function toCanvas(node, options = {}) {
2930
+ const { width, height } = getImageSize(node, options);
2931
+ const svg = await toSvg(node, options);
2932
+ const img = await createImage(svg);
2933
+ const canvas = document.createElement("canvas");
2934
+ const context = canvas.getContext("2d");
2935
+ const ratio = options.pixelRatio || getPixelRatio();
2936
+ const canvasWidth = options.canvasWidth || width;
2937
+ const canvasHeight = options.canvasHeight || height;
2938
+ canvas.width = canvasWidth * ratio;
2939
+ canvas.height = canvasHeight * ratio;
2940
+ if (!options.skipAutoScale) {
2941
+ checkCanvasDimensions(canvas);
2942
+ }
2943
+ canvas.style.width = `${canvasWidth}`;
2944
+ canvas.style.height = `${canvasHeight}`;
2945
+ if (options.backgroundColor) {
2946
+ context.fillStyle = options.backgroundColor;
2947
+ context.fillRect(0, 0, canvas.width, canvas.height);
2948
+ }
2949
+ context.drawImage(img, 0, 0, canvas.width, canvas.height);
2950
+ return canvas;
2951
+ }
2952
+ async function toPng(node, options = {}) {
2953
+ const canvas = await toCanvas(node, options);
2954
+ return canvas.toDataURL();
2955
+ }
2956
+
2957
+ // src/screenshot-utils.ts
2958
+ async function takeScreenshot(node) {
2959
+ const screenshot = await toPng(node, { cacheBust: true }).then((dataUrl) => {
2960
+ return dataUrl;
2961
+ }).catch((err) => {
2962
+ console.error("Error taking screenshot", err);
2963
+ return void 0;
2964
+ });
2965
+ if (!screenshot) {
2966
+ return void 0;
2967
+ }
2968
+ return screenshot;
2969
+ }
1949
2970
  //# sourceMappingURL=index.js.map