@baleada/logic 0.22.3 → 0.22.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/lib/index.cjs +524 -232
  2. package/lib/index.d.ts +269 -216
  3. package/lib/index.js +513 -219
  4. package/package.json +21 -21
package/lib/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var lazyCollections = require('lazy-collections');
6
4
  var slugify = require('@sindresorhus/slugify');
7
5
  var BezierEasing = require('bezier-easing');
@@ -11,19 +9,15 @@ var polygonClipping = require('polygon-clipping');
11
9
  var createDOMPurify = require('dompurify');
12
10
  var fastFuzzy = require('fast-fuzzy');
13
11
 
14
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
-
16
- var slugify__default = /*#__PURE__*/_interopDefaultLegacy(slugify);
17
- var BezierEasing__default = /*#__PURE__*/_interopDefaultLegacy(BezierEasing);
18
- var polygonClipping__default = /*#__PURE__*/_interopDefaultLegacy(polygonClipping);
19
- var createDOMPurify__default = /*#__PURE__*/_interopDefaultLegacy(createDOMPurify);
20
-
21
12
  function createReduceAsync(accumulate, initialValue) {
22
13
  return async (array) => {
23
- return await lazyCollections.reduce(async (accumulatorPromise, item, index) => {
24
- const accumulator = await accumulatorPromise;
25
- return accumulate(accumulator, item, index);
26
- }, Promise.resolve(initialValue))(array);
14
+ return await lazyCollections.reduce(
15
+ async (accumulatorPromise, item, index) => {
16
+ const accumulator = await accumulatorPromise;
17
+ return accumulate(accumulator, item, index);
18
+ },
19
+ Promise.resolve(initialValue)
20
+ )(array);
27
21
  };
28
22
  }
