@baleada/logic 0.23.4 → 0.24.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.
Files changed (4) hide show
  1. package/lib/index.cjs +2268 -1915
  2. package/lib/index.d.ts +936 -587
  3. package/lib/index.js +2195 -1881
  4. package/package.json +4 -3
package/lib/index.cjs CHANGED
@@ -1,99 +1,152 @@
1
1
  'use strict';
2
2
 
3
3
  var BezierEasing = require('bezier-easing');
4
- var color = require('@snigo.dev/color');
5
4
  var lazyCollections = require('lazy-collections');
6
- var perfectFreehand = require('perfect-freehand');
7
- var polygonClipping = require('polygon-clipping');
8
- var ky = require('ky');
9
- var createDOMPurify = require('dompurify');
10
5
  var fastFuzzy = require('fast-fuzzy');
6
+ var createDOMPurify = require('dompurify');
7
+ var slugify = require('@sindresorhus/slugify');
8
+ var arrayShuffle = require('array-shuffle');
11
9
  var klona = require('klona');
12
10
  var dequal = require('dequal');
13
- var slugify = require('@sindresorhus/slugify');
11
+ var merge = require('dset/merge');
12
+ var perfectFreehand = require('perfect-freehand');
13
+ var polygonClipping = require('polygon-clipping');
14
+ var ky = require('ky');
14
15
  var clsx = require('clsx');
15
16
 
