@testing-library/user-event 14.0.3 → 14.1.1

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/dist/index.mjs CHANGED
@@ -158,8 +158,8 @@ var DataTransferStub = class {
158
158
  this.files = createFileList([]);
159
159
  }
160
160
  getData(format) {
161
- var _a3;
162
- const match = (_a3 = this.items.find(getTypeMatcher(format, true))) != null ? _a3 : this.items.find(getTypeMatcher(format, false));
161
+ var _a;
162
+ const match = (_a = this.items.find(getTypeMatcher(format, true))) != null ? _a : this.items.find(getTypeMatcher(format, false));
163
163
  let text = "";
164
164
  match == null ? void 0 : match.getAsString((t) => {
165
165
  text = t;
@@ -197,12 +197,12 @@ var DataTransferStub = class {
197
197
  setDragImage() {
198
198
  }
199
199
  };
200
- function createDataTransfer(window2, files = []) {
201
- const dt = typeof window2.DataTransfer === "undefined" ? new DataTransferStub() : new window2.DataTransfer();
200
+ function createDataTransfer(window, files = []) {
201
+ const dt = typeof window.DataTransfer === "undefined" ? new DataTransferStub() : new window.DataTransfer();
202
202
  Object.defineProperty(dt, "files", { get: () => createFileList(files) });
203
203
  return dt;
204
204
  }
205
- function getBlobFromDataTransferItem(window2, item) {
205
+ function getBlobFromDataTransferItem(window, item) {
206
206
  if (item.kind === "file") {
207
207
  return item.getAsFile();
208
208
  }
@@ -210,7 +210,7 @@ function getBlobFromDataTransferItem(window2, item) {
210
210
  item.getAsString((s) => {
211
211
  data = s;
212
212
  });
213
- return new window2.Blob([data], { type: item.type });
213
+ return new window.Blob([data], { type: item.type });
214
214
  }
215
215
 
216
216
  // src/utils/misc/getWindow.ts
@@ -220,95 +220,88 @@ function getWindow(node) {
220
220
  }
221
221
 
222
222
  // src/utils/dataTransfer/Clipboard.ts
223
- var Window = Symbol("Window reference");
224
- var _a;
225
- var ClipboardItemStub = class {
226
- constructor(data) {
227
- this[_a] = window;
228
- this.data = data;
229
- }
230
- get types() {
231
- return Array.from(Object.keys(this.data));
232
- }
233
- getType(type3) {
234
- return __async(this, null, function* () {
235
- const data = yield this.data[type3];
236
- if (!data) {
237
- throw new Error(`${type3} is not one of the available MIME types on this item.`);
238
- }
239
- return data instanceof this[Window].Blob ? data : new this[Window].Blob([data], { type: type3 });
240
- });
241
- }
242
- };
243
- _a = Window;
244
- var ClipboardStubControl = Symbol("Manage ClipboardSub");
245
- var _a2;
246
- var ClipboardStub = class extends window.EventTarget {
247
- constructor() {
248
- super(...arguments);
249
- this.items = [];
250
- this[_a2] = window;
251
- }
252
- read() {
253
- return __async(this, null, function* () {
254
- return Array.from(this.items);
255
- });
256
- }
257
- readText() {
258
- return __async(this, null, function* () {
259
- let text = "";
260
- for (const item of this.items) {
261
- const type3 = item.types.includes("text/plain") ? "text/plain" : item.types.find((t) => t.startsWith("text/"));
262
- if (type3) {
263
- text += yield item.getType(type3).then((b) => readBlobText(b, this[Window].FileReader));
264
- }
265
- }
266
- return text;
267
- });
268
- }
269
- write(data) {
270
- return __async(this, null, function* () {
271
- this.items = data;
272
- });
273
- }
274
- writeText(text) {
275
- return __async(this, null, function* () {
276
- this.items = [createClipboardItem(this[Window], text)];
277
- });
278
- }
279
- };
280
- _a2 = Window, ClipboardStubControl;
281
- function createClipboardItem(window2, ...blobs) {
282
- const data = Object.fromEntries(blobs.map((b) => [
223
+ function createClipboardItem(window, ...blobs) {
224
+ const dataMap = Object.fromEntries(blobs.map((b) => [
283
225
  typeof b === "string" ? "text/plain" : b.type,
284
226
  Promise.resolve(b)
285
227
  ]));
286
- if (typeof window2.ClipboardItem === "undefined") {
287
- const item = new ClipboardItemStub(data);
288
- item[Window] = window2;
289
- return item;
290
- } else {
291
- return new window2.ClipboardItem(data);
228
+ if (typeof window.ClipboardItem !== "undefined") {
229
+ return new window.ClipboardItem(dataMap);
292
230
  }
231
+ return new class ClipboardItem {
232
+ constructor(d) {
233
+ this.data = d;
234
+ }
235
+ get types() {
236
+ return Array.from(Object.keys(this.data));
237
+ }
238
+ getType(type3) {
239
+ return __async(this, null, function* () {
240
+ const value = yield this.data[type3];
241
+ if (!value) {
242
+ throw new Error(`${type3} is not one of the available MIME types on this item.`);
243
+ }
244
+ return value instanceof window.Blob ? value : new window.Blob([value], { type: type3 });
245
+ });
246
+ }
247
+ }(dataMap);
248
+ }
249
+ var ClipboardStubControl = Symbol("Manage ClipboardSub");
250
+ function createClipboardStub(window) {
251
+ var _a;
252
+ return new (_a = class extends window.EventTarget {
253
+ constructor() {
254
+ super(...arguments);
255
+ this.items = [];
256
+ }
257
+ read() {
258
+ return __async(this, null, function* () {
259
+ return Array.from(this.items);
260
+ });
261
+ }
262
+ readText() {
263
+ return __async(this, null, function* () {
264
+ let text = "";
265
+ for (const item of this.items) {
266
+ const type3 = item.types.includes("text/plain") ? "text/plain" : item.types.find((t) => t.startsWith("text/"));
267
+ if (type3) {
268
+ text += yield item.getType(type3).then((b) => readBlobText(b, window.FileReader));
269
+ }
270
+ }
271
+ return text;
272
+ });
273
+ }
274
+ write(data) {
275
+ return __async(this, null, function* () {
276
+ this.items = data;
277
+ });
278
+ }
279
+ writeText(text) {
280
+ return __async(this, null, function* () {
281
+ this.items = [createClipboardItem(window, text)];
282
+ });
283
+ }
284
+ }, ClipboardStubControl, _a)();
293
285
  }
294
- function attachClipboardStubToView(window2) {
295
- if (window2.navigator.clipboard instanceof ClipboardStub) {
296
- return window2.navigator.clipboard[ClipboardStubControl];
286
+ function isClipboardStub(clipboard) {
287
+ return !!(clipboard == null ? void 0 : clipboard[ClipboardStubControl]);
288
+ }
289
+ function attachClipboardStubToView(window) {
290
+ if (isClipboardStub(window.navigator.clipboard)) {
291
+ return window.navigator.clipboard[ClipboardStubControl];
297
292
  }
298
- const realClipboard = Object.getOwnPropertyDescriptor(window2.navigator, "clipboard");
299
- let stub = new ClipboardStub();
300
- stub[Window] = window2;
293
+ const realClipboard = Object.getOwnPropertyDescriptor(window.navigator, "clipboard");
294
+ let stub = createClipboardStub(window);
301
295
  const control = {
302
296
  resetClipboardStub: () => {
303
- stub = new ClipboardStub();
304
- stub[Window] = window2;
297
+ stub = createClipboardStub(window);
305
298
  stub[ClipboardStubControl] = control;
306
299
  },
307
300
  detachClipboardStub: () => {
308
301
  if (realClipboard) {
309
- Object.defineProperty(window2.navigator, "clipboard", realClipboard);
302
+ Object.defineProperty(window.navigator, "clipboard", realClipboard);
310
303
  } else {
311
- Object.defineProperty(window2.navigator, "clipboard", {
304
+ Object.defineProperty(window.navigator, "clipboard", {
312
305
  value: void 0,
313
306
  configurable: true
314
307
  });
@@ -316,48 +309,48 @@ function attachClipboardStubToView(window2) {
316
309
  }
317
310
  };
318
311
  stub[ClipboardStubControl] = control;
319
- Object.defineProperty(window2.navigator, "clipboard", {
312
+ Object.defineProperty(window.navigator, "clipboard", {
320
313
  get: () => stub,
321
314
  configurable: true
322
315
  });
323
316
  return stub[ClipboardStubControl];
324
317
  }
325
- function resetClipboardStubOnView(window2) {
326
- if (window2.navigator.clipboard instanceof ClipboardStub) {
327
- window2.navigator.clipboard[ClipboardStubControl].resetClipboardStub();
318
+ function resetClipboardStubOnView(window) {
319
+ if (isClipboardStub(window.navigator.clipboard)) {
320
+ window.navigator.clipboard[ClipboardStubControl].resetClipboardStub();
328
321
  }
329
322
  }
330
- function detachClipboardStubFromView(window2) {
331
- if (window2.navigator.clipboard instanceof ClipboardStub) {
332
- window2.navigator.clipboard[ClipboardStubControl].detachClipboardStub();
323
+ function detachClipboardStubFromView(window) {
324
+ if (isClipboardStub(window.navigator.clipboard)) {
325
+ window.navigator.clipboard[ClipboardStubControl].detachClipboardStub();
333
326
  }
334
327
  }
335
- function readDataTransferFromClipboard(document2) {
328
+ function readDataTransferFromClipboard(document) {
336
329
  return __async(this, null, function* () {
337
- const window2 = document2.defaultView;
338
- const clipboard = window2 == null ? void 0 : window2.navigator.clipboard;
330
+ const window = document.defaultView;
331
+ const clipboard = window == null ? void 0 : window.navigator.clipboard;
339
332
  const items = clipboard && (yield clipboard.read());
340
333
  if (!items) {
341
334
  throw new Error("The Clipboard API is unavailable.");
342
335
  }
343
- const dt = createDataTransfer(window2);
336
+ const dt = createDataTransfer(window);
344
337
  for (const item of items) {
345
338
  for (const type3 of item.types) {
346
- dt.setData(type3, yield item.getType(type3).then((b) => readBlobText(b, window2.FileReader)));
339
+ dt.setData(type3, yield item.getType(type3).then((b) => readBlobText(b, window.FileReader)));
347
340
  }
348
341
  }
349
342
  return dt;
350
343
  });
351
344
  }
352
- function writeDataTransferToClipboard(document2, clipboardData) {
345
+ function writeDataTransferToClipboard(document, clipboardData) {
353
346
  return __async(this, null, function* () {
354
- const window2 = getWindow(document2);
355
- const clipboard = window2.navigator.clipboard;
347
+ const window = getWindow(document);
348
+ const clipboard = window.navigator.clipboard;
356
349
  const items = [];
357
350
  for (let i = 0; i < clipboardData.items.length; i++) {
358
351
  const dtItem = clipboardData.items[i];
359
- const blob = getBlobFromDataTransferItem(window2, dtItem);
360
- items.push(createClipboardItem(window2, blob));
352
+ const blob = getBlobFromDataTransferItem(window, dtItem);
353
+ items.push(createClipboardItem(window, blob));
361
354
  }
362
355
  const written = clipboard && (yield clipboard.write(items).then(() => true, () => false));
363
356
  if (!written) {
@@ -365,11 +358,11 @@ function writeDataTransferToClipboard(document2, clipboardData) {
365
358
  }
366
359
  });
367
360
  }
368
- if (typeof afterEach === "function") {
369
- afterEach(() => resetClipboardStubOnView(window));
361
+ if (typeof globalThis.afterEach === "function") {
362
+ globalThis.afterEach(() => resetClipboardStubOnView(globalThis.window));
370
363
  }
371
- if (typeof afterAll === "function") {
372
- afterAll(() => detachClipboardStubFromView(window));
364
+ if (typeof globalThis.afterAll === "function") {
365
+ globalThis.afterAll(() => detachClipboardStubFromView(globalThis.window));
373
366
  }
374
367
 
375
368
  // src/utils/edit/isContentEditable.ts
@@ -396,6 +389,7 @@ function getValue(element) {
396
389
  }
397
390
 
398
391
  // src/utils/edit/buildTimeValue.ts
392
+ var parseInt = globalThis.parseInt;
399
393
  function buildTimeValue(value) {
400
394
  const onlyDigitsValue = value.replace(/\D/g, "");
401
395
  if (onlyDigitsValue.length < 2) {
@@ -452,11 +446,11 @@ function getSpaceUntilMaxLength(element) {
452
446
  return maxLength ? maxLength - value.length : void 0;
453
447
  }
454
448
  function getSanitizedMaxLength(element) {
455
- var _a3;
449
+ var _a;
456
450
  if (!supportsMaxLength(element)) {
457
451
  return void 0;
458
452
  }
459
- const attr = (_a3 = element.getAttribute("maxlength")) != null ? _a3 : "";
453
+ const attr = (_a = element.getAttribute("maxlength")) != null ? _a : "";
460
454
  return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : void 0;
461
455
  }
462
456
  function supportsMaxLength(element) {
@@ -525,7 +519,7 @@ function editContenteditable(config, element, inputRange, data, inputType) {
525
519
  function editInputElement(config, element, inputRange, data, inputType) {
526
520
  let dataToInsert = data;
527
521
  const spaceUntilMaxLength = getSpaceUntilMaxLength(element);
528
- if (spaceUntilMaxLength !== void 0) {
522
+ if (spaceUntilMaxLength !== void 0 && data.length > 0) {
529
523
  if (spaceUntilMaxLength > 0) {
530
524
  dataToInsert = data.substring(0, spaceUntilMaxLength);
531
525
  } else {
@@ -549,6 +543,7 @@ function editInputElement(config, element, inputRange, data, inputType) {
549
543
  if (isValidDateOrTimeValue(element, newValue)) {
550
544
  commitInput(config, element, newOffset, {});
551
545
  dispatchUIEvent(config, element, "change");
546
+ clearInitialValue(element);
552
547
  }
553
548
  } else {
554
549
  commitInput(config, element, newOffset, {
@@ -593,9 +588,9 @@ function commitInput(config, element, newOffset, inputInit) {
593
588
  }
594
589
  }
595
590
  function isValidNumberInput(value) {
596
- var _a3, _b;
591
+ var _a, _b;
597
592
  const valueParts = value.split("e", 2);
598
- return !(/[^\d.\-e]/.test(value) || Number((_a3 = value.match(/-/g)) == null ? void 0 : _a3.length) > 2 || Number((_b = value.match(/\./g)) == null ? void 0 : _b.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
593
+ return !(/[^\d.\-e]/.test(value) || Number((_a = value.match(/-/g)) == null ? void 0 : _a.length) > 2 || Number((_b = value.match(/\./g)) == null ? void 0 : _b.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
599
594
  }
600
595
 
601
596
  // src/utils/edit/isEditable.ts
@@ -624,8 +619,8 @@ function isEditableInput(element) {
624
619
  // src/utils/edit/setFiles.ts
625
620
  var fakeFiles = Symbol("files and value properties are mocked");
626
621
  function setFiles(el, files) {
627
- var _a3;
628
- (_a3 = el[fakeFiles]) == null ? void 0 : _a3.restore();
622
+ var _a;
623
+ (_a = el[fakeFiles]) == null ? void 0 : _a.restore();
629
624
  const objectDescriptors = Object.getOwnPropertyDescriptors(el);
630
625
  const prototypeDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf(el));
631
626
  function restore() {
@@ -643,11 +638,11 @@ function setFiles(el, files) {
643
638
  value: __spreadProps(__spreadValues(__spreadValues({}, prototypeDescriptors.value), objectDescriptors.value), {
644
639
  get: () => files.length ? `C:\\fakepath\\${files[0].name}` : "",
645
640
  set(v) {
646
- var _a4;
641
+ var _a2;
647
642
  if (v === "") {
648
643
  restore();
649
644
  } else {
650
- (_a4 = objectDescriptors.value.set) == null ? void 0 : _a4.call(el, v);
645
+ (_a2 = objectDescriptors.value.set) == null ? void 0 : _a2.call(el, v);
651
646
  }
652
647
  }
653
648
  }),
@@ -674,7 +669,7 @@ function eventWrapper(cb) {
674
669
 
675
670
  // src/utils/misc/isDisabled.ts
676
671
  function isDisabled(element) {
677
- var _a3;
672
+ var _a;
678
673
  for (let el = element; el; el = el.parentElement) {
679
674
  if (isElementType(el, [
680
675
  "button",
@@ -688,7 +683,7 @@ function isDisabled(element) {
688
683
  return true;
689
684
  }
690
685
  } else if (isElementType(el, "fieldset")) {
691
- if (el.hasAttribute("disabled") && !((_a3 = el.querySelector(":scope > legend")) == null ? void 0 : _a3.contains(element))) {
686
+ if (el.hasAttribute("disabled") && !((_a = el.querySelector(":scope > legend")) == null ? void 0 : _a.contains(element))) {
692
687
  return true;
693
688
  }
694
689
  } else if (el.tagName.includes("-")) {
@@ -701,13 +696,13 @@ function isDisabled(element) {
701
696
  }
702
697
 
703
698
  // src/utils/focus/getActiveElement.ts
704
- function getActiveElement(document2) {
705
- const activeElement = document2.activeElement;
699
+ function getActiveElement(document) {
700
+ const activeElement = document.activeElement;
706
701
  if (activeElement == null ? void 0 : activeElement.shadowRoot) {
707
702
  return getActiveElement(activeElement.shadowRoot);
708
703
  } else {
709
704
  if (isDisabled(activeElement)) {
710
- return document2.ownerDocument ? document2.ownerDocument.body : document2.body;
705
+ return document.ownerDocument ? document.ownerDocument.body : document.body;
711
706
  }
712
707
  return activeElement;
713
708
  }
@@ -821,7 +816,7 @@ function isTextNode(node) {
821
816
  return node.nodeType === 3;
822
817
  }
823
818
  function walkNodes(node, direction, callback) {
824
- var _a3;
819
+ var _a;
825
820
  for (; ; ) {
826
821
  const sibling = node[`${direction}Sibling`];
827
822
  if (sibling) {
@@ -829,7 +824,7 @@ function walkNodes(node, direction, callback) {
829
824
  if (callback(node)) {
830
825
  return node;
831
826
  }
832
- } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_a3 = node.ownerDocument) == null ? void 0 : _a3.body))) {
827
+ } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_a = node.ownerDocument) == null ? void 0 : _a.body))) {
833
828
  node = node.parentNode;
834
829
  } else {
835
830
  break;
@@ -845,7 +840,7 @@ function getDescendant(node, direction) {
845
840
 
846
841
  // src/utils/focus/selection.ts
847
842
  function setSelectionRange(element, anchorOffset, focusOffset) {
848
- var _a3;
843
+ var _a;
849
844
  if (hasOwnSelection(element)) {
850
845
  return setSelection({
851
846
  focusNode: element,
@@ -853,7 +848,7 @@ function setSelectionRange(element, anchorOffset, focusOffset) {
853
848
  focusOffset
854
849
  });
855
850
  }
856
- if (isContentEditable(element) && ((_a3 = element.firstChild) == null ? void 0 : _a3.nodeType) === 3) {
851
+ if (isContentEditable(element) && ((_a = element.firstChild) == null ? void 0 : _a.nodeType) === 3) {
857
852
  return setSelection({
858
853
  focusNode: element.firstChild,
859
854
  anchorOffset,
@@ -887,7 +882,7 @@ function getElement2(node) {
887
882
  return node.nodeType === 1 ? node : node.parentElement;
888
883
  }
889
884
  function updateSelectionOnFocus(element) {
890
- var _a3;
885
+ var _a;
891
886
  const selection = element.ownerDocument.getSelection();
892
887
  if (!(selection == null ? void 0 : selection.focusNode)) {
893
888
  return;
@@ -896,7 +891,7 @@ function updateSelectionOnFocus(element) {
896
891
  const contenteditable = getContentEditable(selection.focusNode);
897
892
  if (contenteditable) {
898
893
  if (!selection.isCollapsed) {
899
- const focusNode = ((_a3 = contenteditable.firstChild) == null ? void 0 : _a3.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
894
+ const focusNode = ((_a = contenteditable.firstChild) == null ? void 0 : _a.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
900
895
  selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
901
896
  }
902
897
  } else {
@@ -905,12 +900,12 @@ function updateSelectionOnFocus(element) {
905
900
  }
906
901
  }
907
902
  function getInputRange(focusNode) {
908
- var _a3;
903
+ var _a;
909
904
  const typeAndSelection = getTargetTypeAndSelection(focusNode);
910
905
  if (typeAndSelection.type === "input") {
911
906
  return typeAndSelection.selection;
912
907
  } else if (typeAndSelection.type === "contenteditable") {
913
- return (_a3 = typeAndSelection.selection) == null ? void 0 : _a3.getRangeAt(0);
908
+ return (_a = typeAndSelection.selection) == null ? void 0 : _a.getRangeAt(0);
914
909
  }
915
910
  }
916
911
  function setSelection({
@@ -919,7 +914,7 @@ function setSelection({
919
914
  anchorNode = focusNode,
920
915
  anchorOffset = focusOffset
921
916
  }) {
922
- var _a3, _b;
917
+ var _a, _b;
923
918
  const typeAndSelection = getTargetTypeAndSelection(focusNode);
924
919
  if (typeAndSelection.type === "input") {
925
920
  return setUISelection(focusNode, {
@@ -927,7 +922,7 @@ function setSelection({
927
922
  focusOffset
928
923
  });
929
924
  }
930
- (_b = (_a3 = anchorNode.ownerDocument) == null ? void 0 : _a3.getSelection()) == null ? void 0 : _b.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
925
+ (_b = (_a = anchorNode.ownerDocument) == null ? void 0 : _a.getSelection()) == null ? void 0 : _b.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
931
926
  }
932
927
  function moveSelection(node, direction) {
933
928
  if (hasOwnSelection(node)) {
@@ -1000,9 +995,9 @@ function focus(element) {
1000
995
 
1001
996
  // src/utils/misc/isVisible.ts
1002
997
  function isVisible(element) {
1003
- const window2 = getWindow(element);
998
+ const window = getWindow(element);
1004
999
  for (let el = element; el == null ? void 0 : el.ownerDocument; el = el.parentElement) {
1005
- const { display, visibility } = window2.getComputedStyle(el);
1000
+ const { display, visibility } = window.getComputedStyle(el);
1006
1001
  if (display === "none") {
1007
1002
  return false;
1008
1003
  }
@@ -1015,8 +1010,8 @@ function isVisible(element) {
1015
1010
 
1016
1011
  // src/utils/focus/getTabDestination.ts
1017
1012
  function getTabDestination(activeElement, shift) {
1018
- const document2 = activeElement.ownerDocument;
1019
- const focusableElements = document2.querySelectorAll(FOCUSABLE_SELECTOR);
1013
+ const document = activeElement.ownerDocument;
1014
+ const focusableElements = document.querySelectorAll(FOCUSABLE_SELECTOR);
1020
1015
  const enabledElements = Array.from(focusableElements).filter((el) => el === activeElement || el.getAttribute("tabindex") !== "-1" && !isDisabled(el) && isVisible(el));
1021
1016
  if (activeElement.getAttribute("tabindex") !== "-1") {
1022
1017
  enabledElements.sort((a, b) => {
@@ -1033,7 +1028,7 @@ function getTabDestination(activeElement, shift) {
1033
1028
  });
1034
1029
  }
1035
1030
  const checkedRadio = {};
1036
- let prunedElements = [document2.body];
1031
+ let prunedElements = [document.body];
1037
1032
  const activeRadioGroup = isElementType(activeElement, "input", {
1038
1033
  type: "radio"
1039
1034
  }) ? activeElement.name : void 0;
@@ -1066,7 +1061,7 @@ function getTabDestination(activeElement, shift) {
1066
1061
 
1067
1062
  // src/utils/focus/selectAll.ts
1068
1063
  function selectAll(target) {
1069
- var _a3;
1064
+ var _a;
1070
1065
  if (isElementType(target, "textarea") || isElementType(target, "input") && target.type in editableInputTypes) {
1071
1066
  return setSelection({
1072
1067
  focusNode: target,
@@ -1074,7 +1069,7 @@ function selectAll(target) {
1074
1069
  focusOffset: getUIValue(target).length
1075
1070
  });
1076
1071
  }
1077
- const focusNode = (_a3 = getContentEditable(target)) != null ? _a3 : target.ownerDocument.body;
1072
+ const focusNode = (_a = getContentEditable(target)) != null ? _a : target.ownerDocument.body;
1078
1073
  setSelection({
1079
1074
  focusNode,
1080
1075
  anchorOffset: 0,
@@ -1082,11 +1077,11 @@ function selectAll(target) {
1082
1077
  });
1083
1078
  }
1084
1079
  function isAllSelected(target) {
1085
- var _a3;
1080
+ var _a;
1086
1081
  if (isElementType(target, "textarea") || isElementType(target, "input") && target.type in editableInputTypes) {
1087
1082
  return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
1088
1083
  }
1089
- const focusNode = (_a3 = getContentEditable(target)) != null ? _a3 : target.ownerDocument.body;
1084
+ const focusNode = (_a = getContentEditable(target)) != null ? _a : target.ownerDocument.body;
1090
1085
  const selection = target.ownerDocument.getSelection();
1091
1086
  return (selection == null ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
1092
1087
  }
@@ -1146,12 +1141,12 @@ function readPrintableChar(text, pos, context) {
1146
1141
  };
1147
1142
  }
1148
1143
  function readTag(text, pos, startBracket, context) {
1149
- var _a3, _b, _c;
1144
+ var _a, _b, _c;
1150
1145
  const releasePreviousModifier = text[pos] === "/" ? "/" : "";
1151
1146
  pos += releasePreviousModifier.length;
1152
1147
  const escapedDescriptor = startBracket === "{" && text[pos] === "\\";
1153
1148
  pos += Number(escapedDescriptor);
1154
- const descriptor = escapedDescriptor ? text[pos] : (_a3 = text.slice(pos).match(startBracket === "{" ? /^\w+|^[^}>/]/ : /^\w+/)) == null ? void 0 : _a3[0];
1149
+ const descriptor = escapedDescriptor ? text[pos] : (_a = text.slice(pos).match(startBracket === "{" ? /^\w+|^[^}>/]/ : /^\w+/)) == null ? void 0 : _a[0];
1155
1150
  assertDescriptor(descriptor, text, pos, context);
1156
1151
  pos += descriptor.length;
1157
1152
  const repeatModifier = (_c = (_b = text.slice(pos).match(/^>\d+/)) == null ? void 0 : _b[0]) != null ? _c : "";
@@ -1223,18 +1218,25 @@ function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
1223
1218
  // src/utils/misc/level.ts
1224
1219
  var Level = Symbol("Api level refs");
1225
1220
  function setLevelRef(config, level) {
1226
- var _a3;
1227
- (_a3 = config[Level]) != null ? _a3 : config[Level] = {};
1221
+ var _a;
1222
+ (_a = config[Level]) != null ? _a : config[Level] = {};
1228
1223
  config[Level][level] = {};
1229
1224
  }
1230
1225
  function getLevelRef(config, level) {
1231
- var _a3;
1232
- return (_a3 = config[Level]) == null ? void 0 : _a3[level];
1226
+ var _a;
1227
+ return (_a = config[Level]) == null ? void 0 : _a[level];
1233
1228
  }
1234
1229
 
1235
1230
  // src/utils/misc/wait.ts
1236
- function wait(time) {
1237
- return new Promise((resolve) => setTimeout(() => resolve(), time));
1231
+ function wait(config) {
1232
+ const delay = config.delay;
1233
+ if (typeof delay !== "number") {
1234
+ return;
1235
+ }
1236
+ return Promise.all([
1237
+ new Promise((resolve) => globalThis.setTimeout(() => resolve(), delay)),
1238
+ config.advanceTimers(delay)
1239
+ ]);
1238
1240
  }
1239
1241
 
1240
1242
  // src/keyboard/keyMap.ts
@@ -1315,14 +1317,15 @@ var defaultOptionsDirect = {
1315
1317
  applyAccept: true,
1316
1318
  autoModify: true,
1317
1319
  delay: 0,
1318
- document: global.document,
1320
+ document: globalThis.document,
1319
1321
  keyboardMap: defaultKeyMap,
1320
1322
  pointerMap: defaultKeyMap2,
1321
1323
  pointerEventsCheck: 2 /* EachApiCall */,
1322
1324
  skipAutoClose: false,
1323
1325
  skipClick: false,
1324
1326
  skipHover: false,
1325
- writeToClipboard: false
1327
+ writeToClipboard: false,
1328
+ advanceTimers: () => Promise.resolve()
1326
1329
  };
1327
1330
  var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect), {
1328
1331
  writeToClipboard: true
@@ -1330,9 +1333,9 @@ var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect)
1330
1333
 
1331
1334
  // src/utils/pointer/cssPointerEvents.ts
1332
1335
  function hasPointerEvents(element) {
1333
- const window2 = getWindow(element);
1336
+ const window = getWindow(element);
1334
1337
  for (let el = element; el == null ? void 0 : el.ownerDocument; el = el.parentElement) {
1335
- const pointerEvents = window2.getComputedStyle(el).pointerEvents;
1338
+ const pointerEvents = window.getComputedStyle(el).pointerEvents;
1336
1339
  if (pointerEvents && !["inherit", "unset"].includes(pointerEvents)) {
1337
1340
  return pointerEvents !== "none";
1338
1341
  }
@@ -1444,9 +1447,9 @@ function assignPositionInit(obj, {
1444
1447
  screenX,
1445
1448
  screenY
1446
1449
  }) {
1447
- var _a3, _b, _c, _d;
1450
+ var _a, _b, _c, _d;
1448
1451
  assignProps(obj, {
1449
- x: (_a3 = x != null ? x : clientX) != null ? _a3 : 0,
1452
+ x: (_a = x != null ? x : clientX) != null ? _a : 0,
1450
1453
  y: (_b = y != null ? y : clientY) != null ? _b : 0,
1451
1454
  clientX: (_c = x != null ? x : clientX) != null ? _c : 0,
1452
1455
  clientY: (_d = y != null ? y : clientY) != null ? _d : 0,
@@ -1500,8 +1503,8 @@ behavior.cut = (event, target, config) => {
1500
1503
 
1501
1504
  // src/event/behavior/keydown.ts
1502
1505
  behavior.keydown = (event, target, config) => {
1503
- var _a3, _b;
1504
- return (_b = (_a3 = keydownBehavior[event.key]) == null ? void 0 : _a3.call(keydownBehavior, event, target, config)) != null ? _b : combinationBehavior(event, target, config);
1506
+ var _a, _b;
1507
+ return (_b = (_a = keydownBehavior[event.key]) == null ? void 0 : _a.call(keydownBehavior, event, target, config)) != null ? _b : combinationBehavior(event, target, config);
1505
1508
  };
1506
1509
  var keydownBehavior = {
1507
1510
  ArrowLeft: (event, target) => () => moveSelection(target, -1),
@@ -1523,8 +1526,8 @@ var keydownBehavior = {
1523
1526
  End: (event, target) => {
1524
1527
  if (isElementType(target, ["input", "textarea"]) || isContentEditable(target)) {
1525
1528
  return () => {
1526
- var _a3, _b;
1527
- const newPos = (_b = (_a3 = getValue(target)) == null ? void 0 : _a3.length) != null ? _b : 0;
1529
+ var _a, _b;
1530
+ const newPos = (_b = (_a = getValue(target)) == null ? void 0 : _a.length) != null ? _b : 0;
1528
1531
  setSelectionRange(target, newPos, newPos);
1529
1532
  };
1530
1533
  }
@@ -1616,8 +1619,8 @@ var SubmitSingleInputOnEnter = [
1616
1619
 
1617
1620
  // src/event/behavior/keyup.ts
1618
1621
  behavior.keyup = (event, target, config) => {
1619
- var _a3;
1620
- return (_a3 = keyupBehavior[event.key]) == null ? void 0 : _a3.call(keyupBehavior, event, target, config);
1622
+ var _a;
1623
+ return (_a = keyupBehavior[event.key]) == null ? void 0 : _a.call(keyupBehavior, event, target, config);
1621
1624
  };
1622
1625
  var keyupBehavior = {
1623
1626
  " ": (event, target, config) => {
@@ -1631,8 +1634,8 @@ var keyupBehavior = {
1631
1634
  behavior.paste = (event, target, config) => {
1632
1635
  if (isEditable(target)) {
1633
1636
  return () => {
1634
- var _a3;
1635
- const insertData = (_a3 = event.clipboardData) == null ? void 0 : _a3.getData("text");
1637
+ var _a;
1638
+ const insertData = (_a = event.clipboardData) == null ? void 0 : _a.getData("text");
1636
1639
  if (insertData) {
1637
1640
  input(config, target, insertData, "insertFromPaste");
1638
1641
  }
@@ -1648,10 +1651,10 @@ function wrapEvent(cb, _element) {
1648
1651
 
1649
1652
  // src/event/dispatchEvent.ts
1650
1653
  function dispatchEvent(config, target, event, preventDefault = false) {
1651
- var _a3, _b;
1654
+ var _a, _b;
1652
1655
  const type3 = event.type;
1653
1656
  const behaviorImplementation = preventDefault ? () => {
1654
- } : (_b = (_a3 = behavior)[type3]) == null ? void 0 : _b.call(_a3, event, target, config);
1657
+ } : (_b = (_a = behavior)[type3]) == null ? void 0 : _b.call(_a, event, target, config);
1655
1658
  if (behaviorImplementation) {
1656
1659
  event.preventDefault();
1657
1660
  let defaultPrevented = false;
@@ -1694,13 +1697,18 @@ function prepareInterceptor(element, propName, interceptorImpl) {
1694
1697
  return;
1695
1698
  }
1696
1699
  function intercept(...args) {
1697
- const { applyNative = true, realArgs } = interceptorImpl.call(this, ...args);
1700
+ const {
1701
+ applyNative = true,
1702
+ realArgs,
1703
+ then
1704
+ } = interceptorImpl.call(this, ...args);
1698
1705
  const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
1699
1706
  if (target === "set") {
1700
1707
  realFunc.call(this, realArgs);
1701
1708
  } else {
1702
1709
  realFunc.call(this, ...realArgs);
1703
1710
  }
1711
+ then == null ? void 0 : then();
1704
1712
  }
1705
1713
  ;
1706
1714
  intercept[Interceptor] = Interceptor;
@@ -1729,6 +1737,13 @@ function prepareSelectionInterceptor(element) {
1729
1737
  this[UISelection] = void 0;
1730
1738
  return { realArgs: v };
1731
1739
  });
1740
+ prepareInterceptor(element, "select", function interceptorImpl() {
1741
+ this[UISelection] = {
1742
+ anchorOffset: 0,
1743
+ focusOffset: getUIValue(element).length
1744
+ };
1745
+ return { realArgs: [] };
1746
+ });
1732
1747
  }
1733
1748
  function setUISelection(element, {
1734
1749
  focusOffset: focusOffsetParam,
@@ -1755,9 +1770,9 @@ function setUISelection(element, {
1755
1770
  }
1756
1771
  }
1757
1772
  function getUISelection(element) {
1758
- var _a3, _b, _c;
1773
+ var _a, _b, _c;
1759
1774
  const sel = (_c = element[UISelection]) != null ? _c : {
1760
- anchorOffset: (_a3 = element.selectionStart) != null ? _a3 : 0,
1775
+ anchorOffset: (_a = element.selectionStart) != null ? _a : 0,
1761
1776
  focusOffset: (_b = element.selectionEnd) != null ? _b : 0
1762
1777
  };
1763
1778
  return __spreadProps(__spreadValues({}, sel), {
@@ -1775,12 +1790,11 @@ function valueInterceptor(v) {
1775
1790
  if (isUI) {
1776
1791
  this[UIValue] = String(v);
1777
1792
  setPreviousValue(this, String(this.value));
1778
- } else {
1779
- trackOrSetValue(this, String(v));
1780
1793
  }
1781
1794
  return {
1782
1795
  applyNative: !!isUI,
1783
- realArgs: sanitizeValue(this, v)
1796
+ realArgs: sanitizeValue(this, v),
1797
+ then: isUI ? void 0 : () => trackOrSetValue(this, String(v))
1784
1798
  };
1785
1799
  }
1786
1800
  function sanitizeValue(element, v) {
@@ -1793,6 +1807,9 @@ function prepareValueInterceptor(element) {
1793
1807
  prepareInterceptor(element, "value", valueInterceptor);
1794
1808
  }
1795
1809
  function setUIValue(element, value) {
1810
+ if (element[InitialValue] === void 0) {
1811
+ element[InitialValue] = element.value;
1812
+ }
1796
1813
  element.value = {
1797
1814
  [UIValue]: UIValue,
1798
1815
  toString: () => value
@@ -1801,8 +1818,8 @@ function setUIValue(element, value) {
1801
1818
  function getUIValue(element) {
1802
1819
  return element[UIValue] === void 0 ? element.value : String(element[UIValue]);
1803
1820
  }
1804
- function setInitialValue(element) {
1805
- element[InitialValue] = element.value;
1821
+ function clearInitialValue(element) {
1822
+ element[InitialValue] = void 0;
1806
1823
  }
1807
1824
  function getInitialValue(element) {
1808
1825
  return element[InitialValue];
@@ -1817,22 +1834,21 @@ function startTrackValue(element) {
1817
1834
  });
1818
1835
  }
1819
1836
  function trackOrSetValue(element, v) {
1820
- var _a3, _b, _c;
1821
- (_b = (_a3 = element[TrackChanges]) == null ? void 0 : _a3.tracked) == null ? void 0 : _b.push(v);
1837
+ var _a, _b, _c;
1838
+ (_b = (_a = element[TrackChanges]) == null ? void 0 : _a.tracked) == null ? void 0 : _b.push(v);
1822
1839
  if (!((_c = element[TrackChanges]) == null ? void 0 : _c.tracked)) {
1823
1840
  setCleanValue(element, v);
1824
1841
  }
1825
1842
  }
1826
1843
  function setCleanValue(element, v) {
1827
1844
  element[UIValue] = void 0;
1828
- element[InitialValue] = v;
1829
1845
  setUISelection(element, { focusOffset: v.length });
1830
1846
  }
1831
1847
  function endTrackValue(element) {
1832
- var _a3, _b;
1848
+ var _a, _b;
1833
1849
  const changes = element[TrackChanges];
1834
1850
  element[TrackChanges] = void 0;
1835
- const isJustReactStateUpdate = ((_a3 = changes == null ? void 0 : changes.tracked) == null ? void 0 : _a3.length) === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === changes.nextValue;
1851
+ const isJustReactStateUpdate = ((_a = changes == null ? void 0 : changes.tracked) == null ? void 0 : _a.length) === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === changes.nextValue;
1836
1852
  if (((_b = changes == null ? void 0 : changes.tracked) == null ? void 0 : _b.length) && !isJustReactStateUpdate) {
1837
1853
  setCleanValue(element, changes.tracked[changes.tracked.length - 1]);
1838
1854
  }
@@ -1841,36 +1857,36 @@ function endTrackValue(element) {
1841
1857
 
1842
1858
  // src/document/index.ts
1843
1859
  var isPrepared = Symbol("Node prepared with document state workarounds");
1844
- function prepareDocument(document2) {
1845
- if (document2[isPrepared]) {
1860
+ function prepareDocument(document) {
1861
+ if (document[isPrepared]) {
1846
1862
  return;
1847
1863
  }
1848
- document2.addEventListener("focus", (e) => {
1864
+ document.addEventListener("focus", (e) => {
1849
1865
  const el = e.target;
1850
1866
  prepareElement(el);
1851
1867
  }, {
1852
1868
  capture: true,
1853
1869
  passive: true
1854
1870
  });
1855
- if (document2.activeElement) {
1856
- prepareElement(document2.activeElement);
1871
+ if (document.activeElement) {
1872
+ prepareElement(document.activeElement);
1857
1873
  }
1858
- document2.addEventListener("blur", (e) => {
1874
+ document.addEventListener("blur", (e) => {
1859
1875
  const el = e.target;
1860
1876
  const initialValue = getInitialValue(el);
1861
- if (typeof initialValue === "string" && el.value !== initialValue) {
1862
- dispatchUIEvent({}, el, "change");
1877
+ if (initialValue !== void 0) {
1878
+ if (el.value !== initialValue) {
1879
+ dispatchUIEvent({}, el, "change");
1880
+ }
1881
+ clearInitialValue(el);
1863
1882
  }
1864
1883
  }, {
1865
1884
  capture: true,
1866
1885
  passive: true
1867
1886
  });
1868
- document2[isPrepared] = isPrepared;
1887
+ document[isPrepared] = isPrepared;
1869
1888
  }
1870
1889
  function prepareElement(el) {
1871
- if ("value" in el) {
1872
- setInitialValue(el);
1873
- }
1874
1890
  if (el[isPrepared]) {
1875
1891
  return;
1876
1892
  }
@@ -1905,11 +1921,11 @@ function isModifierLock(key) {
1905
1921
  return modifierLocks.includes(key);
1906
1922
  }
1907
1923
  function preKeydownBehavior(config, { key }, element) {
1908
- var _a3;
1924
+ var _a;
1909
1925
  if (isModifierKey(key)) {
1910
1926
  config.keyboardState.modifiers[key] = true;
1911
1927
  if (key === "AltGraph") {
1912
- const ctrlKeyDef = (_a3 = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a3 : { key: "Control", code: "Control" };
1928
+ const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
1913
1929
  dispatchUIEvent(config, element, "keydown", getKeyEventProps(ctrlKeyDef));
1914
1930
  }
1915
1931
  } else if (isModifierLock(key)) {
@@ -1929,9 +1945,9 @@ function preKeyupBehavior(config, { key }) {
1929
1945
  }
1930
1946
  }
1931
1947
  function postKeyupBehavior(config, { key }, element) {
1932
- var _a3;
1948
+ var _a;
1933
1949
  if (key === "AltGraph") {
1934
- const ctrlKeyDef = (_a3 = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a3 : { key: "Control", code: "Control" };
1950
+ const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
1935
1951
  dispatchUIEvent(config, element, "keyup", getKeyEventProps(ctrlKeyDef));
1936
1952
  }
1937
1953
  }
@@ -1941,16 +1957,16 @@ function keyboardAction(config, actions) {
1941
1957
  return __async(this, null, function* () {
1942
1958
  for (let i = 0; i < actions.length; i++) {
1943
1959
  yield keyboardKeyAction(config, actions[i]);
1944
- if (typeof config.delay === "number" && i < actions.length - 1) {
1945
- yield wait(config.delay);
1960
+ if (i < actions.length - 1) {
1961
+ yield wait(config);
1946
1962
  }
1947
1963
  }
1948
1964
  });
1949
1965
  }
1950
1966
  function keyboardKeyAction(_0, _1) {
1951
1967
  return __async(this, arguments, function* (config, { keyDef, releasePrevious, releaseSelf, repeat }) {
1952
- const { document: document2, keyboardState, delay } = config;
1953
- const getCurrentElement = () => getActive(document2);
1968
+ const { document, keyboardState } = config;
1969
+ const getCurrentElement = () => getActive(document);
1954
1970
  const pressed = keyboardState.pressed.find((p) => p.keyDef === keyDef);
1955
1971
  if (pressed) {
1956
1972
  yield keyup(keyDef, getCurrentElement, config, pressed.unpreventedDefault);
@@ -1962,8 +1978,8 @@ function keyboardKeyAction(_0, _1) {
1962
1978
  if (unpreventedDefault && hasKeyPress(keyDef, config)) {
1963
1979
  yield keypress(keyDef, getCurrentElement, config);
1964
1980
  }
1965
- if (typeof delay === "number" && i < repeat) {
1966
- yield wait(delay);
1981
+ if (i < repeat) {
1982
+ yield wait(config);
1967
1983
  }
1968
1984
  }
1969
1985
  if (releaseSelf) {
@@ -1972,9 +1988,9 @@ function keyboardKeyAction(_0, _1) {
1972
1988
  }
1973
1989
  });
1974
1990
  }
1975
- function getActive(document2) {
1976
- var _a3;
1977
- return (_a3 = getActiveElement(document2)) != null ? _a3 : document2.body;
1991
+ function getActive(document) {
1992
+ var _a;
1993
+ return (_a = getActiveElement(document)) != null ? _a : document.body;
1978
1994
  }
1979
1995
  function releaseAllKeys(config) {
1980
1996
  return __async(this, null, function* () {
@@ -2016,13 +2032,13 @@ function keyup(keyDef, getCurrentElement, config, unprevented) {
2016
2032
  });
2017
2033
  }
2018
2034
  function hasKeyPress(keyDef, config) {
2019
- var _a3;
2020
- return (((_a3 = keyDef.key) == null ? void 0 : _a3.length) === 1 || keyDef.key === "Enter") && !config.keyboardState.modifiers.Control && !config.keyboardState.modifiers.Alt;
2035
+ var _a;
2036
+ return (((_a = keyDef.key) == null ? void 0 : _a.length) === 1 || keyDef.key === "Enter") && !config.keyboardState.modifiers.Control && !config.keyboardState.modifiers.Alt;
2021
2037
  }
2022
2038
 
2023
2039
  // src/keyboard/parseKeyDef.ts
2024
2040
  function parseKeyDef(keyboardMap, text) {
2025
- var _a3;
2041
+ var _a;
2026
2042
  const defs = [];
2027
2043
  do {
2028
2044
  const {
@@ -2033,15 +2049,15 @@ function parseKeyDef(keyboardMap, text) {
2033
2049
  releaseSelf = true,
2034
2050
  repeat
2035
2051
  } = readNextDescriptor(text, "keyboard");
2036
- const keyDef = (_a3 = keyboardMap.find((def) => {
2037
- var _a4, _b;
2052
+ const keyDef = (_a = keyboardMap.find((def) => {
2053
+ var _a2, _b;
2038
2054
  if (type3 === "[") {
2039
- return ((_a4 = def.code) == null ? void 0 : _a4.toLowerCase()) === descriptor.toLowerCase();
2055
+ return ((_a2 = def.code) == null ? void 0 : _a2.toLowerCase()) === descriptor.toLowerCase();
2040
2056
  } else if (type3 === "{") {
2041
2057
  return ((_b = def.key) == null ? void 0 : _b.toLowerCase()) === descriptor.toLowerCase();
2042
2058
  }
2043
2059
  return def.key === descriptor;
2044
- })) != null ? _a3 : {
2060
+ })) != null ? _a : {
2045
2061
  key: "Unknown",
2046
2062
  code: "Unknown",
2047
2063
  [type3 === "[" ? "code" : "key"]: descriptor
@@ -2120,8 +2136,8 @@ function firePointerEvent(config, target, type3, {
2120
2136
  }
2121
2137
  init.button = getMouseButton(button != null ? button : 0);
2122
2138
  init.buttons = getMouseButtons(...config.pointerState.pressed.filter((p) => p.keyDef.pointerType === pointerType).map((p) => {
2123
- var _a3;
2124
- return (_a3 = p.keyDef.button) != null ? _a3 : 0;
2139
+ var _a;
2140
+ return (_a = p.keyDef.button) != null ? _a : 0;
2125
2141
  }));
2126
2142
  if (["mousedown", "mouseup", "click", "dblclick", "contextmenu"].includes(type3)) {
2127
2143
  init.detail = clickCount;
@@ -2283,7 +2299,7 @@ function getNextPointerId(state) {
2283
2299
  return state.pointerId;
2284
2300
  }
2285
2301
  function down(config, pointerName, { keyDef, node, offset, target, coords }, targetIsDisabled) {
2286
- var _a3, _b, _c;
2302
+ var _a, _b, _c;
2287
2303
  setLevelRef(config, 2 /* Trigger */);
2288
2304
  assertPointerEvents(config, target);
2289
2305
  const { pointerState } = config;
@@ -2306,7 +2322,7 @@ function down(config, pointerName, { keyDef, node, offset, target, coords }, tar
2306
2322
  }
2307
2323
  }
2308
2324
  }
2309
- if (((_a3 = pointerState.activeClickCount) == null ? void 0 : _a3[0]) !== name) {
2325
+ if (((_a = pointerState.activeClickCount) == null ? void 0 : _a[0]) !== name) {
2310
2326
  delete pointerState.activeClickCount;
2311
2327
  }
2312
2328
  const clickCount = Number((_c = (_b = pointerState.activeClickCount) == null ? void 0 : _b[1]) != null ? _c : 0) + 1;
@@ -2490,17 +2506,15 @@ function getTextRange(text, pos, clickCount) {
2490
2506
  // src/pointer/pointerAction.ts
2491
2507
  function pointerAction(config, actions) {
2492
2508
  return __async(this, null, function* () {
2493
- var _a3, _b;
2509
+ var _a, _b;
2494
2510
  for (let i = 0; i < actions.length; i++) {
2495
2511
  const action = actions[i];
2496
2512
  const pointerName = "pointerName" in action && action.pointerName ? action.pointerName : "keyDef" in action ? action.keyDef.pointerType === "touch" ? action.keyDef.name : action.keyDef.pointerType : "mouse";
2497
- const target = (_a3 = action.target) != null ? _a3 : getPrevTarget(pointerName, config.pointerState);
2513
+ const target = (_a = action.target) != null ? _a : getPrevTarget(pointerName, config.pointerState);
2498
2514
  const coords = (_b = action.coords) != null ? _b : pointerName in config.pointerState.position ? config.pointerState.position[pointerName].coords : void 0;
2499
2515
  yield "keyDef" in action ? pointerPress(config, __spreadProps(__spreadValues({}, action), { target, coords })) : pointerMove(config, __spreadProps(__spreadValues({}, action), { target, coords }));
2500
- if (typeof config.delay === "number") {
2501
- if (i < actions.length - 1) {
2502
- yield wait(config.delay);
2503
- }
2516
+ if (i < actions.length - 1) {
2517
+ yield wait(config);
2504
2518
  }
2505
2519
  }
2506
2520
  delete config.pointerState.activeClickCount;
@@ -2530,14 +2544,14 @@ function pointer(input2) {
2530
2544
  return pointerAction(this[Config], actions).then(() => void 0);
2531
2545
  });
2532
2546
  }
2533
- function createPointerState(document2) {
2547
+ function createPointerState(document) {
2534
2548
  return {
2535
2549
  pointerId: 1,
2536
2550
  position: {
2537
2551
  mouse: {
2538
2552
  pointerType: "mouse",
2539
2553
  pointerId: 1,
2540
- target: document2.body,
2554
+ target: document.body,
2541
2555
  coords: {
2542
2556
  clientX: 0,
2543
2557
  clientY: 0,
@@ -2624,9 +2638,9 @@ function tab() {
2624
2638
  // src/clipboard/copy.ts
2625
2639
  function copy() {
2626
2640
  return __async(this, null, function* () {
2627
- var _a3;
2641
+ var _a;
2628
2642
  const doc = this[Config].document;
2629
- const target = (_a3 = doc.activeElement) != null ? _a3 : doc.body;
2643
+ const target = (_a = doc.activeElement) != null ? _a : doc.body;
2630
2644
  const clipboardData = copySelection(target);
2631
2645
  if (clipboardData.items.length === 0) {
2632
2646
  return;
@@ -2643,9 +2657,9 @@ function copy() {
2643
2657
  // src/clipboard/cut.ts
2644
2658
  function cut() {
2645
2659
  return __async(this, null, function* () {
2646
- var _a3;
2660
+ var _a;
2647
2661
  const doc = this[Config].document;
2648
- const target = (_a3 = doc.activeElement) != null ? _a3 : doc.body;
2662
+ const target = (_a = doc.activeElement) != null ? _a : doc.body;
2649
2663
  const clipboardData = copySelection(target);
2650
2664
  if (clipboardData.items.length === 0) {
2651
2665
  return;
@@ -2662,9 +2676,9 @@ function cut() {
2662
2676
  // src/clipboard/paste.ts
2663
2677
  function paste(clipboardData) {
2664
2678
  return __async(this, null, function* () {
2665
- var _a3, _b;
2679
+ var _a, _b;
2666
2680
  const doc = this[Config].document;
2667
- const target = (_a3 = doc.activeElement) != null ? _a3 : doc.body;
2681
+ const target = (_a = doc.activeElement) != null ? _a : doc.body;
2668
2682
  const dataTransfer = (_b = typeof clipboardData === "string" ? getClipboardDataFromString(doc, clipboardData) : clipboardData) != null ? _b : yield readDataTransferFromClipboard(doc).catch(() => {
2669
2683
  throw new Error("`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.");
2670
2684
  });
@@ -2828,10 +2842,10 @@ function upload(element, fileOrFiles) {
2828
2842
  return;
2829
2843
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file, input2.accept)).slice(0, input2.multiple ? void 0 : 1);
2830
2844
  const fileDialog = () => {
2831
- var _a3;
2832
- if (files.length === ((_a3 = input2.files) == null ? void 0 : _a3.length) && files.every((f, i) => {
2833
- var _a4;
2834
- return f === ((_a4 = input2.files) == null ? void 0 : _a4.item(i));
2845
+ var _a;
2846
+ if (files.length === ((_a = input2.files) == null ? void 0 : _a.length) && files.every((f, i) => {
2847
+ var _a2;
2848
+ return f === ((_a2 = input2.files) == null ? void 0 : _a2.item(i));
2835
2849
  })) {
2836
2850
  return;
2837
2851
  }
@@ -2867,22 +2881,22 @@ function wrapAsync(implementation) {
2867
2881
 
2868
2882
  // src/setup/setup.ts
2869
2883
  function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
2870
- const document2 = getDocument(options, node);
2884
+ const document = getDocument(options, node, defaults);
2871
2885
  const {
2872
2886
  keyboardState = createKeyboardState(),
2873
- pointerState = createPointerState(document2)
2887
+ pointerState = createPointerState(document)
2874
2888
  } = options;
2875
2889
  return __spreadProps(__spreadValues(__spreadValues({}, defaults), options), {
2876
- document: document2,
2890
+ document,
2877
2891
  keyboardState,
2878
2892
  pointerState
2879
2893
  });
2880
2894
  }
2881
2895
  function setupMain(options = {}) {
2882
- var _a3;
2896
+ var _a;
2883
2897
  const config = createConfig(options);
2884
2898
  prepareDocument(config.document);
2885
- const view = (_a3 = config.document.defaultView) != null ? _a3 : window;
2899
+ const view = (_a = config.document.defaultView) != null ? _a : globalThis.window;
2886
2900
  attachClipboardStubToView(view);
2887
2901
  return doSetup(config);
2888
2902
  }
@@ -2917,9 +2931,9 @@ function doSetup(config) {
2917
2931
  setup: setupSub.bind(instance)
2918
2932
  });
2919
2933
  }
2920
- function getDocument(options, node) {
2921
- var _a3, _b;
2922
- return (_b = (_a3 = options.document) != null ? _a3 : node && getDocumentFromNode(node)) != null ? _b : document;
2934
+ function getDocument(options, node, defaults) {
2935
+ var _a, _b;
2936
+ return (_b = (_a = options.document) != null ? _a : node && getDocumentFromNode(node)) != null ? _b : defaults.document;
2923
2937
  }
2924
2938
 
2925
2939
  // src/setup/directApi.ts