29
23
  function createReduce(accumulate, initialValue) {
@@ -37,11 +31,14 @@ function createForEachAsync(forEach) {
37
31
  }
38
32
  function createMapAsync(transform) {
39
33
  return async (array) => {
40
- return await createReduceAsync(async (resolvedMaps, item, index) => {
41
- const transformed = await transform(item, index);
42
- resolvedMaps.push(transformed);
43
- return resolvedMaps;
44
- }, [])(array);
34
+ return await createReduceAsync(
35
+ async (resolvedMaps, item, index) => {
36
+ const transformed = await transform(item, index);
37
+ resolvedMaps.push(transformed);
38
+ return resolvedMaps;
39
+ },
40
+ []
41
+ )(array);
45
42
  };
46
43
  }
47
44
  function createFilterAsync(condition) {
@@ -50,36 +47,52 @@ function createFilterAsync(condition) {
50
47
  return createFilter((_, index) => transformedAsync[index])(array);
51
48
  };
52
49
  }
53
- function createDelete(index) {
50
+ function createRemove(index) {
54
51
  return (array) => {
55
- return createConcat(createSlice(0, index)(array), createSlice(index + 1)(array))([]);
52
+ return createConcat(
53
+ createSlice(0, index)(array),
54
+ createSlice(index + 1)(array)
55
+ )([]);
56
56
  };
57
57
  }
58
58
  function createInsert(item, index) {
59
59
  return (array) => {
60
60
  const withItems = createConcat(array, [item])([]);
61
- return createReorder({ start: array.length, itemCount: 1 }, index)(withItems);
61
+ return createReorder(
62
+ { start: array.length, itemCount: 1 },
63
+ index
64
+ )(withItems);
62
65
  };
63
66
  }
64
67
  function createReorder(from, to) {
65
68
  return (array) => {
66
- const [itemsToMoveStartIndex, itemsToMoveCount] = isObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
69
+ const [itemsToMoveStartIndex, itemsToMoveCount] = predicateObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
67
70
  if (insertIndex > itemsToMoveStartIndex && insertIndex < itemsToMoveStartIndex + itemsToMoveCount) {
68
71
  return array;
69
72
  }
70
73
  const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
71
74
  if (itemsToMoveStartIndex < insertIndex) {
72
75
  const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
73
- return createConcat(beforeItemsToMove, betweenItemsToMoveAndInsertIndex, itemsToMove, afterInsertIndex)([]);
76
+ return createConcat(
77
+ beforeItemsToMove,
78
+ betweenItemsToMoveAndInsertIndex,
79
+ itemsToMove,
80
+ afterInsertIndex
81
+ )([]);
74
82
  }
75
83
  if (itemsToMoveStartIndex > insertIndex) {
76
84
  const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
77
- return createConcat(beforeInsertion, itemsToMove, betweenInsertionAndItemsToMove, afterItemsToMove)([]);
85
+ return createConcat(
86
+ beforeInsertion,
87
+ itemsToMove,
88
+ betweenInsertionAndItemsToMove,
89
+ afterItemsToMove
90
+ )([]);
78
91
  }
79
92
  return array;
80
93
  };
81
94
  }
82
- function isObject(value) {
95
+ function predicateObject(value) {
83
96
  return typeof value === "object";
84
97
  }
85
98
  function createSwap(indices) {
@@ -107,25 +120,44 @@ function createSwap(indices) {
107
120
  }
108
121
  function createReplace(index, item) {
109
122
  return (array) => {
110
- return createConcat(createSlice(0, index)(array), [item], createSlice(index + 1)(array))([]);
123
+ return createConcat(
124
+ createSlice(0, index)(array),
125
+ [item],
126
+ createSlice(index + 1)(array)
127
+ )([]);
111
128
  };
112
129
  }
113
130
  function createUnique() {
114
- return (array) => lazyCollections.pipe(lazyCollections.unique(), lazyCollections.toArray())(array);
131
+ return (array) => lazyCollections.pipe(
132
+ lazyCollections.unique(),
133
+ lazyCollections.toArray()
134
+ )(array);
115
135
  }
116
136
  function createSlice(from, to) {
117
137
  return (array) => {
118
- return from === to ? [] : lazyCollections.pipe(lazyCollections.slice(from, to - 1), lazyCollections.toArray())(array);
138
+ return from === to ? [] : lazyCollections.pipe(
139
+ lazyCollections.slice(from, to - 1),
140
+ lazyCollections.toArray()
141
+ )(array);
119
142
  };
120
143
  }
121
144
  function createFilter(condition) {
122
- return (array) => lazyCollections.pipe(lazyCollections.filter(condition), lazyCollections.toArray())(array);
145
+ return (array) => lazyCollections.pipe(
146
+ lazyCollections.filter(condition),
147
+ lazyCollections.toArray()
148
+ )(array);
123
149
  }
124
150
  function createMap(transform) {
125
- return (array) => lazyCollections.pipe(lazyCollections.map(transform), lazyCollections.toArray())(array);
151
+ return (array) => lazyCollections.pipe(
152
+ lazyCollections.map(transform),
153
+ lazyCollections.toArray()
154
+ )(array);
126
155
  }
127
156
  function createConcat(...arrays) {
128
- return (array) => lazyCollections.pipe(lazyCollections.concat(array, ...arrays), lazyCollections.toArray())();
157
+ return (array) => lazyCollections.pipe(
158
+ lazyCollections.concat(array, ...arrays),
159
+ lazyCollections.toArray()
160
+ )();
129
161
  }
130
162
  function createReverse() {
131
163
  return (array) => {
@@ -138,12 +170,15 @@ function createReverse() {
138
170
  }
139
171
  function createSort(compare) {
140
172
  return (array) => {
141
- return new Pipeable(array).pipe(createSlice(0), (sliced) => sliced.sort(compare));
173
+ return new Pipeable(array).pipe(
174
+ createSlice(0),
175
+ (sliced) => compare ? sliced.sort(compare) : sliced.sort()
176
+ );
142
177
  };
143
178
  }
144
179
  function createSlug(options) {
145
180
  return (string) => {
146
- return slugify__default["default"](string, options);
181
+ return slugify(string, options);
147
182
  };
148
183
  }
149
184
  function createClip(required) {
@@ -159,7 +194,10 @@ function createClamp(min, max) {
159
194
  }
160
195
  function createDetermine(potentialities) {
161
196
  const predicates = createMap(({ outcome, probability }, index) => {
162
- const lowerBound = index === 0 ? 0 : lazyCollections.pipe(lazyCollections.slice(0, index - 1), lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0))(potentialities), upperBound = lowerBound + probability;
197
+ const lowerBound = index === 0 ? 0 : lazyCollections.pipe(
198
+ lazyCollections.slice(0, index - 1),
199
+ lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0)
200
+ )(potentialities), upperBound = lowerBound + probability;
163
201
  return {
164
202
  outcome,
165
203
  predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
@@ -182,6 +220,37 @@ function createToEntries() {
182
220
  return entries;
183
221
  };
184
222
  }
223
+ function createMatchesKeycombo(keycombo) {
224
+ return (event) => eventMatchesKeycombo(event, narrowKeycombo(keycombo));
225
+ }
226
+ function createMatchesMousecombo(mousecombo) {
227
+ return (event) => eventMatchesMousecombo(event, narrowMousecombo(mousecombo));
228
+ }
229
+ function createMatchesPointercombo(pointercombo) {
230
+ return (event) => eventMatchesPointercombo(event, narrowPointercombo(pointercombo));
231
+ }
232
+ function createToFocusable(order, elementIsCandidate) {
233
+ return (element) => {
234
+ if (elementIsCandidate && predicateFocusable(element))
235
+ return element;
236
+ switch (order) {
237
+ case "first":
238
+ for (let i = 0; i < element.children.length; i++) {
239
+ const focusable = createToFocusable(order, true)(element.children[i]);
240
+ if (focusable)
241
+ return focusable;
242
+ }
243
+ break;
244
+ case "last":
245
+ for (let i = element.children.length - 1; i > -1; i--) {
246
+ const focusable = createToFocusable(order, true)(element.children[i]);
247
+ if (focusable)
248
+ return focusable;
249
+ }
250
+ break;
251
+ }
252
+ };
253
+ }
185
254
  class Pipeable {
186
255
  constructor(state) {
187
256
  this.state = state;
@@ -190,7 +259,10 @@ class Pipeable {
190
259
  return createReduce((piped, fn, index) => fn(piped, index), this.state)(fns);
191
260
  }
192
261
  async pipeAsync(...fns) {
193
- return await createReduceAsync(async (piped, fn, index) => await fn(piped, index), this.state)(fns);
262
+ return await createReduceAsync(
263
+ async (piped, fn, index) => await fn(piped, index),
264
+ this.state
265
+ )(fns);
194
266
  }
195
267
  }
196
268
 
@@ -246,20 +318,27 @@ const keysByName = {
246
318
  f20: "F20"
247
319
  };
248
320
  const toListenableKeycomboItems = createMap((name) => ({ name, type: fromComboItemNameToType(name) }));
249
- function ensureKeycombo(type) {
250
- return new Pipeable(type).pipe(toCombo, toListenableKeycomboItems);
321
+ function narrowKeycombo(type) {
322
+ return new Pipeable(type).pipe(
323
+ toCombo,
324
+ toListenableKeycomboItems
325
+ );
251
326
  }
252
- function ensureClickcombo(type) {
327
+ function narrowMousecombo(type) {
253
328
  return toCombo(type);
254
329
  }
255
- function ensurePointercombo(type) {
330
+ function narrowPointercombo(type) {
256
331
  return toCombo(type);
257
332
  }
258
333
  const toUnique$1 = lazyCollections.unique();
259
334
  const toComboItems = lazyCollections.map((name) => name === "" ? delimiter : name);
260
335
  const delimiter = "+";
261
336
  function toCombo(type) {
262
- return lazyCollections.pipe(toUnique$1, toComboItems, lazyCollections.toArray())(type.split(delimiter));
337
+ return lazyCollections.pipe(
338
+ toUnique$1,
339
+ toComboItems,
340
+ lazyCollections.toArray()
341
+ )(type.split(delimiter));
263
342
  }
264
343
  function fromComboItemNameToType(name) {
265
344
  return lazyCollections.find((type) => predicatesByType[type](name))(listenableComboItemTypes) ?? "custom";
@@ -295,45 +374,39 @@ function createExceptAndOnlyEffect(type, effect, options) {
295
374
  const { except = [], only = [] } = options;
296
375
  if (type === "keydown" || type === "keyup") {
297
376
  return (event) => {
298
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
299
- is: (keycombo) => eventMatchesKeycombo(event, ensureKeycombo(keycombo))
300
- };
377
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
301
378
  if (matchesOnly) {
302
- effect(event, api);
379
+ effect(event);
303
380
  return;
304
381
  }
305
382
  if (only.length === 0 && !matchesExcept) {
306
- effect(event, api);
383
+ effect(event);
307
384
  return;
308
385
  }
309
386
  };
310
387
  }
311
388
  if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
312
389
  return (event) => {
313
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
314
- is: (clickcombo) => eventMatchesClickcombo(event, ensureClickcombo(clickcombo))
315
- };
390
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
316
391
  if (matchesOnly) {
317
- effect(event, api);
392
+ effect(event);
318
393
  return;
319
394
  }
320
395
  if (only.length === 0 && !matchesExcept) {
321
- effect(event, api);
396
+ effect(event);
322
397
  return;
323
398
  }
324
399
  };
325
400
  }
326
401
  if (type.startsWith("pointer")) {
327
402
  return (event) => {
328
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
329
- is: (pointercombo) => eventMatchesPointercombo(event, ensurePointercombo(pointercombo))
330
- };
403
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => lazyCollections.some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
331
404
  if (matchesOnly) {
332
- effect(event, api);
405
+ effect(event);
333
406
  return;
334
407
  }
335
408
  if (only.length === 0 && !matchesExcept) {
336
- effect(event, api);
409
+ effect(event);
337
410
  return;
338
411
  }
339
412
  };
@@ -350,7 +423,7 @@ function createExceptAndOnlyEffect(type, effect, options) {
350
423
  }
351
424
  };
352
425
  }
353
- function isModified({ event, alias }) {
426
+ function predicateModified({ event, alias }) {
354
427
  return predicatesByModifier[alias]?.(event);
355
428
  }
356
429
  const predicatesByModifier = {
@@ -371,24 +444,43 @@ function domIsAvailable() {
371
444
  return false;
372
445
  }
373
446
  }
374
- function isArray(value) {
447
+ function predicateArray(value) {
375
448
  return Array.isArray(value);
376
449
  }
377
- function isUndefined(value) {
450
+ function predicateUndefined(value) {
378
451
  return value === void 0;
379
452
  }
380
- function isFunction(value) {
453
+ function predicateFunction(value) {
381
454
  return typeof value === "function";
382
455
  }
383
- function isNull(value) {
456
+ function predicateNull(value) {
384
457
  return value === null;
385
458
  }
386
- function isNumber(value) {
459
+ function predicateNumber(value) {
387
460
  return typeof value === "number";
388
461
  }
389
- function isString(value) {
462
+ function predicateString(value) {
390
463
  return typeof value === "string";
391
464
  }
465
+ const tabbableSelector = lazyCollections.join(':not([hidden]):not([tabindex="-1"]),')([
466
+ "input:not([disabled]):not([type=hidden])",
467
+ "select:not([disabled])",
468
+ "textarea:not([disabled])",
469
+ "button:not([disabled])",
470
+ "a[href]",
471
+ "area[href]",
472
+ "summary",
473
+ "iframe",
474
+ "object",
475
+ "embed",
476
+ "audio[controls]",
477
+ "video[controls]",
478
+ "[contenteditable]",
479
+ "[tabindex]:not([disabled])"
480
+ ]);
481
+ function predicateFocusable(element) {
482
+ return element.matches(tabbableSelector);
483
+ }
392
484
 
393
485
  class Recognizeable {
394
486
  maxSequenceLength;
@@ -443,13 +535,16 @@ class Recognizeable {
443
535
  this.computedSequence = sequence;
444
536
  return this;
445
537
  }
446
- recognize(sequenceItem, api, { onRecognized } = {}) {
538
+ recognize(sequenceItem, { onRecognized } = {}) {
447
539
  this.recognizing();
448
- const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice(excess)(this.sequence), [sequenceItem])([]);
540
+ const type = this.toType(sequenceItem), excess = predicateNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
541
+ createSlice(excess)(this.sequence),
542
+ [sequenceItem]
543
+ )([]);
449
544
  this.effectApi.getSequence = () => newSequence;
450
545
  this.effectApi.onRecognized = onRecognized || (() => {
451
546
  });
452
- this.effects.get(type)?.(sequenceItem, { ...api, ...this.effectApi });
547
+ this.effects.get(type)?.(sequenceItem, { ...this.effectApi });
453
548
  switch (this.status) {
454
549
  case "denied":
455
550
  this.resetComputedMetadata();
@@ -466,7 +561,7 @@ class Recognizeable {
466
561
  this.computedStatus = "recognizing";
467
562
  }
468
563
  toType(sequenceItem) {
469
- if (isArray(sequenceItem)) {
564
+ if (predicateArray(sequenceItem)) {
470
565
  if (sequenceItem[0] instanceof IntersectionObserverEntry) {
471
566
  return "intersect";
472
567
  }
@@ -545,6 +640,9 @@ class Listenable {
545
640
  case "idle":
546
641
  this.idleListen(effect, options);
547
642
  break;
643
+ case "message":
644
+ this.messageListen(effect, options);
645
+ break;
548
646
  case "recognizeable":
549
647
  this.recognizeableListen(effect, options);
550
648
  break;
@@ -575,22 +673,27 @@ class Listenable {
575
673
  }
576
674
  mediaQueryListen(effect, options) {
577
675
  const target = window.matchMedia(this.type);
578
- if (isFunction(options.instantEffect)) {
676
+ if (predicateFunction(options.instantEffect)) {
579
677
  options.instantEffect(target);
580
678
  }
581
- const withApi = (event) => effect(event, {});
679
+ const withApi = (event) => effect(event);
582
680
  target.addEventListener("change", withApi);
583
681
  this.active.add({ target, id: ["change", withApi] });
584
682
  }
585
683
  idleListen(effect, options) {
586
- const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline, {}), requestIdleCallback);
684
+ const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
587
685
  this.active.add({ target: window, id });
588
686
  }
687
+ messageListen(effect, options) {
688
+ const { target = new BroadcastChannel("baleada") } = options;
689
+ target.addEventListener(this.type, (event) => effect(event));
690
+ this.active.add({ target, id: [this.type, effect] });
691
+ }
589
692
  recognizeableListen(effect, options) {
590
- const guardedEffect = (sequenceItem, api) => {
591
- this.recognizeable.recognize(sequenceItem, api, { onRecognized: (sequenceItem2) => effect(sequenceItem2, api) });
693
+ const guardedEffect = (sequenceItem) => {
694
+ this.recognizeable.recognize(sequenceItem, { onRecognized: (sequenceItem2) => effect(sequenceItem2) });
592
695
  if (this.recognizeable.status === "recognized") {
593
- effect(sequenceItem, api);
696
+ effect(sequenceItem);
594
697
  }
595
698
  };
596
699
  for (const type of this.recognizeableEffectsKeys) {
@@ -600,11 +703,11 @@ class Listenable {
600
703
  }
601
704
  }
602
705
  documentEventListen(effect, options) {
603
- const ensuredOptions = {
706
+ const narrowedOptions = {
604
707
  ...options,
605
708
  target: document
606
709
  };
607
- this.eventListen(effect, ensuredOptions);
710
+ this.eventListen(effect, narrowedOptions);
608
711
  }
609
712
  eventListen(effect, options) {
610
713
  const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
@@ -653,16 +756,21 @@ function stop(stoppable) {
653
756
  id2.disconnect();
654
757
  return;
655
758
  }
656
- if (isArray(stoppable.id)) {
759
+ if ("target" in stoppable && stoppable.target instanceof MediaQueryList) {
657
760
  const { target: target2, id: id2 } = stoppable;
658
761
  target2.removeEventListener(id2[0], id2[1]);
659
762
  return;
660
763
  }
661
- if (isNumber(stoppable.id)) {
764
+ if (predicateNumber(stoppable.id)) {
662
765
  const { target: target2, id: id2 } = stoppable;
663
766
  target2.cancelIdleCallback(id2);
664
767
  return;
665
768
  }
769
+ if ("target" in stoppable && stoppable.target instanceof BroadcastChannel) {
770
+ const { target: target2, id: id2 } = stoppable;
771
+ target2.removeEventListener(id2[0], id2[1]);
772
+ return;
773
+ }
666
774
  const { target, id } = stoppable;
667
775
  target.removeEventListener(id[0], id[1], id[2]);
668
776
  }
@@ -694,6 +802,10 @@ const predicatesByImplementation = /* @__PURE__ */ new Map([
694
802
  "idle",
695
803
  (type) => type === "idle"
696
804
  ],
805
+ [
806
+ "message",
807
+ (type) => type === "message" || type === "messageerror"
808
+ ],
697
809
  [
698
810
  "documentevent",
699
811
  (type) => documentEvents.has(type)
@@ -738,7 +850,7 @@ function eventMatchesKeycombo(event, keycombo) {
738
850
  if (index === keycombo.length - 1) {
739
851
  return name.startsWith("!") ? event.key.toLowerCase() !== toModifier(name.slice(1)).toLowerCase() : event.key.toLowerCase() === toModifier(name).toLowerCase();
740
852
  }
741
- return name.startsWith("!") ? !isModified({ event, alias: name.slice(1) }) : isModified({ event, alias: name });
853
+ return name.startsWith("!") ? !predicateModified({ event, alias: name.slice(1) }) : predicateModified({ event, alias: name });
742
854
  }
743
855
  })(keycombo);
744
856
  }
@@ -802,11 +914,11 @@ const predicatesByArrow = /* @__PURE__ */ new Map([
802
914
  const arrows = /* @__PURE__ */ new Set(["arrowup", "arrowright", "arrowdown", "arrowleft"]);
803
915
  const verticalArrows = /* @__PURE__ */ new Set(["arrowup", "arrowdown"]);
804
916
  const horizontalArrows = /* @__PURE__ */ new Set(["arrowright", "arrowleft"]);
805
- function eventMatchesClickcombo(event, clickcombo) {
806
- return lazyCollections.every((name) => fromComboItemNameToType(name) === "click" || name.startsWith("!") && !isModified({ alias: name.slice(1), event }) || !name.startsWith("!") && isModified({ alias: name, event }))(clickcombo);
917
+ function eventMatchesMousecombo(event, Mousecombo) {
918
+ return lazyCollections.every((name) => fromComboItemNameToType(name) === "click" || name.startsWith("!") && !predicateModified({ alias: name.slice(1), event }) || !name.startsWith("!") && predicateModified({ alias: name, event }))(Mousecombo);
807
919
  }
808
920
  function eventMatchesPointercombo(event, pointercombo) {
809
- return lazyCollections.every((name) => fromComboItemNameToType(name) === "pointer" || name.startsWith("!") && !isModified({ alias: name.slice(1), event }) || !name.startsWith("!") && isModified({ alias: name, event }))(pointercombo);
921
+ return lazyCollections.every((name) => fromComboItemNameToType(name) === "pointer" || name.startsWith("!") && !predicateModified({ alias: name.slice(1), event }) || !name.startsWith("!") && predicateModified({ alias: name, event }))(pointercombo);
810
922
  }
811
923
  const observerAssertionsByType = {
812
924
  intersect: (observer) => observer instanceof IntersectionObserver,
@@ -814,7 +926,7 @@ const observerAssertionsByType = {
814
926
  resize: (observer) => observer instanceof ResizeObserver
815
927
  };
816
928
 
817
- const defaultOptions$6 = {
929
+ const defaultOptions$7 = {
818
930
  duration: 0,
819
931
  timing: [
820
932
  0,
@@ -842,10 +954,10 @@ class Animateable {
842
954
  getEaseables;
843
955
  getReversedEaseables;
844
956
  constructor(keyframes, options = {}) {
845
- this.initialDuration = options?.duration || defaultOptions$6.duration;
846
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$6.timing);
847
- this.iterationLimit = options?.iterations || defaultOptions$6.iterations;
848
- this.alternates = options?.alternates || defaultOptions$6.alternates;
957
+ this.initialDuration = options?.duration || defaultOptions$7.duration;
958
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$7.timing);
959
+ this.iterationLimit = options?.iterations || defaultOptions$7.iterations;
960
+ this.alternates = options?.alternates || defaultOptions$7.alternates;
849
961
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
850
962
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
851
963
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -921,7 +1033,10 @@ class Animateable {
921
1033
  setKeyframes(keyframes) {
922
1034
  this.stop();
923
1035
  this.computedKeyframes = Array.from(keyframes).sort(({ progress: progressA }, { progress: progressB }) => progressA - progressB);
924
- this.reversedKeyframes = new Pipeable(this.keyframes).pipe(createReverse(), createMap(({ progress, properties }) => ({ progress: 1 - progress, properties })));
1036
+ this.reversedKeyframes = new Pipeable(this.keyframes).pipe(
1037
+ createReverse(),
1038
+ createMap(({ progress, properties }) => ({ progress: 1 - progress, properties }))
1039
+ );
925
1040
  this.properties = toProperties(this.keyframes);
926
1041
  this.easeables = this.getEaseables({ keyframes: this.keyframes, properties: this.properties });
927
1042
  this.reversedEaseables = this.getReversedEaseables({ keyframes: this.reversedKeyframes, properties: this.properties });
@@ -931,13 +1046,13 @@ class Animateable {
931
1046
  duration;
932
1047
  totalTimeInvisible;
933
1048
  setPlaybackRate(playbackRate) {
934
- const ensuredPlaybackRate = Math.max(0, playbackRate);
935
- this.computedPlaybackRate = ensuredPlaybackRate;
936
- this.duration = 1 / ensuredPlaybackRate * this.initialDuration;
1049
+ const narrowedPlaybackRate = Math.max(0, playbackRate);
1050
+ this.computedPlaybackRate = narrowedPlaybackRate;
1051
+ this.duration = 1 / narrowedPlaybackRate * this.initialDuration;
937
1052
  switch (this.status) {
938
1053
  case "playing":
939
1054
  case "reversing":
940
- this.totalTimeInvisible = 1 / ensuredPlaybackRate * this.totalTimeInvisible;
1055
+ this.totalTimeInvisible = 1 / narrowedPlaybackRate * this.totalTimeInvisible;
941
1056
  this.seek(this.progress.time);
942
1057
  break;
943
1058
  }
@@ -1191,14 +1306,20 @@ class Animateable {
1191
1306
  return this.reversedEaseables;
1192
1307
  }
1193
1308
  })();
1194
- return lazyCollections.pipe(lazyCollections.filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress), lazyCollections.reduce((frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
1195
- const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
1196
- frame.properties[property] = {
1197
- progress: { time: timeProgress, animation: animationProgress },
1198
- interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
1199
- };
1200
- return frame;
1201
- }, { properties: {}, timestamp }))(easeables);
1309
+ return lazyCollections.pipe(
1310
+ lazyCollections.filter(({ progress: { start, end } }) => start < naiveTimeProgress && end >= naiveTimeProgress),
1311
+ lazyCollections.reduce(
1312
+ (frame, { property, progress, value: { previous, next }, toAnimationProgress }) => {
1313
+ const timeProgress = (naiveTimeProgress - progress.start) / (progress.end - progress.start), animationProgress = toAnimationProgress(timeProgress);
1314
+ frame.properties[property] = {
1315
+ progress: { time: timeProgress, animation: animationProgress },
1316
+ interpolated: toInterpolated({ previous, next, progress: animationProgress }, interpolateOptions)
1317
+ };
1318
+ return frame;
1319
+ },
1320
+ { properties: {}, timestamp }
1321
+ )
1322
+ )(easeables);
1202
1323
  }
1203
1324
  recurse(type, timeRemaining, effect, options) {
1204
1325
  switch (type) {
@@ -1320,51 +1441,51 @@ class Animateable {
1320
1441
  seek(timeProgress, options = {}) {
1321
1442
  const iterations = Math.floor(timeProgress), naiveIterationProgress = timeProgress - iterations, { effect: naiveEffect } = options;
1322
1443
  this.computedIterations = iterations;
1323
- let ensuredTimeProgress, effect;
1444
+ let narrowedTimeProgress, effect;
1324
1445
  if (this.alternates) {
1325
1446
  if (naiveIterationProgress <= 0.5) {
1326
- ensuredTimeProgress = naiveIterationProgress * 2;
1447
+ narrowedTimeProgress = naiveIterationProgress * 2;
1327
1448
  switch (this.alternateCache.status) {
1328
1449
  case "playing":
1329
1450
  this.cancelAnimate();
1330
- this.seekCache = { timeProgress: ensuredTimeProgress };
1451
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1331
1452
  this.sought();
1332
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1453
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1333
1454
  this.play(effect, this.playCache.options);
1334
1455
  break;
1335
1456
  case "reversing":
1336
1457
  this.cancelAnimate();
1337
- this.seekCache = { timeProgress: ensuredTimeProgress };
1458
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1338
1459
  this.sought();
1339
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1460
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1340
1461
  this.reverse(effect, this.reverseCache.options);
1341
1462
  break;
1342
1463
  default:
1343
- this.seekCache = { timeProgress: ensuredTimeProgress };
1464
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1344
1465
  this.sought();
1345
1466
  effect = naiveEffect;
1346
1467
  this.createAnimate("seek")(effect, options);
1347
1468
  break;
1348
1469
  }
1349
1470
  } else {
1350
- ensuredTimeProgress = (naiveIterationProgress - 0.5) * 2;
1471
+ narrowedTimeProgress = (naiveIterationProgress - 0.5) * 2;
1351
1472
  switch (this.alternateCache.status) {
1352
1473
  case "playing":
1353
1474
  this.cancelAnimate();
1354
- this.seekCache = { timeProgress: ensuredTimeProgress };
1475
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1355
1476
  this.sought();
1356
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1477
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1357
1478
  this.reverse(effect, this.reverseCache.options);
1358
1479
  break;
1359
1480
  case "reversing":
1360
1481
  this.cancelAnimate();
1361
- this.seekCache = { timeProgress: ensuredTimeProgress };
1482
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1362
1483
  this.sought();
1363
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1484
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1364
1485
  this.play(effect, this.playCache.options);
1365
1486
  break;
1366
1487
  default:
1367
- this.seekCache = { timeProgress: ensuredTimeProgress };
1488
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1368
1489
  this.sought();
1369
1490
  effect = naiveEffect;
1370
1491
  if (effect) {
@@ -1374,24 +1495,24 @@ class Animateable {
1374
1495
  }
1375
1496
  }
1376
1497
  } else {
1377
- ensuredTimeProgress = naiveIterationProgress;
1498
+ narrowedTimeProgress = naiveIterationProgress;
1378
1499
  switch (this.status) {
1379
1500
  case "playing":
1380
1501
  this.cancelAnimate();
1381
- this.seekCache = { timeProgress: ensuredTimeProgress };
1502
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1382
1503
  this.sought();
1383
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1504
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1384
1505
  this.play(effect, this.playCache.options);
1385
1506
  break;
1386
1507
  case "reversing":
1387
1508
  this.cancelAnimate();
1388
- this.seekCache = { timeProgress: ensuredTimeProgress };
1509
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1389
1510
  this.sought();
1390
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1511
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1391
1512
  this.reverse(effect, this.reverseCache.options);
1392
1513
  break;
1393
1514
  default:
1394
- this.seekCache = { timeProgress: ensuredTimeProgress };
1515
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1395
1516
  this.sought();
1396
1517
  effect = naiveEffect;
1397
1518
  if (effect) {
@@ -1455,26 +1576,36 @@ class Animateable {
1455
1576
  }
1456
1577
  function createGetEaseables(fromKeyframeToControlPoints) {
1457
1578
  return ({ properties, keyframes }) => {
1458
- const fromPropertiesToEasables = createReduce((easeables, property) => {
1459
- const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce((propertyEaseables2, keyframe, index) => {
1460
- 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 ? (timeProgress) => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
1461
- propertyEaseables2.push({
1579
+ const fromPropertiesToEasables = createReduce(
1580
+ (easeables, property) => {
1581
+ const propertyKeyframes = createFilter(({ properties: properties2 }) => properties2.hasOwnProperty(property))(keyframes), fromKeyframesToEaseables = createReduce(
1582
+ (propertyEaseables2, keyframe, index) => {
1583
+ 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 ? (timeProgress) => 1 : createToAnimationProgress(fromKeyframeToControlPoints({ keyframe, index, propertyKeyframes }));
1584
+ propertyEaseables2.push({
1585
+ property,
1586
+ value: { previous, next },
1587
+ progress: { start, end },
1588
+ hasCustomTiming,
1589
+ toAnimationProgress
1590
+ });
1591
+ return propertyEaseables2;
1592
+ },
1593
+ []
1594
+ ), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
1462
1595
  property,
1463
- value: { previous, next },
1464
- progress: { start, end },
1465
- hasCustomTiming,
1466
- toAnimationProgress
1467
- });
1468
- return propertyEaseables2;
1469
- }, []), propertyEaseables = fromKeyframesToEaseables(propertyKeyframes), firstEaseable = {
1470
- property,
1471
- value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
1472
- progress: { start: -1, end: propertyEaseables[0].progress.start },
1473
- toAnimationProgress: (timeProgress) => 1,
1474
- hasCustomTiming: false
1475
- };
1476
- return createConcat(easeables, [firstEaseable], propertyEaseables)([]);
1477
- }, []);
1596
+ value: { previous: propertyEaseables[0].value.previous, next: propertyEaseables[0].value.previous },
1597
+ progress: { start: -1, end: propertyEaseables[0].progress.start },
1598
+ toAnimationProgress: (timeProgress) => 1,
1599
+ hasCustomTiming: false
1600
+ };
1601
+ return createConcat(
1602
+ easeables,
1603
+ [firstEaseable],
1604
+ propertyEaseables
1605
+ )([]);
1606
+ },
1607
+ []
1608
+ );
1478
1609
  return fromPropertiesToEasables(properties);
1479
1610
  };
1480
1611
  }
@@ -1504,23 +1635,26 @@ function fromControlPointsToReversedControlPoints(points) {
1504
1635
  }
1505
1636
  function createToAnimationProgress(points) {
1506
1637
  const { 0: { x: point1x, y: point1y }, 1: { x: point2x, y: point2y } } = points;
1507
- return BezierEasing__default["default"](point1x, point1y, point2x, point2y);
1638
+ return BezierEasing(point1x, point1y, point2x, point2y);
1508
1639
  }
1509
1640
  function toInterpolated({ previous, next, progress }, options = {}) {
1510
- if (isUndefined(previous)) {
1641
+ if (predicateUndefined(previous)) {
1511
1642
  return next;
1512
1643
  }
1513
- if (isNumber(previous) && isNumber(next)) {
1644
+ if (predicateNumber(previous) && predicateNumber(next)) {
1514
1645
  return (next - previous) * progress + previous;
1515
1646
  }
1516
- if (isString(previous) && isString(next)) {
1517
- return color.mix(options.colorModel, {
1518
- start: previous,
1519
- end: next,
1520
- alpha: progress
1521
- }).toRgb().toRgbString();
1647
+ if (predicateString(previous) && predicateString(next)) {
1648
+ return color.mix(
1649
+ options.colorModel,
1650
+ {
1651
+ start: previous,
1652
+ end: next,
1653
+ alpha: progress
1654
+ }
1655
+ ).toRgb().toRgbString();
1522
1656
  }
1523
- if (isArray(previous) && isArray(next)) {
1657
+ if (predicateArray(previous) && predicateArray(next)) {
1524
1658
  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;
1525
1659
  return createSlice(0, sliceEnd)(sliceTarget);
1526
1660
  }
@@ -1706,6 +1840,78 @@ const easingsNetInOutBack = [
1706
1840
  1.6
1707
1841
  ];
1708
1842
 
1843
+ const defaultOptions$6 = {
1844
+ name: "baleada"
1845
+ };
1846
+ class Broadcastable {
1847
+ name;
1848
+ constructor(state, options = {}) {
1849
+ this.setState(state);
1850
+ this.name = options.name ?? defaultOptions$6.name;
1851
+ this.ready();
1852
+ }
1853
+ computedStatus;
1854
+ ready() {
1855
+ this.computedStatus = "ready";
1856
+ }
1857
+ get state() {
1858
+ return this.computedState;
1859
+ }
1860
+ set state(state) {
1861
+ this.setState(state);
1862
+ }
1863
+ get status() {
1864
+ return this.computedStatus;
1865
+ }
1866
+ computedChannel;
1867
+ get channel() {
1868
+ return this.computedChannel || (this.computedChannel = new BroadcastChannel(this.name));
1869
+ }
1870
+ computedError;
1871
+ get error() {
1872
+ return this.computedError;
1873
+ }
1874
+ computedState;
1875
+ setState(state) {
1876
+ this.computedState = state;
1877
+ return this;
1878
+ }
1879
+ broadcast() {
1880
+ this.broadcasting();
1881
+ try {
1882
+ this.channel.postMessage(this.state);
1883
+ this.broadcasted();
1884
+ } catch (error) {
1885
+ this.computedError = error;
1886
+ this.errored();
1887
+ }
1888
+ return this;
1889
+ }
1890
+ broadcasting() {
1891
+ this.computedStatus = "broadcasting";
1892
+ }
1893
+ broadcasted() {
1894
+ this.computedStatus = "broadcasted";
1895
+ }
1896
+ errored() {
1897
+ this.computedStatus = "errored";
1898
+ }
1899
+ stop() {
1900
+ this.channel.close();
1901
+ this.stopped();
1902
+ return this;
1903
+ }
1904
+ stopped() {
1905
+ this.computedStatus = "stopped";
1906
+ }
1907
+ }
1908
+ function toMessageListenParams(instance, effect) {
1909
+ return [
1910
+ effect,
1911
+ { target: instance.channel }
1912
+ ];
1913
+ }
1914
+
1709
1915
  const defaultOptions$5 = {
1710
1916
  segment: {
1711
1917
  from: "start",
@@ -1754,7 +1960,10 @@ class Completeable {
1754
1960
  return this.computedStatus;
1755
1961
  }
1756
1962
  get segment() {
1757
- return this.string.slice(this.getSegmentStartIndex(), this.getSegmentEndIndex());
1963
+ return this.string.slice(
1964
+ this.getSegmentStartIndex(),
1965
+ this.getSegmentEndIndex()
1966
+ );
1758
1967
  }
1759
1968
  get dividerIndices() {
1760
1969
  return this.computedDividerIndices;
@@ -1811,7 +2020,7 @@ class Completeable {
1811
2020
  complete(completion, options = {}) {
1812
2021
  this.completing();
1813
2022
  const { select } = { ...defaultCompleteOptions, ...options }, before = this.getBefore(), after = this.getAfter(), completedString = before + completion + after, completedSelection = (() => {
1814
- if (isFunction(select)) {
2023
+ if (predicateFunction(select)) {
1815
2024
  return select({ before, completion, after });
1816
2025
  }
1817
2026
  switch (select) {
@@ -1867,7 +2076,12 @@ function toPreviousMatch({ string, re, from }) {
1867
2076
  if (!re.test(string.slice(0, from)) || from === 0) {
1868
2077
  indexOf = -1;
1869
2078
  } else {
1870
- const reversedStringBeforeFrom = new Pipeable(string).pipe((string2) => string2.slice(0, from), (sliced) => sliced.split(""), reverse, toString), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
2079
+ const reversedStringBeforeFrom = new Pipeable(string).pipe(
2080
+ (string2) => string2.slice(0, from),
2081
+ (sliced) => sliced.split(""),
2082
+ reverse,
2083
+ toString
2084
+ ), toNextMatchIndex = toNextMatch({ string: reversedStringBeforeFrom, re, from: 0 });
1871
2085
  indexOf = toNextMatchIndex === -1 ? -1 : reversedStringBeforeFrom.length - 1 - toNextMatchIndex;
1872
2086
  }
1873
2087
  return indexOf;
@@ -1959,7 +2173,7 @@ class Copyable {
1959
2173
  errored() {
1960
2174
  this.computedStatus = "errored";
1961
2175
  }
1962
- effectClipboardTextChanges() {
2176
+ listenForClipboardEvents() {
1963
2177
  this.copyListenable.listen(this.copyAndCutEffect);
1964
2178
  this.cutListenable.listen(this.copyAndCutEffect);
1965
2179
  }
@@ -1976,13 +2190,16 @@ const defaultOptions$4 = {
1976
2190
  class Delayable {
1977
2191
  animateable;
1978
2192
  constructor(effect, options = {}) {
1979
- this.animateable = new Animateable([
1980
- { progress: 0, properties: { progress: 0 } },
1981
- { progress: 1, properties: { progress: 1 } }
1982
- ], {
1983
- duration: options?.delay ?? defaultOptions$4.delay,
1984
- iterations: options?.executions ?? defaultOptions$4.executions
1985
- });
2193
+ this.animateable = new Animateable(
2194
+ [
2195
+ { progress: 0, properties: { progress: 0 } },
2196
+ { progress: 1, properties: { progress: 1 } }
2197
+ ],
2198
+ {
2199
+ duration: options?.delay ?? defaultOptions$4.delay,
2200
+ iterations: options?.executions ?? defaultOptions$4.executions
2201
+ }
2202
+ );
1986
2203
  this.setEffect(effect);
1987
2204
  this.ready();
1988
2205
  }
@@ -2169,7 +2386,7 @@ function toFlattenedD(stroke) {
2169
2386
  if (stroke.length === 0) {
2170
2387
  return "";
2171
2388
  }
2172
- const multiPolygon = polygonClipping__default["default"].union([stroke]);
2389
+ const multiPolygon = polygonClipping.union([stroke]);
2173
2390
  return createReduce((dFromMultiPolygon, polygon) => {
2174
2391
  return dFromMultiPolygon + createReduce((dFromRing, points) => {
2175
2392
  return dFromRing + toD(points);
@@ -2208,7 +2425,7 @@ class Resolveable {
2208
2425
  this.resolving();
2209
2426
  try {
2210
2427
  const promises = this.getPromise(...args);
2211
- this.computedValue = isArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
2428
+ this.computedValue = predicateArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
2212
2429
  this.resolved();
2213
2430
  } catch (error) {
2214
2431
  this.computedValue = error;
@@ -2269,34 +2486,19 @@ class Fetchable {
2269
2486
  return this.computedError;
2270
2487
  }
2271
2488
  get arrayBuffer() {
2272
- return this.getUsedBody(this.computedArrayBuffer);
2489
+ return this.computedArrayBuffer;
2273
2490
  }
2274
2491
  get blob() {
2275
- return this.getUsedBody(this.computedBlob);
2492
+ return this.computedBlob;
2276
2493
  }
2277
2494
  get formData() {
2278
- return this.getUsedBody(this.computedFormData);
2495
+ return this.computedFormData;
2279
2496
  }
2280
2497
  get json() {
2281
- return this.getUsedBody(this.computedJson);
2498
+ return this.computedJson;
2282
2499
  }
2283
2500
  get text() {
2284
- return this.getUsedBody(this.computedText);
2285
- }
2286
- getUsedBody(resolveable) {
2287
- const bodyUsed = "bodyUsed" in this.response ? this.response.bodyUsed : false;
2288
- if (!bodyUsed) {
2289
- return resolveable.resolve();
2290
- }
2291
- switch (resolveable.status) {
2292
- case "ready":
2293
- break;
2294
- case "resolving":
2295
- break;
2296
- case "resolved":
2297
- case "errored":
2298
- return resolveable;
2299
- }
2501
+ return this.computedText;
2300
2502
  }
2301
2503
  computedResource;
2302
2504
  setResource(resource) {
@@ -2306,34 +2508,49 @@ class Fetchable {
2306
2508
  computedResponse;
2307
2509
  computedError;
2308
2510
  async fetch(options = {}) {
2309
- this.computedStatus = "fetching";
2511
+ this.fetching();
2310
2512
  try {
2311
- this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...ensureOptions(options) });
2312
- this.computedStatus = "fetched";
2513
+ this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...narrowOptions(options) });
2514
+ this.fetched();
2313
2515
  } catch (error) {
2314
2516
  this.computedError = error;
2315
- this.computedStatus = error.name === "AbortError" ? "aborted" : "errored";
2517
+ if (error.name === "AbortError")
2518
+ this.aborted();
2519
+ else
2520
+ this.errored();
2316
2521
  }
2317
2522
  return this;
2318
2523
  }
2524
+ fetching() {
2525
+ this.computedStatus = "fetching";
2526
+ }
2527
+ fetched() {
2528
+ this.computedStatus = "fetched";
2529
+ }
2530
+ aborted() {
2531
+ this.computedStatus = "aborted";
2532
+ }
2533
+ errored() {
2534
+ this.computedStatus = "errored";
2535
+ }
2319
2536
  async get(options = {}) {
2320
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "get" });
2537
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "get" });
2321
2538
  return this;
2322
2539
  }
2323
2540
  async patch(options = {}) {
2324
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "patch" });
2541
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "patch" });
2325
2542
  return this;
2326
2543
  }
2327
2544
  async post(options = {}) {
2328
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "post" });
2545
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "post" });
2329
2546
  return this;
2330
2547
  }
2331
2548
  async put(options = {}) {
2332
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "put" });
2549
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "put" });
2333
2550
  return this;
2334
2551
  }
2335
2552
  async delete(options = {}) {
2336
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "delete" });
2553
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "delete" });
2337
2554
  return this;
2338
2555
  }
2339
2556
  abort() {
@@ -2341,8 +2558,8 @@ class Fetchable {
2341
2558
  return this;
2342
2559
  }
2343
2560
  }
2344
- function ensureOptions(options) {
2345
- return isFunction(options) ? options({ withJson }) : options;
2561
+ function narrowOptions(options) {
2562
+ return predicateFunction(options) ? options({ withJson }) : options;
2346
2563
  }
2347
2564
  function withJson(data) {
2348
2565
  return {
@@ -2525,7 +2742,7 @@ class Navigateable {
2525
2742
  }
2526
2743
  _navigate(location, options = {}) {
2527
2744
  const { allow } = { ...defaultNavigateOptions, ...options };
2528
- const ensuredLocation = (() => {
2745
+ const narrowedLocation = (() => {
2529
2746
  if (allow === "possible") {
2530
2747
  if (location < 0 && allow === "possible") {
2531
2748
  return 0;
@@ -2536,7 +2753,7 @@ class Navigateable {
2536
2753
  }
2537
2754
  return location;
2538
2755
  })();
2539
- this.computedLocation = ensuredLocation;
2756
+ this.computedLocation = narrowedLocation;
2540
2757
  }
2541
2758
  next(options = {}) {
2542
2759
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
@@ -2679,38 +2896,50 @@ class Pickable {
2679
2896
  }
2680
2897
  pick(indexOrIndices, options = {}) {
2681
2898
  const { replace, allowsDuplicates } = { ...defaultPickOptions, ...options };
2682
- this.computedPicks = new Pipeable(indexOrIndices).pipe(ensureIndices, this.toPossiblePicks, (possiblePicks) => {
2683
- if (replace === "all") {
2684
- return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
2685
- }
2686
- const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter((possiblePick) => typeof lazyCollections.find((pick) => pick === possiblePick)(this.picks || []) !== "number")(possiblePicks);
2687
- switch (replace) {
2688
- case "none":
2689
- return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
2690
- case "fifo":
2691
- if (maybeWithoutDuplicates.length === 0) {
2692
- return this.picks;
2693
- }
2694
- if (maybeWithoutDuplicates.length === this.picks.length) {
2695
- return maybeWithoutDuplicates;
2696
- }
2697
- if (maybeWithoutDuplicates.length > this.picks.length) {
2698
- return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
2699
- }
2700
- return new Pipeable(this.picks).pipe(createSlice(maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
2701
- case "lifo":
2702
- if (maybeWithoutDuplicates.length === 0) {
2703
- return this.picks;
2704
- }
2705
- if (maybeWithoutDuplicates.length === this.picks.length) {
2706
- return maybeWithoutDuplicates;
2707
- }
2708
- if (maybeWithoutDuplicates.length > this.picks.length) {
2709
- return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
2710
- }
2711
- return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
2899
+ this.computedPicks = new Pipeable(indexOrIndices).pipe(
2900
+ narrowIndices,
2901
+ this.toPossiblePicks,
2902
+ (possiblePicks) => {
2903
+ if (replace === "all") {
2904
+ return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
2905
+ }
2906
+ const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter(
2907
+ (possiblePick) => typeof lazyCollections.find((pick) => pick === possiblePick)(this.picks || []) !== "number"
2908
+ )(possiblePicks);
2909
+ switch (replace) {
2910
+ case "none":
2911
+ return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
2912
+ case "fifo":
2913
+ if (maybeWithoutDuplicates.length === 0) {
2914
+ return this.picks;
2915
+ }
2916
+ if (maybeWithoutDuplicates.length === this.picks.length) {
2917
+ return maybeWithoutDuplicates;
2918
+ }
2919
+ if (maybeWithoutDuplicates.length > this.picks.length) {
2920
+ return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
2921
+ }
2922
+ return new Pipeable(this.picks).pipe(
2923
+ createSlice(maybeWithoutDuplicates.length),
2924
+ createConcat(maybeWithoutDuplicates)
2925
+ );
2926
+ case "lifo":
2927
+ if (maybeWithoutDuplicates.length === 0) {
2928
+ return this.picks;
2929
+ }
2930
+ if (maybeWithoutDuplicates.length === this.picks.length) {
2931
+ return maybeWithoutDuplicates;
2932
+ }
2933
+ if (maybeWithoutDuplicates.length > this.picks.length) {
2934
+ return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
2935
+ }
2936
+ return new Pipeable(this.picks).pipe(
2937
+ createSlice(0, this.picks.length - maybeWithoutDuplicates.length),
2938
+ createConcat(maybeWithoutDuplicates)
2939
+ );
2940
+ }
2712
2941
  }
2713
- });
2942
+ );
2714
2943
  this.computedFirst = Math.min(...this.picks);
2715
2944
  this.computedLast = Math.max(...this.picks);
2716
2945
  this.computedMultiple = toUnique(this.picks).length > 1;
@@ -2721,7 +2950,7 @@ class Pickable {
2721
2950
  this.computedStatus = "picked";
2722
2951
  }
2723
2952
  omit(indexOrIndices, options = { reference: "array" }) {
2724
- if (isUndefined(indexOrIndices)) {
2953
+ if (predicateUndefined(indexOrIndices)) {
2725
2954
  this.computedPicks = [];
2726
2955
  this.computedFirst = void 0;
2727
2956
  this.computedLast = void 0;
@@ -2729,8 +2958,10 @@ class Pickable {
2729
2958
  this.omitted();
2730
2959
  return this;
2731
2960
  }
2732
- const omits = ensureIndices(indexOrIndices);
2733
- this.computedPicks = createFilter((pick, index) => options.reference === "array" ? isUndefined(lazyCollections.find((omit) => pick === omit)(omits)) : isUndefined(lazyCollections.find((omit) => index === omit)(omits)))(this.computedPicks);
2961
+ const omits = narrowIndices(indexOrIndices);
2962
+ this.computedPicks = createFilter(
2963
+ (pick, index) => options.reference === "array" ? predicateUndefined(lazyCollections.find((omit) => pick === omit)(omits)) : predicateUndefined(lazyCollections.find((omit) => index === omit)(omits))
2964
+ )(this.computedPicks);
2734
2965
  this.computedFirst = Math.min(...this.picks);
2735
2966
  this.computedLast = Math.max(...this.picks);
2736
2967
  this.computedMultiple = toUnique(this.picks).length > 1;
@@ -2741,7 +2972,7 @@ class Pickable {
2741
2972
  this.computedStatus = "omitted";
2742
2973
  }
2743
2974
  }
2744
- function ensureIndices(indexOrIndices) {
2975
+ function narrowIndices(indexOrIndices) {
2745
2976
  return Array.isArray(indexOrIndices) ? indexOrIndices : [indexOrIndices];
2746
2977
  }
2747
2978
  const toUnique = createUnique();
@@ -2757,7 +2988,7 @@ class Sanitizeable {
2757
2988
  computedStatus;
2758
2989
  ready() {
2759
2990
  if (domIsAvailable()) {
2760
- this.computedDompurify = createDOMPurify__default["default"]();
2991
+ this.computedDompurify = createDOMPurify();
2761
2992
  this.computedDompurify.setConfig(this.domPurifyConfig);
2762
2993
  }
2763
2994
  this.computedStatus = "ready";
@@ -2770,7 +3001,7 @@ class Sanitizeable {
2770
3001
  }
2771
3002
  get dompurify() {
2772
3003
  if (!this.computedDompurify && domIsAvailable()) {
2773
- this.computedDompurify = createDOMPurify__default["default"]();
3004
+ this.computedDompurify = createDOMPurify();
2774
3005
  this.computedDompurify.setConfig(this.domPurifyConfig);
2775
3006
  }
2776
3007
  return this.computedDompurify;
@@ -2838,6 +3069,60 @@ class Searchable {
2838
3069
  }
2839
3070
  }
2840
3071
 
3072
+ class Shareable {
3073
+ constructor(state, options = {}) {
3074
+ this.setState(state);
3075
+ this.ready();
3076
+ }
3077
+ computedStatus;
3078
+ ready() {
3079
+ this.computedStatus = "ready";
3080
+ }
3081
+ get state() {
3082
+ return this.computedState;
3083
+ }
3084
+ set state(state) {
3085
+ this.setState(state);
3086
+ }
3087
+ get status() {
3088
+ return this.computedStatus;
3089
+ }
3090
+ computedCan;
3091
+ get can() {
3092
+ return this.computedCan;
3093
+ }
3094
+ computedError;
3095
+ get error() {
3096
+ return this.computedError;
3097
+ }
3098
+ computedState;
3099
+ setState(state) {
3100
+ this.computedState = state;
3101
+ this.computedCan = new Resolveable(async () => await navigator.canShare(state));
3102
+ return this;
3103
+ }
3104
+ async share() {
3105
+ this.sharing();
3106
+ try {
3107
+ await navigator.share(this.state);
3108
+ this.shared();
3109
+ } catch (error) {
3110
+ this.computedError = error;
3111
+ this.errored();
3112
+ }
3113
+ return this;
3114
+ }
3115
+ sharing() {
3116
+ this.computedStatus = "sharing";
3117
+ }
3118
+ shared() {
3119
+ this.computedStatus = "shared";
3120
+ }
3121
+ errored() {
3122
+ this.computedStatus = "errored";
3123
+ }
3124
+ }
3125
+
2841
3126
  const defaultOptions = {
2842
3127
  kind: "local",
2843
3128
  statusKeySuffix: " status"
@@ -2859,7 +3144,7 @@ class Storeable {
2859
3144
  ready() {
2860
3145
  this.computedStatus = "ready";
2861
3146
  if (domIsAvailable()) {
2862
- if (isNull(this.storage.getItem(this.computedStatusKey))) {
3147
+ if (predicateNull(this.storage.getItem(this.computedStatusKey))) {
2863
3148
  this.storeStatus();
2864
3149
  }
2865
3150
  }
@@ -2873,7 +3158,7 @@ class Storeable {
2873
3158
  get status() {
2874
3159
  if (domIsAvailable()) {
2875
3160
  const storedStatus = this.storage.getItem(this.computedStatusKey);
2876
- if (this.computedStatus !== storedStatus && isString(storedStatus)) {
3161
+ if (this.computedStatus !== storedStatus && predicateString(storedStatus)) {
2877
3162
  this.computedStatus = storedStatus;
2878
3163
  }
2879
3164
  }
@@ -2960,6 +3245,7 @@ class Storeable {
2960
3245
  }
2961
3246
 
2962
3247
  exports.Animateable = Animateable;
3248
+ exports.Broadcastable = Broadcastable;
2963
3249
  exports.Completeable = Completeable;
2964
3250
  exports.Copyable = Copyable;
2965
3251
  exports.Delayable = Delayable;
@@ -2975,11 +3261,11 @@ exports.Recognizeable = Recognizeable;
2975
3261
  exports.Resolveable = Resolveable;
2976
3262
  exports.Sanitizeable = Sanitizeable;
2977
3263
  exports.Searchable = Searchable;
3264
+ exports.Shareable = Shareable;
2978
3265
  exports.Storeable = Storeable;
2979
3266
  exports.createClamp = createClamp;
2980
3267
  exports.createClip = createClip;
2981
3268
  exports.createConcat = createConcat;
2982
- exports.createDelete = createDelete;
2983
3269
  exports.createDetermine = createDetermine;
2984
3270
  exports.createFilter = createFilter;
2985
3271
  exports.createFilterAsync = createFilterAsync;
@@ -2987,8 +3273,12 @@ exports.createForEachAsync = createForEachAsync;
2987
3273
  exports.createInsert = createInsert;
2988
3274
  exports.createMap = createMap;
2989
3275
  exports.createMapAsync = createMapAsync;
3276
+ exports.createMatchesKeycombo = createMatchesKeycombo;
3277
+ exports.createMatchesMousecombo = createMatchesMousecombo;
3278
+ exports.createMatchesPointercombo = createMatchesPointercombo;
2990
3279
  exports.createReduce = createReduce;
2991
3280
  exports.createReduceAsync = createReduceAsync;
3281
+ exports.createRemove = createRemove;
2992
3282
  exports.createRename = createRename;
2993
3283
  exports.createReorder = createReorder;
2994
3284
  exports.createReplace = createReplace;
@@ -2998,6 +3288,7 @@ exports.createSlug = createSlug;
2998
3288
  exports.createSort = createSort;
2999
3289
  exports.createSwap = createSwap;
3000
3290
  exports.createToEntries = createToEntries;
3291
+ exports.createToFocusable = createToFocusable;
3001
3292
  exports.createUnique = createUnique;
3002
3293
  exports.easingsNetInBack = easingsNetInBack;
3003
3294
  exports.easingsNetInCirc = easingsNetInCirc;
@@ -3027,6 +3318,7 @@ exports.materialDecelerated = materialDecelerated;
3027
3318
  exports.materialStandard = materialStandard;
3028
3319
  exports.toD = toD;
3029
3320
  exports.toFlattenedD = toFlattenedD;
3321
+ exports.toMessageListenParams = toMessageListenParams;
3030
3322
  exports.verouEase = verouEase;
3031
3323
  exports.verouEaseIn = verouEaseIn;
3032
3324
  exports.verouEaseInOut = verouEaseInOut;