16
- function fromComboToAliases(combo) {
17
- const delimiter = "+";
18
- return lazyCollections.pipe(
19
- lazyCollections.unique(),
20
- lazyCollections.map((name) => name === "" ? delimiter : name.toLowerCase()),
21
- lazyCollections.toArray()
22
- )(combo.split(delimiter));
17
+ function createClip(content) {
18
+ return (string) => {
19
+ return string.replace(content, "");
20
+ };
21
+ }
22
+ function createSlug(options) {
23
+ return (string) => {
24
+ return slugify(string, options);
25
+ };
26
+ }
27
+ function createSanitize(options) {
28
+ const dompurify = createDOMPurify();
29
+ dompurify.setConfig(options);
30
+ return (string) => {
31
+ return dompurify.sanitize(string);
32
+ };
33
+ }
34
+ function createSplit(options) {
35
+ const { separator = "", limit } = options;
36
+ return (string) => {
37
+ return string.split(separator, limit);
38
+ };
39
+ }
40
+ function createNumber(options = {}) {
41
+ const { radix = 10 } = options;
42
+ return (string) => parseInt(string, radix);
43
+ }
44
+ function createResults(candidates, options = {}) {
45
+ const narrowedOptions = predicateFunction(options) ? options({ sortKind: fastFuzzy.sortKind }) : options, searcher = new fastFuzzy.Searcher(candidates, narrowedOptions);
46
+ return (query) => searcher.search(query);
23
47
  }
24
48
 
25
- function fromAliasToDownKeys(alias) {
26
- if (alias in keysByAlias) {
27
- return [{ key: keysByAlias[alias] }];
28
- }
49
+ function fromShorthandAliasToLonghandAlias(shorthand) {
50
+ if (capitalLetterRE.test(shorthand))
51
+ return `shift+${shorthand.toLowerCase()}`;
52
+ if (shorthand in keycombosBySpecialCharacter)
53
+ return keycombosBySpecialCharacter[shorthand];
54
+ return shorthand;
55
+ }
56
+ const capitalLetterRE = /^[A-Z]$/;
57
+ const keycombosBySpecialCharacter = {
58
+ "~": "shift+`",
59
+ _: "shift+-",
60
+ "+": "shift+=",
61
+ "{": "shift+[",
62
+ "}": "shift+]",
63
+ "|": "shift+\\",
64
+ ":": "shift+;",
65
+ '"': "shift+'",
66
+ "<": "shift+,",
67
+ ">": "shift+.",
68
+ "?": "shift+/",
69
+ "!": "shift+1",
70
+ "@": "shift+2",
71
+ "#": "shift+3",
72
+ $: "shift+4",
73
+ "%": "shift+5",
74
+ "^": "shift+6",
75
+ "&": "shift+7",
76
+ "*": "shift+8",
77
+ "(": "shift+9",
78
+ ")": "shift+0"
79
+ };
80
+
81
+ function createAliases(options = {}) {
82
+ const { toLonghand = fromShorthandAliasToLonghandAlias } = options;
83
+ return (combo) => {
84
+ const separator = "+", splitByPlus = createSplit({ separator });
85
+ return lazyCollections.pipe(
86
+ splitByPlus,
87
+ lazyCollections.flatMap(
88
+ (alias) => lazyCollections.pipe(
89
+ toLonghand,
90
+ splitByPlus
91
+ )(alias)
92
+ ),
93
+ // If the separator is used as a character in the type,
94
+ // two empty strings will be produced by the split.
95
+ // unique() combines those two into one, and also removes
96
+ // duplicates in longhand transformations.
97
+ lazyCollections.unique(),
98
+ lazyCollections.map((name) => name === "" ? separator : name.toLowerCase()),
99
+ lazyCollections.toArray()
100
+ )(combo);
101
+ };
102
+ }
103
+
104
+ function fromAliasToCode(alias) {
105
+ if (alias in partialCodesByAlias)
106
+ return partialCodesByAlias[alias];
29
107
  if (alias in keyStatusKeysByAlias)
30
108
  return keyStatusKeysByAlias[alias];
31
- return [{
32
- code: (() => {
33
- if (letterRE.test(alias))
34
- return `Key${alias.toUpperCase()}`;
35
- if (digitRE.test(alias))
36
- return `Digit${alias}`;
37
- if (functionRE.test(alias))
38
- return alias.toUpperCase();
39
- return "unsupported";
40
- })()
41
- }];
109
+ if (letterRE.test(alias))
110
+ return `Key${alias.toUpperCase()}`;
111
+ if (digitRE.test(alias))
112
+ return `Digit${alias}`;
113
+ if (functionRE.test(alias))
114
+ return alias.toUpperCase();
115
+ return "unsupported";
42
116
  }
43
117
  const digitRE = /^[0-9]$/;
44
118
  const letterRE = /^[a-zA-Z]$/;
45
119
  const functionRE = /^[fF][0-9]{1,2}$/;
46
120
  const keyStatusKeysByAlias = {
47
- "`": [{ code: "Backquote" }],
48
- "~": [{ code: "Backquote" }, { key: "Shift" }],
49
- "-": [{ code: "Minus" }],
50
- _: [{ code: "Minus" }, { key: "Shift" }],
51
- "=": [{ code: "Equal" }],
52
- "+": [{ code: "Equal" }, { key: "Shift" }],
53
- "[": [{ code: "BracketLeft" }],
54
- "{": [{ code: "BracketLeft" }, { key: "Shift" }],
55
- "]": [{ code: "BracketRight" }],
56
- "}": [{ code: "BracketRight" }, { key: "Shift" }],
57
- "\\": [{ code: "Backslash" }],
58
- "|": [{ code: "Backslash" }, { key: "Shift" }],
59
- ";": [{ code: "Semicolon" }],
60
- ":": [{ code: "Semicolon" }, { key: "Shift" }],
61
- "'": [{ code: "Quote" }],
62
- '"': [{ code: "Quote" }, { key: "Shift" }],
63
- ",": [{ code: "Comma" }],
64
- "<": [{ code: "Comma" }, { key: "Shift" }],
65
- ".": [{ code: "Period" }],
66
- ">": [{ code: "Period" }, { key: "Shift" }],
67
- "/": [{ code: "Slash" }],
68
- "?": [{ code: "Slash" }, { key: "Shift" }],
69
- "!": [{ code: "Digit1" }, { key: "Shift" }],
70
- "@": [{ code: "Digit2" }, { key: "Shift" }],
71
- "#": [{ code: "Digit3" }, { key: "Shift" }],
72
- $: [{ code: "Digit4" }, { key: "Shift" }],
73
- "%": [{ code: "Digit5" }, { key: "Shift" }],
74
- "^": [{ code: "Digit6" }, { key: "Shift" }],
75
- "&": [{ code: "Digit7" }, { key: "Shift" }],
76
- "*": [{ code: "Digit8" }, { key: "Shift" }],
77
- "(": [{ code: "Digit9" }, { key: "Shift" }],
78
- ")": [{ code: "Digit0" }, { key: "Shift" }],
79
- up: [{ code: "ArrowUp" }],
80
- down: [{ code: "ArrowDown" }],
81
- left: [{ code: "ArrowLeft" }],
82
- right: [{ code: "ArrowRight" }],
83
- enter: [{ code: "Enter" }],
84
- space: [{ code: "Space" }],
85
- tab: [{ code: "Tab" }],
86
- esc: [{ code: "Escape" }],
87
- backspace: [{ code: "Backspace" }],
88
- delete: [{ code: "Delete" }],
89
- home: [{ code: "Home" }],
90
- end: [{ code: "End" }],
91
- pagedown: [{ code: "PageDown" }],
92
- pageup: [{ code: "PageUp" }],
93
- capslock: [{ code: "CapsLock" }],
94
- camera: [{ code: "Camera" }]
121
+ "`": "Backquote",
122
+ "-": "Minus",
123
+ "=": "Equal",
124
+ "": "BracketLeft",
125
+ "]": "BracketRight",
126
+ "\\": "Backslash",
127
+ ";": "Semicolon",
128
+ "'": "Quote",
129
+ ",": "Comma",
130
+ ".": "Period",
131
+ "/": "Slash",
132
+ up: "ArrowUp",
133
+ down: "ArrowDown",
134
+ left: "ArrowLeft",
135
+ right: "ArrowRight",
136
+ enter: "Enter",
137
+ space: "Space",
138
+ tab: "Tab",
139
+ esc: "Escape",
140
+ backspace: "Backspace",
141
+ delete: "Delete",
142
+ home: "Home",
143
+ end: "End",
144
+ pagedown: "PageDown",
145
+ pageup: "PageUp",
146
+ capslock: "CapsLock",
147
+ camera: "Camera"
95
148
  };
96
- const keysByAlias = {
149
+ const partialCodesByAlias = {
97
150
  alt: "Alt",
98
151
  opt: "Alt",
99
152
  option: "Alt",
@@ -105,119 +158,6 @@ const keysByAlias = {
105
158
  shift: "Shift"
106
159
  };
107
160
 
108
- const defaultOptions$m = {
109
- toDownKeys: (alias) => fromAliasToDownKeys(alias)
110
- };
111
- const createPredicateKeycomboDown = (keycombo, options = {}) => {
112
- const { toDownKeys } = { ...defaultOptions$m, ...options }, downKeys = lazyCollections.pipe(
113
- fromComboToAliases,
114
- lazyCollections.map(toDownKeys)
115
- )(keycombo);
116
- return (statuses) => {
117
- const predicateAliasEntriesDown = lazyCollections.every(
118
- (key) => statuses.toValue(key) === "down"
119
- );
120
- return lazyCollections.every(predicateAliasEntriesDown)(downKeys);
121
- };
122
- };
123
-
124
- function fromEventToAliases(event) {
125
- if (event.shiftKey && event.code in aliasesByShiftCode) {
126
- return [aliasesByShiftCode[event.code]];
127
- }
128
- if (event.key in aliasListsByModifier) {
129
- return aliasListsByModifier[event.key];
130
- }
131
- return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
132
- }
133
- const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
134
- const aliasesByCode = {
135
- Backquote: "`",
136
- Minus: "-",
137
- Equal: "=",
138
- BracketLeft: "[",
139
- BracketRight: "]",
140
- Backslash: "\\",
141
- Semicolon: ";",
142
- Quote: "'",
143
- Comma: ",",
144
- Period: ".",
145
- Slash: "/",
146
- ArrowUp: "up",
147
- ArrowDown: "down",
148
- ArrowLeft: "left",
149
- ArrowRight: "right",
150
- Enter: "enter",
151
- Space: "space",
152
- Tab: "tab",
153
- Escape: "esc",
154
- Backspace: "backspace",
155
- Delete: "delete",
156
- Home: "home",
157
- End: "end",
158
- PageDown: "pagedown",
159
- PageUp: "pageup",
160
- CapsLock: "capslock",
161
- Camera: "camera"
162
- };
163
- const aliasesByShiftCode = {
164
- Backquote: "~",
165
- Minus: "_",
166
- Equal: "+",
167
- BracketLeft: "{",
168
- BracketRight: "}",
169
- Backslash: "|",
170
- Semicolon: ":",
171
- Quote: '"',
172
- Comma: "<",
173
- Period: ">",
174
- Slash: "?",
175
- Digit1: "!",
176
- Digit2: "@",
177
- Digit3: "#",
178
- Digit4: "$",
179
- Digit5: "%",
180
- Digit6: "^",
181
- Digit7: "&",
182
- Digit8: "*",
183
- Digit9: "(",
184
- Digit0: ")"
185
- };
186
- const aliasListsByModifier = {
187
- Alt: ["alt", "option", "opt"],
188
- Control: ["control", "ctrl"],
189
- Meta: ["meta", "command", "cmd"],
190
- Shift: ["shift"]
191
- };
192
-
193
- const defaultOptions$l = {
194
- toDownKeys: (alias) => fromAliasToDownKeys(alias),
195
- toAliases: (event) => fromEventToAliases(event)
196
- };
197
- const createPredicateKeycomboMatch$1 = (keycombo, options = {}) => {
198
- const { toDownKeys, toAliases } = { ...defaultOptions$l, ...options }, aliases = fromComboToAliases(keycombo), downKeys = lazyCollections.map(toDownKeys)(aliases);
199
- return (statuses) => {
200
- const predicateAliasDown = lazyCollections.every(
201
- (key) => statuses.toValue(key) === "down"
202
- );
203
- return lazyCollections.every(predicateAliasDown)(downKeys) && lazyCollections.every(
204
- ([key, value]) => value === "up" || lazyCollections.pipe(
205
- toAliases,
206
- lazyCollections.some((alias) => lazyCollections.includes(alias)(aliases))
207
- )(key)
208
- )(statuses.toEntries());
209
- };
210
- };
211
-
212
- function createClone() {
213
- return (any) => {
214
- return klona.klona(any);
215
- };
216
- }
217
- function createEqual(compared) {
218
- return (any) => dequal.dequal(any, compared);
219
- }
220
-
221
161
  function createConcat(...arrays) {
222
162
  return (array) => lazyCollections.pipe(
223
163
  lazyCollections.concat(array, ...arrays),
@@ -297,6 +237,8 @@ function createReverse() {
297
237
  };
298
238
  }
299
239
  function createSlice(from, to) {
240
+ if (from < 0 || to && to < 0)
241
+ return (array) => array.slice(from, to);
300
242
  const toSliced = to ? lazyCollections.slice(from, to - 1) : lazyCollections.slice(from);
301
243
  return (array) => {
302
244
  return from === to ? [] : lazyCollections.pipe(
@@ -305,6 +247,11 @@ function createSlice(from, to) {
305
247
  )(array);
306
248
  };
307
249
  }
250
+ function createShuffle() {
251
+ return (array) => {
252
+ return arrayShuffle(array);
253
+ };
254
+ }
308
255
  function createSort(compare) {
309
256
  return (array) => {
310
257
  return lazyCollections.pipe(
@@ -313,19 +260,19 @@ function createSort(compare) {
313
260
  )(array);
314
261
  };
315
262
  }
316
- function createSwap(indices) {
263
+ function createSwap(item1Index, item2Index) {
317
264
  return (array) => {
318
- const { 0: from, 1: to } = indices, { reorderFrom, reorderTo } = (() => {
319
- if (from < to) {
265
+ const { reorderFrom, reorderTo } = (() => {
266
+ if (item1Index < item2Index) {
320
267
  return {
321
- reorderFrom: createReorder(from, to),
322
- reorderTo: createReorder(to - 1, from)
268
+ reorderFrom: createReorder(item1Index, item2Index),
269
+ reorderTo: createReorder(item2Index - 1, item1Index)
323
270
  };
324
271
  }
325
- if (from > to) {
272
+ if (item1Index > item2Index) {
326
273
  return {
327
- reorderFrom: createReorder(from, to),
328
- reorderTo: createReorder(to + 1, from)
274
+ reorderFrom: createReorder(item1Index, item2Index),
275
+ reorderTo: createReorder(item2Index + 1, item1Index)
329
276
  };
330
277
  }
331
278
  return {
@@ -343,6 +290,55 @@ function createUnique() {
343
290
  )(array);
344
291
  }
345
292
 
293
+ function createClone() {
294
+ return (any) => {
295
+ return klona.klona(any);
296
+ };
297
+ }
298
+ function createDeepEqual(compared) {
299
+ return (any) => dequal.dequal(any, compared);
300
+ }
301
+ function createEqual(compared) {
302
+ return (any) => any === compared;
303
+ }
304
+
305
+ function createValue$2(key, options = {}) {
306
+ const { predicateKey = createEqual(key) } = options;
307
+ return (associativeArray) => {
308
+ return lazyCollections.find(
309
+ ([candidate]) => predicateKey(candidate)
310
+ )(associativeArray)?.[1];
311
+ };
312
+ }
313
+ function createHas$1(key, options = {}) {
314
+ const { predicateKey = createEqual(key) } = options;
315
+ return (associativeArray) => {
316
+ return lazyCollections.findIndex(
317
+ ([candidate]) => predicateKey(candidate)
318
+ )(associativeArray) !== -1;
319
+ };
320
+ }
321
+ function createKeys$1() {
322
+ return (associativeArray) => {
323
+ return createMap(([key]) => key)(associativeArray);
324
+ };
325
+ }
326
+ function createValues$1() {
327
+ return (associativeArray) => {
328
+ return createMap(([, value]) => value)(associativeArray);
329
+ };
330
+ }
331
+
332
+ function createForEachAsync(effect) {
333
+ return async (array) => {
334
+ for (let i = 0; i < array.length; i++) {
335
+ const item = array[i];
336
+ await effect(item, i);
337
+ }
338
+ return array;
339
+ };
340
+ }
341
+
346
342
  function createFilterAsync(predicate) {
347
343
  return async (array) => {
348
344
  const transformedAsync = await createMapAsync(predicate)(array);
@@ -367,15 +363,6 @@ function createFindIndexAsync(predicate) {
367
363
  }
368
364
  };
369
365
  }
370
- function createForEachAsync(forEach) {
371
- return async (array) => {
372
- for (let i = 0; i < array.length; i++) {
373
- const item = array[i];
374
- await forEach(item, i);
375
- }
376
- return array;
377
- };
378
- }
379
366
  function createMapAsync(transform) {
380
367
  return async (array) => {
381
368
  return await createReduceAsync(
@@ -400,709 +387,495 @@ function createReduceAsync(accumulate, initialValue) {
400
387
  };
401
388
  }
402
389
 
403
- function createClip(required) {
404
- return (string) => {
405
- return string.replace(required, "");
406
- };
407
- }
408
- function createSlug(options) {
409
- return (string) => {
410
- return slugify(string, options);
411
- };
412
- }
413
-
414
- function createClamp(min, max) {
415
- return (number) => {
416
- const maxed = Math.max(number, min);
417
- return Math.min(maxed, max);
418
- };
419
- }
420
- function createDetermine(potentialities) {
421
- const predicates = createMap(({ outcome, probability }, index) => {
422
- const lowerBound = index === 0 ? 0 : lazyCollections.pipe(
423
- lazyCollections.slice(0, index - 1),
424
- lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
425
- )(potentialities), upperBound = lowerBound + probability;
426
- return {
427
- outcome,
428
- predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
429
- };
430
- })(potentialities);
431
- return (determinant) => lazyCollections.find(({ predicate }) => predicate(determinant))(predicates).outcome;
390
+ function createList() {
391
+ return (...classValues) => clsx(...classValues);
432
392
  }
433
393
 
434
- function createEntries() {
435
- return (object) => {
436
- const entries = [];
437
- for (const key in object) {
438
- entries.push([key, object[key]]);
439
- }
440
- return entries;
441
- };
442
- }
443
- function createKeys() {
444
- return (object) => {
445
- const keys = [];
446
- for (const key in object) {
447
- keys.push(key);
448
- }
449
- return keys;
450
- };
451
- }
452
- function createEvery(predicate) {
453
- return (object) => {
454
- for (const key in object) {
455
- if (!predicate(key, object[key])) {
456
- return false;
457
- }
458
- }
459
- return true;
460
- };
461
- }
462
- function createSome(predicate) {
463
- return (object) => {
464
- for (const key in object) {
465
- if (predicate(key, object[key]))
466
- return true;
467
- }
468
- return false;
394
+ const defaultCreateMixOptions = {
395
+ method: "oklch",
396
+ tag: "div",
397
+ getParent: () => document.body
398
+ };
399
+ function createMix(color2, options = {}) {
400
+ const { method, tag, getParent } = { ...defaultCreateMixOptions, ...options };
401
+ return (color1) => {
402
+ const element = document.createElement(tag), parent = getParent();
403
+ element.style.color = `color-mix(in ${method}, ${color1}, ${color2})`;
404
+ parent.appendChild(element);
405
+ const mixed = getComputedStyle(element).color;
406
+ parent.removeChild(element);
407
+ return mixed;
469
408
  };
470
409
  }
471
410
 
472
- function createRename(from, to) {
473
- return (map) => {
474
- const keys = [...map.keys()], keyToRenameIndex = lazyCollections.findIndex((k) => k === from)(keys), newKeys = createReplace(keyToRenameIndex, to)(keys), values = [...map.values()];
475
- return createReduce((renamed, key, index) => renamed.set(key, values[index]), /* @__PURE__ */ new Map())(newKeys);
476
- };
411
+ function createDepthPathConfig(directedAcyclic) {
412
+ const predicateTerminal = createTerminal(directedAcyclic), predicatePathable = (node) => !predicateTerminal(node), toTraversalCandidates = (path) => lazyCollections.pipe(
413
+ lazyCollections.at(-1),
414
+ createOutgoing(directedAcyclic)
415
+ )(path);
416
+ return { predicatePathable, toTraversalCandidates };
477
417
  }
478
418
 
479
- const defaultOptions$k = {
480
- elementIsCandidate: false,
481
- // Adapted from React Aria https://github.com/adobe/react-spectrum/blob/b6786da906973130a1746b2bee63215bba013ca4/packages/%40react-aria/focus/src/FocusScope.tsx#L256
482
- tabbableSelector: lazyCollections.join(':not([hidden]):not([tabindex="-1"]),')([
483
- "input:not([disabled]):not([type=hidden])",
484
- "select:not([disabled])",
485
- "textarea:not([disabled])",
486
- "button:not([disabled])",
487
- "a[href]",
488
- "area[href]",
489
- "summary",
490
- "iframe",
491
- "object",
492
- "embed",
493
- "audio[controls]",
494
- "video[controls]",
495
- "[contenteditable]",
496
- "[tabindex]:not([disabled])"
497
- ])
498
- };
499
- function createFocusable(order, options = {}) {
500
- const { elementIsCandidate, tabbableSelector } = { ...defaultOptions$k, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
501
- return (element) => {
502
- if (elementIsCandidate && predicateFocusable(element))
503
- return element;
504
- switch (order) {
505
- case "first":
506
- for (let i = 0; i < element.children.length; i++) {
507
- const focusable = createFocusable(order, { elementIsCandidate: true })(element.children[i]);
508
- if (focusable)
509
- return focusable;
510
- }
511
- break;
512
- case "last":
513
- for (let i = element.children.length - 1; i > -1; i--) {
514
- const focusable = createFocusable(order, { elementIsCandidate: true })(element.children[i]);
515
- if (focusable)
516
- return focusable;
517
- }
518
- break;
519
- }
520
- };
419
+ function createBreadthPathConfig(directedAcyclic) {
420
+ const predicateOnlyChild = createOnlyChild(directedAcyclic), predicatePathable = (node) => !predicateOnlyChild(node), toTraversalCandidates = (path) => lazyCollections.pipe(
421
+ lazyCollections.at(-2),
422
+ createOutgoing(directedAcyclic)
423
+ )(path);
424
+ return { predicatePathable, toTraversalCandidates };
521
425
  }
522
426
 
523
- function createToIndegree(graph) {
524
- const toIncoming = createToIncoming(graph);
525
- return (node) => lazyCollections.pipe(
526
- toIncoming,
527
- toLength()
528
- )(node);
529
- }
530
- function createToOutdegree(graph) {
531
- const toOutgoing = createToOutgoing(graph);
532
- return (node) => lazyCollections.pipe(
533
- toOutgoing,
534
- toLength()
535
- )(node);
536
- }
537
- function createToIncoming(graph) {
538
- const { edges } = graph;
539
- return function* (node) {
540
- yield* lazyCollections.filter(
541
- ({ to }) => to === node
542
- )(edges);
543
- };
544
- }
545
- function createToOutgoing(graph) {
546
- const { edges } = graph;
547
- return function* (node) {
548
- yield* lazyCollections.filter(
549
- ({ from }) => from === node
550
- )(edges);
551
- };
552
- }
553
- function createPredicateRoot(graph) {
554
- const toIndegree = createToIndegree(graph);
555
- return (node) => toIndegree(node) === 0;
556
- }
557
-
558
- function createFind(node) {
559
- return (tree) => {
560
- for (const treeNode of tree) {
561
- if (treeNode.node === node)
562
- return treeNode;
563
- const found = createFind(node)(treeNode.children);
564
- if (found)
565
- return found;
566
- }
567
- };
568
- }
569
-
570
- function createToLayers$1(options = {}) {
571
- const toSteps = createToSteps$2(options.createToSteps);
572
- return function toLayers(directedAcyclic) {
573
- const layers = [];
574
- for (const { path } of toSteps(directedAcyclic)) {
575
- const node = path.at(-1), depth = path.length - 1;
576
- (layers[depth] || (layers[depth] = [])).push(node);
577
- }
578
- return layers;
579
- };
580
- }
581
- function createToTree$2(options = {}) {
582
- const toSteps = createToSteps$2(options.createToSteps);
583
- return function toTree(directedAcyclic) {
584
- const firstRoot = lazyCollections.pipe(
585
- createToRoots(),
586
- lazyCollections.at(0)
587
- )(directedAcyclic), tree = [];
588
- tree.push({
589
- node: firstRoot,
590
- children: []
591
- });
592
- for (const { path } of toSteps(directedAcyclic)) {
593
- const node = path.at(-1), parent = path.at(-2);
594
- if (parent) {
595
- const parentTreeNode = createFind(parent)(tree);
596
- if (parentTreeNode) {
597
- parentTreeNode.children.push({
598
- node,
599
- children: []
600
- });
601
- }
602
- }
603
- }
604
- return tree;
605
- };
606
- }
607
- function createToCommonAncestors$2(directedAcyclic) {
608
- const toNodeSteps = createToNodeSteps$2(directedAcyclic);
609
- return function* (a, b) {
610
- for (const { path: aPath } of toNodeSteps(a)) {
611
- for (const { path: bPath } of toNodeSteps(b)) {
612
- for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
613
- for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
614
- if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
615
- yield {
616
- node: aPath[aPathIndex],
617
- distances: {
618
- [a]: aPath.length - aPathIndex - 1,
619
- [b]: bPath.length - bPathIndex - 1
620
- }
621
- };
622
- }
623
- }
624
- }
427
+ class Recognizeable {
428
+ maxSequenceLength;
429
+ effects;
430
+ effectApi;
431
+ constructor(sequence, options = {}) {
432
+ const defaultOptions = {
433
+ maxSequenceLength: true,
434
+ effects: {}
435
+ };
436
+ this.maxSequenceLength = options?.maxSequenceLength || defaultOptions.maxSequenceLength;
437
+ this.effects = options?.effects || defaultOptions.effects;
438
+ this.resetComputedMetadata();
439
+ this.setSequence(sequence);
440
+ this.effectApi = {
441
+ getStatus: () => this.status,
442
+ getMetadata: () => this.metadata,
443
+ setMetadata: (metadata) => this.computedMetadata = metadata,
444
+ recognized: () => this.recognized(),
445
+ denied: () => this.denied(),
446
+ ready: () => this.ready()
447
+ };
448
+ this.ready();
449
+ }
450
+ computedMetadata;
451
+ resetComputedMetadata() {
452
+ this.computedMetadata = {};
453
+ }
454
+ recognized() {
455
+ this.computedStatus = "recognized";
456
+ }
457
+ denied() {
458
+ this.computedStatus = "denied";
459
+ }
460
+ computedStatus;
461
+ ready() {
462
+ this.computedStatus = "ready";
463
+ }
464
+ get sequence() {
465
+ return this.computedSequence;
466
+ }
467
+ set sequence(sequence) {
468
+ this.setSequence(sequence);
469
+ }
470
+ get status() {
471
+ return this.computedStatus;
472
+ }
473
+ get metadata() {
474
+ return this.computedMetadata;
475
+ }
476
+ computedSequence;
477
+ setSequence(sequence) {
478
+ this.computedSequence = sequence;
479
+ return this;
480
+ }
481
+ recognize(sequenceItem, options = {}) {
482
+ this.recognizing();
483
+ const type = this.toType(sequenceItem), pushSequence = (sequenceItem2) => {
484
+ newSequence.push(sequenceItem2);
485
+ if (this.maxSequenceLength !== true && newSequence.length > this.maxSequenceLength) {
486
+ newSequence.shift();
625
487
  }
488
+ }, newSequence = [];
489
+ for (const sequenceItem2 of this.sequence) {
490
+ pushSequence(sequenceItem2);
626
491
  }
627
- };
628
- }
629
- function createPredicateAncestor$2(directedAcyclic) {
630
- const toNodeSteps = createToNodeSteps$2(directedAcyclic);
631
- return function(descendant, ancestor) {
632
- return lazyCollections.pipe(
633
- toNodeSteps,
634
- lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
635
- )(descendant);
636
- };
637
- }
638
- function createToNodeSteps$2(directedAcyclic, options = {}) {
639
- const toSteps = createToSteps$2(options.createToSteps);
640
- return function* (node) {
641
- yield* lazyCollections.pipe(
642
- toSteps,
643
- lazyCollections.filter(({ path }) => path.at(-1) === node)
644
- )(directedAcyclic);
645
- };
646
- }
647
- const defaultCreateToStepsOptions$1 = {
648
- toUnsetMetadata: () => 0,
649
- toMockMetadata: (node, totalConnectionsFollowed) => totalConnectionsFollowed,
650
- kind: "directed acyclic"
651
- };
652
- function createToSteps$2(options = {}) {
653
- const { toUnsetMetadata, toMockMetadata, root, kind } = { ...defaultCreateToStepsOptions$1, ...options };
654
- return function* (directedAcyclic) {
655
- const { nodes } = directedAcyclic, toOutdegree = createToOutdegree(directedAcyclic), toPath = createToPath$2(directedAcyclic), roots = lazyCollections.pipe(
656
- createToRoots({ kind }),
657
- lazyCollections.toArray()
658
- )(directedAcyclic), state = {}, totalConnectionsFollowedByNode = {}, predicateExhausted = (node) => {
659
- return totalConnectionsFollowedByNode[node] === toOutdegree(node);
492
+ pushSequence(sequenceItem);
493
+ this.effectApi.getSequence = () => newSequence;
494
+ this.effectApi.pushSequence = pushSequence;
495
+ this.effectApi.listenInjection = {
496
+ effect: options.listenInjection?.effect || (() => {
497
+ }),
498
+ optionsByType: options.listenInjection?.optionsByType || {}
660
499
  };
661
- for (const node of nodes) {
662
- state[node] = {
663
- status: "unset",
664
- metadata: toUnsetMetadata(node)
665
- };
500
+ this.effects[type]?.(sequenceItem, { ...this.effectApi });
501
+ switch (this.status) {
502
+ case "ready":
503
+ case "denied":
504
+ this.resetComputedMetadata();
505
+ this.setSequence([]);
506
+ break;
507
+ case "recognizing":
508
+ case "recognized":
509
+ this.setSequence(newSequence);
510
+ break;
666
511
  }
667
- let location = root || lazyCollections.at(0)(roots);
668
- const path = toPath(state);
669
- yield { path, state: JSON.parse(JSON.stringify(state)) };
670
- function* toStep() {
671
- if (predicateExhausted(location)) {
672
- if (lazyCollections.includes(location)(roots))
673
- return;
674
- state[location].status = "unset";
675
- state[location].metadata = toUnsetMetadata(location);
676
- const path3 = toPath(state);
677
- location = path3.at(-2);
678
- yield* toStep();
679
- return;
512
+ return this;
513
+ }
514
+ recognizing() {
515
+ this.computedStatus = "recognizing";
516
+ }
517
+ toType(sequenceItem) {
518
+ if (predicateArray(sequenceItem)) {
519
+ if (sequenceItem[0] instanceof IntersectionObserverEntry) {
520
+ return "intersect";
680
521
  }
681
- if (!(location in totalConnectionsFollowedByNode))
682
- totalConnectionsFollowedByNode[location] = 0;
683
- state[location].status = "set";
684
- state[location].metadata = toMockMetadata(location, totalConnectionsFollowedByNode[location]);
685
- const path2 = toPath(state);
686
- yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
687
- totalConnectionsFollowedByNode[location]++;
688
- const newLocation = path2.at(-1);
689
- if (toOutdegree(newLocation) > 0)
690
- location = newLocation;
691
- yield* toStep();
692
- }
693
- yield* toStep();
694
- };
695
- }
696
- function createToPath$2(directedAcyclic) {
697
- const toOutdegree = createToOutdegree(directedAcyclic), toOutgoing = createToOutgoing(directedAcyclic), firstRoot = lazyCollections.pipe(
698
- createToRoots(),
699
- lazyCollections.at(0)
700
- )(directedAcyclic);
701
- return (state) => {
702
- const path = [firstRoot], getLastOutdegree = () => toOutdegree(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
703
- while (getLastOutdegree() > 0 && getLastStatus() === "set") {
704
- const edge = lazyCollections.pipe(
705
- toOutgoing,
706
- lazyCollections.find(
707
- ({ predicateTraversable }) => predicateTraversable(state)
708
- )
709
- )(path.at(-1));
710
- path.push(edge.to);
711
- }
712
- return path;
713
- };
714
- }
715
- function createToRoots(options = {}) {
716
- return function* (directedAcyclic) {
717
- const { nodes } = directedAcyclic;
718
- for (const node of nodes) {
719
- if (createPredicateRoot(directedAcyclic)(node))
720
- yield node;
721
- if (options.kind === "arborescence")
722
- break;
522
+ if (sequenceItem[0] instanceof MutationRecord) {
523
+ return "mutate";
524
+ }
525
+ if (sequenceItem[0] instanceof ResizeObserverEntry) {
526
+ return "resize";
527
+ }
528
+ } else {
529
+ if (sequenceItem instanceof MediaQueryListEvent) {
530
+ return sequenceItem.media;
531
+ }
532
+ if ("didTimeout" in sequenceItem) {
533
+ return "idle";
534
+ }
535
+ return sequenceItem.type;
723
536
  }
724
- };
537
+ }
725
538
  }
726
539
 
727
- function createToLayers(options = {}) {
728
- const toSteps = createToSteps$1(options.createToSteps);
729
- return async function toLayers(directedAcyclic) {
730
- const layers = [];
731
- for await (const { path } of toSteps(directedAcyclic)) {
732
- const node = path.at(-1), depth = path.length - 1;
733
- (layers[depth] || (layers[depth] = [])).push(node);
734
- }
735
- return layers;
736
- };
737
- }
738
- function createToTree$1(options = {}) {
739
- const toSteps = createToSteps$1(options.createToSteps);
740
- return async function toTree(directedAcyclic) {
741
- const firstRoot = lazyCollections.pipe(
742
- createToRoots(),
743
- lazyCollections.at(0)
744
- )(directedAcyclic), tree = [];
745
- tree.push({
746
- node: firstRoot,
747
- children: []
748
- });
749
- for await (const { path } of toSteps(directedAcyclic)) {
750
- const node = path.at(-1), parent = path.at(-2);
751
- if (parent) {
752
- const parentTreeNode = createFind(parent)(tree);
753
- if (parentTreeNode) {
754
- parentTreeNode.children.push({
755
- node,
756
- children: []
757
- });
758
- }
759
- }
540
+ class Listenable {
541
+ computedRecognizeable;
542
+ recognizeableEffectsKeys;
543
+ computedActive;
544
+ constructor(type, options) {
545
+ if (type === "recognizeable") {
546
+ this.computedRecognizeable = new Recognizeable([], options?.recognizeable);
547
+ this.recognizeableEffectsKeys = Object.keys(options?.recognizeable?.effects);
760
548
  }
761
- return tree;
762
- };
763
- }
764
- function createToCommonAncestors$1(directedAcyclic) {
765
- const toNodeSteps = createToNodeSteps$1(directedAcyclic);
766
- return async function* (a, b) {
767
- for await (const { path: aPath } of toNodeSteps(a)) {
768
- for await (const { path: bPath } of toNodeSteps(b)) {
769
- for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
770
- for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
771
- if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
772
- yield {
773
- node: aPath[aPathIndex],
774
- distances: {
775
- [a]: aPath.length - aPathIndex - 1,
776
- [b]: bPath.length - bPathIndex - 1
777
- }
778
- };
779
- }
780
- }
781
- }
782
- }
549
+ this.computedActive = /* @__PURE__ */ new Set();
550
+ this.setType(type);
551
+ this.ready();
552
+ }
553
+ computedStatus;
554
+ ready() {
555
+ this.computedStatus = "ready";
556
+ }
557
+ get type() {
558
+ return this.computedType;
559
+ }
560
+ set type(type) {
561
+ this.setType(type);
562
+ }
563
+ get status() {
564
+ return this.computedStatus;
565
+ }
566
+ get active() {
567
+ return this.computedActive;
568
+ }
569
+ get recognizeable() {
570
+ return this.computedRecognizeable;
571
+ }
572
+ computedType;
573
+ implementation;
574
+ setType(type) {
575
+ this.stop();
576
+ this.computedType = type;
577
+ this.implementation = toImplementation(type);
578
+ return this;
579
+ }
580
+ listen(effect, options = {}) {
581
+ switch (this.implementation) {
582
+ case "intersection":
583
+ this.intersectionListen(effect, options);
584
+ break;
585
+ case "mutation":
586
+ this.mutationListen(effect, options);
587
+ break;
588
+ case "resize":
589
+ this.resizeListen(effect, options);
590
+ break;
591
+ case "mediaquery":
592
+ this.mediaQueryListen(effect, options);
593
+ break;
594
+ case "idle":
595
+ this.idleListen(effect, options);
596
+ break;
597
+ case "message":
598
+ this.messageListen(effect, options);
599
+ break;
600
+ case "recognizeable":
601
+ this.recognizeableListen(effect, options);
602
+ break;
603
+ case "documentevent":
604
+ this.documentEventListen(effect, options);
605
+ break;
606
+ case "event":
607
+ this.eventListen(effect, options);
608
+ break;
783
609
  }
784
- };
785
- }
786
- function createPredicateAncestor$1(directedAcyclic) {
787
- const toNodeSteps = createToNodeSteps$1(directedAcyclic);
788
- return async function(descendant, ancestor) {
789
- return await lazyCollections.pipe(
790
- toNodeSteps,
791
- lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
792
- )(descendant);
793
- };
794
- }
795
- function createToNodeSteps$1(directedAcyclic, options = {}) {
796
- const toSteps = createToSteps$1(options.createToSteps);
797
- return async function* (node) {
798
- yield* await lazyCollections.pipe(
799
- toSteps,
800
- lazyCollections.filter(({ path }) => path.at(-1) === node)
801
- )(directedAcyclic);
802
- };
803
- }
804
- function createToSteps$1(options = {}) {
805
- const { toUnsetMetadata, toMockMetadata, root, kind } = { ...defaultCreateToStepsOptions$1, ...options };
806
- return async function* (directedAcyclic) {
807
- const { nodes } = directedAcyclic, toOutdegree = createToOutdegree(directedAcyclic), toPath = createToPath$1(directedAcyclic), roots = lazyCollections.pipe(
808
- createToRoots({ kind }),
809
- lazyCollections.toArray()
810
- )(directedAcyclic), state = {}, totalConnectionsFollowedByNode = {}, predicateExhausted = (node) => {
811
- return totalConnectionsFollowedByNode[node] === toOutdegree(node);
812
- };
813
- for (const node of nodes) {
814
- state[node] = {
815
- status: "unset",
816
- metadata: toUnsetMetadata(node)
610
+ this.listening();
611
+ return this;
612
+ }
613
+ intersectionListen(effect, options) {
614
+ const { target, observer } = { ...this.getDefaultListenOptions(), ...options }, id = new IntersectionObserver(effect, observer);
615
+ id.observe(target);
616
+ this.active.add({ target, id });
617
+ }
618
+ mutationListen(effect, options) {
619
+ const { target, observe } = { ...this.getDefaultListenOptions(), ...options }, id = new MutationObserver(effect);
620
+ id.observe(target, observe);
621
+ this.active.add({ target, id });
622
+ }
623
+ resizeListen(effect, options) {
624
+ const { target, observe } = { ...this.getDefaultListenOptions(), ...options }, id = new ResizeObserver(effect);
625
+ id.observe(target, observe);
626
+ this.active.add({ target, id });
627
+ }
628
+ mediaQueryListen(effect, options) {
629
+ const target = window.matchMedia(this.type), { instantEffect } = { ...this.getDefaultListenOptions(), ...options };
630
+ instantEffect(target);
631
+ const withApi = (event) => effect(event);
632
+ target.addEventListener("change", withApi);
633
+ this.active.add({ target, id: ["change", withApi] });
634
+ }
635
+ idleListen(effect, options) {
636
+ const { requestIdleCallback } = { ...this.getDefaultListenOptions(), ...options }, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
637
+ this.active.add({ target: window, id });
638
+ }
639
+ messageListen(effect, options) {
640
+ const { target = new BroadcastChannel("baleada") } = options;
641
+ target.addEventListener(this.type, (event) => effect(event));
642
+ this.active.add({ target, id: [this.type, effect] });
643
+ }
644
+ recognizeableListen(effect, options) {
645
+ const guardedEffect = (sequenceItem) => {
646
+ this.recognizeable.recognize(
647
+ sequenceItem,
648
+ { listenInjection: { effect, optionsByType } }
649
+ );
650
+ if (this.recognizeable.status === "recognized")
651
+ effect(sequenceItem);
652
+ }, optionsByType = {};
653
+ for (const type of this.recognizeableEffectsKeys) {
654
+ optionsByType[type] = {
655
+ ...this.getDefaultListenOptions(toImplementation(type)),
656
+ ...options
817
657
  };
818
658
  }
819
- let location = root || lazyCollections.at(0)(roots);
820
- const path = await toPath(state);
821
- yield { path, state: JSON.parse(JSON.stringify(state)) };
822
- async function* toStep() {
823
- if (predicateExhausted(location)) {
824
- if (lazyCollections.includes(location)(roots))
825
- return;
826
- state[location].status = "unset";
827
- state[location].metadata = toUnsetMetadata(location);
828
- const path3 = await toPath(state);
829
- location = path3.at(-2);
830
- yield* await toStep();
831
- return;
832
- }
833
- if (!(location in totalConnectionsFollowedByNode))
834
- totalConnectionsFollowedByNode[location] = 0;
835
- state[location].status = "set";
836
- state[location].metadata = toMockMetadata(location, totalConnectionsFollowedByNode[location]);
837
- const path2 = await toPath(state);
838
- yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
839
- totalConnectionsFollowedByNode[location]++;
840
- const newLocation = path2.at(-1);
841
- if (toOutdegree(newLocation) > 0)
842
- location = newLocation;
843
- yield* await toStep();
844
- }
845
- yield* await toStep();
846
- };
847
- }
848
- function createToPath$1(directedAcyclic) {
849
- const toOutdegree = createToOutdegree(directedAcyclic), toOutgoing = createToOutgoing(directedAcyclic), firstRoot = lazyCollections.pipe(
850
- createToRoots(),
851
- lazyCollections.at(0)
852
- )(directedAcyclic);
853
- return async (state) => {
854
- const path = [firstRoot], getLastOutdegree = () => toOutdegree(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
855
- while (getLastOutdegree() > 0 && getLastStatus() === "set") {
856
- const edge = await lazyCollections.pipe(
857
- toOutgoing,
858
- lazyCollections.toArray(),
859
- createFindAsync(
860
- async ({ predicateTraversable }) => await predicateTraversable(state)
861
- )
862
- )(path.at(-1));
863
- path.push(edge.to);
659
+ for (const type of this.recognizeableEffectsKeys) {
660
+ const listenable = new Listenable(type);
661
+ listenable.listen(guardedEffect, options);
662
+ this.active.add({ id: listenable });
864
663
  }
865
- return path;
866
- };
867
- }
868
-
869
- const defaultCreateToStepsOptions = {
870
- priorityBranch: false,
871
- kind: "directed acyclic"
872
- };
873
- function createToTree(options = {}) {
874
- const withDefaults = {
875
- ...options,
876
- createToSteps: {
877
- ...defaultCreateToStepsOptions,
878
- ...options.createToSteps
664
+ }
665
+ documentEventListen(effect, options) {
666
+ const narrowedOptions = {
667
+ ...this.getDefaultListenOptions(),
668
+ target: document
669
+ };
670
+ this.eventListen(effect, narrowedOptions);
671
+ }
672
+ eventListen(effect, options) {
673
+ const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
674
+ this.addEventListeners(eventListeners, options);
675
+ }
676
+ addEventListeners(eventListeners, options) {
677
+ const { target } = { ...this.getDefaultListenOptions(), ...options };
678
+ for (const eventListener of eventListeners) {
679
+ target.addEventListener(eventListener[0], eventListener[1], eventListener[2]);
680
+ this.active.add({ target, id: eventListener });
879
681
  }
880
- };
881
- return createToTree$2({
882
- ...withDefaults,
883
- createToSteps: toCreateDirectedAcyclicToStepsOptions(withDefaults.createToSteps)
884
- });
885
- }
886
- function createToCommonAncestors(...params) {
887
- return createToCommonAncestors$2(...params);
888
- }
889
- function createPredicateAncestor(...params) {
890
- return createPredicateAncestor$2(...params);
891
- }
892
- function createToNodeSteps(decisionTree, options = {}) {
893
- const withDefaults = {
894
- ...options,
895
- createToSteps: {
896
- ...defaultCreateToStepsOptions,
897
- ...options.createToSteps
682
+ }
683
+ listening() {
684
+ this.computedStatus = "listening";
685
+ }
686
+ stop(options = {}) {
687
+ const { target } = options;
688
+ switch (this.status) {
689
+ case "ready":
690
+ case void 0:
691
+ break;
692
+ default:
693
+ const stoppables = [...this.active].filter((active) => !target || ("target" in active ? active.target === target : false)), shouldUpdateStatus = stoppables.length === this.active.size;
694
+ for (const stoppable of stoppables) {
695
+ stop(stoppable);
696
+ this.active.delete(stoppable);
697
+ }
698
+ if (shouldUpdateStatus) {
699
+ this.stopped();
700
+ }
701
+ break;
898
702
  }
899
- };
900
- return createToNodeSteps$2(
901
- decisionTree,
902
- {
903
- ...withDefaults,
904
- createToSteps: toCreateDirectedAcyclicToStepsOptions(withDefaults.createToSteps)
703
+ return this;
704
+ }
705
+ stopped() {
706
+ this.computedStatus = "stopped";
707
+ }
708
+ getDefaultListenOptions(implementation) {
709
+ switch (implementation || this.implementation) {
710
+ case "intersection":
711
+ return {
712
+ target: document.querySelector("html"),
713
+ observer: {}
714
+ };
715
+ case "mutation":
716
+ return {
717
+ target: document.querySelector("html"),
718
+ observe: {}
719
+ };
720
+ case "resize":
721
+ return {
722
+ target: document.querySelector("html"),
723
+ observe: {}
724
+ };
725
+ case "mediaquery":
726
+ return {
727
+ instantEffect: () => {
728
+ }
729
+ };
730
+ case "idle":
731
+ return {
732
+ requestIdleCallback: {}
733
+ };
734
+ case "message":
735
+ return {
736
+ target: new BroadcastChannel("baleada")
737
+ };
738
+ case "recognizeable":
739
+ return {};
740
+ case "documentevent":
741
+ return {};
742
+ case "event":
743
+ return { target: document };
905
744
  }
906
- );
907
- }
908
- function createToSteps(options = {}) {
909
- const withDefaults = {
910
- ...defaultCreateToStepsOptions,
911
- ...options
912
- };
913
- return createToSteps$2(
914
- toCreateDirectedAcyclicToStepsOptions(withDefaults)
915
- );
916
- }
917
- function createToPath(...params) {
918
- return createToPath$2(...params);
745
+ }
919
746
  }
920
- function toCreateDirectedAcyclicToStepsOptions(options) {
921
- return {
922
- ...defaultCreateToStepsOptions,
923
- ...options,
924
- ...{
925
- toUnsetMetadata: () => false,
926
- toMockMetadata: (node, totalConnectionsFollowed) => options.priorityBranch ? !totalConnectionsFollowed : !!totalConnectionsFollowed
927
- }
928
- };
747
+ function stop(stoppable) {
748
+ if (stoppable.id instanceof Listenable) {
749
+ stoppable.id.stop();
750
+ return;
751
+ }
752
+ if (lazyCollections.some((type) => observerAssertionsByType[type](stoppable.id))(["intersect", "mutate", "resize"])) {
753
+ const { id: id2 } = stoppable;
754
+ id2.disconnect();
755
+ return;
756
+ }
757
+ if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
758
+ const { target: target2, id: id2 } = stoppable;
759
+ target2.removeEventListener(id2[0], id2[1]);
760
+ return;
761
+ }
762
+ if (predicateNumber(stoppable.id)) {
763
+ const { target: target2, id: id2 } = stoppable;
764
+ target2.cancelIdleCallback(id2);
765
+ return;
766
+ }
767
+ if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
768
+ const { target: target2, id: id2 } = stoppable;
769
+ target2.removeEventListener(id2[0], id2[1]);
770
+ return;
771
+ }
772
+ const { target, id } = stoppable;
773
+ target.removeEventListener(id[0], id[1], id[2]);
929
774
  }
930
-
931
- function createList() {
932
- return (...classValues) => clsx(...classValues);
775
+ function toImplementation(type) {
776
+ return lazyCollections.find((implementation) => predicatesByImplementation.get(implementation)(type))(predicatesByImplementation.keys());
933
777
  }
934
-
935
- const defaultOptions$j = {
936
- toId: (node) => node.id,
937
- toChildren: (node) => node.children
778
+ const predicatesByImplementation = /* @__PURE__ */ new Map([
779
+ [
780
+ "recognizeable",
781
+ (type) => type === "recognizeable"
782
+ ],
783
+ [
784
+ "intersection",
785
+ (type) => type === "intersect"
786
+ ],
787
+ [
788
+ "mutation",
789
+ (type) => type === "mutate"
790
+ ],
791
+ [
792
+ "resize",
793
+ (type) => type === "resize"
794
+ ],
795
+ [
796
+ "mediaquery",
797
+ (type) => implementationREs.mediaquery.test(type)
798
+ ],
799
+ [
800
+ "idle",
801
+ (type) => type === "idle"
802
+ ],
803
+ [
804
+ "message",
805
+ (type) => type === "message" || type === "messageerror"
806
+ ],
807
+ [
808
+ "documentevent",
809
+ (type) => documentEvents.has(type)
810
+ ],
811
+ [
812
+ "event",
813
+ () => true
814
+ ]
815
+ ]);
816
+ const documentEvents = /* @__PURE__ */ new Set([
817
+ "fullscreenchange",
818
+ "fullscreenerror",
819
+ "pointerlockchange",
820
+ "pointerlockerror",
821
+ "readystatechange",
822
+ "visibilitychange"
823
+ ]);
824
+ const implementationREs = {
825
+ mediaquery: /^\(.+\)$/
938
826
  };
939
- function createToGraph(options = {}) {
940
- const { toId, toChildren } = { ...defaultOptions$j, ...options };
941
- return function* (tree) {
942
- const root = tree[0], rootId = toId(root);
943
- function* toPair(node, id) {
944
- const children = toChildren(node) || [];
945
- for (const child of children) {
946
- const childId = toId(child);
947
- yield {
948
- node: childId,
949
- edge: { from: id, to: childId }
950
- };
951
- yield* toPair(child, childId);
952
- }
953
- }
954
- yield { node: rootId };
955
- yield* toPair(root, rootId);
956
- };
827
+ function toAddEventListenerParams(type, effect, options) {
828
+ const { addEventListener, useCapture } = options, exceptAndOnlyEffect = createExceptAndOnlyEffect(type, effect, options), effectOptions = [addEventListener || useCapture];
829
+ return { exceptAndOnlyEffect, effectOptions };
957
830
  }
958
-
959
- const defaultOptions$i = {
960
- toDownKeys: (alias) => fromAliasToDownKeys(alias),
961
- toAliases: (event) => fromEventToAliases(event)
962
- };
963
- const createPredicateKeycomboMatch = (keycombo, options = {}) => {
964
- const { toDownKeys, toAliases } = { ...defaultOptions$i, ...options }, aliases = fromComboToAliases(keycombo), downKeys = createMap(toDownKeys)(aliases), implicitModifierAliases = (() => {
965
- const implicitModifierAliases2 = [];
966
- for (const aliasDownKeys of downKeys) {
967
- for (const { key } of aliasDownKeys) {
968
- if (lazyCollections.includes(key)(modifiers))
969
- implicitModifierAliases2.push(key.toLowerCase());
970
- }
971
- }
972
- return implicitModifierAliases2;
973
- })();
974
- return (event) => {
975
- const statuses = createKeyStatuses(), predicateAliasDown = lazyCollections.every(
976
- (key) => statuses.toValue(key) === "down"
977
- );
978
- statuses.set(fromEventToKeyStatusKey(event), "down");
979
- for (const modifier of modifiers) {
980
- if (event[`${modifier.toLowerCase()}Key`])
981
- statuses.set({ key: modifier }, "down");
982
- }
983
- const events = createMap(
984
- ([key]) => {
985
- const e = { ...key };
986
- for (const modifier of modifiers) {
987
- e[`${modifier.toLowerCase()}Key`] = event[`${modifier.toLowerCase()}Key`];
988
- }
989
- return e;
990
- }
991
- )(statuses.toEntries());
992
- return lazyCollections.every(predicateAliasDown)(downKeys) && lazyCollections.every(
993
- (e) => lazyCollections.pipe(
994
- toAliases,
995
- lazyCollections.some(
996
- (alias) => lazyCollections.includes(alias)(aliases) || lazyCollections.includes(alias)(implicitModifierAliases)
997
- )
998
- )(e)
999
- )(events);
1000
- };
1001
- };
1002
-
1003
- const defaultOptions$h = {
1004
- initial: [],
1005
- createPredicateKey: (query) => (candidate) => query === candidate
831
+ const observerAssertionsByType = {
832
+ intersect: (observer) => observer instanceof IntersectionObserver,
833
+ mutate: (observer) => observer instanceof MutationObserver,
834
+ resize: (observer) => observer instanceof ResizeObserver
1006
835
  };
1007
- function createAssociativeArray(options = {}) {
1008
- const { initial, createPredicateKey } = { ...defaultOptions$h, ...options }, entries = [...initial];
1009
- const toValue = (key) => {
1010
- const predicateKey = createPredicateKey(key);
1011
- return lazyCollections.find(
1012
- ([candidate]) => predicateKey(candidate)
1013
- )(entries)?.[1];
1014
- };
1015
- const set = (key, value) => {
1016
- const predicateKey = createPredicateKey(key), index = lazyCollections.findIndex(
1017
- ([candidate]) => predicateKey(candidate)
1018
- )(entries);
1019
- if (index === -1) {
1020
- entries.push([key, value]);
1021
- return;
1022
- }
1023
- entries[index][1] = value;
1024
- };
1025
- const predicateHas = (key) => {
1026
- const predicateKey = createPredicateKey(key);
1027
- return lazyCollections.findIndex(
1028
- ([candidate]) => predicateKey(candidate)
1029
- )(entries) !== -1;
1030
- };
1031
- const clear = () => {
1032
- entries.length = 0;
1033
- };
1034
- const del = (key) => {
1035
- const predicateKey = createPredicateKey(key), index = lazyCollections.findIndex(
1036
- ([candidate]) => predicateKey(candidate)
1037
- )(entries);
1038
- if (index === -1) {
1039
- return false;
1040
- }
1041
- entries.splice(index, 1);
1042
- return true;
1043
- };
1044
- const toKeys = () => {
1045
- return createMap(([key]) => key)(entries);
1046
- };
1047
- const toValues = () => {
1048
- return createMap(([, value]) => value)(entries);
1049
- };
1050
- const toEntries = () => {
1051
- return entries;
1052
- };
1053
- return {
1054
- toValue,
1055
- set,
1056
- predicateHas,
1057
- clear,
1058
- delete: del,
1059
- toKeys,
1060
- toValues,
1061
- toEntries
1062
- // get: toValue,
1063
- // has: predicateHas,
1064
- // keys: toKeys,
1065
- // values: toValues,
1066
- };
1067
- }
1068
836
 
1069
- const defaultOptions$g = {
837
+ const defaultOptions$k = {
1070
838
  minDuration: 0,
1071
839
  preventsDefaultUnlessDenied: true,
1072
- toDownKeys: (alias) => fromAliasToDownKeys(alias),
1073
- toAliases: (event) => fromEventToAliases(event)
840
+ toCode: (alias) => fromAliasToCode(alias),
841
+ toAliases: (code) => fromCodeToAliases(code)
1074
842
  };
1075
843
  function createKeypress(keycomboOrKeycombos, options = {}) {
1076
844
  const {
1077
845
  minDuration,
1078
846
  preventsDefaultUnlessDenied,
1079
- toDownKeys,
847
+ toLonghand,
848
+ toCode,
1080
849
  toAliases,
1081
850
  onDown,
1082
851
  onUp,
1083
852
  onVisibilitychange
1084
- } = { ...defaultOptions$g, ...options }, {
853
+ } = { ...defaultOptions$k, ...options }, {
1085
854
  matchPredicatesByKeycombo,
1086
855
  getDownCombos,
1087
856
  predicateValid,
1088
857
  cleanup,
1089
- statuses
858
+ statuses,
859
+ toStatus,
860
+ setStatus,
861
+ clearStatuses,
862
+ deleteStatus
1090
863
  } = createKeyState({
1091
864
  keycomboOrKeycombos,
1092
- unsupportedAliases: unsupportedAliases$2,
1093
- toDownKeys,
865
+ toLonghand,
866
+ toCode,
1094
867
  toAliases,
1095
868
  getRequest: () => request
1096
- });
869
+ }), fromComboToAliasesLength = createAliasesLength({ toLonghand });
1097
870
  let request;
1098
871
  let localStatus;
1099
872
  const keydown = (event, api) => {
1100
- const { denied, getStatus } = api, key = fromEventToKeyStatusKey(event);
1101
- if (statuses.toValue(key) === "down") {
873
+ const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
874
+ if (toStatus(key) === "down") {
1102
875
  onDown?.(toHookApi(api));
1103
876
  return;
1104
877
  }
1105
- statuses.set(key, "down");
878
+ setStatus(key, "down");
1106
879
  if (localStatus === "denied") {
1107
880
  denied();
1108
881
  onDown?.(toHookApi(api));
@@ -1115,15 +888,15 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
1115
888
  ) {
1116
889
  denied();
1117
890
  localStatus = getStatus();
1118
- if (lazyCollections.includes(event.key)(unsupportedKeys$2))
1119
- statuses.clear();
891
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
892
+ clearStatuses();
1120
893
  onDown?.(toHookApi(api));
1121
894
  return;
1122
895
  }
1123
896
  if (preventsDefaultUnlessDenied)
1124
897
  event.preventDefault();
1125
898
  const { getMetadata } = api, metadata = getMetadata();
1126
- metadata.pressed = downCombos[0];
899
+ metadata.keycombo = downCombos[0];
1127
900
  localStatus = "recognizing";
1128
901
  cleanup();
1129
902
  storeKeyboardTimeMetadata({
@@ -1132,6 +905,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
1132
905
  getTimeMetadata: getMetadata,
1133
906
  getShouldStore: () => downCombos.length && getDownCombos()[0] === downCombos[0],
1134
907
  setRequest: (newRequest) => request = newRequest,
908
+ // @ts-expect-error
1135
909
  recognize
1136
910
  });
1137
911
  onDown?.(toHookApi(api));
@@ -1145,23 +919,23 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
1145
919
  }
1146
920
  };
1147
921
  const keyup = (event, api) => {
1148
- const { denied } = api, key = fromEventToKeyStatusKey(event);
922
+ const { denied } = api, key = fromEventToKeyStatusCode(event);
1149
923
  if (localStatus === "denied") {
1150
924
  denied();
1151
- if (lazyCollections.includes(event.key)(unsupportedKeys$2))
1152
- statuses.clear();
925
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
926
+ clearStatuses();
1153
927
  else
1154
- statuses.delete(key);
928
+ deleteStatus(key);
1155
929
  if (!predicateSomeKeyDown(statuses))
1156
930
  localStatus = "recognizing";
1157
931
  onUp?.(toHookApi(api));
1158
932
  return;
1159
933
  }
1160
- statuses.delete(key);
934
+ deleteStatus(key);
1161
935
  const downCombos = getDownCombos(), matches = matchPredicatesByKeycombo[downCombos[0]]?.(statuses);
1162
936
  if (downCombos.length && matches) {
1163
937
  const { getMetadata } = api, metadata = getMetadata();
1164
- metadata.pressed = downCombos[0];
938
+ metadata.keycombo = downCombos[0];
1165
939
  if (preventsDefaultUnlessDenied)
1166
940
  event.preventDefault();
1167
941
  localStatus = "recognizing";
@@ -1174,7 +948,7 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
1174
948
  };
1175
949
  const visibilitychange = (event, api) => {
1176
950
  if (document.visibilityState === "hidden") {
1177
- statuses.clear();
951
+ clearStatuses();
1178
952
  localStatus = "recognizing";
1179
953
  cleanup();
1180
954
  }
@@ -1186,45 +960,63 @@ function createKeypress(keycomboOrKeycombos, options = {}) {
1186
960
  visibilitychange
1187
961
  };
1188
962
  }
1189
- const unsupportedAliases$2 = ["meta", "command", "cmd"];
1190
- const unsupportedKeys$2 = ["Meta"];
963
+ class Keypress extends Listenable {
964
+ constructor(keycomboOrKeycombos, options) {
965
+ super(
966
+ "recognizeable",
967
+ {
968
+ recognizeable: {
969
+ effects: createKeypress(keycomboOrKeycombos, options)
970
+ }
971
+ }
972
+ );
973
+ }
974
+ get metadata() {
975
+ return this.recognizeable.metadata;
976
+ }
977
+ }
1191
978
 
1192
- const defaultOptions$f = {
979
+ const defaultOptions$j = {
1193
980
  minDuration: 0,
1194
981
  preventsDefaultUnlessDenied: true,
1195
- toDownKeys: (alias) => fromAliasToDownKeys(alias),
1196
- toAliases: (event) => fromEventToAliases(event)
982
+ toCode: (alias) => fromAliasToCode(alias),
983
+ toAliases: (code) => fromCodeToAliases(code)
1197
984
  };
1198
985
  function createKeyrelease(keycomboOrKeycombos, options = {}) {
1199
986
  const {
1200
987
  minDuration,
1201
988
  preventsDefaultUnlessDenied,
1202
- toDownKeys,
989
+ toLonghand,
990
+ toCode,
1203
991
  toAliases,
1204
992
  onDown,
1205
993
  onUp,
1206
994
  onVisibilitychange
1207
- } = { ...defaultOptions$f, ...options }, {
995
+ } = { ...defaultOptions$j, ...options }, {
1208
996
  matchPredicatesByKeycombo,
1209
997
  getDownCombos,
1210
998
  predicateValid,
1211
999
  cleanup,
1212
- statuses
1000
+ statuses,
1001
+ toStatus,
1002
+ setStatus,
1003
+ clearStatuses,
1004
+ deleteStatus
1213
1005
  } = createKeyState({
1214
1006
  keycomboOrKeycombos,
1215
- unsupportedAliases: unsupportedAliases$1,
1216
- toDownKeys,
1007
+ toLonghand,
1008
+ toCode,
1217
1009
  toAliases,
1218
1010
  getRequest: () => request
1219
- });
1011
+ }), fromComboToAliasesLength = createAliasesLength({ toLonghand });
1220
1012
  let request, localStatus;
1221
1013
  const keydown = (event, api) => {
1222
- const { denied, getStatus } = api, key = fromEventToKeyStatusKey(event);
1223
- if (statuses.toValue(key) === "down") {
1014
+ const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
1015
+ if (toStatus(key) === "down") {
1224
1016
  onDown?.(toHookApi(api));
1225
1017
  return;
1226
1018
  }
1227
- statuses.set(key, "down");
1019
+ setStatus(key, "down");
1228
1020
  if (localStatus === "denied") {
1229
1021
  denied();
1230
1022
  onDown?.(toHookApi(api));
@@ -1237,8 +1029,8 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1237
1029
  ) {
1238
1030
  denied();
1239
1031
  localStatus = getStatus();
1240
- if (lazyCollections.includes(event.key)(unsupportedKeys$1))
1241
- statuses.clear();
1032
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
1033
+ clearStatuses();
1242
1034
  onDown?.(toHookApi(api));
1243
1035
  return;
1244
1036
  }
@@ -1261,21 +1053,21 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1261
1053
  getStatus,
1262
1054
  getMetadata,
1263
1055
  denied
1264
- } = api, metadata = getMetadata(), key = fromEventToKeyStatusKey(event);
1056
+ } = api, metadata = getMetadata(), key = fromEventToKeyStatusCode(event);
1265
1057
  if (["denied", "recognized"].includes(localStatus)) {
1266
1058
  if (localStatus === "denied")
1267
1059
  denied();
1268
- if (lazyCollections.includes(event.key)(unsupportedKeys$1))
1269
- statuses.clear();
1060
+ if (lazyCollections.includes(event.key)(unsupportedKeys))
1061
+ clearStatuses();
1270
1062
  else
1271
- statuses.delete(key);
1063
+ deleteStatus(key);
1272
1064
  if (!predicateSomeKeyDown(statuses))
1273
1065
  localStatus = "recognizing";
1274
1066
  onUp?.(toHookApi(api));
1275
1067
  return;
1276
1068
  }
1277
1069
  const downCombos = getDownCombos(), matches = matchPredicatesByKeycombo[downCombos[0]]?.(statuses);
1278
- statuses.delete(key);
1070
+ deleteStatus(key);
1279
1071
  if (!downCombos.length || !matches) {
1280
1072
  onUp?.(toHookApi(api));
1281
1073
  return;
@@ -1284,7 +1076,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1284
1076
  const status = getStatus();
1285
1077
  if (status === "recognized") {
1286
1078
  localStatus = status;
1287
- metadata.released = downCombos[0];
1079
+ metadata.keycombo = downCombos[0];
1288
1080
  }
1289
1081
  if (preventsDefaultUnlessDenied)
1290
1082
  event.preventDefault();
@@ -1300,7 +1092,7 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1300
1092
  };
1301
1093
  const visibilitychange = (event, api) => {
1302
1094
  if (document.visibilityState === "hidden") {
1303
- statuses.clear();
1095
+ clearStatuses();
1304
1096
  localStatus = "recognizing";
1305
1097
  cleanup();
1306
1098
  }
@@ -1312,50 +1104,64 @@ function createKeyrelease(keycomboOrKeycombos, options = {}) {
1312
1104
  visibilitychange
1313
1105
  };
1314
1106
  }
1315
- const unsupportedAliases$1 = ["meta", "command", "cmd"];
1316
- const unsupportedKeys$1 = ["Meta"];
1107
+ class Keyrelease extends Listenable {
1108
+ constructor(keycomboOrKeycombos, options) {
1109
+ super(
1110
+ "recognizeable",
1111
+ {
1112
+ recognizeable: {
1113
+ effects: createKeyrelease(keycomboOrKeycombos, options)
1114
+ }
1115
+ }
1116
+ );
1117
+ }
1118
+ get metadata() {
1119
+ return this.recognizeable.metadata;
1120
+ }
1121
+ }
1317
1122
 
1318
- const defaultOptions$e = {
1123
+ const defaultOptions$i = {
1319
1124
  minDuration: 0,
1320
1125
  maxInterval: 5e3,
1321
1126
  // VS Code default
1322
1127
  preventsDefaultUnlessDenied: true,
1323
- toDownKeys: (alias) => fromAliasToDownKeys(alias),
1324
- toAliases: (event) => fromEventToAliases(event)
1128
+ toCode: (alias) => fromAliasToCode(alias),
1129
+ toAliases: (code) => fromCodeToAliases(code)
1325
1130
  };
1326
- function createKeychord(keychord, options = {}) {
1131
+ function createKeychord(keycombos, options = {}) {
1327
1132
  const {
1328
1133
  minDuration,
1329
1134
  maxInterval,
1330
1135
  preventsDefaultUnlessDenied,
1331
- toDownKeys,
1136
+ toLonghand,
1137
+ toCode,
1332
1138
  toAliases,
1333
1139
  onDown,
1334
1140
  onUp,
1335
1141
  onVisibilitychange
1336
- } = { ...defaultOptions$e, ...options }, narrowedKeychord = keychord.split(" "), keyStates = createMap((keycombo) => createKeyState({
1142
+ } = { ...defaultOptions$i, ...options }, narrowedKeycombos = keycombos.split(" "), keyStates = createMap((keycombo) => createKeyState({
1337
1143
  keycomboOrKeycombos: keycombo,
1338
- unsupportedAliases,
1339
- toDownKeys,
1144
+ toLonghand,
1145
+ toCode,
1340
1146
  toAliases,
1341
1147
  getRequest: () => request
1342
- }))(narrowedKeychord), localStatuses = createMap(
1148
+ }))(narrowedKeycombos), localStatuses = createMap(
1343
1149
  () => "recognizing"
1344
- )(keyStates);
1150
+ )(keyStates), fromComboToAliasesLength = createAliasesLength({ toLonghand });
1345
1151
  let request, playedIndex = 0;
1346
1152
  const keydown = (event, api) => {
1347
- const { denied, getStatus } = api, key = fromEventToKeyStatusKey(event);
1348
- if (keyStates[playedIndex].statuses.toValue(key) === "down") {
1153
+ const { denied, getStatus } = api, key = fromEventToKeyStatusCode(event);
1154
+ if (keyStates[playedIndex].toStatus(key) === "down") {
1349
1155
  onDown?.(toHookApi(api));
1350
1156
  return;
1351
1157
  }
1352
1158
  if (localStatuses[playedIndex] === "recognized") {
1353
1159
  playedIndex++;
1354
- for (const [key2, status] of keyStates[playedIndex - 1].statuses.toEntries()) {
1355
- keyStates[playedIndex].statuses.set(key2, status);
1160
+ for (const [key2, status] of keyStates[playedIndex - 1].statuses) {
1161
+ keyStates[playedIndex].setStatus(key2, status);
1356
1162
  }
1357
1163
  }
1358
- keyStates[playedIndex].statuses.set(key, "down");
1164
+ keyStates[playedIndex].setStatus(key, "down");
1359
1165
  if (localStatuses[playedIndex] === "denied") {
1360
1166
  denied();
1361
1167
  onDown?.(toHookApi(api));
@@ -1371,8 +1177,8 @@ function createKeychord(keychord, options = {}) {
1371
1177
  denied();
1372
1178
  localStatuses[playedIndex] = getStatus();
1373
1179
  if (lazyCollections.includes(event.key)(unsupportedKeys)) {
1374
- for (const { statuses } of keyStates)
1375
- statuses.clear();
1180
+ for (const { clearStatuses } of keyStates)
1181
+ clearStatuses();
1376
1182
  }
1377
1183
  onDown?.(toHookApi(api));
1378
1184
  return;
@@ -1398,30 +1204,30 @@ function createKeychord(keychord, options = {}) {
1398
1204
  getStatus,
1399
1205
  getMetadata,
1400
1206
  denied
1401
- } = api, metadata = getMetadata(), key = fromEventToKeyStatusKey(event);
1207
+ } = api, metadata = getMetadata(), key = fromEventToKeyStatusCode(event);
1402
1208
  if (["denied", "recognized"].includes(localStatuses[playedIndex])) {
1403
1209
  if (localStatuses[playedIndex] === "denied")
1404
1210
  denied();
1405
- for (const { statuses } of keyStates) {
1211
+ for (const { clearStatuses, deleteStatus } of keyStates) {
1406
1212
  if (lazyCollections.includes(event.key)(unsupportedKeys))
1407
- statuses.clear();
1213
+ clearStatuses();
1408
1214
  else
1409
- statuses.delete(key);
1215
+ deleteStatus(key);
1410
1216
  }
1411
1217
  if (!predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
1412
- if (localStatuses[playedIndex] === "denied" || playedIndex === narrowedKeychord.length - 1 && localStatuses[playedIndex] === "recognized") {
1218
+ if (localStatuses[playedIndex] === "denied" || playedIndex === narrowedKeycombos.length - 1 && localStatuses[playedIndex] === "recognized") {
1413
1219
  playedIndex = 0;
1414
1220
  for (let i = 0; i < localStatuses.length; i++)
1415
1221
  localStatuses[i] = "recognizing";
1416
- for (const { statuses } of keyStates)
1417
- statuses.clear();
1222
+ for (const { clearStatuses } of keyStates)
1223
+ clearStatuses();
1418
1224
  }
1419
1225
  }
1420
1226
  onUp?.(toHookApi(api));
1421
1227
  return;
1422
1228
  }
1423
1229
  const downCombos = keyStates[playedIndex].getDownCombos(), matches = keyStates[playedIndex].matchPredicatesByKeycombo[downCombos[0]]?.(keyStates[playedIndex].statuses);
1424
- keyStates[playedIndex].statuses.delete(key);
1230
+ keyStates[playedIndex].deleteStatus(key);
1425
1231
  if (!downCombos.length || !matches) {
1426
1232
  onUp?.(toHookApi(api));
1427
1233
  return;
@@ -1431,17 +1237,17 @@ function createKeychord(keychord, options = {}) {
1431
1237
  if (status === "recognizing" && localStatuses[playedIndex] === "recognized" || status === "recognized") {
1432
1238
  metadata.played[playedIndex] = {
1433
1239
  ...metadata.played[playedIndex],
1434
- released: downCombos[0]
1240
+ keycombo: downCombos[0]
1435
1241
  };
1436
1242
  }
1437
1243
  if (preventsDefaultUnlessDenied)
1438
1244
  event.preventDefault();
1439
- if (playedIndex === narrowedKeychord.length - 1 && !predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
1245
+ if (playedIndex === narrowedKeycombos.length - 1 && !predicateSomeKeyDown(keyStates[playedIndex].statuses)) {
1440
1246
  playedIndex = 0;
1441
1247
  for (let i = 0; i < localStatuses.length; i++)
1442
1248
  localStatuses[i] = "recognizing";
1443
- for (const { statuses } of keyStates)
1444
- statuses.clear();
1249
+ for (const { clearStatuses } of keyStates)
1250
+ clearStatuses();
1445
1251
  }
1446
1252
  onUp?.(toHookApi(api));
1447
1253
  };
@@ -1451,7 +1257,7 @@ function createKeychord(keychord, options = {}) {
1451
1257
  denied();
1452
1258
  return;
1453
1259
  }
1454
- if (playedIndex === narrowedKeychord.length - 1) {
1260
+ if (playedIndex === narrowedKeycombos.length - 1) {
1455
1261
  recognized();
1456
1262
  localStatuses[playedIndex] = "recognized";
1457
1263
  return;
@@ -1460,8 +1266,8 @@ function createKeychord(keychord, options = {}) {
1460
1266
  };
1461
1267
  const visibilitychange = (event, api) => {
1462
1268
  if (document.visibilityState === "hidden") {
1463
- for (const { statuses } of keyStates)
1464
- statuses.clear();
1269
+ for (const { clearStatuses } of keyStates)
1270
+ clearStatuses();
1465
1271
  localStatuses[playedIndex] = "recognizing";
1466
1272
  keyStates[playedIndex].cleanup();
1467
1273
  playedIndex = 0;
@@ -1474,30 +1280,56 @@ function createKeychord(keychord, options = {}) {
1474
1280
  visibilitychange
1475
1281
  };
1476
1282
  }
1477
- const unsupportedAliases = ["meta", "command", "cmd"];
1478
- const unsupportedKeys = ["Meta"];
1283
+ class Keychord extends Listenable {
1284
+ constructor(keycombos, options) {
1285
+ super(
1286
+ "recognizeable",
1287
+ {
1288
+ recognizeable: {
1289
+ effects: createKeychord(keycombos, options)
1290
+ }
1291
+ }
1292
+ );
1293
+ }
1294
+ get metadata() {
1295
+ return this.recognizeable.metadata;
1296
+ }
1297
+ }
1479
1298
 
1480
1299
  function createKonami(options = {}) {
1481
1300
  return createKeychord("up up down down left right left right b a enter", options);
1482
1301
  }
1302
+ class Konami extends Listenable {
1303
+ constructor(options) {
1304
+ super(
1305
+ "recognizeable",
1306
+ {
1307
+ recognizeable: {
1308
+ effects: createKonami(options)
1309
+ }
1310
+ }
1311
+ );
1312
+ }
1313
+ get metadata() {
1314
+ return this.recognizeable.metadata;
1315
+ }
1316
+ }
1483
1317
 
1484
- const defaultOptions$d = {
1318
+ const defaultOptions$h = {
1485
1319
  minDuration: 0,
1486
- minDistance: 0,
1487
- getMousemoveTarget: (event) => event.target
1320
+ minDistance: 0
1488
1321
  };
1489
1322
  function createMousepress(options = {}) {
1490
1323
  const {
1491
1324
  minDuration,
1492
1325
  minDistance,
1493
- getMousemoveTarget,
1494
1326
  onDown,
1495
1327
  onLeave,
1496
1328
  onMove,
1497
1329
  onUp
1498
- } = { ...defaultOptions$d, ...options }, cleanup = (event) => {
1330
+ } = { ...defaultOptions$h, ...options }, cleanup = (target) => {
1499
1331
  window.cancelAnimationFrame(request);
1500
- getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
1332
+ target.removeEventListener("mousemove", mousemoveEffect);
1501
1333
  };
1502
1334
  let request;
1503
1335
  let mousemoveEffect;
@@ -1512,9 +1344,11 @@ function createMousepress(options = {}) {
1512
1344
  api,
1513
1345
  () => mouseStatus === "down",
1514
1346
  (newRequest) => request = newRequest,
1347
+ // @ts-expect-error
1515
1348
  recognize
1516
1349
  );
1517
- getMousemoveTarget(event).addEventListener("mousemove", mousemoveEffect);
1350
+ const { listenInjection: { optionsByType: { mousedown: { target } } } } = api;
1351
+ target.addEventListener("mousemove", mousemoveEffect);
1518
1352
  onDown?.(toHookApi(api));
1519
1353
  };
1520
1354
  const mousemove = (event, api) => {
@@ -1531,20 +1365,20 @@ function createMousepress(options = {}) {
1531
1365
  }
1532
1366
  };
1533
1367
  const mouseleave = (event, api) => {
1534
- const { denied } = api;
1368
+ const { denied, listenInjection: { optionsByType: { mouseleave: { target } } } } = api;
1535
1369
  if (mouseStatus === "down") {
1536
1370
  denied();
1537
- cleanup(event);
1371
+ cleanup(target);
1538
1372
  mouseStatus = "leave";
1539
1373
  }
1540
1374
  onLeave?.(toHookApi(api));
1541
1375
  };
1542
1376
  const mouseup = (event, api) => {
1543
- const { denied } = api;
1377
+ const { denied, listenInjection: { optionsByType: { mouseup: { target } } } } = api;
1544
1378
  if (mouseStatus !== "down")
1545
1379
  return;
1546
1380
  denied();
1547
- cleanup(event);
1381
+ cleanup(target);
1548
1382
  mouseStatus = "up";
1549
1383
  onUp?.(toHookApi(api));
1550
1384
  };
@@ -1554,26 +1388,39 @@ function createMousepress(options = {}) {
1554
1388
  mouseup
1555
1389
  };
1556
1390
  }
1391
+ class Mousepress extends Listenable {
1392
+ constructor(options) {
1393
+ super(
1394
+ "recognizeable",
1395
+ {
1396
+ recognizeable: {
1397
+ effects: createMousepress(options)
1398
+ }
1399
+ }
1400
+ );
1401
+ }
1402
+ get metadata() {
1403
+ return this.recognizeable.metadata;
1404
+ }
1405
+ }
1557
1406
 
1558
- const defaultOptions$c = {
1407
+ const defaultOptions$g = {
1559
1408
  minDuration: 0,
1560
1409
  minDistance: 0,
1561
- minVelocity: 0,
1562
- getMousemoveTarget: (event) => event.target
1410
+ minVelocity: 0
1563
1411
  };
1564
1412
  function createMouserelease(options = {}) {
1565
1413
  const {
1566
1414
  minDuration,
1567
1415
  minDistance,
1568
1416
  minVelocity,
1569
- getMousemoveTarget,
1570
1417
  onDown,
1571
1418
  onLeave,
1572
1419
  onMove,
1573
1420
  onUp
1574
- } = { ...defaultOptions$c, ...options }, cleanup = (event) => {
1421
+ } = { ...defaultOptions$g, ...options }, cleanup = (target) => {
1575
1422
  window.cancelAnimationFrame(request);
1576
- getMousemoveTarget(event).removeEventListener("mousemove", mousemoveEffect);
1423
+ target.removeEventListener("mousemove", mousemoveEffect);
1577
1424
  };
1578
1425
  let request;
1579
1426
  let mousemoveEffect;
@@ -1589,7 +1436,8 @@ function createMouserelease(options = {}) {
1589
1436
  () => mouseStatus === "down",
1590
1437
  (newRequest) => request = newRequest
1591
1438
  );
1592
- getMousemoveTarget(event).addEventListener("mousemove", mousemoveEffect);
1439
+ const { listenInjection: { optionsByType: { mousedown: { target } } } } = api;
1440
+ target.addEventListener("mousemove", mousemoveEffect);
1593
1441
  onDown?.(toHookApi(api));
1594
1442
  };
1595
1443
  const mousemove = (event, api) => {
@@ -1597,10 +1445,10 @@ function createMouserelease(options = {}) {
1597
1445
  onMove?.(toHookApi(api));
1598
1446
  };
1599
1447
  const mouseleave = (event, api) => {
1600
- const { denied } = api;
1448
+ const { denied, listenInjection: { optionsByType: { mouseleave: { target } } } } = api;
1601
1449
  if (mouseStatus === "down") {
1602
1450
  denied();
1603
- cleanup(event);
1451
+ cleanup(target);
1604
1452
  mouseStatus = "leave";
1605
1453
  }
1606
1454
  onLeave?.(toHookApi(api));
@@ -1609,7 +1457,8 @@ function createMouserelease(options = {}) {
1609
1457
  if (mouseStatus !== "down")
1610
1458
  return;
1611
1459
  storePointerMoveMetadata(event, api);
1612
- cleanup(event);
1460
+ const { listenInjection: { optionsByType: { mouseup: { target } } } } = api;
1461
+ cleanup(target);
1613
1462
  mouseStatus = "up";
1614
1463
  recognize(event, api);
1615
1464
  onUp?.(toHookApi(api));
@@ -1628,8 +1477,23 @@ function createMouserelease(options = {}) {
1628
1477
  mouseup
1629
1478
  };
1630
1479
  }
1480
+ class Mouserelease extends Listenable {
1481
+ constructor(options) {
1482
+ super(
1483
+ "recognizeable",
1484
+ {
1485
+ recognizeable: {
1486
+ effects: createMouserelease(options)
1487
+ }
1488
+ }
1489
+ );
1490
+ }
1491
+ get metadata() {
1492
+ return this.recognizeable.metadata;
1493
+ }
1494
+ }
1631
1495
 
1632
- const defaultOptions$b = {
1496
+ const defaultOptions$f = {
1633
1497
  minDuration: 0,
1634
1498
  minDistance: 0
1635
1499
  };
@@ -1641,7 +1505,7 @@ function createTouchpress(options = {}) {
1641
1505
  onCancel,
1642
1506
  onMove,
1643
1507
  onEnd
1644
- } = { ...defaultOptions$b, ...options }, cleanup = () => {
1508
+ } = { ...defaultOptions$f, ...options }, cleanup = () => {
1645
1509
  window.cancelAnimationFrame(request);
1646
1510
  };
1647
1511
  let request;
@@ -1662,6 +1526,7 @@ function createTouchpress(options = {}) {
1662
1526
  api,
1663
1527
  () => totalTouches === 1,
1664
1528
  (newRequest) => request = newRequest,
1529
+ // @ts-expect-error
1665
1530
  recognize
1666
1531
  );
1667
1532
  onStart?.(toHookApi(api));
@@ -1701,8 +1566,23 @@ function createTouchpress(options = {}) {
1701
1566
  touchend
1702
1567
  };
1703
1568
  }
1569
+ class Touchpress extends Listenable {
1570
+ constructor(options) {
1571
+ super(
1572
+ "recognizeable",
1573
+ {
1574
+ recognizeable: {
1575
+ effects: createTouchpress(options)
1576
+ }
1577
+ }
1578
+ );
1579
+ }
1580
+ get metadata() {
1581
+ return this.recognizeable.metadata;
1582
+ }
1583
+ }
1704
1584
 
1705
- const defaultOptions$a = {
1585
+ const defaultOptions$e = {
1706
1586
  minDuration: 0,
1707
1587
  minDistance: 0,
1708
1588
  minVelocity: 0
@@ -1716,7 +1596,7 @@ function createTouchrelease(options = {}) {
1716
1596
  onCancel,
1717
1597
  onMove,
1718
1598
  onEnd
1719
- } = { ...defaultOptions$a, ...options }, cleanup = () => {
1599
+ } = { ...defaultOptions$e, ...options }, cleanup = () => {
1720
1600
  window.cancelAnimationFrame(request);
1721
1601
  };
1722
1602
  let request;
@@ -1730,867 +1610,1392 @@ function createTouchrelease(options = {}) {
1730
1610
  onStart?.(toHookApi(api));
1731
1611
  return;
1732
1612
  }
1733
- storePointerStartMetadata(event, api);
1734
- storePointerMoveMetadata(event, api);
1735
- storePointerTimeMetadata(
1736
- event,
1737
- api,
1738
- () => totalTouches === 1,
1739
- (newRequest) => request = newRequest
1740
- );
1741
- onStart?.(toHookApi(api));
1742
- };
1743
- const touchmove = (event, api) => {
1744
- const { getStatus } = api;
1745
- if (getStatus() !== "denied")
1746
- storePointerMoveMetadata(event, api);
1747
- onMove?.(toHookApi(api));
1748
- };
1749
- const touchcancel = (event, api) => {
1750
- const { denied } = api;
1751
- cleanup();
1752
- denied();
1753
- totalTouches--;
1754
- onCancel?.(toHookApi(api));
1613
+ storePointerStartMetadata(event, api);
1614
+ storePointerMoveMetadata(event, api);
1615
+ storePointerTimeMetadata(
1616
+ event,
1617
+ api,
1618
+ () => totalTouches === 1,
1619
+ (newRequest) => request = newRequest
1620
+ );
1621
+ onStart?.(toHookApi(api));
1622
+ };
1623
+ const touchmove = (event, api) => {
1624
+ const { getStatus } = api;
1625
+ if (getStatus() !== "denied")
1626
+ storePointerMoveMetadata(event, api);
1627
+ onMove?.(toHookApi(api));
1628
+ };
1629
+ const touchcancel = (event, api) => {
1630
+ const { denied } = api;
1631
+ cleanup();
1632
+ denied();
1633
+ totalTouches--;
1634
+ onCancel?.(toHookApi(api));
1635
+ };
1636
+ const touchend = (event, api) => {
1637
+ const { denied } = api;
1638
+ if (totalTouches !== 1) {
1639
+ cleanup();
1640
+ denied();
1641
+ onEnd?.(toHookApi(api));
1642
+ return;
1643
+ }
1644
+ storePointerMoveMetadata(event, api);
1645
+ cleanup();
1646
+ totalTouches--;
1647
+ recognize(event, api);
1648
+ onEnd?.(toHookApi(api));
1649
+ };
1650
+ const recognize = (event, api) => {
1651
+ const { getMetadata, recognized, denied } = api, metadata = getMetadata();
1652
+ if (metadata.duration >= minDuration && metadata.distance.straight.fromStart >= minDistance && metadata.velocity >= minVelocity) {
1653
+ recognized();
1654
+ } else {
1655
+ denied();
1656
+ }
1657
+ };
1658
+ return {
1659
+ touchstart,
1660
+ touchmove,
1661
+ touchcancel,
1662
+ touchend
1663
+ };
1664
+ }
1665
+ class Touchrelease extends Listenable {
1666
+ constructor(options) {
1667
+ super(
1668
+ "recognizeable",
1669
+ {
1670
+ recognizeable: {
1671
+ effects: createTouchrelease(options)
1672
+ }
1673
+ }
1674
+ );
1675
+ }
1676
+ get metadata() {
1677
+ return this.recognizeable.metadata;
1678
+ }
1679
+ }
1680
+
1681
+ function createRoot(graph) {
1682
+ const toIndegree = createIndegree(graph);
1683
+ return (node) => toIndegree(node) === 0;
1684
+ }
1685
+ function createTerminal(graph) {
1686
+ const toOutdegree = createOutdegree(graph);
1687
+ return (node) => toOutdegree(node) === 0;
1688
+ }
1689
+ function createChildren(graph) {
1690
+ return function* (node) {
1691
+ const outgoing = createOutgoing(graph)(node);
1692
+ for (const edge of outgoing)
1693
+ yield edge.to;
1694
+ };
1695
+ }
1696
+ function createIndegree(graph) {
1697
+ const toIncoming = createIncoming(graph);
1698
+ return (node) => lazyCollections.pipe(
1699
+ toIncoming,
1700
+ lazyCollections.toLength()
1701
+ )(node);
1702
+ }
1703
+ function createOutdegree(graph) {
1704
+ const toOutgoing = createOutgoing(graph);
1705
+ return (node) => lazyCollections.pipe(
1706
+ toOutgoing,
1707
+ lazyCollections.toLength()
1708
+ )(node);
1709
+ }
1710
+ function createIncoming(graph) {
1711
+ const { edges } = graph;
1712
+ return function* (node) {
1713
+ yield* lazyCollections.filter(
1714
+ ({ to }) => to === node
1715
+ )(edges);
1716
+ };
1717
+ }
1718
+ function createOutgoing(graph) {
1719
+ const { edges } = graph;
1720
+ return function* (node) {
1721
+ yield* lazyCollections.filter(
1722
+ ({ from }) => from === node
1723
+ )(edges);
1724
+ };
1725
+ }
1726
+ function createOnlyChild(graph) {
1727
+ const toTotalSiblings = createTotalSiblings(graph);
1728
+ return (node) => toTotalSiblings(node) === 0;
1729
+ }
1730
+ function createTotalSiblings(graph) {
1731
+ const toSiblings = createSiblings(graph);
1732
+ return (node) => lazyCollections.pipe(
1733
+ toSiblings,
1734
+ lazyCollections.toLength()
1735
+ )(node);
1736
+ }
1737
+ function createSiblings(graph) {
1738
+ const { edges } = graph;
1739
+ return function* (node) {
1740
+ const parents = lazyCollections.pipe(
1741
+ lazyCollections.filter(
1742
+ ({ to }) => to === node
1743
+ ),
1744
+ lazyCollections.map(
1745
+ ({ from }) => from
1746
+ )
1747
+ )(edges);
1748
+ for (const parent of parents) {
1749
+ yield* lazyCollections.pipe(
1750
+ lazyCollections.filter(
1751
+ ({ from, to }) => from === parent && to !== node
1752
+ ),
1753
+ lazyCollections.map(
1754
+ ({ to }) => to
1755
+ )
1756
+ )(edges);
1757
+ }
1758
+ };
1759
+ }
1760
+
1761
+ function createFind(node) {
1762
+ return (tree) => {
1763
+ for (const treeNode of tree) {
1764
+ if (treeNode.node === node)
1765
+ return treeNode;
1766
+ const found = createFind(node)(treeNode.children);
1767
+ if (found)
1768
+ return found;
1769
+ }
1770
+ };
1771
+ }
1772
+
1773
+ function createPath$2(directedAcyclic, config) {
1774
+ const { predicatePathable, toTraversalCandidates } = config, firstRoot = lazyCollections.pipe(
1775
+ createRoots(),
1776
+ lazyCollections.at(0)
1777
+ )(directedAcyclic);
1778
+ return (state) => {
1779
+ const path = [firstRoot], getLastPathable = () => predicatePathable(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
1780
+ while (getLastPathable() && getLastStatus() === "set") {
1781
+ const edge = lazyCollections.pipe(
1782
+ toTraversalCandidates,
1783
+ lazyCollections.find(
1784
+ ({ predicateShouldTraverse }) => predicateShouldTraverse(state)
1785
+ )
1786
+ )(path);
1787
+ path.push(edge.to);
1788
+ }
1789
+ return path;
1790
+ };
1791
+ }
1792
+
1793
+ function createLayers$1(options = {}) {
1794
+ const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
1795
+ return function* toLayers(directedAcyclic) {
1796
+ const layers = [];
1797
+ for (const { path } of toSteps(directedAcyclic)) {
1798
+ const node = path.at(-1), depth = path.length - 1;
1799
+ if (!layers[depth] && depth > 0)
1800
+ yield layers[depth - 1];
1801
+ (layers[depth] || (layers[depth] = [])).push(node);
1802
+ }
1803
+ };
1804
+ }
1805
+ function createTree$2(options = {}) {
1806
+ const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
1807
+ return (directedAcyclic) => {
1808
+ const firstRoot = lazyCollections.pipe(
1809
+ createRoots(),
1810
+ lazyCollections.at(0)
1811
+ )(directedAcyclic), tree = [];
1812
+ tree.push({
1813
+ node: firstRoot,
1814
+ children: []
1815
+ });
1816
+ for (const { path } of toSteps(directedAcyclic)) {
1817
+ const node = path.at(-1), parent = path.at(-2);
1818
+ if (parent) {
1819
+ const parentTreeNode = createFind(parent)(tree);
1820
+ if (parentTreeNode) {
1821
+ parentTreeNode.children.push({
1822
+ node,
1823
+ children: []
1824
+ });
1825
+ }
1826
+ }
1827
+ }
1828
+ return tree;
1829
+ };
1830
+ }
1831
+ const defaultCreateDepthFirstStepsOptions = {
1832
+ getSetStateValue: ({ totalChildrenDiscovered }) => totalChildrenDiscovered
1833
+ };
1834
+ function createDepthFirstSteps$2(options = {}) {
1835
+ return createSteps$1(
1836
+ createConfigureDepthFirstSteps(options),
1837
+ options
1838
+ );
1839
+ }
1840
+ function createConfigureDepthFirstSteps(options) {
1841
+ const { getSetStateValue: getSetStateValueOption } = {
1842
+ ...defaultCreateDepthFirstStepsOptions,
1843
+ ...options
1844
+ };
1845
+ return function(directedAcyclic) {
1846
+ const getSetStateValue = (node) => getSetStateValueOption({
1847
+ node,
1848
+ totalChildrenDiscovered: totalChildrenDiscoveredByNode[node]
1849
+ }), stepFromEffect = (node) => totalChildrenDiscoveredByNode[node]++, predicateSteppable = (node) => !predicateTerminal(node), predicateTerminal = createTerminal(directedAcyclic), predicateExhausted = (node) => totalChildrenDiscoveredByNode[node] === toTotalSiblings(node), toTotalSiblings = createOutdegree(directedAcyclic), totalChildrenDiscoveredByNode = createReduce(
1850
+ (totalChildrenDiscoveredByNode2, node) => {
1851
+ totalChildrenDiscoveredByNode2[node] = 0;
1852
+ return totalChildrenDiscoveredByNode2;
1853
+ },
1854
+ {}
1855
+ )(directedAcyclic.nodes);
1856
+ return {
1857
+ getSetStateValue,
1858
+ stepFromEffect,
1859
+ predicateSteppable,
1860
+ predicateExhausted,
1861
+ createPath: createDepthPathConfig(directedAcyclic)
1862
+ };
1863
+ };
1864
+ }
1865
+ const defaultCreateStepsOptions$1 = {
1866
+ kind: "directed acyclic"
1867
+ };
1868
+ function createSteps$1(configure, options = {}) {
1869
+ return function* (directedAcyclic) {
1870
+ const {
1871
+ getSetStateValue,
1872
+ stepFromEffect,
1873
+ predicateSteppable,
1874
+ predicateExhausted,
1875
+ createPath: createPathConfig
1876
+ } = configure(directedAcyclic), { kind, root } = { ...defaultCreateStepsOptions$1, ...options }, { nodes } = directedAcyclic, toPath = createPath$2(directedAcyclic, createPathConfig), roots = lazyCollections.pipe(
1877
+ createRoots({ kind }),
1878
+ lazyCollections.toArray()
1879
+ )(directedAcyclic), state = {};
1880
+ for (const node of nodes) {
1881
+ state[node] = {
1882
+ status: "unset",
1883
+ value: void 0
1884
+ };
1885
+ }
1886
+ let location = root || lazyCollections.at(0)(roots);
1887
+ const path = toPath(state);
1888
+ yield { path, state: JSON.parse(JSON.stringify(state)) };
1889
+ function* toStep() {
1890
+ if (predicateExhausted(location)) {
1891
+ if (lazyCollections.includes(location)(roots))
1892
+ return;
1893
+ state[location].status = "unset";
1894
+ delete state[location].value;
1895
+ const path3 = toPath(state);
1896
+ location = path3.at(-2);
1897
+ yield* toStep();
1898
+ return;
1899
+ }
1900
+ state[location].status = "set";
1901
+ state[location].value = getSetStateValue(location);
1902
+ const path2 = toPath(state);
1903
+ yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
1904
+ stepFromEffect(location);
1905
+ const newLocation = path2.at(-1);
1906
+ if (predicateSteppable(newLocation))
1907
+ location = newLocation;
1908
+ yield* toStep();
1909
+ }
1910
+ yield* toStep();
1755
1911
  };
1756
- const touchend = (event, api) => {
1757
- const { denied } = api;
1758
- if (totalTouches !== 1) {
1759
- cleanup();
1760
- denied();
1761
- onEnd?.(toHookApi(api));
1762
- return;
1912
+ }
1913
+ function createRoots(options = {}) {
1914
+ return function* (directedAcyclic) {
1915
+ const { nodes } = directedAcyclic, predicateRoot = createRoot(directedAcyclic);
1916
+ for (const node of nodes) {
1917
+ if (predicateRoot(node))
1918
+ yield node;
1919
+ if (options.kind === "arborescence")
1920
+ break;
1763
1921
  }
1764
- storePointerMoveMetadata(event, api);
1765
- cleanup();
1766
- totalTouches--;
1767
- recognize(event, api);
1768
- onEnd?.(toHookApi(api));
1769
1922
  };
1770
- const recognize = (event, api) => {
1771
- const { getMetadata, recognized, denied } = api, metadata = getMetadata();
1772
- if (metadata.duration >= minDuration && metadata.distance.straight.fromStart >= minDistance && metadata.velocity >= minVelocity) {
1773
- recognized();
1774
- } else {
1775
- denied();
1923
+ }
1924
+
1925
+ function createCommonAncestors$2(directedAcyclic) {
1926
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps$2(directedAcyclic);
1927
+ return function* (a, b) {
1928
+ for (const { path: aPath } of toNodeDepthFirstSteps(a)) {
1929
+ for (const { path: bPath } of toNodeDepthFirstSteps(b)) {
1930
+ for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
1931
+ for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
1932
+ if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
1933
+ yield {
1934
+ node: aPath[aPathIndex],
1935
+ distances: {
1936
+ [a]: aPath.length - aPathIndex - 1,
1937
+ [b]: bPath.length - bPathIndex - 1
1938
+ }
1939
+ };
1940
+ }
1941
+ }
1942
+ }
1943
+ }
1776
1944
  }
1777
1945
  };
1778
- return {
1779
- touchstart,
1780
- touchmove,
1781
- touchcancel,
1782
- touchend
1946
+ }
1947
+ function createAncestor$2(directedAcyclic) {
1948
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps$2(directedAcyclic);
1949
+ return function(descendant, ancestor) {
1950
+ return lazyCollections.pipe(
1951
+ toNodeDepthFirstSteps,
1952
+ lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
1953
+ )(descendant);
1954
+ };
1955
+ }
1956
+ function createNodeDepthFirstSteps$2(directedAcyclic, options = {}) {
1957
+ const toSteps = createDepthFirstSteps$2(options.createDepthFirstSteps);
1958
+ return function* (node) {
1959
+ yield* lazyCollections.pipe(
1960
+ toSteps,
1961
+ lazyCollections.filter(({ path }) => path.at(-1) === node)
1962
+ )(directedAcyclic);
1783
1963
  };
1784
1964
  }
1785
1965
 
1786
- const defaultOptions$9 = {
1787
- initial: []
1966
+ const defaultCreateStepsOptions = {
1967
+ priorityBranch: false,
1968
+ kind: "directed acyclic"
1788
1969
  };
1789
- function createKeyStatuses(options = {}) {
1790
- return createAssociativeArray({
1791
- ...defaultOptions$9,
1970
+ function createTree$1(options = {}) {
1971
+ const withDefaults = {
1792
1972
  ...options,
1793
- createPredicateKey: (query) => (key) => {
1794
- for (const prop in query) {
1795
- if (query[prop] !== key[prop]) {
1796
- return false;
1797
- }
1798
- }
1799
- return true;
1973
+ createDepthFirstSteps: {
1974
+ ...defaultCreateStepsOptions,
1975
+ ...options.createDepthFirstSteps
1976
+ }
1977
+ };
1978
+ return createTree$2(withDefaults);
1979
+ }
1980
+ function createCommonAncestors$1(...params) {
1981
+ return createCommonAncestors$2(...params);
1982
+ }
1983
+ function createAncestor$1(...params) {
1984
+ return createAncestor$2(...params);
1985
+ }
1986
+ function createNodeDepthFirstSteps$1(decisionTree, options = {}) {
1987
+ const withDefaults = {
1988
+ ...options,
1989
+ createDepthFirstSteps: {
1990
+ ...defaultCreateStepsOptions,
1991
+ ...options.createDepthFirstSteps
1800
1992
  }
1993
+ };
1994
+ return createNodeDepthFirstSteps$2(
1995
+ decisionTree,
1996
+ withDefaults
1997
+ );
1998
+ }
1999
+ function createDepthFirstSteps$1(options) {
2000
+ const { priorityBranch } = { ...defaultCreateStepsOptions, ...options }, configureDepthFirstSteps = createConfigureDepthFirstSteps({
2001
+ getSetStateValue: ({ totalChildrenDiscovered }) => totalChildrenDiscovered === 0 ? priorityBranch : !priorityBranch
1801
2002
  });
2003
+ return createSteps$1(configureDepthFirstSteps, options);
1802
2004
  }
1803
- function predicateSomeKeyDown(statuses) {
1804
- return lazyCollections.includes("down")(statuses.toValues());
2005
+ function createPath$1(...params) {
2006
+ return createPath$2(...params);
1805
2007
  }
1806
2008
 
1807
- function createKeyState({
1808
- keycomboOrKeycombos,
1809
- unsupportedAliases,
1810
- toDownKeys,
1811
- toAliases,
1812
- getRequest
1813
- }) {
1814
- const narrowedKeycombos = createFilter(
1815
- (keycombo) => !lazyCollections.some(
1816
- (alias) => lazyCollections.includes(alias)(unsupportedAliases)
1817
- )(fromComboToAliases(keycombo))
1818
- )(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createPredicateKeycomboDownOptions = { toDownKeys }, downPredicatesByKeycombo = (() => {
1819
- const predicates = [];
1820
- for (const keycombo of narrowedKeycombos) {
1821
- predicates.push([
1822
- keycombo,
1823
- createPredicateKeycomboDown(
1824
- keycombo,
1825
- createPredicateKeycomboDownOptions
2009
+ function createPath(directedAcyclicAsync, config) {
2010
+ const { predicatePathable, toTraversalCandidates } = config, firstRoot = lazyCollections.pipe(
2011
+ createRoots(),
2012
+ lazyCollections.at(0)
2013
+ )(directedAcyclicAsync);
2014
+ return async (state) => {
2015
+ const path = [firstRoot], getLastPathable = () => predicatePathable(path.at(-1)), getLastStatus = () => state[path.at(-1)].status;
2016
+ while (getLastPathable() && getLastStatus() === "set") {
2017
+ const edge = await lazyCollections.pipe(
2018
+ toTraversalCandidates,
2019
+ lazyCollections.toArray(),
2020
+ createFindAsync(
2021
+ async ({ predicateShouldTraverse }) => await predicateShouldTraverse(state)
1826
2022
  )
1827
- ]);
1828
- }
1829
- return predicates;
1830
- })(), createPredicateKeycomboMatchOptions = { ...createPredicateKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
1831
- const predicates = {};
1832
- for (const keycombo of narrowedKeycombos) {
1833
- predicates[keycombo] = createPredicateKeycomboMatch$1(
1834
- keycombo,
1835
- createPredicateKeycomboMatchOptions
1836
- );
2023
+ )(path);
2024
+ path.push(edge.to);
1837
2025
  }
1838
- return predicates;
1839
- })(), validAliases = lazyCollections.pipe(
1840
- lazyCollections.flatMap(fromComboToAliases),
1841
- lazyCollections.unique(),
1842
- lazyCollections.toArray()
1843
- )(narrowedKeycombos), getDownCombos = () => lazyCollections.pipe(
1844
- lazyCollections.filter(([, predicate]) => predicate(statuses)),
1845
- lazyCollections.map(([keycombo]) => [keycombo, fromComboToAliases(keycombo)]),
1846
- lazyCollections.sort(([, aliasesA], [, aliasesB]) => aliasesB.length - aliasesA.length),
1847
- lazyCollections.map(([keycombo]) => keycombo),
1848
- lazyCollections.toArray()
1849
- )(downPredicatesByKeycombo), predicateValid = (event) => {
1850
- const aliases = toAliases(event);
1851
- return lazyCollections.some(
1852
- (validAlias) => lazyCollections.includes(validAlias)(aliases)
1853
- )(validAliases);
1854
- }, cleanup = () => {
1855
- window.cancelAnimationFrame(getRequest());
1856
- }, statuses = createKeyStatuses();
1857
- return {
1858
- narrowedKeycombos,
1859
- createPredicateKeycomboDownOptions,
1860
- downPredicatesByKeycombo,
1861
- createPredicateKeycomboMatchOptions,
1862
- matchPredicatesByKeycombo,
1863
- validAliases,
1864
- getDownCombos,
1865
- predicateValid,
1866
- cleanup,
1867
- statuses
2026
+ return path;
1868
2027
  };
1869
2028
  }
1870
2029
 
1871
- function toLength() {
1872
- return function toLengthFn(data) {
1873
- return [...data].length;
2030
+ function createLayers(options = {}) {
2031
+ const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
2032
+ return async function toLayers(directedAcyclicAsync) {
2033
+ const layers = [];
2034
+ for await (const { path } of toSteps(directedAcyclicAsync)) {
2035
+ const node = path.at(-1), depth = path.length - 1;
2036
+ (layers[depth] || (layers[depth] = [])).push(node);
2037
+ }
2038
+ return layers;
1874
2039
  };
1875
2040
  }
1876
-
1877
- const fromComboToAliasesLength = lazyCollections.pipe(
1878
- fromComboToAliases,
1879
- toLength()
1880
- );
1881
-
1882
- function fromEventToKeyStatusKey({ key, code }) {
1883
- return lazyCollections.includes(key)(modifiers) ? { key } : { code };
2041
+ function createTree(options = {}) {
2042
+ const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
2043
+ return async function toTree(directedAcyclicAsync) {
2044
+ const firstRoot = lazyCollections.pipe(
2045
+ createRoots(),
2046
+ lazyCollections.at(0)
2047
+ )(directedAcyclicAsync), tree = [];
2048
+ tree.push({
2049
+ node: firstRoot,
2050
+ children: []
2051
+ });
2052
+ for await (const { path } of toSteps(directedAcyclicAsync)) {
2053
+ const node = path.at(-1), parent = path.at(-2);
2054
+ if (parent) {
2055
+ const parentTreeNode = createFind(parent)(tree);
2056
+ if (parentTreeNode) {
2057
+ parentTreeNode.children.push({
2058
+ node,
2059
+ children: []
2060
+ });
2061
+ }
2062
+ }
2063
+ }
2064
+ return tree;
2065
+ };
1884
2066
  }
1885
- const modifiers = ["Alt", "Control", "Meta", "Shift"];
1886
-
1887
- function toDirection(angle, unit = "degrees") {
1888
- return Object.keys(directions).find((direction) => directions[direction][unit](angle));
2067
+ function createDepthFirstSteps(options = {}) {
2068
+ return createSteps(
2069
+ createConfigureDepthFirstSteps(options),
2070
+ options
2071
+ );
1889
2072
  }
1890
- const directions = {
1891
- up: {
1892
- degrees: (degrees) => degrees >= 67.5 && degrees <= 112.5,
1893
- radians: (radians) => radians >= 0.375 * Math.PI && radians <= 0.625 * Math.PI
1894
- },
1895
- upRight: {
1896
- degrees: (degrees) => degrees >= 22.5 && degrees < 67.5,
1897
- radians: (radians) => radians >= 0.125 * Math.PI && radians < 0.375 * Math.PI
1898
- },
1899
- right: {
1900
- degrees: (degrees) => degrees > 337.5 && degrees <= 360 || degrees < 22.5 && degrees >= 0,
1901
- radians: (radians) => radians > 1.875 * Math.PI && radians <= 2 * Math.PI || radians < 0.125 * Math.PI && radians >= 0
1902
- },
1903
- downRight: {
1904
- degrees: (degrees) => degrees > 292.5 && degrees <= 337.5,
1905
- radians: (radians) => radians > 1.625 * Math.PI && radians <= 1.875 * Math.PI
1906
- },
1907
- down: {
1908
- degrees: (degrees) => degrees >= 247.5 && degrees <= 292.5,
1909
- radians: (radians) => radians >= 1.375 * Math.PI && radians <= 1.625 * Math.PI
1910
- },
1911
- downLeft: {
1912
- degrees: (degrees) => degrees >= 202.5 && degrees < 247.5,
1913
- radians: (radians) => radians >= 1.125 * Math.PI && radians < 1.375 * Math.PI
1914
- },
1915
- left: {
1916
- degrees: (degrees) => degrees > 157.5 && degrees < 202.5,
1917
- radians: (radians) => radians > 0.875 * Math.PI && radians < 1.125 * Math.PI
1918
- },
1919
- upLeft: {
1920
- degrees: (degrees) => degrees > 112.5 && degrees <= 157.5,
1921
- radians: (radians) => radians > 0.625 * Math.PI && radians <= 0.875 * Math.PI
1922
- }
1923
- };
1924
-
1925
- function toHookApi({
1926
- getSequence,
1927
- getStatus,
1928
- getMetadata
1929
- }) {
1930
- return {
1931
- sequence: getSequence(),
1932
- status: getStatus(),
1933
- metadata: getMetadata()
2073
+ function createSteps(configure, options = {}) {
2074
+ return async function* (directedAcyclicAsync) {
2075
+ const {
2076
+ getSetStateValue,
2077
+ stepFromEffect,
2078
+ predicateSteppable,
2079
+ predicateExhausted,
2080
+ createPath: createPathConfig
2081
+ } = configure(directedAcyclicAsync), { kind, root } = { ...defaultCreateStepsOptions$1, ...options }, { nodes } = directedAcyclicAsync, toPath = createPath(directedAcyclicAsync, createPathConfig), roots = lazyCollections.pipe(
2082
+ createRoots({ kind }),
2083
+ lazyCollections.toArray()
2084
+ )(directedAcyclicAsync), state = {};
2085
+ for (const node of nodes) {
2086
+ state[node] = {
2087
+ status: "unset",
2088
+ value: void 0
2089
+ };
2090
+ }
2091
+ let location = root || lazyCollections.at(0)(roots);
2092
+ const path = await toPath(state);
2093
+ yield { path, state: JSON.parse(JSON.stringify(state)) };
2094
+ async function* toStep() {
2095
+ if (predicateExhausted(location)) {
2096
+ if (lazyCollections.includes(location)(roots))
2097
+ return;
2098
+ state[location].status = "unset";
2099
+ delete state[location].value;
2100
+ const path3 = await toPath(state);
2101
+ location = path3.at(-2);
2102
+ yield* await toStep();
2103
+ return;
2104
+ }
2105
+ state[location].status = "set";
2106
+ state[location].value = getSetStateValue(location);
2107
+ const path2 = await toPath(state);
2108
+ yield { path: path2, state: JSON.parse(JSON.stringify(state)) };
2109
+ stepFromEffect(location);
2110
+ const newLocation = path2.at(-1);
2111
+ if (predicateSteppable(newLocation))
2112
+ location = newLocation;
2113
+ yield* await toStep();
2114
+ }
2115
+ yield* await toStep();
1934
2116
  };
1935
2117
  }
1936
2118
 
1937
- function toMousePoint(event) {
1938
- return {
1939
- x: event.clientX,
1940
- y: event.clientY
2119
+ function createCommonAncestors(directedAcyclicAsync) {
2120
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps(directedAcyclicAsync);
2121
+ return async function* (a, b) {
2122
+ for await (const { path: aPath } of toNodeDepthFirstSteps(a)) {
2123
+ for await (const { path: bPath } of toNodeDepthFirstSteps(b)) {
2124
+ for (let aPathIndex = aPath.length - 1; aPathIndex >= 0; aPathIndex--) {
2125
+ for (let bPathIndex = bPath.length - 1; bPathIndex >= 0; bPathIndex--) {
2126
+ if (aPath[aPathIndex] === bPath[bPathIndex] && !lazyCollections.includes(aPath[aPathIndex])([a, b])) {
2127
+ yield {
2128
+ node: aPath[aPathIndex],
2129
+ distances: {
2130
+ [a]: aPath.length - aPathIndex - 1,
2131
+ [b]: bPath.length - bPathIndex - 1
2132
+ }
2133
+ };
2134
+ }
2135
+ }
2136
+ }
2137
+ }
2138
+ }
1941
2139
  };
1942
2140
  }
1943
- function toTouchMovePoint(event) {
1944
- return {
1945
- x: event.touches.item(0).clientX,
1946
- y: event.touches.item(0).clientY
2141
+ function createAncestor(directedAcyclicAsync) {
2142
+ const toNodeDepthFirstSteps = createNodeDepthFirstSteps(directedAcyclicAsync);
2143
+ return async function(descendant, ancestor) {
2144
+ return await lazyCollections.pipe(
2145
+ toNodeDepthFirstSteps,
2146
+ lazyCollections.some(({ path }) => lazyCollections.includes(ancestor)(path))
2147
+ )(descendant);
1947
2148
  };
1948
2149
  }
1949
- function toTouchEndPoint(event) {
1950
- return {
1951
- x: event.changedTouches.item(0).clientX,
1952
- y: event.changedTouches.item(0).clientY
2150
+ function createNodeDepthFirstSteps(directedAcyclicAsync, options = {}) {
2151
+ const toSteps = createDepthFirstSteps(options.createDepthFirstSteps);
2152
+ return async function* (node) {
2153
+ yield* await lazyCollections.pipe(
2154
+ toSteps,
2155
+ lazyCollections.filter(({ path }) => path.at(-1) === node)
2156
+ )(directedAcyclicAsync);
1953
2157
  };
1954
2158
  }
1955
2159
 
1956
- function toPolarCoordinates({ xA, xB, yA, yB }) {
1957
- const distance = Math.hypot(xB - xA, yB - yA), angle = Math.atan2(yA - yB, xB - xA), radians = angle >= 0 ? angle : 2 * Math.PI + angle, degrees = radians * 180 / Math.PI;
1958
- return {
1959
- distance,
1960
- angle: { radians, degrees }
2160
+ const defaultOptions$d = {
2161
+ predicatesElement: false,
2162
+ // Adapted from React Aria https://github.com/adobe/react-spectrum/blob/b6786da906973130a1746b2bee63215bba013ca4/packages/%40react-aria/focus/src/FocusScope.tsx#L256
2163
+ tabbableSelector: lazyCollections.join(':not([hidden]):not([tabindex="-1"]),')([
2164
+ "input:not([disabled]):not([type=hidden])",
2165
+ "select:not([disabled])",
2166
+ "textarea:not([disabled])",
2167
+ "button:not([disabled])",
2168
+ "a[href]",
2169
+ "area[href]",
2170
+ "summary",
2171
+ "iframe",
2172
+ "object",
2173
+ "embed",
2174
+ "audio[controls]",
2175
+ "video[controls]",
2176
+ "[contenteditable]",
2177
+ "[tabindex]:not([disabled])"
2178
+ ])
2179
+ };
2180
+ function createFocusable(order, options = {}) {
2181
+ const { predicatesElement, tabbableSelector } = { ...defaultOptions$d, ...options }, predicateFocusable = (element) => element.matches(tabbableSelector);
2182
+ return (element) => {
2183
+ if (predicatesElement && predicateFocusable(element))
2184
+ return element;
2185
+ switch (order) {
2186
+ case "first":
2187
+ for (let i = 0; i < element.children.length; i++) {
2188
+ const focusable = createFocusable(order, { predicatesElement: true })(element.children[i]);
2189
+ if (focusable)
2190
+ return focusable;
2191
+ }
2192
+ break;
2193
+ case "last":
2194
+ for (let i = element.children.length - 1; i > -1; i--) {
2195
+ const focusable = createFocusable(order, { predicatesElement: true })(element.children[i]);
2196
+ if (focusable)
2197
+ return focusable;
2198
+ }
2199
+ break;
2200
+ }
1961
2201
  };
1962
2202
  }
2203
+ function createComputedStyle(pseudoElement) {
2204
+ return (element) => getComputedStyle(element, pseudoElement);
2205
+ }
1963
2206
 
1964
- const initialMetadata$3 = {
1965
- times: {
1966
- start: 0,
1967
- end: 0
1968
- },
1969
- duration: 0
2207
+ const defaultOptions$c = {
2208
+ toCode: (alias) => fromAliasToCode(alias),
2209
+ toAliases: (descriptor) => fromKeyboardEventDescriptorToAliases(descriptor)
1970
2210
  };
1971
- function storeKeyboardTimeMetadata({
1972
- event,
1973
- api,
1974
- getTimeMetadata,
1975
- getShouldStore,
1976
- setRequest,
1977
- recognize
1978
- }) {
1979
- if (!getShouldStore())
1980
- return;
1981
- const { getStatus, onRecognized } = api, timeMetadata = getTimeMetadata();
1982
- if (!timeMetadata.times)
1983
- timeMetadata.times = createClone()(initialMetadata$3.times);
1984
- timeMetadata.times.start = Math.round(event.timeStamp);
1985
- timeMetadata.times.end = Math.round(event.timeStamp);
1986
- const storeDuration = () => {
1987
- const request = requestAnimationFrame((timestamp) => {
1988
- if (!getShouldStore())
1989
- return;
1990
- timeMetadata.times.end = Math.round(timestamp);
1991
- timeMetadata.duration = Math.max(0, timeMetadata.times.end - timeMetadata.times.start);
1992
- if (recognize) {
1993
- recognize(event, api);
1994
- if (getStatus() === "recognized")
1995
- onRecognized(event);
2211
+ const createKeycomboMatch$1 = (keycombo, options = {}) => {
2212
+ const { toLonghand, toCode, toAliases: fromDescriptorToAliases } = { ...defaultOptions$c, ...options }, fromComboToAliases = createAliases({ toLonghand }), aliases = fromComboToAliases(keycombo), codes = createMap(toCode)(aliases), implicitModifierAliases = (() => {
2213
+ const implicitModifierAliases2 = [];
2214
+ for (const code of codes) {
2215
+ const implicitModifier = lazyCollections.find(
2216
+ (modifier) => code.includes(modifier)
2217
+ )(modifiers);
2218
+ if (implicitModifier)
2219
+ implicitModifierAliases2.push(implicitModifier.toLowerCase());
2220
+ }
2221
+ return implicitModifierAliases2;
2222
+ })();
2223
+ return (event) => {
2224
+ const statuses = [];
2225
+ createSet(fromEventToKeyStatusCode(event), "down")(statuses);
2226
+ for (const modifier of modifiers) {
2227
+ if (event[`${modifier.toLowerCase()}Key`])
2228
+ createSet(modifier, "down")(statuses);
2229
+ }
2230
+ const events = createMap(
2231
+ ([code]) => {
2232
+ const e = { code };
2233
+ for (const modifier of modifiers) {
2234
+ e[`${modifier.toLowerCase()}Key`] = event[`${modifier.toLowerCase()}Key`];
2235
+ }
2236
+ return e;
1996
2237
  }
1997
- storeDuration();
1998
- });
1999
- setRequest(request);
2238
+ )(statuses);
2239
+ return lazyCollections.every(
2240
+ (code) => createValue(
2241
+ code,
2242
+ { predicateKey: createCode(code) }
2243
+ )(statuses) === "down"
2244
+ )(codes) && lazyCollections.every(
2245
+ (e) => lazyCollections.pipe(
2246
+ fromDescriptorToAliases,
2247
+ lazyCollections.map(fromComboToAliases),
2248
+ lazyCollections.some(
2249
+ (longhandAliases) => lazyCollections.every(
2250
+ (longhandAlias) => lazyCollections.includes(longhandAlias)(aliases) || lazyCollections.includes(longhandAlias)(implicitModifierAliases)
2251
+ )(longhandAliases)
2252
+ )
2253
+ )(e)
2254
+ )(events);
2000
2255
  };
2001
- storeDuration();
2002
- }
2003
-
2004
- const initialMetadata$2 = {
2005
- points: {
2006
- start: { x: 0, y: 0 },
2007
- end: { x: 0, y: 0 }
2008
- }
2009
2256
  };
2010
- function storePointerStartMetadata(event, api) {
2011
- const { getMetadata } = api, metadata = getMetadata();
2012
- const point = event instanceof MouseEvent ? toMousePoint(event) : toTouchMovePoint(event);
2013
- if (!metadata.points)
2014
- metadata.points = createClone()(initialMetadata$2.points);
2015
- metadata.points.start = point;
2016
- metadata.points.end = point;
2257
+
2258
+ function createClamp(min, max) {
2259
+ return (number) => {
2260
+ const maxed = Math.max(number, min);
2261
+ return Math.min(maxed, max);
2262
+ };
2263
+ }
2264
+ function createDetermine(potentialities) {
2265
+ const predicates = createMap(
2266
+ ({ outcome, probability }, index) => {
2267
+ const lowerBound = index === 0 ? 0 : lazyCollections.pipe(
2268
+ lazyCollections.slice(0, index - 1),
2269
+ lazyCollections.reduce(
2270
+ (lowerBound2, { probability: probability2 }) => lowerBound2 + probability2,
2271
+ 0
2272
+ )
2273
+ )(potentialities), upperBound = lowerBound + probability;
2274
+ return {
2275
+ outcome,
2276
+ predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
2277
+ };
2278
+ }
2279
+ )(potentialities);
2280
+ return (determinant) => lazyCollections.find(
2281
+ ({ predicate }) => predicate(determinant)
2282
+ )(predicates).outcome;
2283
+ }
2284
+ function createGreater(threshold) {
2285
+ return (number) => number > threshold;
2286
+ }
2287
+ function createGreaterOrEqual(threshold) {
2288
+ return (number) => number >= threshold;
2289
+ }
2290
+ function createLessOrEqual(threshold) {
2291
+ return (number) => number <= threshold;
2292
+ }
2293
+ function createLess(threshold) {
2294
+ return (number) => number < threshold;
2017
2295
  }
2018
2296
 
2019
- const initialMetadata$1 = {
2020
- distance: {
2021
- straight: {
2022
- fromStart: 0,
2023
- fromPrevious: 0
2024
- },
2025
- horizontal: {
2026
- fromStart: 0,
2027
- fromPrevious: 0
2028
- },
2029
- vertical: {
2030
- fromStart: 0,
2031
- fromPrevious: 0
2297
+ function createValue$1(key) {
2298
+ return (object) => object[key];
2299
+ }
2300
+ function createHas(key) {
2301
+ return (object) => key in object;
2302
+ }
2303
+ function createKeys() {
2304
+ return (object) => {
2305
+ const keys = [];
2306
+ for (const key in object) {
2307
+ keys.push(key);
2032
2308
  }
2033
- },
2034
- angle: {
2035
- fromPrevious: { radians: 0, degrees: 0 },
2036
- fromStart: { radians: 0, degrees: 0 }
2037
- },
2038
- direction: {
2039
- fromPrevious: "up",
2040
- fromStart: "up"
2041
- }
2042
- };
2043
- function storePointerMoveMetadata(event, api) {
2044
- const { getMetadata } = api, metadata = getMetadata();
2045
- if (!metadata.distance) {
2046
- metadata.distance = createClone()(initialMetadata$1.distance);
2047
- metadata.angle = createClone()(initialMetadata$1.angle);
2048
- metadata.direction = createClone()(initialMetadata$1.direction);
2049
- }
2050
- const { x: previousX, y: previousY } = metadata.points.end, { x: startX, y: startY } = metadata.points.start, { x: newX, y: newY } = (() => {
2051
- if (event instanceof MouseEvent) {
2052
- return toMousePoint(event);
2309
+ return keys;
2310
+ };
2311
+ }
2312
+ function createEntries() {
2313
+ return (object) => {
2314
+ const entries = [];
2315
+ for (const key in object) {
2316
+ entries.push([key, object[key]]);
2053
2317
  }
2054
- if (event instanceof TouchEvent) {
2055
- if (event.type === "touchmove") {
2056
- return toTouchMovePoint(event);
2318
+ return entries;
2319
+ };
2320
+ }
2321
+ function createEvery(predicate) {
2322
+ return (object) => {
2323
+ for (const key in object) {
2324
+ if (!predicate(key, object[key])) {
2325
+ return false;
2057
2326
  }
2058
- return toTouchEndPoint(event);
2059
2327
  }
2060
- })(), { distance: distanceFromPrevious, angle: angleFromPrevious } = toPolarCoordinates({
2061
- xA: previousX,
2062
- xB: newX,
2063
- yA: previousY,
2064
- yB: newY
2065
- }), { distance: distanceFromStart, angle: angleFromStart } = toPolarCoordinates({
2066
- xA: startX,
2067
- xB: newX,
2068
- yA: startY,
2069
- yB: newY
2070
- });
2071
- metadata.distance.straight.fromPrevious = distanceFromPrevious;
2072
- metadata.distance.horizontal.fromPrevious = newX - previousX;
2073
- metadata.distance.vertical.fromPrevious = newY - previousY;
2074
- metadata.angle.fromPrevious = angleFromPrevious;
2075
- metadata.direction.fromPrevious = toDirection(angleFromPrevious.degrees);
2076
- metadata.distance.straight.fromStart = distanceFromStart;
2077
- metadata.distance.horizontal.fromStart = newX - startX;
2078
- metadata.distance.vertical.fromStart = newY - startY;
2079
- metadata.angle.fromStart = angleFromStart;
2080
- metadata.direction.fromStart = toDirection(angleFromStart.degrees);
2081
- metadata.points.end = { x: newX, y: newY };
2328
+ return true;
2329
+ };
2330
+ }
2331
+ function createSome(predicate) {
2332
+ return (object) => {
2333
+ for (const key in object) {
2334
+ if (predicate(key, object[key]))
2335
+ return true;
2336
+ }
2337
+ return false;
2338
+ };
2339
+ }
2340
+ function createDeepMerge(override) {
2341
+ return (object) => {
2342
+ const merged = createClone()(object);
2343
+ return merge.merge(merged, override || {});
2344
+ };
2082
2345
  }
2083
2346
 
2084
- const initialMetadata = {
2085
- times: {
2086
- start: 0,
2087
- end: 0
2088
- },
2089
- duration: 0,
2090
- velocity: 0
2347
+ let totalGraphNodes = -1;
2348
+ const defaultOptions$b = {
2349
+ toId: () => `${totalGraphNodes++}`,
2350
+ toChildren: (node) => node.children
2091
2351
  };
2092
- function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recognize) {
2093
- const { getSequence, getMetadata, getStatus, onRecognized } = api, metadata = getMetadata();
2094
- if (!metadata.times) {
2095
- metadata.times = createClone()(initialMetadata.times);
2096
- }
2097
- metadata.times.start = Math.round(event.timeStamp);
2098
- metadata.times.end = Math.round(event.timeStamp);
2099
- let previousTime = metadata.times.start;
2100
- const storeDuration = () => {
2101
- const request = requestAnimationFrame((timestamp) => {
2102
- if (getShouldStore()) {
2103
- previousTime = metadata.times.end;
2104
- metadata.times.end = Math.round(timestamp);
2105
- metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
2106
- const durationFromPrevious = Math.max(0, metadata.times.end - previousTime);
2107
- metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious;
2108
- const event2 = getSequence().at(-1);
2109
- recognize?.(event2, api);
2110
- if (getStatus() === "recognized")
2111
- onRecognized(event2);
2112
- storeDuration();
2352
+ function createGraph(options = {}) {
2353
+ const { toId, toChildren } = { ...defaultOptions$b, ...options };
2354
+ return function* (tree) {
2355
+ const root = tree[0], rootId = toId(root);
2356
+ function* toPair(node, id) {
2357
+ const children = toChildren(node) || [];
2358
+ for (const child of children) {
2359
+ const childId = toId(child);
2360
+ yield {
2361
+ node: childId,
2362
+ edge: { from: id, to: childId }
2363
+ };
2364
+ yield* toPair(child, childId);
2113
2365
  }
2114
- });
2115
- setRequest(request);
2366
+ }
2367
+ yield { node: rootId };
2368
+ yield* toPair(root, rootId);
2116
2369
  };
2117
- storeDuration();
2118
2370
  }
2119
2371
 
2120
- function defineGraph(nodes, edges) {
2121
- return { nodes, edges };
2372
+ function createSet$2(key, value, options = {}) {
2373
+ const { predicateKey = createEqual(key) } = options;
2374
+ return (associativeArray) => {
2375
+ const index = lazyCollections.findIndex(
2376
+ ([candidate]) => predicateKey(candidate)
2377
+ )(associativeArray);
2378
+ if (index === -1) {
2379
+ associativeArray.push([key, value]);
2380
+ return;
2381
+ }
2382
+ associativeArray[index][1] = value;
2383
+ return associativeArray;
2384
+ };
2122
2385
  }
2123
- function defineGraphNodes(nodes) {
2124
- return nodes;
2386
+ function createClear$2() {
2387
+ return (associativeArray) => {
2388
+ associativeArray.length = 0;
2389
+ return associativeArray;
2390
+ };
2125
2391
  }
2126
- function defineGraphEdges(edges) {
2127
- return edges;
2392
+ function createDelete$2(key, options = {}) {
2393
+ const { predicateKey = createEqual(key) } = options;
2394
+ return (associativeArray) => {
2395
+ const index = lazyCollections.findIndex(
2396
+ ([candidate]) => predicateKey(candidate)
2397
+ )(associativeArray);
2398
+ if (index === -1)
2399
+ return associativeArray;
2400
+ associativeArray.splice(index, 1);
2401
+ return associativeArray;
2402
+ };
2128
2403
  }
2129
- function defineGraphNode(node) {
2130
- return node;
2404
+
2405
+ function createSet$1(key, value) {
2406
+ return (object) => {
2407
+ object[key] = value;
2408
+ return object;
2409
+ };
2131
2410
  }
2132
- function defineGraphEdge(from, to, predicateTraversable) {
2133
- return { from, to, predicateTraversable };
2411
+ function createDelete$1(key) {
2412
+ return (object) => {
2413
+ delete object[key];
2414
+ return object;
2415
+ };
2134
2416
  }
2135
- function defineAsyncGraph(nodes, edges) {
2136
- return { nodes, edges };
2417
+ function createClear$1() {
2418
+ return (object) => {
2419
+ for (const key in object) {
2420
+ delete object[key];
2421
+ }
2422
+ return object;
2423
+ };
2137
2424
  }
2138
- function defineAsyncGraphEdges(edges) {
2139
- return edges;
2425
+
2426
+ function fromEventToKeyStatusCode({ code }) {
2427
+ const modifier = lazyCollections.find(
2428
+ (modifier2) => code.includes(modifier2)
2429
+ )(modifiers);
2430
+ return modifier || code;
2431
+ }
2432
+ const modifiers = ["Alt", "Control", "Meta", "Shift"];
2433
+
2434
+ const createValue = createValue$2;
2435
+ function createSet(code, value) {
2436
+ return createSet$2(code, value);
2437
+ }
2438
+ const createClear = createClear$2;
2439
+ function createDelete(code) {
2440
+ return createDelete$2(code);
2441
+ }
2442
+ function createCode(query) {
2443
+ return function(candidate) {
2444
+ return query === candidate || lazyCollections.includes(query)(modifiers) && candidate.includes(query) || lazyCollections.includes(candidate)(modifiers) && query.includes(candidate);
2445
+ };
2140
2446
  }
2141
- function defineAsyncGraphEdge(from, to, predicateTraversable) {
2142
- return { from, to, predicateTraversable };
2447
+ const createValues = createValues$1;
2448
+ function predicateSomeKeyDown(statuses) {
2449
+ return lazyCollections.includes("down")(createValues()(statuses));
2450
+ }
2451
+
2452
+ const defaultOptions$a = {
2453
+ toCode: (alias) => fromAliasToCode(alias)
2454
+ };
2455
+ const createKeycomboDown = (keycombo, options = {}) => {
2456
+ const { toLonghand, toCode } = { ...defaultOptions$a, ...options }, codes = lazyCollections.pipe(
2457
+ createAliases({ toLonghand }),
2458
+ lazyCollections.map(toCode)
2459
+ )(keycombo);
2460
+ return (statuses) => lazyCollections.every(
2461
+ (code) => createValue(
2462
+ code,
2463
+ { predicateKey: createCode(code) }
2464
+ )(statuses) === "down"
2465
+ )(codes);
2466
+ };
2467
+
2468
+ function fromKeyboardEventDescriptorToAliases(event) {
2469
+ if (event.shiftKey && event.code in aliasesByShiftCode)
2470
+ return [aliasesByShiftCode[event.code]];
2471
+ const withoutModifierSide = toWithoutModifierSide(event.code);
2472
+ if (withoutModifierSide in aliasListsByModifier)
2473
+ return aliasListsByModifier[withoutModifierSide];
2474
+ return event.code in aliasesByCode ? [aliasesByCode[event.code]] : [event.code.match(aliasCaptureRE)?.[1].toLowerCase() || "unsupported"];
2143
2475
  }
2476
+ const toWithoutModifierSide = createClip(/(?:Left|Right)$/);
2477
+ const aliasCaptureRE = /^(?:Digit|Key)?(F[0-9]{1,2}|[0-9]|[A-Z])$/;
2478
+ const aliasesByCode = {
2479
+ Backquote: "`",
2480
+ Minus: "-",
2481
+ Equal: "=",
2482
+ BracketLeft: "[",
2483
+ BracketRight: "]",
2484
+ Backslash: "\\",
2485
+ Semicolon: ";",
2486
+ Quote: "'",
2487
+ Comma: ",",
2488
+ Period: ".",
2489
+ Slash: "/",
2490
+ ArrowUp: "up",
2491
+ ArrowDown: "down",
2492
+ ArrowLeft: "left",
2493
+ ArrowRight: "right",
2494
+ Enter: "enter",
2495
+ Space: "space",
2496
+ Tab: "tab",
2497
+ Escape: "esc",
2498
+ Backspace: "backspace",
2499
+ Delete: "delete",
2500
+ Home: "home",
2501
+ End: "end",
2502
+ PageDown: "pagedown",
2503
+ PageUp: "pageup",
2504
+ CapsLock: "capslock",
2505
+ Camera: "camera"
2506
+ };
2507
+ const aliasesByShiftCode = {
2508
+ Backquote: "~",
2509
+ Minus: "_",
2510
+ Equal: "+",
2511
+ BracketLeft: "{",
2512
+ BracketRight: "}",
2513
+ Backslash: "|",
2514
+ Semicolon: ":",
2515
+ Quote: '"',
2516
+ Comma: "<",
2517
+ Period: ">",
2518
+ Slash: "?",
2519
+ Digit1: "!",
2520
+ Digit2: "@",
2521
+ Digit3: "#",
2522
+ Digit4: "$",
2523
+ Digit5: "%",
2524
+ Digit6: "^",
2525
+ Digit7: "&",
2526
+ Digit8: "*",
2527
+ Digit9: "(",
2528
+ Digit0: ")"
2529
+ };
2530
+ const aliasListsByModifier = {
2531
+ Alt: ["alt", "option", "opt"],
2532
+ Control: ["control", "ctrl"],
2533
+ Meta: ["meta", "command", "cmd"],
2534
+ Shift: ["shift"]
2535
+ };
2144
2536
 
2145
- function defineAssociativeArrayEntries(entries) {
2146
- return entries;
2537
+ function fromCodeToAliases(code) {
2538
+ return fromKeyboardEventDescriptorToAliases({ code });
2147
2539
  }
2148
2540
 
2149
- function createExceptAndOnlyEffect(type, effect, options) {
2150
- const { except = [], only = [] } = options;
2151
- if (type === "keydown" || type === "keyup") {
2152
- return (event) => {
2153
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2154
- if (matchesOnly) {
2155
- effect(event);
2156
- return;
2157
- }
2158
- if (only.length === 0 && !matchesExcept) {
2159
- effect(event);
2160
- return;
2161
- }
2162
- };
2163
- }
2164
- if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
2165
- return (event) => {
2166
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2167
- if (matchesOnly) {
2168
- effect(event);
2169
- return;
2170
- }
2171
- if (only.length === 0 && !matchesExcept) {
2172
- effect(event);
2173
- return;
2174
- }
2175
- };
2176
- }
2177
- if (type.startsWith("pointer")) {
2178
- return (event) => {
2179
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2180
- if (matchesOnly) {
2181
- effect(event);
2182
- return;
2183
- }
2184
- if (only.length === 0 && !matchesExcept) {
2185
- effect(event);
2186
- return;
2187
- }
2188
- };
2189
- }
2190
- return (event) => {
2191
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2192
- if (matchesOnly) {
2193
- effect(event, {});
2194
- return;
2541
+ const defaultOptions$9 = {
2542
+ toCode: (alias) => fromAliasToCode(alias),
2543
+ toAliases: (code) => fromCodeToAliases(code)
2544
+ };
2545
+ const createKeycomboMatch = (keycombo, options = {}) => {
2546
+ const { toLonghand, toCode, toAliases } = { ...defaultOptions$9, ...options }, aliases = createAliases({ toLonghand })(keycombo), codes = lazyCollections.map(toCode)(aliases);
2547
+ return (statuses) => lazyCollections.every(
2548
+ (code) => createValue(
2549
+ code,
2550
+ { predicateKey: createCode(code) }
2551
+ )(statuses) === "down"
2552
+ )(codes) && lazyCollections.every(
2553
+ ([code, value]) => value === "up" || lazyCollections.pipe(
2554
+ toAliases,
2555
+ lazyCollections.some((alias) => lazyCollections.includes(alias)(aliases))
2556
+ )(code)
2557
+ )(statuses);
2558
+ };
2559
+
2560
+ function createKeyState({
2561
+ keycomboOrKeycombos,
2562
+ toLonghand,
2563
+ toCode,
2564
+ toAliases,
2565
+ getRequest
2566
+ }) {
2567
+ const fromComboToAliases = createAliases({ toLonghand }), narrowedKeycombos = createFilter(
2568
+ (keycombo) => !lazyCollections.some(
2569
+ (alias) => lazyCollections.includes(alias)(unsupportedAliases)
2570
+ )(fromComboToAliases(keycombo))
2571
+ )(Array.isArray(keycomboOrKeycombos) ? keycomboOrKeycombos : [keycomboOrKeycombos]), createKeycomboDownOptions = { toLonghand, toCode }, downPredicatesByKeycombo = (() => {
2572
+ const predicates = [];
2573
+ for (const keycombo of narrowedKeycombos) {
2574
+ predicates.push([
2575
+ keycombo,
2576
+ createKeycomboDown(
2577
+ keycombo,
2578
+ createKeycomboDownOptions
2579
+ )
2580
+ ]);
2195
2581
  }
2196
- if (only.length === 0 && !matchesExcept) {
2197
- effect(event, {});
2198
- return;
2582
+ return predicates;
2583
+ })(), createKeycomboMatchOptions = { ...createKeycomboDownOptions, toAliases }, matchPredicatesByKeycombo = (() => {
2584
+ const predicates = {};
2585
+ for (const keycombo of narrowedKeycombos) {
2586
+ predicates[keycombo] = createKeycomboMatch(
2587
+ keycombo,
2588
+ createKeycomboMatchOptions
2589
+ );
2199
2590
  }
2591
+ return predicates;
2592
+ })(), validAliases = lazyCollections.pipe(
2593
+ lazyCollections.flatMap(fromComboToAliases),
2594
+ lazyCollections.unique(),
2595
+ lazyCollections.toArray()
2596
+ )(narrowedKeycombos), getDownCombos = () => lazyCollections.pipe(
2597
+ lazyCollections.filter(([, predicate]) => predicate(statuses)),
2598
+ lazyCollections.map(([keycombo]) => [keycombo, fromComboToAliases(keycombo)]),
2599
+ lazyCollections.sort(([, aliasesA], [, aliasesB]) => aliasesB.length - aliasesA.length),
2600
+ lazyCollections.map(([keycombo]) => keycombo),
2601
+ lazyCollections.toArray()
2602
+ )(downPredicatesByKeycombo), predicateValid = (event) => {
2603
+ const aliases = toAliases(event.code);
2604
+ return lazyCollections.some(
2605
+ (validAlias) => lazyCollections.includes(validAlias)(aliases)
2606
+ )(validAliases);
2607
+ }, cleanup = () => {
2608
+ window.cancelAnimationFrame(getRequest());
2609
+ }, statuses = [], toStatus = (...params) => createValue(...params)(statuses), setStatus = (...params) => createSet(...params)(statuses), clearStatuses = (...params) => createClear(...params)(statuses), deleteStatus = (...params) => createDelete(...params)(statuses);
2610
+ return {
2611
+ narrowedKeycombos,
2612
+ createKeycomboDownOptions,
2613
+ downPredicatesByKeycombo,
2614
+ createKeycomboMatchOptions,
2615
+ matchPredicatesByKeycombo,
2616
+ validAliases,
2617
+ getDownCombos,
2618
+ predicateValid,
2619
+ cleanup,
2620
+ statuses,
2621
+ toStatus,
2622
+ setStatus,
2623
+ clearStatuses,
2624
+ deleteStatus
2200
2625
  };
2201
2626
  }
2627
+ const unsupportedAliases = ["meta", "command", "cmd"];
2628
+ const unsupportedKeys = ["Meta"];
2202
2629
 
2203
- function getDomAvailability() {
2204
- try {
2205
- return !!window ? "available" : "unavailable";
2206
- } catch (error) {
2207
- return "unavailable";
2208
- }
2630
+ function createAliasesLength(options) {
2631
+ return lazyCollections.pipe(
2632
+ createAliases(options),
2633
+ lazyCollections.toLength()
2634
+ );
2209
2635
  }
2210
2636
 
2211
- function predicateArray(value) {
2212
- return Array.isArray(value);
2213
- }
2214
- function predicateUndefined(value) {
2215
- return value === void 0;
2216
- }
2217
- function predicateFunction(value) {
2218
- return typeof value === "function";
2637
+ function toDirection(angle, unit = "degrees") {
2638
+ return Object.keys(directions).find((direction) => directions[direction][unit](angle));
2219
2639
  }
2220
- function predicateNull(value) {
2221
- return value === null;
2640
+ const directions = {
2641
+ up: {
2642
+ degrees: (degrees) => degrees >= 67.5 && degrees <= 112.5,
2643
+ radians: (radians) => radians >= 0.375 * Math.PI && radians <= 0.625 * Math.PI
2644
+ },
2645
+ upRight: {
2646
+ degrees: (degrees) => degrees >= 22.5 && degrees < 67.5,
2647
+ radians: (radians) => radians >= 0.125 * Math.PI && radians < 0.375 * Math.PI
2648
+ },
2649
+ right: {
2650
+ degrees: (degrees) => degrees > 337.5 && degrees <= 360 || degrees < 22.5 && degrees >= 0,
2651
+ radians: (radians) => radians > 1.875 * Math.PI && radians <= 2 * Math.PI || radians < 0.125 * Math.PI && radians >= 0
2652
+ },
2653
+ downRight: {
2654
+ degrees: (degrees) => degrees > 292.5 && degrees <= 337.5,
2655
+ radians: (radians) => radians > 1.625 * Math.PI && radians <= 1.875 * Math.PI
2656
+ },
2657
+ down: {
2658
+ degrees: (degrees) => degrees >= 247.5 && degrees <= 292.5,
2659
+ radians: (radians) => radians >= 1.375 * Math.PI && radians <= 1.625 * Math.PI
2660
+ },
2661
+ downLeft: {
2662
+ degrees: (degrees) => degrees >= 202.5 && degrees < 247.5,
2663
+ radians: (radians) => radians >= 1.125 * Math.PI && radians < 1.375 * Math.PI
2664
+ },
2665
+ left: {
2666
+ degrees: (degrees) => degrees > 157.5 && degrees < 202.5,
2667
+ radians: (radians) => radians > 0.875 * Math.PI && radians < 1.125 * Math.PI
2668
+ },
2669
+ upLeft: {
2670
+ degrees: (degrees) => degrees > 112.5 && degrees <= 157.5,
2671
+ radians: (radians) => radians > 0.625 * Math.PI && radians <= 0.875 * Math.PI
2672
+ }
2673
+ };
2674
+
2675
+ function toHookApi({
2676
+ getSequence,
2677
+ getStatus,
2678
+ getMetadata
2679
+ }) {
2680
+ return {
2681
+ sequence: getSequence(),
2682
+ status: getStatus(),
2683
+ metadata: getMetadata()
2684
+ };
2222
2685
  }
2223
- function predicateNumber(value) {
2224
- return typeof value === "number";
2686
+
2687
+ function toMousePoint(event) {
2688
+ return {
2689
+ x: event.clientX,
2690
+ y: event.clientY
2691
+ };
2225
2692
  }
2226
- function predicateString(value) {
2227
- return typeof value === "string";
2693
+ function toTouchMovePoint(event) {
2694
+ return {
2695
+ x: event.touches.item(0).clientX,
2696
+ y: event.touches.item(0).clientY
2697
+ };
2228
2698
  }
2229
- function predicateObject(value) {
2230
- return typeof value === "object";
2699
+ function toTouchEndPoint(event) {
2700
+ return {
2701
+ x: event.changedTouches.item(0).clientX,
2702
+ y: event.changedTouches.item(0).clientY
2703
+ };
2231
2704
  }
2232
2705
 
2233
- class Recognizeable {
2234
- maxSequenceLength;
2235
- effects;
2236
- effectApi;
2237
- constructor(sequence, options = {}) {
2238
- const defaultOptions = {
2239
- maxSequenceLength: true,
2240
- effects: {}
2241
- };
2242
- this.maxSequenceLength = options?.maxSequenceLength || defaultOptions.maxSequenceLength;
2243
- this.effects = options?.effects || defaultOptions.effects;
2244
- this.resetComputedMetadata();
2245
- this.setSequence(sequence);
2246
- this.effectApi = {
2247
- getStatus: () => this.status,
2248
- getMetadata: () => this.metadata,
2249
- setMetadata: (metadata) => this.computedMetadata = metadata,
2250
- recognized: () => this.recognized(),
2251
- denied: () => this.denied(),
2252
- ready: () => this.ready()
2253
- };
2254
- this.ready();
2255
- }
2256
- computedMetadata;
2257
- resetComputedMetadata() {
2258
- this.computedMetadata = {};
2259
- }
2260
- recognized() {
2261
- this.computedStatus = "recognized";
2262
- }
2263
- denied() {
2264
- this.computedStatus = "denied";
2265
- }
2266
- computedStatus;
2267
- ready() {
2268
- this.computedStatus = "ready";
2269
- }
2270
- get sequence() {
2271
- return this.computedSequence;
2272
- }
2273
- set sequence(sequence) {
2274
- this.setSequence(sequence);
2275
- }
2276
- get status() {
2277
- return this.computedStatus;
2278
- }
2279
- get metadata() {
2280
- return this.computedMetadata;
2281
- }
2282
- computedSequence;
2283
- setSequence(sequence) {
2284
- this.computedSequence = sequence;
2285
- return this;
2286
- }
2287
- recognize(sequenceItem, { onRecognized } = {}) {
2288
- this.recognizing();
2289
- const type = this.toType(sequenceItem), pushSequence = (sequenceItem2) => {
2290
- newSequence.push(sequenceItem2);
2291
- if (this.maxSequenceLength !== true && newSequence.length > this.maxSequenceLength) {
2292
- newSequence.shift();
2293
- }
2294
- }, newSequence = [];
2295
- for (const sequenceItem2 of this.sequence) {
2296
- pushSequence(sequenceItem2);
2297
- }
2298
- pushSequence(sequenceItem);
2299
- this.effectApi.getSequence = () => newSequence;
2300
- this.effectApi.pushSequence = pushSequence;
2301
- this.effectApi.onRecognized = onRecognized || (() => {
2302
- });
2303
- this.effects[type]?.(sequenceItem, { ...this.effectApi });
2304
- switch (this.status) {
2305
- case "ready":
2306
- case "denied":
2307
- this.resetComputedMetadata();
2308
- this.setSequence([]);
2309
- break;
2310
- case "recognizing":
2311
- case "recognized":
2312
- this.setSequence(newSequence);
2313
- break;
2314
- }
2315
- return this;
2316
- }
2317
- recognizing() {
2318
- this.computedStatus = "recognizing";
2319
- }
2320
- toType(sequenceItem) {
2321
- if (predicateArray(sequenceItem)) {
2322
- if (sequenceItem[0] instanceof IntersectionObserverEntry) {
2323
- return "intersect";
2324
- }
2325
- if (sequenceItem[0] instanceof MutationRecord) {
2326
- return "mutate";
2327
- }
2328
- if (sequenceItem[0] instanceof ResizeObserverEntry) {
2329
- return "resize";
2330
- }
2331
- } else {
2332
- if (sequenceItem instanceof MediaQueryListEvent) {
2333
- return sequenceItem.media;
2334
- }
2335
- if ("didTimeout" in sequenceItem) {
2336
- return "idle";
2337
- }
2338
- return sequenceItem.type;
2339
- }
2340
- }
2706
+ function toPolarCoordinates({ xA, xB, yA, yB }) {
2707
+ const distance = Math.hypot(xB - xA, yB - yA), angle = Math.atan2(yA - yB, xB - xA), radians = angle >= 0 ? angle : 2 * Math.PI + angle, degrees = radians * 180 / Math.PI;
2708
+ return {
2709
+ distance,
2710
+ angle: { radians, degrees }
2711
+ };
2341
2712
  }
2342
2713
 
2343
- class Listenable {
2344
- computedRecognizeable;
2345
- recognizeableEffectsKeys;
2346
- computedActive;
2347
- constructor(type, options) {
2348
- if (type === "recognizeable") {
2349
- this.computedRecognizeable = new Recognizeable([], options?.recognizeable);
2350
- this.recognizeableEffectsKeys = Object.keys(options?.recognizeable?.effects);
2351
- }
2352
- this.computedActive = /* @__PURE__ */ new Set();
2353
- this.setType(type);
2354
- this.ready();
2355
- }
2356
- computedStatus;
2357
- ready() {
2358
- this.computedStatus = "ready";
2359
- }
2360
- get type() {
2361
- return this.computedType;
2362
- }
2363
- set type(type) {
2364
- this.setType(type);
2365
- }
2366
- get status() {
2367
- return this.computedStatus;
2368
- }
2369
- get active() {
2370
- return this.computedActive;
2371
- }
2372
- get recognizeable() {
2373
- return this.computedRecognizeable;
2374
- }
2375
- computedType;
2376
- implementation;
2377
- setType(type) {
2378
- this.stop();
2379
- this.computedType = type;
2380
- this.implementation = toImplementation(type);
2381
- return this;
2714
+ const initialMetadata$3 = {
2715
+ times: {
2716
+ start: 0,
2717
+ end: 0
2718
+ },
2719
+ duration: 0
2720
+ };
2721
+ function storeKeyboardTimeMetadata({
2722
+ event,
2723
+ api,
2724
+ getTimeMetadata,
2725
+ getShouldStore,
2726
+ setRequest,
2727
+ recognize
2728
+ }) {
2729
+ if (!getShouldStore())
2730
+ return;
2731
+ const { getStatus, listenInjection: { effect } } = api, timeMetadata = getTimeMetadata();
2732
+ if (!timeMetadata.times)
2733
+ timeMetadata.times = createClone()(initialMetadata$3.times);
2734
+ timeMetadata.times.start = Math.round(event.timeStamp);
2735
+ timeMetadata.times.end = Math.round(event.timeStamp);
2736
+ const storeDuration = () => {
2737
+ const request = requestAnimationFrame((timestamp) => {
2738
+ if (!getShouldStore())
2739
+ return;
2740
+ timeMetadata.times.end = Math.round(timestamp);
2741
+ timeMetadata.duration = Math.max(0, timeMetadata.times.end - timeMetadata.times.start);
2742
+ if (recognize) {
2743
+ recognize(event, api);
2744
+ if (getStatus() === "recognized")
2745
+ effect(event);
2746
+ }
2747
+ storeDuration();
2748
+ });
2749
+ setRequest(request);
2750
+ };
2751
+ storeDuration();
2752
+ }
2753
+
2754
+ const initialMetadata$2 = {
2755
+ points: {
2756
+ start: { x: 0, y: 0 },
2757
+ end: { x: 0, y: 0 }
2382
2758
  }
2383
- listen(effect, options = {}) {
2384
- switch (this.implementation) {
2385
- case "intersection":
2386
- this.intersectionListen(effect, options);
2387
- break;
2388
- case "mutation":
2389
- this.mutationListen(effect, options);
2390
- break;
2391
- case "resize":
2392
- this.resizeListen(effect, options);
2393
- break;
2394
- case "mediaquery":
2395
- this.mediaQueryListen(effect, options);
2396
- break;
2397
- case "idle":
2398
- this.idleListen(effect, options);
2399
- break;
2400
- case "message":
2401
- this.messageListen(effect, options);
2402
- break;
2403
- case "recognizeable":
2404
- this.recognizeableListen(effect, options);
2405
- break;
2406
- case "documentevent":
2407
- this.documentEventListen(effect, options);
2408
- break;
2409
- case "event":
2410
- this.eventListen(effect, options);
2411
- break;
2759
+ };
2760
+ function storePointerStartMetadata(event, api) {
2761
+ const { getMetadata } = api, metadata = getMetadata();
2762
+ const point = event instanceof MouseEvent ? toMousePoint(event) : toTouchMovePoint(event);
2763
+ if (!metadata.points)
2764
+ metadata.points = createClone()(initialMetadata$2.points);
2765
+ metadata.points.start = point;
2766
+ metadata.points.end = point;
2767
+ }
2768
+
2769
+ const initialMetadata$1 = {
2770
+ distance: {
2771
+ straight: {
2772
+ fromStart: 0,
2773
+ fromPrevious: 0
2774
+ },
2775
+ horizontal: {
2776
+ fromStart: 0,
2777
+ fromPrevious: 0
2778
+ },
2779
+ vertical: {
2780
+ fromStart: 0,
2781
+ fromPrevious: 0
2412
2782
  }
2413
- this.listening();
2414
- return this;
2415
- }
2416
- intersectionListen(effect, options) {
2417
- const { target = document.querySelector("html"), observer } = options, id = new IntersectionObserver(effect, observer);
2418
- id.observe(target);
2419
- this.active.add({ target, id });
2420
- }
2421
- mutationListen(effect, options) {
2422
- const { target = document.querySelector("html"), observe } = options, id = new MutationObserver(effect);
2423
- id.observe(target, observe);
2424
- this.active.add({ target, id });
2783
+ },
2784
+ angle: {
2785
+ fromPrevious: { radians: 0, degrees: 0 },
2786
+ fromStart: { radians: 0, degrees: 0 }
2787
+ },
2788
+ direction: {
2789
+ fromPrevious: "up",
2790
+ fromStart: "up"
2425
2791
  }
2426
- resizeListen(effect, options) {
2427
- const { target = document.querySelector("html"), observe } = options, id = new ResizeObserver(effect);
2428
- id.observe(target, observe);
2429
- this.active.add({ target, id });
2792
+ };
2793
+ function storePointerMoveMetadata(event, api) {
2794
+ const { getMetadata } = api, metadata = getMetadata();
2795
+ if (!metadata.distance) {
2796
+ metadata.distance = createClone()(initialMetadata$1.distance);
2797
+ metadata.angle = createClone()(initialMetadata$1.angle);
2798
+ metadata.direction = createClone()(initialMetadata$1.direction);
2430
2799
  }
2431
- mediaQueryListen(effect, options) {
2432
- const target = window.matchMedia(this.type);
2433
- if (predicateFunction(options.instantEffect)) {
2434
- options.instantEffect(target);
2800
+ const { x: previousX, y: previousY } = metadata.points.end, { x: startX, y: startY } = metadata.points.start, { x: newX, y: newY } = (() => {
2801
+ if (event instanceof MouseEvent) {
2802
+ return toMousePoint(event);
2435
2803
  }
2436
- const withApi = (event) => effect(event);
2437
- target.addEventListener("change", withApi);
2438
- this.active.add({ target, id: ["change", withApi] });
2439
- }
2440
- idleListen(effect, options) {
2441
- const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
2442
- this.active.add({ target: window, id });
2443
- }
2444
- messageListen(effect, options) {
2445
- const { target = new BroadcastChannel("baleada") } = options;
2446
- target.addEventListener(this.type, (event) => effect(event));
2447
- this.active.add({ target, id: [this.type, effect] });
2448
- }
2449
- recognizeableListen(effect, options) {
2450
- const guardedEffect = (sequenceItem) => {
2451
- this.recognizeable.recognize(sequenceItem, { onRecognized: (sequenceItem2) => effect(sequenceItem2) });
2452
- if (this.recognizeable.status === "recognized")
2453
- effect(sequenceItem);
2454
- };
2455
- for (const type of this.recognizeableEffectsKeys) {
2456
- const listenable = new Listenable(type);
2457
- listenable.listen(guardedEffect, options);
2458
- this.active.add({ id: listenable });
2804
+ if (event instanceof TouchEvent) {
2805
+ if (event.type === "touchmove") {
2806
+ return toTouchMovePoint(event);
2807
+ }
2808
+ return toTouchEndPoint(event);
2459
2809
  }
2810
+ })(), { distance: distanceFromPrevious, angle: angleFromPrevious } = toPolarCoordinates({
2811
+ xA: previousX,
2812
+ xB: newX,
2813
+ yA: previousY,
2814
+ yB: newY
2815
+ }), { distance: distanceFromStart, angle: angleFromStart } = toPolarCoordinates({
2816
+ xA: startX,
2817
+ xB: newX,
2818
+ yA: startY,
2819
+ yB: newY
2820
+ });
2821
+ metadata.distance.straight.fromPrevious = distanceFromPrevious;
2822
+ metadata.distance.horizontal.fromPrevious = newX - previousX;
2823
+ metadata.distance.vertical.fromPrevious = newY - previousY;
2824
+ metadata.angle.fromPrevious = angleFromPrevious;
2825
+ metadata.direction.fromPrevious = toDirection(angleFromPrevious.degrees);
2826
+ metadata.distance.straight.fromStart = distanceFromStart;
2827
+ metadata.distance.horizontal.fromStart = newX - startX;
2828
+ metadata.distance.vertical.fromStart = newY - startY;
2829
+ metadata.angle.fromStart = angleFromStart;
2830
+ metadata.direction.fromStart = toDirection(angleFromStart.degrees);
2831
+ metadata.points.end = { x: newX, y: newY };
2832
+ }
2833
+
2834
+ const initialMetadata = {
2835
+ times: {
2836
+ start: 0,
2837
+ end: 0
2838
+ },
2839
+ duration: 0,
2840
+ velocity: 0
2841
+ };
2842
+ function storePointerTimeMetadata(event, api, getShouldStore, setRequest, recognize) {
2843
+ const { getSequence, getMetadata, getStatus, listenInjection: { effect } } = api, metadata = getMetadata();
2844
+ if (!metadata.times) {
2845
+ metadata.times = createClone()(initialMetadata.times);
2460
2846
  }
2461
- documentEventListen(effect, options) {
2462
- const narrowedOptions = {
2463
- ...options,
2464
- target: document
2847
+ metadata.times.start = Math.round(event.timeStamp);
2848
+ metadata.times.end = Math.round(event.timeStamp);
2849
+ let previousTime = metadata.times.start;
2850
+ const storeDuration = () => {
2851
+ const request = requestAnimationFrame((timestamp) => {
2852
+ if (getShouldStore()) {
2853
+ previousTime = metadata.times.end;
2854
+ metadata.times.end = Math.round(timestamp);
2855
+ metadata.duration = Math.max(0, metadata.times.end - metadata.times.start);
2856
+ const durationFromPrevious = Math.max(0, metadata.times.end - previousTime);
2857
+ metadata.velocity = metadata.distance.straight.fromPrevious / durationFromPrevious;
2858
+ const event2 = getSequence().at(-1);
2859
+ recognize?.(event2, api);
2860
+ if (getStatus() === "recognized")
2861
+ effect(event2);
2862
+ storeDuration();
2863
+ }
2864
+ });
2865
+ setRequest(request);
2866
+ };
2867
+ storeDuration();
2868
+ }
2869
+
2870
+ function defineGraph(nodes, edges) {
2871
+ return { nodes, edges };
2872
+ }
2873
+ function defineGraphNodes(nodes) {
2874
+ return nodes;
2875
+ }
2876
+ function defineGraphEdges(edges) {
2877
+ return edges;
2878
+ }
2879
+ function defineGraphNode(node) {
2880
+ return node;
2881
+ }
2882
+ function defineGraphEdge(from, to, predicateShouldTraverse) {
2883
+ return { from, to, predicateShouldTraverse };
2884
+ }
2885
+ function defineGraphAsync(nodes, edges) {
2886
+ return { nodes, edges };
2887
+ }
2888
+ function defineGraphAsyncEdges(edges) {
2889
+ return edges;
2890
+ }
2891
+ function defineGraphAsyncEdge(from, to, predicateShouldTraverse) {
2892
+ return { from, to, predicateShouldTraverse };
2893
+ }
2894
+
2895
+ function defineAssociativeArray(associativeArray) {
2896
+ return associativeArray;
2897
+ }
2898
+
2899
+ function createExceptAndOnlyEffect(type, effect, options) {
2900
+ const { except = [], only = [] } = options;
2901
+ if (type === "keydown" || type === "keyup") {
2902
+ return (event) => {
2903
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2904
+ if (matchesOnly) {
2905
+ effect(event);
2906
+ return;
2907
+ }
2908
+ if (only.length === 0 && !matchesExcept) {
2909
+ effect(event);
2910
+ return;
2911
+ }
2465
2912
  };
2466
- this.eventListen(effect, narrowedOptions);
2467
- }
2468
- eventListen(effect, options) {
2469
- const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
2470
- this.addEventListeners(eventListeners, options);
2471
- }
2472
- addEventListeners(eventListeners, options) {
2473
- const { target = document } = options;
2474
- for (const eventListener of eventListeners) {
2475
- target.addEventListener(eventListener[0], eventListener[1], eventListener[2]);
2476
- this.active.add({ target, id: eventListener });
2477
- }
2478
2913
  }
2479
- listening() {
2480
- this.computedStatus = "listening";
2481
- }
2482
- stop(options = {}) {
2483
- const { target } = options;
2484
- switch (this.status) {
2485
- case "ready":
2486
- case void 0:
2487
- break;
2488
- default:
2489
- const stoppables = [...this.active].filter((active) => !target || ("target" in active ? active.target === target : false)), shouldUpdateStatus = stoppables.length === this.active.size;
2490
- for (const stoppable of stoppables) {
2491
- stop(stoppable);
2492
- this.active.delete(stoppable);
2493
- }
2494
- if (shouldUpdateStatus) {
2495
- this.stopped();
2496
- }
2497
- break;
2498
- }
2499
- return this;
2914
+ if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
2915
+ return (event) => {
2916
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2917
+ if (matchesOnly) {
2918
+ effect(event);
2919
+ return;
2920
+ }
2921
+ if (only.length === 0 && !matchesExcept) {
2922
+ effect(event);
2923
+ return;
2924
+ }
2925
+ };
2500
2926
  }
2501
- stopped() {
2502
- this.computedStatus = "stopped";
2927
+ if (type.startsWith("pointer")) {
2928
+ return (event) => {
2929
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2930
+ if (matchesOnly) {
2931
+ effect(event);
2932
+ return;
2933
+ }
2934
+ if (only.length === 0 && !matchesExcept) {
2935
+ effect(event);
2936
+ return;
2937
+ }
2938
+ };
2503
2939
  }
2940
+ return (event) => {
2941
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, false];
2942
+ if (matchesOnly) {
2943
+ effect(event, {});
2944
+ return;
2945
+ }
2946
+ if (only.length === 0 && !matchesExcept) {
2947
+ effect(event, {});
2948
+ return;
2949
+ }
2950
+ };
2504
2951
  }
2505
- function stop(stoppable) {
2506
- if (stoppable.id instanceof Listenable) {
2507
- stoppable.id.stop();
2508
- return;
2952
+
2953
+ function getDomAvailability() {
2954
+ try {
2955
+ return !!window ? "available" : "unavailable";
2956
+ } catch (error) {
2957
+ return "unavailable";
2509
2958
  }
2510
- if (lazyCollections.some((type) => observerAssertionsByType[type](stoppable.id))(["intersect", "mutate", "resize"])) {
2511
- const { id: id2 } = stoppable;
2512
- id2.disconnect();
2513
- return;
2959
+ }
2960
+
2961
+ function predicateArray(value) {
2962
+ return Array.isArray(value);
2963
+ }
2964
+ function predicateUndefined(value) {
2965
+ return value === void 0;
2966
+ }
2967
+ function predicateFunction(value) {
2968
+ return typeof value === "function";
2969
+ }
2970
+ function predicateNull(value) {
2971
+ return value === null;
2972
+ }
2973
+ function predicateNumber(value) {
2974
+ return typeof value === "number";
2975
+ }
2976
+ function predicateString(value) {
2977
+ return typeof value === "string";
2978
+ }
2979
+ function predicateObject(value) {
2980
+ return typeof value === "object";
2981
+ }
2982
+
2983
+ function toInterpolated({ previous, next, progress }, options = {}) {
2984
+ if (predicateUndefined(previous)) {
2985
+ return next;
2514
2986
  }
2515
- if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
2516
- const { target: target2, id: id2 } = stoppable;
2517
- target2.removeEventListener(id2[0], id2[1]);
2518
- return;
2987
+ if (predicateNumber(previous) && predicateNumber(next)) {
2988
+ return (next - previous) * progress + previous;
2519
2989
  }
2520
- if (predicateNumber(stoppable.id)) {
2521
- const { target: target2, id: id2 } = stoppable;
2522
- target2.cancelIdleCallback(id2);
2523
- return;
2990
+ if (predicateString(previous) && predicateString(next)) {
2991
+ const { color: createMixOptions } = options;
2992
+ return createMix(`${next} ${progress * 100}%`, createMixOptions)(previous);
2524
2993
  }
2525
- if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
2526
- const { target: target2, id: id2 } = stoppable;
2527
- target2.removeEventListener(id2[0], id2[1]);
2528
- return;
2994
+ if (predicateArray(previous) && predicateArray(next)) {
2995
+ const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
2996
+ return createSlice(0, sliceEnd)(sliceTarget);
2529
2997
  }
2530
- const { target, id } = stoppable;
2531
- target.removeEventListener(id[0], id[1], id[2]);
2532
- }
2533
- function toImplementation(type) {
2534
- return lazyCollections.find((implementation) => predicatesByImplementation.get(implementation)(type))(predicatesByImplementation.keys());
2535
- }
2536
- const predicatesByImplementation = /* @__PURE__ */ new Map([
2537
- [
2538
- "recognizeable",
2539
- (type) => type === "recognizeable"
2540
- ],
2541
- [
2542
- "intersection",
2543
- (type) => type === "intersect"
2544
- ],
2545
- [
2546
- "mutation",
2547
- (type) => type === "mutate"
2548
- ],
2549
- [
2550
- "resize",
2551
- (type) => type === "resize"
2552
- ],
2553
- [
2554
- "mediaquery",
2555
- (type) => implementationREs.mediaquery.test(type)
2556
- ],
2557
- [
2558
- "idle",
2559
- (type) => type === "idle"
2560
- ],
2561
- [
2562
- "message",
2563
- (type) => type === "message" || type === "messageerror"
2564
- ],
2565
- [
2566
- "documentevent",
2567
- (type) => documentEvents.has(type)
2568
- ],
2569
- [
2570
- "event",
2571
- () => true
2572
- ]
2573
- ]);
2574
- const documentEvents = /* @__PURE__ */ new Set([
2575
- "fullscreenchange",
2576
- "fullscreenerror",
2577
- "pointerlockchange",
2578
- "pointerlockerror",
2579
- "readystatechange",
2580
- "visibilitychange"
2581
- ]);
2582
- const implementationREs = {
2583
- mediaquery: /^\(.+\)$/
2584
- };
2585
- function toAddEventListenerParams(type, effect, options) {
2586
- const { addEventListener, useCapture } = options, exceptAndOnlyEffect = createExceptAndOnlyEffect(type, effect, options), effectOptions = [addEventListener || useCapture];
2587
- return { exceptAndOnlyEffect, effectOptions };
2588
2998
  }
2589
- const observerAssertionsByType = {
2590
- intersect: (observer) => observer instanceof IntersectionObserver,
2591
- mutate: (observer) => observer instanceof MutationObserver,
2592
- resize: (observer) => observer instanceof ResizeObserver
2593
- };
2594
2999
 
2595
3000
  const defaultOptions$8 = {
2596
3001
  duration: 0,
@@ -2605,6 +3010,14 @@ const defaultOptions$8 = {
2605
3010
  iterations: 1,
2606
3011
  alternates: false
2607
3012
  };
3013
+ const defaultAnimateOptions = {
3014
+ interpolate: {
3015
+ color: {
3016
+ method: "oklch",
3017
+ ...defaultCreateMixOptions
3018
+ }
3019
+ }
3020
+ };
2608
3021
  class Animateable {
2609
3022
  initialDuration;
2610
3023
  iterationLimit;
@@ -2627,8 +3040,8 @@ class Animateable {
2627
3040
  this.iterationLimit = options?.iterations || defaultOptions$8.iterations;
2628
3041
  this.alternates = options?.alternates || defaultOptions$8.alternates;
2629
3042
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
2630
- this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
2631
- this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
3043
+ this.toAnimationProgress = createAnimationProgress(this.controlPoints);
3044
+ this.reversedToAnimationProgress = createAnimationProgress(this.reversedControlPoints);
2632
3045
  this.playCache = {};
2633
3046
  this.reverseCache = {};
2634
3047
  this.pauseCache = {};
@@ -2878,7 +3291,7 @@ class Animateable {
2878
3291
  computedRequest;
2879
3292
  createAnimate(type) {
2880
3293
  return (effect, options = {}) => {
2881
- const { interpolate: interpolateOptions } = options;
3294
+ const { interpolate: interpolateOptions } = createDeepMerge(options)(defaultAnimateOptions);
2882
3295
  this.computedRequest = window.requestAnimationFrame((timestamp) => {
2883
3296
  this.setStartTimeAndStatus(type, timestamp);
2884
3297
  const timeElapsed = Math.min(timestamp - this.startTime - this.totalTimeInvisible, this.duration), timeRemaining = this.duration - timeElapsed, timeProgress = timeElapsed / this.duration, toAnimationProgress = this.getToAnimationProgress(type), animationProgress = toAnimationProgress(timeProgress);
@@ -3249,7 +3662,7 @@ function createGetEaseables(fromKeyframeToControlPoints) {
3249
3662
  (easeables, property) => {
3250
3663
  const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
3251
3664
  (propertyEaseables2, keyframe, index) => {
3252
- const previous = keyframe.properties[property], next = index === propertyKeyframes.length - 1 ? previous : propertyKeyframes[index + 1].properties[property], start = keyframe.progress, end = index === propertyKeyframes.length - 1 ? 2 : propertyKeyframes[index + 1].progress, hasCustomTiming = !!keyframe.timing, toAnimationProgress = index === propertyKeyframes.length - 1 ? () => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
3665
+ const previous = keyframe.properties[property], next = index === propertyKeyframes.length - 1 ? previous : propertyKeyframes[index + 1].properties[property], start = keyframe.progress, end = index === propertyKeyframes.length - 1 ? 2 : propertyKeyframes[index + 1].progress, hasCustomTiming = !!keyframe.timing, toAnimationProgress = index === propertyKeyframes.length - 1 ? () => 1 : createAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
3253
3666
  propertyEaseables2.push({
3254
3667
  property,
3255
3668
  value: { previous, next },
@@ -3302,32 +3715,10 @@ function fromControlPointsToReversedControlPoints(points) {
3302
3715
  { x: 1 - points[0].x, y: 1 - points[0].y }
3303
3716
  ];
3304
3717
  }
3305
- function createToAnimationProgress(points) {
3718
+ function createAnimationProgress(points) {
3306
3719
  const { 0: { x: point1x, y: point1y }, 1: { x: point2x, y: point2y } } = points;
3307
3720
  return BezierEasing(point1x, point1y, point2x, point2y);
3308
3721
  }
3309
- function toInterpolated({ previous, next, progress }, options = {}) {
3310
- if (predicateUndefined(previous)) {
3311
- return next;
3312
- }
3313
- if (predicateNumber(previous) && predicateNumber(next)) {
3314
- return (next - previous) * progress + previous;
3315
- }
3316
- if (predicateString(previous) && predicateString(next)) {
3317
- return color.mix(
3318
- options.colorModel,
3319
- {
3320
- start: previous,
3321
- end: next,
3322
- alpha: progress
3323
- }
3324
- ).toRgb().toRgbString();
3325
- }
3326
- if (predicateArray(previous) && predicateArray(next)) {
3327
- const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
3328
- return createSlice(0, sliceEnd)(sliceTarget);
3329
- }
3330
- }
3331
3722
  const linear = [
3332
3723
  0,
3333
3724
  0,
@@ -3726,7 +4117,6 @@ class Completeable {
3726
4117
  }
3727
4118
  return this;
3728
4119
  }
3729
- // TODO: Support array of selections for multi cursor editing
3730
4120
  computedSelection;
3731
4121
  setSelection(selection) {
3732
4122
  this.computedSelection = selection;
@@ -4104,22 +4494,32 @@ class Drawable {
4104
4494
  }
4105
4495
  }
4106
4496
  function toD(stroke) {
4107
- return createReduce((d, [x0, y0], index) => {
4108
- const [x1, y1] = stroke[(index + 1) % stroke.length];
4109
- return `${d} ${x0} ${y0} ${(x0 + x1) / 2} ${(y0 + y1) / 2}`;
4110
- }, `M ${stroke[0][0]} ${stroke[0][1]} Q`)(stroke) + "Z";
4497
+ if (stroke.length < 4)
4498
+ return "";
4499
+ let a = stroke[0];
4500
+ let b = stroke[1];
4501
+ const c = stroke[2];
4502
+ let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${lazyCollections.average()([b[0], c[0]]).toFixed(2)},${lazyCollections.average()([b[1], c[1]]).toFixed(2)} T`;
4503
+ for (let i = 2; i < stroke.length - 1; i++) {
4504
+ a = stroke[i];
4505
+ b = stroke[i + 1];
4506
+ result += `${lazyCollections.average()([a[0], b[0]]).toFixed(2)},${lazyCollections.average()([a[1], b[1]]).toFixed(2)} `;
4507
+ }
4508
+ return `${result}Z`;
4111
4509
  }
4112
4510
  function toFlattenedD(stroke) {
4113
- if (stroke.length === 0) {
4511
+ if (stroke.length === 0)
4114
4512
  return "";
4513
+ const faces = polygonClipping.union([stroke]);
4514
+ const flattenedD = [];
4515
+ for (const face of faces) {
4516
+ for (const ring of face) {
4517
+ flattenedD.push(toD(ring));
4518
+ }
4115
4519
  }
4116
- const multiPolygon = polygonClipping.union([stroke]);
4117
- return createReduce((dFromMultiPolygon, polygon) => {
4118
- return dFromMultiPolygon + createReduce((dFromRing, points) => {
4119
- return dFromRing + toD(points);
4120
- }, "")(polygon);
4121
- }, "")(multiPolygon);
4520
+ return toSpaceSeparated(flattenedD);
4122
4521
  }
4522
+ const toSpaceSeparated = lazyCollections.join(" ");
4123
4523
 
4124
4524
  class Resolveable {
4125
4525
  constructor(getPromise, options = {}) {
@@ -4142,20 +4542,23 @@ class Resolveable {
4142
4542
  get value() {
4143
4543
  return this.computedValue;
4144
4544
  }
4545
+ get error() {
4546
+ return this.computedError;
4547
+ }
4145
4548
  computedGetPromise;
4146
4549
  setGetPromise(getPromise) {
4147
4550
  this.computedGetPromise = getPromise;
4148
4551
  return this;
4149
4552
  }
4150
4553
  computedValue;
4151
- async resolve(...args) {
4554
+ computedError;
4555
+ async resolve() {
4152
4556
  this.resolving();
4153
4557
  try {
4154
- const promises = this.getPromise(...args);
4155
- this.computedValue = predicateArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
4558
+ this.computedValue = await this.getPromise();
4156
4559
  this.resolved();
4157
4560
  } catch (error) {
4158
- this.computedValue = error;
4561
+ this.computedError = error;
4159
4562
  this.errored();
4160
4563
  }
4161
4564
  return this;
@@ -4197,27 +4600,26 @@ class Fetchable {
4197
4600
  set resource(resource) {
4198
4601
  this.setResource(resource);
4199
4602
  }
4603
+ get status() {
4604
+ return this.computedStatus;
4605
+ }
4200
4606
  computedKy;
4201
4607
  get ky() {
4202
4608
  return this.computedKy;
4203
4609
  }
4204
4610
  computedAbortController;
4205
4611
  get abortController() {
4206
- if (!this.computedAbortController) {
4612
+ if (!this.computedAbortController)
4207
4613
  this.computedAbortController = new AbortController();
4208
- }
4209
4614
  return this.computedAbortController;
4210
4615
  }
4211
- get status() {
4212
- return this.computedStatus;
4213
- }
4214
- get response() {
4215
- return this.computedResponse;
4216
- }
4217
4616
  computedRetryCount = 0;
4218
4617
  get retryCount() {
4219
4618
  return this.computedRetryCount;
4220
4619
  }
4620
+ get response() {
4621
+ return this.computedResponse;
4622
+ }
4221
4623
  get error() {
4222
4624
  return this.computedError;
4223
4625
  }
@@ -4289,27 +4691,27 @@ class Fetchable {
4289
4691
  this.computedStatus = "errored";
4290
4692
  }
4291
4693
  async get(options = {}) {
4292
- await this.fetch({ signal: this.abortController.signal, ...options, method: "get" });
4694
+ await this.fetch({ ...options, method: "get" });
4293
4695
  return this;
4294
4696
  }
4295
4697
  async patch(options = {}) {
4296
- await this.fetch({ signal: this.abortController.signal, ...options, method: "patch" });
4698
+ await this.fetch({ ...options, method: "patch" });
4297
4699
  return this;
4298
4700
  }
4299
4701
  async post(options = {}) {
4300
- await this.fetch({ signal: this.abortController.signal, ...options, method: "post" });
4702
+ await this.fetch({ ...options, method: "post" });
4301
4703
  return this;
4302
4704
  }
4303
4705
  async put(options = {}) {
4304
- await this.fetch({ signal: this.abortController.signal, ...options, method: "put" });
4706
+ await this.fetch({ ...options, method: "put" });
4305
4707
  return this;
4306
4708
  }
4307
4709
  async delete(options = {}) {
4308
- await this.fetch({ signal: this.abortController.signal, ...options, method: "delete" });
4710
+ await this.fetch({ ...options, method: "delete" });
4309
4711
  return this;
4310
4712
  }
4311
4713
  async head(options = {}) {
4312
- await this.fetch({ signal: this.abortController.signal, ...options, method: "head" });
4714
+ await this.fetch({ ...options, method: "head" });
4313
4715
  return this;
4314
4716
  }
4315
4717
  abort() {
@@ -4406,6 +4808,9 @@ class Grantable {
4406
4808
  get permission() {
4407
4809
  return this.computedPermission;
4408
4810
  }
4811
+ get error() {
4812
+ return this.computedError;
4813
+ }
4409
4814
  get status() {
4410
4815
  return this.computedStatus;
4411
4816
  }
@@ -4415,22 +4820,23 @@ class Grantable {
4415
4820
  return this;
4416
4821
  }
4417
4822
  computedPermission;
4418
- async query() {
4419
- this.querying();
4823
+ computedError;
4824
+ async grant() {
4825
+ this.granting();
4420
4826
  try {
4421
4827
  this.computedPermission = await navigator.permissions.query(this.descriptor);
4422
- this.queried();
4828
+ this.granted();
4423
4829
  } catch (error) {
4424
- this.computedPermission = error;
4830
+ this.computedError = error;
4425
4831
  this.errored();
4426
4832
  }
4427
4833
  return this;
4428
4834
  }
4429
- querying() {
4430
- this.computedStatus = "querying";
4835
+ granting() {
4836
+ this.computedStatus = "granting";
4431
4837
  }
4432
- queried() {
4433
- this.computedStatus = "queried";
4838
+ granted() {
4839
+ this.computedStatus = "granted";
4434
4840
  }
4435
4841
  errored() {
4436
4842
  this.computedStatus = "errored";
@@ -4626,9 +5032,6 @@ class Pickable {
4626
5032
  get newest() {
4627
5033
  return this.picks[this.picks.length - 1];
4628
5034
  }
4629
- get status() {
4630
- return this.computedStatus;
4631
- }
4632
5035
  get items() {
4633
5036
  return this.toItems(this.picks);
4634
5037
  }
@@ -4637,6 +5040,9 @@ class Pickable {
4637
5040
  get multiple() {
4638
5041
  return this.computedMultiple;
4639
5042
  }
5043
+ get status() {
5044
+ return this.computedStatus;
5045
+ }
4640
5046
  toPossiblePicks;
4641
5047
  setArray(array) {
4642
5048
  this.computedArray = array;
@@ -4730,112 +5136,20 @@ function narrowIndices(indexOrIndices) {
4730
5136
  }
4731
5137
  const toUnique = createUnique();
4732
5138
 
4733
- class Sanitizeable {
4734
- domPurifyConfig;
4735
- constructor(html, options) {
4736
- this.computedHtml = html;
4737
- this.domPurifyConfig = options;
4738
- this.ready();
4739
- }
4740
- computedDompurify;
4741
- computedStatus;
4742
- ready() {
4743
- if (getDomAvailability() === "available") {
4744
- this.computedDompurify = createDOMPurify();
4745
- this.computedDompurify.setConfig(this.domPurifyConfig);
4746
- }
4747
- this.computedStatus = "ready";
4748
- }
4749
- get html() {
4750
- return this.computedHtml;
4751
- }
4752
- set html(html) {
4753
- this.setHtml(html);
4754
- }
4755
- get dompurify() {
4756
- if (!this.computedDompurify && getDomAvailability() === "available") {
4757
- this.computedDompurify = createDOMPurify();
4758
- this.computedDompurify.setConfig(this.domPurifyConfig);
4759
- }
4760
- return this.computedDompurify;
4761
- }
4762
- get status() {
4763
- return this.computedStatus;
4764
- }
4765
- computedHtml;
4766
- setHtml(html) {
4767
- this.computedHtml = html;
4768
- return this;
4769
- }
4770
- sanitize() {
4771
- this.setHtml(this.dompurify.sanitize(this.html));
4772
- this.sanitized();
4773
- return this;
4774
- }
4775
- sanitized() {
4776
- this.computedStatus = "sanitized";
4777
- }
4778
- }
4779
-
4780
- class Searchable {
4781
- searcherOptions;
4782
- computedResults;
4783
- constructor(candidates, options = {}) {
4784
- this.searcherOptions = options;
4785
- this.setCandidates(candidates);
4786
- this.computedResults = [];
4787
- this.ready();
4788
- }
4789
- computedStatus;
4790
- ready() {
4791
- this.computedStatus = "ready";
4792
- }
4793
- computedCandidates;
4794
- get candidates() {
4795
- return this.computedCandidates;
4796
- }
4797
- set candidates(candidates) {
4798
- this.setCandidates(candidates);
4799
- }
4800
- get results() {
4801
- return this.computedResults;
4802
- }
4803
- get searcher() {
4804
- return this.computedSearcher;
4805
- }
4806
- get status() {
4807
- return this.computedStatus;
4808
- }
4809
- computedSearcher;
4810
- setCandidates(candidates) {
4811
- this.computedCandidates = Array.from(candidates);
4812
- this.computedSearcher = new fastFuzzy.Searcher(candidates, this.searcherOptions);
4813
- return this;
4814
- }
4815
- search(query, options) {
4816
- this.computedResults = this.searcher.search(query, options);
4817
- this.searched();
4818
- return this;
4819
- }
4820
- searched() {
4821
- this.computedStatus = "searched";
4822
- }
4823
- }
4824
-
4825
5139
  class Shareable {
4826
- constructor(state, options = {}) {
4827
- this.setState(state);
5140
+ constructor(shareData, options = {}) {
5141
+ this.setShareData(shareData);
4828
5142
  this.ready();
4829
5143
  }
4830
5144
  computedStatus;
4831
5145
  ready() {
4832
5146
  this.computedStatus = "ready";
4833
5147
  }
4834
- get state() {
5148
+ get shareData() {
4835
5149
  return this.computedState;
4836
5150
  }
4837
- set state(state) {
4838
- this.setState(state);
5151
+ set shareData(shareData) {
5152
+ this.setShareData(shareData);
4839
5153
  }
4840
5154
  get status() {
4841
5155
  return this.computedStatus;
@@ -4849,15 +5163,15 @@ class Shareable {
4849
5163
  return this.computedError;
4850
5164
  }
4851
5165
  computedState;
4852
- setState(state) {
4853
- this.computedState = state;
4854
- this.computedCan = new Resolveable(async () => await navigator.canShare(state));
5166
+ setShareData(shareData) {
5167
+ this.computedState = shareData;
5168
+ this.computedCan = new Resolveable(async () => await navigator.canShare(shareData));
4855
5169
  return this;
4856
5170
  }
4857
5171
  async share() {
4858
5172
  this.sharing();
4859
5173
  try {
4860
- await navigator.share(this.state);
5174
+ await navigator.share(this.shareData);
4861
5175
  this.shared();
4862
5176
  } catch (error) {
4863
5177
  this.computedError = error;
@@ -5007,42 +5321,62 @@ exports.Drawable = Drawable;
5007
5321
  exports.Fetchable = Fetchable;
5008
5322
  exports.Fullscreenable = Fullscreenable;
5009
5323
  exports.Grantable = Grantable;
5324
+ exports.Keychord = Keychord;
5325
+ exports.Keypress = Keypress;
5326
+ exports.Keyrelease = Keyrelease;
5327
+ exports.Konami = Konami;
5010
5328
  exports.Listenable = Listenable;
5329
+ exports.Mousepress = Mousepress;
5330
+ exports.Mouserelease = Mouserelease;
5011
5331
  exports.Navigateable = Navigateable;
5012
5332
  exports.Pickable = Pickable;
5013
5333
  exports.Recognizeable = Recognizeable;
5014
5334
  exports.Resolveable = Resolveable;
5015
- exports.Sanitizeable = Sanitizeable;
5016
- exports.Searchable = Searchable;
5017
5335
  exports.Shareable = Shareable;
5018
5336
  exports.Storeable = Storeable;
5019
- exports.createAssociativeArray = createAssociativeArray;
5020
- exports.createAsyncDirectedAcyclicPredicateAncestor = createPredicateAncestor$1;
5021
- exports.createAsyncDirectedAcyclicToCommonAncestors = createToCommonAncestors$1;
5022
- exports.createAsyncDirectedAcyclicToLayers = createToLayers;
5023
- exports.createAsyncDirectedAcyclicToNodeSteps = createToNodeSteps$1;
5024
- exports.createAsyncDirectedAcyclicToPath = createToPath$1;
5025
- exports.createAsyncDirectedAcyclicToSteps = createToSteps$1;
5026
- exports.createAsyncDirectedAcyclicToTree = createToTree$1;
5337
+ exports.Touchpress = Touchpress;
5338
+ exports.Touchrelease = Touchrelease;
5339
+ exports.createAssociativeArrayClear = createClear$2;
5340
+ exports.createAssociativeArrayDelete = createDelete$2;
5341
+ exports.createAssociativeArrayHas = createHas$1;
5342
+ exports.createAssociativeArrayKeys = createKeys$1;
5343
+ exports.createAssociativeArraySet = createSet$2;
5344
+ exports.createAssociativeArrayValue = createValue$2;
5345
+ exports.createAssociativeArrayValues = createValues$1;
5346
+ exports.createBreadthPathConfig = createBreadthPathConfig;
5347
+ exports.createChildren = createChildren;
5027
5348
  exports.createClamp = createClamp;
5349
+ exports.createClear = createClear$1;
5028
5350
  exports.createClip = createClip;
5029
5351
  exports.createClone = createClone;
5352
+ exports.createComputedStyle = createComputedStyle;
5030
5353
  exports.createConcat = createConcat;
5031
- exports.createDecisionTreePredicateAncestor = createPredicateAncestor;
5032
- exports.createDecisionTreeToCommonAncestors = createToCommonAncestors;
5033
- exports.createDecisionTreeToNodeSteps = createToNodeSteps;
5034
- exports.createDecisionTreeToPath = createToPath;
5035
- exports.createDecisionTreeToSteps = createToSteps;
5036
- exports.createDecisionTreeToTree = createToTree;
5354
+ exports.createDecisionTreeAncestor = createAncestor$1;
5355
+ exports.createDecisionTreeCommonAncestors = createCommonAncestors$1;
5356
+ exports.createDecisionTreeNodeDepthFirstSteps = createNodeDepthFirstSteps$1;
5357
+ exports.createDecisionTreePath = createPath$1;
5358
+ exports.createDecisionTreeSteps = createDepthFirstSteps$1;
5359
+ exports.createDecisionTreeTree = createTree$1;
5360
+ exports.createDeepEqual = createDeepEqual;
5361
+ exports.createDeepMerge = createDeepMerge;
5362
+ exports.createDelete = createDelete$1;
5363
+ exports.createDepthPathConfig = createDepthPathConfig;
5037
5364
  exports.createDetermine = createDetermine;
5038
- exports.createDirectedAcyclicPredicateAncestor = createPredicateAncestor$2;
5039
- exports.createDirectedAcyclicToCommonAncestors = createToCommonAncestors$2;
5040
- exports.createDirectedAcyclicToLayers = createToLayers$1;
5041
- exports.createDirectedAcyclicToNodeSteps = createToNodeSteps$2;
5042
- exports.createDirectedAcyclicToPath = createToPath$2;
5043
- exports.createDirectedAcyclicToRoots = createToRoots;
5044
- exports.createDirectedAcyclicToSteps = createToSteps$2;
5045
- exports.createDirectedAcyclicToTree = createToTree$2;
5365
+ exports.createDirectedAcyclicAncestor = createAncestor$2;
5366
+ exports.createDirectedAcyclicAsyncAncestor = createAncestor;
5367
+ exports.createDirectedAcyclicAsyncCommonAncestors = createCommonAncestors;
5368
+ exports.createDirectedAcyclicAsyncDepthFirstSteps = createDepthFirstSteps;
5369
+ exports.createDirectedAcyclicAsyncLayers = createLayers;
5370
+ exports.createDirectedAcyclicAsyncNodeDepthFirstSteps = createNodeDepthFirstSteps;
5371
+ exports.createDirectedAcyclicAsyncPath = createPath;
5372
+ exports.createDirectedAcyclicAsyncTree = createTree;
5373
+ exports.createDirectedAcyclicCommonAncestors = createCommonAncestors$2;
5374
+ exports.createDirectedAcyclicDepthFirstSteps = createDepthFirstSteps$2;
5375
+ exports.createDirectedAcyclicLayers = createLayers$1;
5376
+ exports.createDirectedAcyclicNodeDepthFirstSteps = createNodeDepthFirstSteps$2;
5377
+ exports.createDirectedAcyclicPath = createPath$2;
5378
+ exports.createDirectedAcyclicRoots = createRoots;
5379
+ exports.createDirectedAcyclicTree = createTree$2;
5046
5380
  exports.createEntries = createEntries;
5047
5381
  exports.createEqual = createEqual;
5048
5382
  exports.createEvery = createEvery;
@@ -5052,45 +5386,60 @@ exports.createFindAsync = createFindAsync;
5052
5386
  exports.createFindIndexAsync = createFindIndexAsync;
5053
5387
  exports.createFocusable = createFocusable;
5054
5388
  exports.createForEachAsync = createForEachAsync;
5389
+ exports.createGraph = createGraph;
5390
+ exports.createGreater = createGreater;
5391
+ exports.createGreaterOrEqual = createGreaterOrEqual;
5392
+ exports.createHas = createHas;
5393
+ exports.createIncoming = createIncoming;
5394
+ exports.createIndegree = createIndegree;
5055
5395
  exports.createInsert = createInsert;
5056
5396
  exports.createKeychord = createKeychord;
5397
+ exports.createKeycomboMatch = createKeycomboMatch$1;
5057
5398
  exports.createKeypress = createKeypress;
5058
5399
  exports.createKeyrelease = createKeyrelease;
5059
5400
  exports.createKeys = createKeys;
5060
5401
  exports.createKonami = createKonami;
5402
+ exports.createLess = createLess;
5403
+ exports.createLessOrEqual = createLessOrEqual;
5061
5404
  exports.createList = createList;
5062
5405
  exports.createMap = createMap;
5063
5406
  exports.createMapAsync = createMapAsync;
5407
+ exports.createMix = createMix;
5064
5408
  exports.createMousepress = createMousepress;
5065
5409
  exports.createMouserelease = createMouserelease;
5066
- exports.createPredicateKeycomboMatch = createPredicateKeycomboMatch;
5067
- exports.createPredicateRoot = createPredicateRoot;
5410
+ exports.createNumber = createNumber;
5411
+ exports.createOnlyChild = createOnlyChild;
5412
+ exports.createOutdegree = createOutdegree;
5413
+ exports.createOutgoing = createOutgoing;
5068
5414
  exports.createReduce = createReduce;
5069
5415
  exports.createReduceAsync = createReduceAsync;
5070
5416
  exports.createRemove = createRemove;
5071
- exports.createRename = createRename;
5072
5417
  exports.createReorder = createReorder;
5073
5418
  exports.createReplace = createReplace;
5419
+ exports.createResults = createResults;
5074
5420
  exports.createReverse = createReverse;
5421
+ exports.createRoot = createRoot;
5422
+ exports.createSanitize = createSanitize;
5423
+ exports.createSet = createSet$1;
5424
+ exports.createShuffle = createShuffle;
5425
+ exports.createSiblings = createSiblings;
5075
5426
  exports.createSlice = createSlice;
5076
5427
  exports.createSlug = createSlug;
5077
5428
  exports.createSome = createSome;
5078
5429
  exports.createSort = createSort;
5079
5430
  exports.createSwap = createSwap;
5080
- exports.createToGraph = createToGraph;
5081
- exports.createToIncoming = createToIncoming;
5082
- exports.createToIndegree = createToIndegree;
5083
- exports.createToOutdegree = createToOutdegree;
5084
- exports.createToOutgoing = createToOutgoing;
5431
+ exports.createTerminal = createTerminal;
5432
+ exports.createTotalSiblings = createTotalSiblings;
5085
5433
  exports.createTouchpress = createTouchpress;
5086
5434
  exports.createTouchrelease = createTouchrelease;
5087
5435
  exports.createTreeFind = createFind;
5088
5436
  exports.createUnique = createUnique;
5089
- exports.defineAssociativeArrayEntries = defineAssociativeArrayEntries;
5090
- exports.defineAsyncGraph = defineAsyncGraph;
5091
- exports.defineAsyncGraphEdge = defineAsyncGraphEdge;
5092
- exports.defineAsyncGraphEdges = defineAsyncGraphEdges;
5437
+ exports.createValue = createValue$1;
5438
+ exports.defineAssociativeArray = defineAssociativeArray;
5093
5439
  exports.defineGraph = defineGraph;
5440
+ exports.defineGraphAsync = defineGraphAsync;
5441
+ exports.defineGraphAsyncEdge = defineGraphAsyncEdge;
5442
+ exports.defineGraphAsyncEdges = defineGraphAsyncEdges;
5094
5443
  exports.defineGraphEdge = defineGraphEdge;
5095
5444
  exports.defineGraphEdges = defineGraphEdges;
5096
5445
  exports.defineGraphNode = defineGraphNode;
@@ -5117,6 +5466,10 @@ exports.easingsNetOutExpo = easingsNetOutExpo;
5117
5466
  exports.easingsNetOutQuad = easingsNetOutQuad;
5118
5467
  exports.easingsNetOutQuint = easingsNetOutQuint;
5119
5468
  exports.easingsNetOutSine = easingsNetOutSine;
5469
+ exports.fromAliasToCode = fromAliasToCode;
5470
+ exports.fromCodeToAliases = fromCodeToAliases;
5471
+ exports.fromKeyboardEventDescriptorToAliases = fromKeyboardEventDescriptorToAliases;
5472
+ exports.fromShorthandAliasToLonghandAlias = fromShorthandAliasToLonghandAlias;
5120
5473
  exports.linear = linear;
5121
5474
  exports.materialAccelerated = materialAccelerated;
5122
5475
  exports.materialDecelerated = materialDecelerated;