securemark 0.262.1 → 0.263.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.262.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.263.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -178,7 +178,28 @@ function splice(as, index, count, ...values) {
178
178
  return push(as, values), [];
179
179
  }
180
180
 
181
- return arguments.length > 2 ? as.splice(index, count, ...values) : as.splice(index);
181
+ switch (values.length) {
182
+ case 0:
183
+ return arguments.length > 2 ? as.splice(index, count) : as.splice(index);
184
+
185
+ case 1:
186
+ return as.splice(index, count, values[0]);
187
+
188
+ case 2:
189
+ return as.splice(index, count, values[0], values[1]);
190
+
191
+ case 3:
192
+ return as.splice(index, count, values[0], values[1], values[2]);
193
+
194
+ case 4:
195
+ return as.splice(index, count, values[0], values[1], values[2], values[3]);
196
+
197
+ case 5:
198
+ return as.splice(index, count, values[0], values[1], values[2], values[3], values[4]);
199
+
200
+ default:
201
+ return as.splice(index, count, ...values);
202
+ }
182
203
  }
183
204
 
184
205
  exports.splice = splice;
@@ -367,18 +388,19 @@ class Cache {
367
388
  constructor(capacity, opts = {}) {
368
389
  this.settings = {
369
390
  capacity: 0,
391
+ window: 100,
370
392
  age: global_1.Infinity,
371
393
  earlyExpiring: false,
372
394
  capture: {
373
395
  delete: true,
374
396
  clear: true
375
397
  },
376
- window: 0,
377
398
  resolution: 1,
378
399
  offset: 0,
379
- block: 20,
400
+ entrance: 50,
401
+ threshold: 20,
380
402
  sweep: 10,
381
- limit: 950
403
+ test: false
382
404
  };
383
405
  this.overlap = 0;
384
406
  this.SIZE = 0;
@@ -402,13 +424,15 @@ class Cache {
402
424
  });
403
425
  this.capacity = settings.capacity;
404
426
  if (this.capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
405
- this.window = settings.window || this.capacity;
427
+ this.window = settings.window * this.capacity / 100 >>> 0 || this.capacity;
406
428
  if (this.window * 1000 >= this.capacity === false) throw new Error(`Spica: Cache: Window must be 0.1% of capacity or more.`);
407
- this.block = settings.block;
408
- this.limit = settings.limit;
429
+ this.threshold = settings.threshold;
430
+ this.limit = 1000 - settings.entrance;
431
+ this.age = settings.age;
409
432
  this.earlyExpiring = settings.earlyExpiring;
410
433
  this.disposer = settings.disposer;
411
- this.stats = new Stats(this.window, settings.resolution, settings.offset);
434
+ this.stats = opts.resolution || opts.offset ? new StatsExperimental(this.window, settings.resolution, settings.offset) : new Stats(this.window);
435
+ this.test = settings.test;
412
436
  }
413
437
 
414
438
  get length() {
@@ -424,7 +448,12 @@ class Cache {
424
448
  const index = node.value;
425
449
  callback &&= !!this.disposer;
426
450
  this.overlap -= +(index.region === 'LFU' && node.list === this.indexes.LRU);
427
- index.enode && this.expiries.delete(index.enode);
451
+
452
+ if (index.enode) {
453
+ this.expiries.delete(index.enode);
454
+ index.enode = void 0;
455
+ }
456
+
428
457
  node.delete();
429
458
  this.memory.delete(index.key);
430
459
  this.SIZE -= index.size;
@@ -461,8 +490,8 @@ class Cache {
461
490
  // fallthrough
462
491
 
463
492
  default:
464
- if (this.misses * 100 > LRU.length * this.block) {
465
- this.sweep ||= LRU.length * this.settings.sweep / 100 + 1 | 0;
493
+ if (this.misses * 100 > LRU.length * this.threshold) {
494
+ this.sweep ||= LRU.length * this.settings.sweep / 100 + 1 >>> 0;
466
495
 
467
496
  if (this.sweep > 0) {
468
497
  LRU.head = LRU.head.next.next;
@@ -486,14 +515,18 @@ class Cache {
486
515
 
487
516
  put(key, value, {
488
517
  size = 1,
489
- age = this.settings.age
518
+ age = this.age
490
519
  } = {}) {
491
520
  if (size < 1 || this.capacity < size || age <= 0) {
492
521
  this.disposer?.(value, key);
493
522
  return false;
494
523
  }
495
524
 
496
- const expiry = age === global_1.Infinity ? global_1.Infinity : (0, clock_1.now)() + age;
525
+ if (age === global_1.Infinity) {
526
+ age = 0;
527
+ }
528
+
529
+ const expiry = age ? (0, clock_1.now)() + age : global_1.Infinity;
497
530
  const node = this.memory.get(key);
498
531
 
499
532
  if (node && this.ensure(size, node)) {
@@ -503,7 +536,7 @@ class Cache {
503
536
  index.size = size;
504
537
  index.expiry = expiry;
505
538
 
506
- if (this.earlyExpiring && expiry !== global_1.Infinity) {
539
+ if (this.earlyExpiring && age) {
507
540
  index.enode ? this.expiries.update(index.enode, expiry) : index.enode = this.expiries.insert(node, expiry);
508
541
  } else if (index.enode) {
509
542
  this.expiries.delete(index.enode);
@@ -528,7 +561,7 @@ class Cache {
528
561
  region: 'LRU'
529
562
  }));
530
563
 
531
- if (this.earlyExpiring && expiry !== global_1.Infinity) {
564
+ if (this.earlyExpiring && age) {
532
565
  LRU.head.value.enode = this.expiries.insert(LRU.head, expiry);
533
566
  }
534
567
 
@@ -559,7 +592,7 @@ class Cache {
559
592
  this.misses &&= 0;
560
593
  this.sweep &&= 0; // Optimization for memoize.
561
594
 
562
- if (this.capacity > 3 && node === node.list.head) return node.value.value;
595
+ if (!this.test && node === node.list.head) return node.value.value;
563
596
  this.access(node);
564
597
  this.adjust();
565
598
  return node.value.value;
@@ -644,13 +677,15 @@ class Cache {
644
677
  stats,
645
678
  indexes
646
679
  } = this;
647
- if (stats.subtotal() * 1000 % capacity || !stats.full()) return;
680
+ if (stats.subtotal() * 1000 % capacity || !stats.isFull()) return;
648
681
  const lenR = indexes.LRU.length;
649
682
  const lenF = indexes.LFU.length;
650
683
  const lenO = this.overlap;
651
684
  const leverage = (lenF + lenO) * 1000 / (lenR + lenF) | 0;
652
- const rateR0 = stats.rateLRU() * leverage;
653
- const rateF0 = stats.rateLFU() * (1000 - leverage);
685
+ const rateR = stats.rateLRU();
686
+ const rateF = 10000 - rateR;
687
+ const rateR0 = rateR * leverage;
688
+ const rateF0 = rateF * (1000 - leverage);
654
689
  const rateF1 = stats.offset && stats.rateLFU(true) * (1000 - leverage); // 操作頻度を超えてキャッシュ比率を増減させても余剰比率の消化が追いつかず無駄
655
690
  // LRUの下限設定ではLRU拡大の要否を迅速に判定できないためLFUのヒット率低下の検出で代替する
656
691
 
@@ -694,53 +729,51 @@ class Cache {
694
729
  exports.Cache = Cache;
695
730
 
696
731
  class Stats {
697
- constructor(window, resolution, offset) {
732
+ constructor(window) {
698
733
  this.window = window;
699
- this.resolution = resolution;
700
- this.offset = offset;
701
- this.max = (0, alias_1.ceil)(this.resolution * (100 + this.offset) / 100) + 1;
734
+ this.offset = 0;
735
+ this.max = 2;
702
736
  this.LRU = [0];
703
737
  this.LFU = [0];
704
738
  }
705
739
 
740
+ static rate(window, hits1, hits2, offset) {
741
+ const currTotal = hits1[0] + hits2[0];
742
+ const prevTotal = hits1[1] + hits2[1];
743
+ const currHits = hits1[0];
744
+ const prevHits = hits1[1];
745
+ const prevRate = prevHits * 100 / (prevTotal || 1);
746
+ const currRatio = currTotal * 100 / window - offset;
747
+ if (currRatio <= 0) return prevRate * 100 | 0;
748
+ const currRate = currHits * 100 / (currTotal || 1);
749
+ const prevRatio = 100 - currRatio;
750
+ return currRate * currRatio + prevRate * prevRatio | 0;
751
+ }
752
+
706
753
  get length() {
707
754
  return this.LRU.length;
708
755
  }
709
756
 
710
- full() {
757
+ isFull() {
711
758
  return this.length === this.max;
712
759
  }
713
760
 
714
761
  rateLRU(offset = false) {
715
- return rate(this.window, this.LRU, this.LFU, +offset && this.offset);
762
+ return Stats.rate(this.window, this.LRU, this.LFU, +offset & 0);
716
763
  }
717
764
 
718
765
  rateLFU(offset = false) {
719
- return rate(this.window, this.LFU, this.LRU, +offset && this.offset);
766
+ return Stats.rate(this.window, this.LFU, this.LRU, +offset & 0);
720
767
  }
721
768
 
722
769
  subtotal() {
723
770
  const {
724
771
  LRU,
725
772
  LFU,
726
- window,
727
- resolution,
728
- offset
773
+ window
729
774
  } = this;
730
-
731
- if (offset && LRU[0] + LFU[0] >= window * offset / 100) {
732
- if (this.length === 1) {
733
- this.slide();
734
- } else {
735
- LRU[1] += LRU[0];
736
- LFU[1] += LFU[0];
737
- LRU[0] = 0;
738
- LFU[0] = 0;
739
- }
740
- }
741
-
742
- const subtotal = LRU[+offset && 1] + LFU[+offset && 1] || 0;
743
- subtotal >= window / resolution && this.slide();
775
+ const subtotal = LRU[0] + LFU[0];
776
+ subtotal >= window && this.slide();
744
777
  return LRU[0] + LFU[0];
745
778
  }
746
779
 
@@ -767,26 +800,69 @@ class Stats {
767
800
 
768
801
  }
769
802
 
770
- function rate(window, hits1, hits2, offset) {
771
- let total = 0;
772
- let hits = 0;
773
- let ratio = 100;
803
+ class StatsExperimental extends Stats {
804
+ constructor(window, resolution, offset) {
805
+ super(window);
806
+ this.resolution = resolution;
807
+ this.offset = offset;
808
+ this.max = (0, alias_1.ceil)(this.resolution * (100 + this.offset) / 100) + 1;
809
+ }
810
+
811
+ static rate(window, hits1, hits2, offset) {
812
+ let total = 0;
813
+ let hits = 0;
814
+ let ratio = 100;
774
815
 
775
- for (let len = hits1.length, i = 0; i < len; ++i) {
776
- const subtotal = hits1[i] + hits2[i];
777
- if (subtotal === 0) continue;
778
- offset = i + 1 === len ? 0 : offset;
779
- const subratio = (0, alias_1.min)(subtotal * 100 / window, ratio) - offset;
780
- offset = offset && subratio < 0 ? -subratio : 0;
781
- if (subratio <= 0) continue;
782
- const rate = window * subratio / subtotal;
783
- total += subtotal * rate;
784
- hits += hits1[i] * rate;
785
- ratio -= subratio;
786
- if (ratio <= 0) break;
816
+ for (let len = hits1.length, i = 0; i < len; ++i) {
817
+ const subtotal = hits1[i] + hits2[i];
818
+ if (subtotal === 0) continue;
819
+ offset = i + 1 === len ? 0 : offset;
820
+ const subratio = (0, alias_1.min)(subtotal * 100 / window, ratio) - offset;
821
+ offset = offset && subratio < 0 ? -subratio : 0;
822
+ if (subratio <= 0) continue;
823
+ const rate = window * subratio / subtotal;
824
+ total += subtotal * rate;
825
+ hits += hits1[i] * rate;
826
+ ratio -= subratio;
827
+ if (ratio <= 0) break;
828
+ }
829
+
830
+ return hits * 10000 / total | 0;
831
+ }
832
+
833
+ rateLRU(offset = false) {
834
+ return StatsExperimental.rate(this.window, this.LRU, this.LFU, +offset && this.offset);
835
+ }
836
+
837
+ rateLFU(offset = false) {
838
+ return StatsExperimental.rate(this.window, this.LFU, this.LRU, +offset && this.offset);
839
+ }
840
+
841
+ subtotal() {
842
+ const {
843
+ LRU,
844
+ LFU,
845
+ window,
846
+ resolution,
847
+ offset
848
+ } = this;
849
+
850
+ if (offset && LRU[0] + LFU[0] >= window * offset / 100) {
851
+ if (this.length === 1) {
852
+ this.slide();
853
+ } else {
854
+ LRU[1] += LRU[0];
855
+ LFU[1] += LFU[0];
856
+ LRU[0] = 0;
857
+ LFU[0] = 0;
858
+ }
859
+ }
860
+
861
+ const subtotal = LRU[offset && 1] + LFU[offset && 1] || 0;
862
+ subtotal >= window / resolution && this.slide();
863
+ return LRU[0] + LFU[0];
787
864
  }
788
865
 
789
- return hits * 10000 / total | 0;
790
866
  }
791
867
 
792
868
  /***/ }),
@@ -800,7 +876,7 @@ function rate(window, hits1, hits2, offset) {
800
876
  Object.defineProperty(exports, "__esModule", ({
801
877
  value: true
802
878
  }));
803
- exports.tick = exports.promise = exports.clock = exports.now = void 0;
879
+ exports.clock = exports.now = void 0;
804
880
 
805
881
  const global_1 = __webpack_require__(4128);
806
882
 
@@ -814,7 +890,7 @@ let count = 0;
814
890
 
815
891
  function now(nocache) {
816
892
  if (time === undefined) {
817
- tick(() => time = undefined);
893
+ exports.clock.now(() => time = undefined);
818
894
  } else if (!nocache && count++ !== 20) {
819
895
  return time;
820
896
  }
@@ -824,32 +900,45 @@ function now(nocache) {
824
900
  }
825
901
 
826
902
  exports.now = now;
827
- exports.clock = global_1.Promise.resolve(undefined);
903
+ exports.clock = new class Clock extends global_1.Promise {
904
+ constructor() {
905
+ super(resolve => resolve(undefined)); // Promise subclass is slow.
828
906
 
829
- function promise(cb) {
830
- global_1.Promise.resolve().then(cb);
831
- }
907
+ const clock = global_1.Promise.resolve();
908
+ clock.next = this.next;
909
+ clock.now = this.now;
910
+ return clock;
911
+ }
912
+
913
+ next(callback) {
914
+ scheduled || schedule();
915
+ exports.clock.then(callback);
916
+ }
832
917
 
833
- exports.promise = promise;
918
+ now(callback) {
919
+ scheduled || schedule();
920
+ queue.push(callback);
921
+ }
922
+
923
+ }();
834
924
  const queue = new queue_1.Queue();
835
- const scheduler = global_1.Promise.resolve();
925
+ let scheduled = false;
836
926
 
837
- function tick(cb) {
838
- queue.isEmpty() && scheduler.then(run);
839
- queue.push(cb);
927
+ function schedule() {
928
+ scheduled = true;
929
+ exports.clock.then(run);
840
930
  }
841
931
 
842
- exports.tick = tick;
843
-
844
932
  function run() {
845
- for (let count = queue.length; count--;) {
933
+ for (let cb; cb = queue.pop();) {
846
934
  try {
847
- // @ts-expect-error
848
- (0, queue.pop())();
935
+ cb();
849
936
  } catch (reason) {
850
937
  (0, exception_1.causeAsyncException)(reason);
851
938
  }
852
939
  }
940
+
941
+ scheduled = false;
853
942
  }
854
943
 
855
944
  /***/ }),
@@ -873,110 +962,6 @@ exports.equal = equal;
873
962
 
874
963
  /***/ }),
875
964
 
876
- /***/ 5084:
877
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
878
-
879
- "use strict";
880
-
881
-
882
- Object.defineProperty(exports, "__esModule", ({
883
- value: true
884
- }));
885
- exports.MultiMap = void 0;
886
-
887
- const global_1 = __webpack_require__(4128);
888
-
889
- const ring_1 = __webpack_require__(6395);
890
-
891
- class MultiMap {
892
- constructor(entries = [], memory = new global_1.Map()) {
893
- this.memory = memory;
894
-
895
- for (const {
896
- 0: k,
897
- 1: v
898
- } of entries) {
899
- this.set(k, v);
900
- }
901
- }
902
-
903
- get(key) {
904
- return this.memory.get(key)?.at(0);
905
- }
906
-
907
- getAll(key) {
908
- return this.memory.get(key);
909
- }
910
-
911
- set(key, val) {
912
- let vs = this.memory.get(key);
913
- if (vs) return vs.push(val), this;
914
- vs = new ring_1.Ring();
915
- vs.push(val);
916
- this.memory.set(key, vs);
917
- return this;
918
- }
919
-
920
- has(key, value) {
921
- const vs = this.memory.get(key);
922
- if (!vs?.length) return false;
923
- if (arguments.length < 2) return true;
924
- return vs.includes(value);
925
- }
926
-
927
- delete(key, value) {
928
- if (arguments.length < 2) return this.memory.delete(key);
929
- const vs = this.memory.get(key);
930
- if (!vs?.length) return false;
931
- const i = vs.indexOf(value);
932
- if (i === -1) return false;
933
- vs.splice(i, 1);
934
- return true;
935
- }
936
-
937
- clear() {
938
- this.memory.clear();
939
- }
940
-
941
- take(key, count) {
942
- const vs = this.memory.get(key);
943
- if (count === void 0) return vs?.shift();
944
- const acc = [];
945
-
946
- while (vs?.length && count--) {
947
- acc.push(vs.shift());
948
- }
949
-
950
- return acc;
951
- }
952
-
953
- ref(key) {
954
- let vs = this.memory.get(key);
955
- if (vs) return vs;
956
- vs = new ring_1.Ring();
957
- this.memory.set(key, vs);
958
- return vs;
959
- }
960
-
961
- *[Symbol.iterator]() {
962
- for (const {
963
- 0: k,
964
- 1: vs
965
- } of this.memory) {
966
- for (let i = 0; i < vs.length; ++i) {
967
- yield [k, vs.at(i)];
968
- }
969
- }
970
-
971
- return;
972
- }
973
-
974
- }
975
-
976
- exports.MultiMap = MultiMap;
977
-
978
- /***/ }),
979
-
980
965
  /***/ 8099:
981
966
  /***/ ((__unused_webpack_module, exports) => {
982
967
 
@@ -1145,16 +1130,36 @@ exports.duffReduce = duffReduce;
1145
1130
  Object.defineProperty(exports, "__esModule", ({
1146
1131
  value: true
1147
1132
  }));
1148
- exports.causeAsyncException = void 0;
1133
+ exports.suppressAsyncException = exports.causeAsyncException = void 0;
1149
1134
 
1150
1135
  const global_1 = __webpack_require__(4128);
1151
1136
 
1137
+ const stack_1 = __webpack_require__(5352);
1138
+
1139
+ const stack = new stack_1.Stack();
1140
+
1152
1141
  function causeAsyncException(reason) {
1153
- global_1.Promise.reject(reason);
1142
+ if (stack.isEmpty()) {
1143
+ global_1.Promise.reject(reason);
1144
+ } else {
1145
+ stack.peek().push(reason);
1146
+ }
1154
1147
  }
1155
1148
 
1156
1149
  exports.causeAsyncException = causeAsyncException;
1157
1150
 
1151
+ function suppressAsyncException(test) {
1152
+ return done => {
1153
+ stack.push([]);
1154
+ return test(err => {
1155
+ stack.pop();
1156
+ done(err);
1157
+ });
1158
+ };
1159
+ }
1160
+
1161
+ exports.suppressAsyncException = suppressAsyncException;
1162
+
1158
1163
  /***/ }),
1159
1164
 
1160
1165
  /***/ 4128:
@@ -1259,8 +1264,7 @@ class Heap {
1259
1264
  const array = this.array;
1260
1265
  const index = node[2];
1261
1266
  if (array[index] !== node) throw new Error('Invalid node');
1262
- swap(array, index, --this.$length); // @ts-expect-error
1263
-
1267
+ swap(array, index, --this.$length);
1264
1268
  array[this.$length] = undefined;
1265
1269
  index < this.$length && sort(this.cmp, array, index, this.$length, this.stable);
1266
1270
  return node[1];
@@ -1282,6 +1286,10 @@ class Heap {
1282
1286
  sort(this.cmp, array, node[2], this.$length, this.stable);
1283
1287
  }
1284
1288
 
1289
+ find(order) {
1290
+ return this.array.find(node => node && node[0] === order);
1291
+ }
1292
+
1285
1293
  clear() {
1286
1294
  this.array = (0, global_1.Array)(size);
1287
1295
  this.$length = 0;
@@ -1300,7 +1308,7 @@ class MultiHeap {
1300
1308
  this.cmp = cmp;
1301
1309
  this.clean = clean;
1302
1310
  this.heap = new Heap(this.cmp);
1303
- this.dict = new Map();
1311
+ this.dict = new global_1.Map();
1304
1312
  this.list = (0, memoize_1.memoize)(order => {
1305
1313
  const list = new invlist_1.List();
1306
1314
  list[MultiHeap.order] = order;
@@ -1328,8 +1336,7 @@ class MultiHeap {
1328
1336
  }
1329
1337
 
1330
1338
  ++this.$length;
1331
- const list = this.list(order);
1332
- return [order, list.push(value)];
1339
+ return this.list(order).push(value);
1333
1340
  }
1334
1341
 
1335
1342
  extract() {
@@ -1347,35 +1354,37 @@ class MultiHeap {
1347
1354
  }
1348
1355
 
1349
1356
  delete(node) {
1350
- if (!node[1].list) throw new Error('Invalid node');
1351
- const {
1352
- 0: order,
1353
- 1: lnode
1354
- } = node;
1357
+ const list = node.list;
1358
+ if (!list) throw new Error('Invalid node');
1355
1359
  --this.$length;
1356
1360
 
1357
- if (lnode.list.length === 1) {
1358
- this.heap.delete(lnode[MultiHeap.heap]);
1359
- this.clean && this.dict.delete(order);
1361
+ if (list.length === 1) {
1362
+ this.heap.delete(list[MultiHeap.heap]);
1363
+ this.clean && this.dict.delete(list[MultiHeap.order]);
1360
1364
  }
1361
1365
 
1362
- return lnode.delete();
1366
+ return node.delete();
1363
1367
  }
1364
1368
 
1365
1369
  update(node, order, value) {
1366
- if (!node[1].list) throw new Error('Invalid node');
1370
+ const list = node.list;
1371
+ if (!list) throw new Error('Invalid node');
1367
1372
 
1368
1373
  if (arguments.length < 2) {
1369
- order = node[0];
1374
+ order = list[MultiHeap.order];
1370
1375
  }
1371
1376
 
1372
1377
  if (arguments.length > 2) {
1373
- node[1].value = value;
1378
+ node.value = value;
1374
1379
  }
1375
1380
 
1376
- if (this.cmp(node[0], order) === 0) return node;
1381
+ if (this.cmp(list[MultiHeap.order], order) === 0) return node;
1377
1382
  this.delete(node);
1378
- return this.insert(node[1].value, order);
1383
+ return this.insert(node.value, order);
1384
+ }
1385
+
1386
+ find(order) {
1387
+ return this.dict.get(order);
1379
1388
  }
1380
1389
 
1381
1390
  clear() {
@@ -1491,23 +1500,20 @@ __exportStar(__webpack_require__(2310), exports);
1491
1500
  "use strict";
1492
1501
  // Circular Inverse List
1493
1502
 
1494
- var _a;
1495
-
1496
1503
  Object.defineProperty(exports, "__esModule", ({
1497
1504
  value: true
1498
1505
  }));
1499
1506
  exports.List = void 0;
1500
1507
  const undefined = void 0;
1501
- const LENGTH = Symbol('length');
1502
1508
 
1503
1509
  class List {
1504
1510
  constructor() {
1505
- this[_a] = 0;
1511
+ this.$length = 0;
1506
1512
  this.head = undefined;
1507
1513
  }
1508
1514
 
1509
1515
  get length() {
1510
- return this[LENGTH];
1516
+ return this.$length;
1511
1517
  }
1512
1518
 
1513
1519
  get tail() {
@@ -1520,7 +1526,7 @@ class List {
1520
1526
 
1521
1527
  clear() {
1522
1528
  this.head = undefined;
1523
- this[LENGTH] = 0;
1529
+ this.$length = 0;
1524
1530
  }
1525
1531
 
1526
1532
  unshift(value) {
@@ -1566,9 +1572,8 @@ class List {
1566
1572
  insert(node, before = this.head) {
1567
1573
  if (node.list === this) return node.moveTo(before), node;
1568
1574
  node.delete();
1569
- ++this[LENGTH];
1570
- this.head ??= node; // @ts-expect-error
1571
-
1575
+ ++this.$length;
1576
+ this.head ??= node;
1572
1577
  node.list = this;
1573
1578
  const next = node.next = before ?? node;
1574
1579
  const prev = node.prev = next.prev ?? node;
@@ -1576,11 +1581,43 @@ class List {
1576
1581
  return node;
1577
1582
  }
1578
1583
 
1579
- *[(_a = LENGTH, Symbol.iterator)]() {
1580
- for (let node = this.head; node;) {
1584
+ find(f) {
1585
+ for (let head = this.head, node = head; node;) {
1586
+ if (f(node.value)) return node;
1587
+ node = node.next;
1588
+ if (node === head) break;
1589
+ }
1590
+ }
1591
+
1592
+ toNodes() {
1593
+ const acc = [];
1594
+
1595
+ for (let head = this.head, node = head; node;) {
1596
+ acc.push(node);
1597
+ node = node.next;
1598
+ if (node === head) break;
1599
+ }
1600
+
1601
+ return acc;
1602
+ }
1603
+
1604
+ toArray() {
1605
+ const acc = [];
1606
+
1607
+ for (let head = this.head, node = head; node;) {
1608
+ acc.push(node.value);
1609
+ node = node.next;
1610
+ if (node === head) break;
1611
+ }
1612
+
1613
+ return acc;
1614
+ }
1615
+
1616
+ *[Symbol.iterator]() {
1617
+ for (let head = this.head, node = head; node;) {
1581
1618
  yield node.value;
1582
1619
  node = node.next;
1583
- if (node === this.head) return;
1620
+ if (node === head) return;
1584
1621
  }
1585
1622
  }
1586
1623
 
@@ -1594,21 +1631,26 @@ class Node {
1594
1631
  this.value = value;
1595
1632
  this.next = next;
1596
1633
  this.prev = prev;
1597
- ++list[LENGTH];
1634
+ ++list['$length'];
1598
1635
  list.head ??= this;
1599
1636
  next && prev ? next.prev = prev.next = this : this.next = this.prev = this;
1600
1637
  }
1601
1638
 
1639
+ get alive() {
1640
+ return this.list !== undefined;
1641
+ }
1642
+
1602
1643
  delete() {
1603
- if (!this.list) return this.value;
1604
- --this.list[LENGTH];
1644
+ const list = this.list;
1645
+ if (!list) return this.value;
1646
+ --list['$length'];
1605
1647
  const {
1606
1648
  next,
1607
1649
  prev
1608
1650
  } = this;
1609
1651
 
1610
- if (this.list.head === this) {
1611
- this.list.head = next === this ? undefined : next;
1652
+ if (list.head === this) {
1653
+ list.head = next === this ? undefined : next;
1612
1654
  }
1613
1655
 
1614
1656
  if (next) {
@@ -1617,11 +1659,9 @@ class Node {
1617
1659
 
1618
1660
  if (prev) {
1619
1661
  prev.next = next;
1620
- } // @ts-expect-error
1621
-
1622
-
1623
- this.list = undefined; // @ts-expect-error
1662
+ }
1624
1663
 
1664
+ this.list = undefined;
1625
1665
  this.next = this.prev = undefined;
1626
1666
  return this.value;
1627
1667
  }
@@ -1759,43 +1799,6 @@ exports.reduce = reduce;
1759
1799
 
1760
1800
  /***/ }),
1761
1801
 
1762
- /***/ 940:
1763
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1764
-
1765
- "use strict";
1766
-
1767
-
1768
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1769
- if (k2 === undefined) k2 = k;
1770
- var desc = Object.getOwnPropertyDescriptor(m, k);
1771
-
1772
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1773
- desc = {
1774
- enumerable: true,
1775
- get: function () {
1776
- return m[k];
1777
- }
1778
- };
1779
- }
1780
-
1781
- Object.defineProperty(o, k2, desc);
1782
- } : function (o, m, k, k2) {
1783
- if (k2 === undefined) k2 = k;
1784
- o[k2] = m[k];
1785
- });
1786
-
1787
- var __exportStar = this && this.__exportStar || function (m, exports) {
1788
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1789
- };
1790
-
1791
- Object.defineProperty(exports, "__esModule", ({
1792
- value: true
1793
- }));
1794
-
1795
- __exportStar(__webpack_require__(5084), exports);
1796
-
1797
- /***/ }),
1798
-
1799
1802
  /***/ 4934:
1800
1803
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1801
1804
 
@@ -1805,7 +1808,7 @@ __exportStar(__webpack_require__(5084), exports);
1805
1808
  Object.defineProperty(exports, "__esModule", ({
1806
1809
  value: true
1807
1810
  }));
1808
- exports.PriorityQueue = exports.Queue = void 0;
1811
+ exports.MultiQueue = exports.PriorityQueue = exports.Queue = void 0;
1809
1812
 
1810
1813
  const global_1 = __webpack_require__(4128);
1811
1814
 
@@ -1935,7 +1938,7 @@ class FixedQueue {
1935
1938
  class PriorityQueue {
1936
1939
  constructor(cmp = PriorityQueue.max, clean = true) {
1937
1940
  this.clean = clean;
1938
- this.dict = new Map();
1941
+ this.dict = new global_1.Map();
1939
1942
  this.queue = (0, memoize_1.memoize)(priority => {
1940
1943
  const queue = new Queue();
1941
1944
  queue[PriorityQueue.priority] = priority;
@@ -1954,22 +1957,22 @@ class PriorityQueue {
1954
1957
  return this.$length === 0;
1955
1958
  }
1956
1959
 
1957
- peek() {
1958
- return this.heap.peek()?.peek();
1960
+ peek(priority) {
1961
+ return arguments.length === 0 ? this.heap.peek()?.peek() : this.dict.get(priority)?.peek();
1959
1962
  }
1960
1963
 
1961
- push(value, priority) {
1964
+ push(priority, value) {
1962
1965
  ++this.$length;
1963
1966
  this.queue(priority).push(value);
1964
1967
  }
1965
1968
 
1966
- pop() {
1969
+ pop(priority) {
1967
1970
  if (this.$length === 0) return;
1968
1971
  --this.$length;
1969
- const queue = this.heap.peek();
1970
- const value = queue.pop();
1972
+ const queue = arguments.length === 0 ? this.heap.peek() : this.dict.get(priority);
1973
+ const value = queue?.pop();
1971
1974
 
1972
- if (queue.isEmpty()) {
1975
+ if (queue?.isEmpty()) {
1973
1976
  this.heap.extract();
1974
1977
  this.clean && this.dict.delete(queue[PriorityQueue.priority]);
1975
1978
  }
@@ -1998,6 +2001,103 @@ PriorityQueue.priority = Symbol('priority');
1998
2001
  PriorityQueue.max = heap_1.Heap.max;
1999
2002
  PriorityQueue.min = heap_1.Heap.min;
2000
2003
 
2004
+ class MultiQueue {
2005
+ constructor(entries) {
2006
+ this.dict = new global_1.Map();
2007
+ if (entries) for (const {
2008
+ 0: k,
2009
+ 1: v
2010
+ } of entries) {
2011
+ this.set(k, v);
2012
+ }
2013
+ }
2014
+
2015
+ get length() {
2016
+ return this.dict.size;
2017
+ }
2018
+
2019
+ isEmpty() {
2020
+ return this.dict.size === 0;
2021
+ }
2022
+
2023
+ peek(key) {
2024
+ return this.dict.get(key)?.peek();
2025
+ }
2026
+
2027
+ push(key, value) {
2028
+ let vs = this.dict.get(key);
2029
+ if (vs) return void vs.push(value);
2030
+ vs = new Queue();
2031
+ vs.push(value);
2032
+ this.dict.set(key, vs);
2033
+ }
2034
+
2035
+ pop(key) {
2036
+ return this.dict.get(key)?.pop();
2037
+ }
2038
+
2039
+ clear() {
2040
+ this.dict = new global_1.Map();
2041
+ }
2042
+
2043
+ take(key, count) {
2044
+ if (count === void 0) return this.pop(key);
2045
+ const vs = this.dict.get(key);
2046
+ const acc = [];
2047
+
2048
+ while (vs && !vs.isEmpty() && count--) {
2049
+ acc.push(vs.pop());
2050
+ }
2051
+
2052
+ return acc;
2053
+ }
2054
+
2055
+ ref(key) {
2056
+ let vs = this.dict.get(key);
2057
+ if (vs) return vs;
2058
+ vs = new Queue();
2059
+ this.dict.set(key, vs);
2060
+ return vs;
2061
+ }
2062
+
2063
+ get size() {
2064
+ return this.length;
2065
+ }
2066
+
2067
+ get(key) {
2068
+ return this.peek(key);
2069
+ }
2070
+
2071
+ set(key, value) {
2072
+ this.push(key, value);
2073
+ return this;
2074
+ }
2075
+
2076
+ has(key) {
2077
+ return this.dict.has(key);
2078
+ }
2079
+
2080
+ delete(key) {
2081
+ return this.dict.delete(key);
2082
+ }
2083
+
2084
+ *[Symbol.iterator]() {
2085
+ for (const {
2086
+ 0: k,
2087
+ 1: vs
2088
+ } of this.dict) {
2089
+ while (!vs.isEmpty()) {
2090
+ yield [k, vs.pop()];
2091
+ }
2092
+ }
2093
+
2094
+ return;
2095
+ }
2096
+
2097
+ }
2098
+
2099
+ exports.MultiQueue = MultiQueue;
2100
+
2001
2101
  /***/ }),
2002
2102
 
2003
2103
  /***/ 7325:
@@ -2009,14 +2109,14 @@ PriorityQueue.min = heap_1.Heap.min;
2009
2109
  Object.defineProperty(exports, "__esModule", ({
2010
2110
  value: true
2011
2111
  }));
2012
- exports.unique = exports.rndAf = exports.rndAP = exports.rnd0_ = exports.rnd0Z = exports.rnd0v = exports.rnd0f = exports.rnd64 = exports.rnd62 = exports.rnd32 = exports.rnd16 = void 0;
2112
+ exports.pcg32 = exports.xorshift = exports.unique = exports.rndAf = exports.rndAP = exports.rnd0_ = exports.rnd0Z = exports.rnd0v = exports.rnd0f = exports.rnd64 = exports.rnd62 = exports.rnd32 = exports.rnd16 = void 0;
2013
2113
 
2014
2114
  const global_1 = __webpack_require__(4128);
2015
2115
 
2016
2116
  const radixes = Object.freeze([...Array(7)].map((_, i) => 1 << i));
2017
2117
  const masks = Object.freeze(radixes.map(radix => radix - 1));
2018
- const dict0_ = Object.freeze([...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_']);
2019
- const dictAz = Object.freeze([...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)]);
2118
+ const dict0_ = [...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_'].join('');
2119
+ const dictAz = [...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)].join('');
2020
2120
  exports.rnd16 = cons(16);
2021
2121
  exports.rnd32 = cons(32);
2022
2122
  exports.rnd62 = cons(62);
@@ -2094,239 +2194,176 @@ function conv(rnd, dict) {
2094
2194
  const buffer = new Uint16Array(512);
2095
2195
  const digit = 16;
2096
2196
  let index = buffer.length;
2197
+ let rnd = 2 ** digit;
2097
2198
  let offset = digit;
2098
2199
 
2099
2200
  function random(len) {
2100
- if (index === buffer.length) {
2201
+ if (rnd === 2 ** digit) {
2101
2202
  global_1.crypto.getRandomValues(buffer);
2102
2203
  index = 0;
2204
+ rnd = buffer[index];
2103
2205
  }
2104
2206
 
2105
2207
  if (offset === len) {
2106
2208
  offset = digit;
2107
- return buffer[index++] & masks[len];
2209
+ const r = rnd & masks[len];
2210
+ rnd = buffer[++index] ?? 2 ** digit;
2211
+ return r;
2108
2212
  } else if (offset > len) {
2109
2213
  offset -= len;
2110
- return buffer[index] >> offset & masks[len];
2214
+ return rnd >> offset & masks[len];
2111
2215
  } else {
2112
2216
  offset = digit;
2113
- ++index;
2217
+ rnd = buffer[++index] ?? 2 ** digit;
2114
2218
  return random(len);
2115
2219
  }
2116
2220
  }
2117
2221
 
2118
- /***/ }),
2119
-
2120
- /***/ 6395:
2121
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2122
-
2123
- "use strict";
2124
-
2125
-
2126
- Object.defineProperty(exports, "__esModule", ({
2127
- value: true
2128
- }));
2129
- exports.Ring = void 0;
2130
-
2131
- const global_1 = __webpack_require__(4128);
2132
-
2133
- const alias_1 = __webpack_require__(5406);
2134
-
2135
- const array_1 = __webpack_require__(8112);
2136
-
2137
- const undefined = void 0;
2138
- const empty = Symbol('empty');
2222
+ function xorshift(seed = xorshift.seed()) {
2223
+ return () => {
2224
+ let x = seed;
2225
+ x ^= x << 13;
2226
+ x ^= x >> 17;
2227
+ x ^= x << 5;
2228
+ return seed = x >>> 0;
2229
+ };
2230
+ }
2139
2231
 
2140
- const unempty = value => value === empty ? undefined : value;
2232
+ exports.xorshift = xorshift;
2141
2233
 
2142
- const space = Object.freeze((0, global_1.Array)(100).fill(empty));
2143
- let size = 16;
2234
+ (function (xorshift) {
2235
+ const max = -1 >>> 0;
2144
2236
 
2145
- class Ring {
2146
- constructor() {
2147
- this.array = (0, global_1.Array)(size);
2148
- this.head = 0;
2149
- this.tail = 0;
2150
- this.$length = 0;
2151
- this.excess = 0;
2237
+ function seed() {
2238
+ return global_1.Math.random() * max + 1 >>> 0;
2152
2239
  }
2153
2240
 
2154
- get length() {
2155
- return this.$length;
2241
+ xorshift.seed = seed;
2242
+
2243
+ function random(seed) {
2244
+ const rnd = xorshift(seed);
2245
+ return () => rnd() / (max + 1);
2156
2246
  }
2157
2247
 
2158
- at(index) {
2159
- // Inline the code for optimization.
2160
- const array = this.array;
2248
+ xorshift.random = random;
2249
+ })(xorshift = exports.xorshift || (exports.xorshift = {}));
2161
2250
 
2162
- if (index >= 0) {
2163
- if (index >= this.$length) return;
2164
- return unempty(array[(this.head - 1 + index) % array.length]);
2165
- } else {
2166
- if (-index > this.$length) return;
2167
- return this.tail + index >= 0 ? unempty(array[this.tail + index]) : unempty(array[array.length + this.tail + index]);
2168
- }
2169
- }
2251
+ const uint32n = n => n & 2n ** 32n - 1n;
2170
2252
 
2171
- replace(index, value, replacer) {
2172
- const array = this.array;
2253
+ const uint64n = n => n & 2n ** 64n - 1n; // https://www.pcg-random.org/download.html
2254
+ // https://github.com/imneme/pcg-c/blob/master/include/pcg_variants.h
2173
2255
 
2174
- if (index >= 0) {
2175
- if (index >= this.$length) throw new RangeError('Invalid index');
2176
- index = (this.head - 1 + index) % array.length;
2177
- } else {
2178
- if (-index > this.$length) throw new RangeError('Invalid index');
2179
- index = this.tail + index >= 0 ? this.tail + index : array.length + this.tail + index;
2180
- }
2181
2256
 
2182
- const val = unempty(array[index]);
2183
- array[index] = replacer ? replacer(val, value) : value;
2184
- return val;
2185
- }
2257
+ function pcg32(seed = pcg32.seed()) {
2258
+ return () => pcg32.next(seed);
2259
+ }
2186
2260
 
2187
- push(value) {
2188
- const array = this.array;
2189
- let {
2190
- head,
2191
- tail
2192
- } = this;
2193
- tail = this.tail = next(head, tail, array.length);
2194
- head = this.head ||= tail;
2261
+ exports.pcg32 = pcg32;
2195
2262
 
2196
- if (head === tail && this.$length !== 0) {
2197
- (0, array_1.splice)(array, tail - 1, 0, ...space);
2198
- head = this.head += space.length;
2199
- }
2263
+ (function (pcg32) {
2264
+ const MULT = 6364136223846793005n;
2200
2265
 
2201
- array[tail - 1] = value;
2202
- ++this.$length;
2266
+ function random(seed) {
2267
+ const rnd = pcg32(seed);
2268
+ return () => rnd() / 2 ** 32;
2203
2269
  }
2204
2270
 
2205
- unshift(value) {
2206
- const array = this.array;
2207
- let {
2208
- head,
2209
- tail
2210
- } = this;
2211
- head = this.head = prev(head, tail, array.length);
2212
- tail = this.tail ||= head;
2213
-
2214
- if (head === tail && this.$length !== 0) {
2215
- (0, array_1.splice)(array, head, 0, ...space);
2216
- head = this.head += space.length;
2217
- }
2271
+ pcg32.random = random;
2218
2272
 
2219
- array[head - 1] = value;
2220
- ++this.$length;
2273
+ function seed(state = BigInt(xorshift.seed()) << 32n | BigInt(xorshift.seed()), inc = BigInt(xorshift.seed()) << 32n | BigInt(xorshift.seed())) {
2274
+ const seed = [0n, uint64n(inc << 1n | 1n)];
2275
+ seed[0] = uint64n(seed[0] * MULT + seed[1]);
2276
+ seed[0] = uint64n(seed[0] + state);
2277
+ seed[0] = uint64n(seed[0] * MULT + seed[1]);
2278
+ return seed;
2221
2279
  }
2222
2280
 
2223
- pop() {
2224
- if (this.$length === 0) return;
2225
- const array = this.array;
2226
- const i = this.tail - 1;
2227
- const value = unempty(array[i]);
2228
- array[i] = empty;
2229
- --this.$length === 0 ? this.head = this.tail = 0 : this.tail = this.tail === 1 ? array.length : this.tail - 1;
2230
- return value;
2231
- }
2281
+ pcg32.seed = seed;
2232
2282
 
2233
- shift() {
2234
- if (this.$length === 0) return;
2235
- const array = this.array;
2236
- const i = this.head - 1;
2237
- const value = unempty(array[i]);
2238
- array[i] = empty;
2239
- --this.$length === 0 ? this.head = this.tail = 0 : this.head = this.head === array.length ? 1 : this.head + 1;
2240
- return value;
2283
+ function next(seed) {
2284
+ const oldstate = seed[0];
2285
+ seed[0] = uint64n(oldstate * MULT + seed[1]);
2286
+ const xorshifted = uint32n((oldstate >> 18n ^ oldstate) >> 27n);
2287
+ const rot = oldstate >> 59n;
2288
+ return (0, global_1.Number)(uint32n(xorshifted >> rot | xorshifted << (-rot & 31n)));
2241
2289
  }
2242
2290
 
2243
- splice(index, count, ...values) {
2244
- const array = this.array;
2291
+ pcg32.next = next;
2245
2292
 
2246
- if (this.excess > 100 && array.length - this.$length > 200) {
2247
- (0, array_1.splice)(array, 0, 100 - (0, array_1.splice)(array, this.tail, 100).length);
2248
- this.excess -= 100;
2249
- } else if (-this.excess > array.length * 2) {
2250
- this.excess = array.length;
2293
+ function advance(seed, delta) {
2294
+ while (delta < 0) {
2295
+ delta = 2n ** 64n + delta;
2251
2296
  }
2252
2297
 
2253
- index = index < 0 ? (0, alias_1.max)(0, this.$length + index) : index <= this.$length ? index : this.$length;
2254
- count = (0, alias_1.min)((0, alias_1.max)(count, 0), this.$length - index);
2255
-
2256
- if (values.length === 0) {
2257
- if (count === 0) return [];
2298
+ delta = uint64n(delta);
2299
+ let acc_mult = 1n;
2300
+ let acc_plus = 0n;
2301
+ let cur_mult = MULT;
2302
+ let cur_plus = seed[1];
2258
2303
 
2259
- switch (index) {
2260
- case 0:
2261
- if (count === 1) return [this.shift()];
2262
- break;
2263
-
2264
- case this.$length - 1:
2265
- if (count === 1) return [this.pop()];
2266
- break;
2267
-
2268
- case this.$length:
2269
- return [];
2304
+ while (delta > 0) {
2305
+ if (delta & 1n) {
2306
+ acc_mult = uint64n(acc_mult * cur_mult);
2307
+ acc_plus = uint64n(acc_plus * cur_mult + cur_plus);
2270
2308
  }
2309
+
2310
+ cur_plus = uint64n((cur_mult + 1n) * cur_plus);
2311
+ cur_mult = uint64n(cur_mult * cur_mult);
2312
+ delta /= 2n;
2271
2313
  }
2272
2314
 
2273
- index = (this.head || 1) - 1 + index;
2274
- index = index > array.length ? index % array.length : index;
2275
- this.excess += values.length - count;
2276
- this.$length += values.length - count; // |--H>*>T--|
2315
+ seed[0] = uint64n(acc_mult * seed[0] + acc_plus);
2316
+ return seed;
2317
+ }
2277
2318
 
2278
- if (this.head <= this.tail) {
2279
- this.tail += values.length - count;
2280
- return (0, array_1.splice)(array, index, count, ...values);
2281
- } // |*>T---H>>|
2319
+ pcg32.advance = advance;
2320
+ })(pcg32 = exports.pcg32 || (exports.pcg32 = {}));
2282
2321
 
2322
+ /***/ }),
2283
2323
 
2284
- if (index < this.tail) {
2285
- this.head += values.length - count;
2286
- this.tail += values.length - count;
2287
- return (0, array_1.splice)(array, index, count, ...values);
2288
- } // |>>T---H>*|
2324
+ /***/ 5352:
2325
+ /***/ ((__unused_webpack_module, exports) => {
2289
2326
 
2327
+ "use strict";
2290
2328
 
2291
- const cnt = (0, alias_1.min)(count, array.length - index);
2292
- const vs = (0, array_1.splice)(array, index, cnt, ...(0, array_1.splice)(values, 0, cnt));
2293
- vs.push(...(0, array_1.splice)(array, 0, count - vs.length, ...values));
2294
- return vs;
2295
- }
2296
2329
 
2297
- clear() {
2298
- this.array = (0, global_1.Array)(size);
2299
- this.$length = this.head = this.tail = 0;
2330
+ Object.defineProperty(exports, "__esModule", ({
2331
+ value: true
2332
+ }));
2333
+ exports.Stack = void 0;
2334
+
2335
+ class Stack {
2336
+ constructor() {
2337
+ this.array = [];
2300
2338
  }
2301
2339
 
2302
- includes(value) {
2303
- return this.array.includes(value);
2340
+ get length() {
2341
+ return this.array.length;
2304
2342
  }
2305
2343
 
2306
- relational(index) {
2307
- if (index === -1) return -1;
2308
- return index + 1 >= this.head ? index + 1 - this.head : this.array.length - this.head + index;
2344
+ isEmpty() {
2345
+ return this.length === 0;
2309
2346
  }
2310
2347
 
2311
- indexOf(value) {
2312
- return this.relational((0, array_1.indexOf)(this.array, value));
2348
+ peek(index = 0) {
2349
+ return index === 0 ? this.array[this.array.length - 1] : this.array[0];
2313
2350
  }
2314
2351
 
2315
- findIndex(f) {
2316
- return this.relational(this.array.findIndex(value => value !== empty && f(value)));
2352
+ push(value) {
2353
+ this.array.push(value);
2317
2354
  }
2318
2355
 
2319
- find(f) {
2320
- return unempty(this.array.find(value => value !== empty && f(value)));
2356
+ pop() {
2357
+ return this.array.pop();
2321
2358
  }
2322
2359
 
2323
- toArray() {
2324
- return this.head <= this.tail ? this.array.slice((this.head || 1) - 1, this.tail) : this.array.slice((this.head || 1) - 1).concat(this.array.slice(0, this.tail));
2360
+ clear() {
2361
+ this.array = [];
2325
2362
  }
2326
2363
 
2327
2364
  *[Symbol.iterator]() {
2328
- for (let i = 0; i < this.$length; ++i) {
2329
- yield this.at(i);
2365
+ while (!this.isEmpty()) {
2366
+ yield this.pop();
2330
2367
  }
2331
2368
 
2332
2369
  return;
@@ -2334,15 +2371,7 @@ class Ring {
2334
2371
 
2335
2372
  }
2336
2373
 
2337
- exports.Ring = Ring;
2338
-
2339
- function next(head, tail, length) {
2340
- return tail === length && head !== 1 ? 1 : tail + 1;
2341
- }
2342
-
2343
- function prev(head, tail, length) {
2344
- return head === 0 || head === 1 ? tail === length ? length + 1 : length : head - 1;
2345
- }
2374
+ exports.Stack = Stack;
2346
2375
 
2347
2376
  /***/ }),
2348
2377
 
@@ -2384,7 +2413,7 @@ function type(value) {
2384
2413
  return 'Object';
2385
2414
 
2386
2415
  default:
2387
- return (0, alias_1.toString)(value).slice(8, -1);
2416
+ return value?.constructor?.name || (0, alias_1.toString)(value).slice(8, -1);
2388
2417
  }
2389
2418
 
2390
2419
  default:
@@ -2968,7 +2997,7 @@ function convert(conv, parser) {
2968
2997
  context
2969
2998
  }) => {
2970
2999
  if (source === '') return;
2971
- const src = conv(source);
3000
+ const src = conv(source, context);
2972
3001
  if (src === '') return [[], ''];
2973
3002
  context.offset ??= 0;
2974
3003
  context.offset += source.length - src.length;
@@ -5220,11 +5249,17 @@ const blockquote_1 = __webpack_require__(7859);
5220
5249
 
5221
5250
  const placeholder_1 = __webpack_require__(5198);
5222
5251
 
5252
+ const inline_1 = __webpack_require__(1160);
5253
+
5223
5254
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)(['[$', '$'], (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^(?=\s).*\n/)), (0, combinator_1.union)([codeblock_1.segment, mathblock_1.segment, table_1.segment, blockquote_1.segment, placeholder_1.segment, (0, combinator_1.some)(source_1.contentline)])])));
5224
- exports.fig = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.verify)((0, combinator_1.convert)(source => {
5255
+ exports.fig = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.verify)((0, combinator_1.convert)((source, context) => {
5225
5256
  const fence = (/^[^\n]*\n!?>+\s/.test(source) && source.match(/^~{3,}(?=[^\S\n]*$)/mg) || []).reduce((max, fence) => fence > max ? fence : max, '~~') + '~';
5226
- return `${fence}figure ${source}\n\n${fence}`;
5257
+ return parser({
5258
+ source,
5259
+ context
5260
+ }) ? `${fence}figure ${source.replace(/^(.+\n.+\n)([\S\s]+?)\n?$/, '$1\n$2')}\n${fence}` : `${fence}figure ${source}\n\n${fence}`;
5227
5261
  }, (0, combinator_1.union)([figure_1.figure])), ([el]) => el.tagName === 'FIGURE')));
5262
+ const parser = (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^(?=\s).*\n/)), (0, combinator_1.line)((0, combinator_1.union)([inline_1.media, inline_1.shortmedia])), (0, combinator_1.some)(source_1.contentline)]);
5228
5263
 
5229
5264
  /***/ }),
5230
5265
 
@@ -7150,8 +7185,6 @@ const combinator_1 = __webpack_require__(2087);
7150
7185
 
7151
7186
  const dom_1 = __webpack_require__(3252);
7152
7187
 
7153
- const query_1 = __webpack_require__(6120);
7154
-
7155
7188
  function indexee(parser, optional) {
7156
7189
  return (0, combinator_1.fmap)(parser, ([el], _, {
7157
7190
  id
@@ -7176,7 +7209,7 @@ function text(source, optional = false) {
7176
7209
  if (index) return index;
7177
7210
  const target = source.cloneNode(true);
7178
7211
 
7179
- for (let es = (0, query_1.querySelectorAll)(target, 'code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), i = 0; i < es.length; ++i) {
7212
+ for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), len = es.length, i = 0; i < len; ++i) {
7180
7213
  const el = es[i];
7181
7214
 
7182
7215
  switch (el.tagName) {
@@ -8147,14 +8180,12 @@ const ja_1 = __webpack_require__(1499);
8147
8180
 
8148
8181
  const dom_1 = __webpack_require__(3252);
8149
8182
 
8150
- const query_1 = __webpack_require__(6120);
8151
-
8152
8183
  function localize(parser) {
8153
8184
  return (0, combinator_1.fmap)(parser, ns => {
8154
8185
  if (ns.length === 0) return ns;
8155
8186
  const el = ns.length === 1 && typeof ns[0] === 'object' ? ns[0] : (0, dom_1.html)('div', ns);
8156
8187
 
8157
- for (let es = (0, query_1.querySelectorAll)(el, '.linebreak:not(:empty)'), i = 0; i < es.length; ++i) {
8188
+ for (let es = el.querySelectorAll('.linebreak:not(:empty)'), len = es.length, i = 0; i < len; ++i) {
8158
8189
  const el = es[i];
8159
8190
  if (!check(el)) continue;
8160
8191
  el.firstChild.remove();
@@ -8245,7 +8276,7 @@ const global_1 = __webpack_require__(4128);
8245
8276
 
8246
8277
  const label_1 = __webpack_require__(466);
8247
8278
 
8248
- const multimap_1 = __webpack_require__(940);
8279
+ const queue_1 = __webpack_require__(4934);
8249
8280
 
8250
8281
  const array_1 = __webpack_require__(8112);
8251
8282
 
@@ -8254,15 +8285,15 @@ const dom_1 = __webpack_require__(3252);
8254
8285
  const query_1 = __webpack_require__(6120);
8255
8286
 
8256
8287
  function* figure(target, footnotes, opts = {}) {
8257
- const refs = new multimap_1.MultiMap((0, array_1.push)((0, query_1.querySelectorAll)(target, 'a.label:not(.disabled)[data-label]'), footnotes && (0, query_1.querySelectorAll)(footnotes.references, 'a.label:not(.disabled)') || []).map(el => [el.getAttribute('data-label'), el]));
8288
+ const refs = new queue_1.MultiQueue((0, array_1.push)((0, query_1.querySelectorAll)(target, 'a.label:not(.disabled)[data-label]'), footnotes && (0, query_1.querySelectorAll)(footnotes.references, 'a.label:not(.disabled)') || []).map(el => [el.getAttribute('data-label'), el]));
8258
8289
  const labels = new global_1.Set();
8259
8290
  const numbers = new global_1.Map();
8260
8291
  let base = '0';
8261
8292
  let bases = base.split('.');
8262
8293
  let index = bases; // Bug: Firefox
8263
- //for (let defs = querySelectorAll(target, ':scope > figure[data-label], :scope > h1, :scope > h2'), len = defs.length, i = 0; i < len; ++i) {
8294
+ //for (let defs = target.querySelectorAll(':scope > figure[data-label], :scope > h1, :scope > h2'), len = defs.length, i = 0; i < len; ++i) {
8264
8295
 
8265
- for (let defs = (0, query_1.querySelectorAll)(target, 'figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
8296
+ for (let defs = target.querySelectorAll('figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
8266
8297
  yield;
8267
8298
  const def = defs[i];
8268
8299
  if (def.parentNode !== target) continue;
@@ -8444,16 +8475,14 @@ const global_1 = __webpack_require__(4128);
8444
8475
 
8445
8476
  const indexee_1 = __webpack_require__(1269);
8446
8477
 
8447
- const multimap_1 = __webpack_require__(940);
8478
+ const queue_1 = __webpack_require__(4934);
8448
8479
 
8449
8480
  const dom_1 = __webpack_require__(3252);
8450
8481
 
8451
- const query_1 = __webpack_require__(6120);
8452
-
8453
8482
  function* footnote(target, footnotes, opts = {}, bottom = null) {
8454
8483
  // Bug: Firefox
8455
- //querySelectorAll(target, `:scope > .annotations`).forEach(el => el.remove());
8456
- for (let es = (0, query_1.querySelectorAll)(target, `.annotations`), i = 0; i < es.length; ++i) {
8484
+ //target.querySelectorAll(`:scope > .annotations`).forEach(el => el.remove());
8485
+ for (let es = target.querySelectorAll(`.annotations`), len = es.length, i = 0; i < len; ++i) {
8457
8486
  const el = es[i];
8458
8487
  el.parentNode === target && el.remove();
8459
8488
  }
@@ -8472,13 +8501,13 @@ function build(syntax, marker, splitter) {
8472
8501
  // 構文ごとに各1回の処理では不可能
8473
8502
  return function* (target, footnote, opts = {}, bottom = null) {
8474
8503
  const defs = new global_1.Map();
8475
- const buffer = new multimap_1.MultiMap();
8504
+ const buffer = new queue_1.MultiQueue();
8476
8505
  const titles = new global_1.Map(); // Bug: Firefox
8477
- //const splitters = push([], querySelectorAll(target, `:scope > :is(${splitter ?? '_'})`));
8506
+ //const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
8478
8507
 
8479
8508
  const splitters = [];
8480
8509
 
8481
- for (let es = (0, query_1.querySelectorAll)(target, splitter ?? '_'), i = 0; i < es.length; ++i) {
8510
+ for (let es = target.querySelectorAll(splitter ?? '_'), len = es.length, i = 0; i < len; ++i) {
8482
8511
  const el = es[i];
8483
8512
  el.parentNode === target && splitters.push(el);
8484
8513
  }
@@ -8487,7 +8516,7 @@ function build(syntax, marker, splitter) {
8487
8516
  let total = 0;
8488
8517
  let style;
8489
8518
 
8490
- for (let refs = (0, query_1.querySelectorAll)(target, `sup.${syntax}:not(.disabled)`), len = refs.length, i = 0; i < len; ++i) {
8519
+ for (let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`), len = refs.length, i = 0; i < len; ++i) {
8491
8520
  yield;
8492
8521
  const ref = refs[i];
8493
8522
 
@@ -9838,8 +9867,6 @@ exports.info = void 0;
9838
9867
 
9839
9868
  const scope_1 = __webpack_require__(5202);
9840
9869
 
9841
- const query_1 = __webpack_require__(6120);
9842
-
9843
9870
  function info(source) {
9844
9871
  const match = (0, scope_1.scope)(source, '.invalid');
9845
9872
  return {
@@ -9858,7 +9885,7 @@ function info(source) {
9858
9885
  function find(selector) {
9859
9886
  const acc = [];
9860
9887
 
9861
- for (let es = (0, query_1.querySelectorAll)(source, selector), i = 0; i < es.length; ++i) {
9888
+ for (let es = source.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
9862
9889
  const el = es[i];
9863
9890
  match(el) && acc.push(el);
9864
9891
  }
@@ -9890,8 +9917,6 @@ const cite_1 = __webpack_require__(6315);
9890
9917
 
9891
9918
  const dom_1 = __webpack_require__(3252);
9892
9919
 
9893
- const query_1 = __webpack_require__(6120);
9894
-
9895
9920
  function quote(anchor, range) {
9896
9921
  if ((0, parser_1.exec)((0, cite_1.cite)({
9897
9922
  source: `>>${anchor}`,
@@ -9901,7 +9926,7 @@ function quote(anchor, range) {
9901
9926
  const node = trim(range.cloneContents());
9902
9927
  if (!node.firstChild) return '';
9903
9928
 
9904
- for (let es = (0, query_1.querySelectorAll)(node, 'code[data-src], .math[data-src], .media[data-src], rt, rp'), i = 0; i < es.length; ++i) {
9929
+ for (let es = node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), len = es.length, i = 0; i < len; ++i) {
9905
9930
  const el = es[i];
9906
9931
 
9907
9932
  switch (true) {
@@ -9927,7 +9952,7 @@ function quote(anchor, range) {
9927
9952
  anchor = '';
9928
9953
  }
9929
9954
 
9930
- for (let es = (0, query_1.querySelectorAll)(node, 'br'), i = 0; i < es.length; ++i) {
9955
+ for (let es = node.querySelectorAll('br'), len = es.length, i = 0; i < len; ++i) {
9931
9956
  const el = es[i];
9932
9957
 
9933
9958
  if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
@@ -10037,10 +10062,8 @@ const global_1 = __webpack_require__(4128);
10037
10062
 
10038
10063
  const array_1 = __webpack_require__(8112);
10039
10064
 
10040
- const dom_1 = __webpack_require__(3252);
10041
-
10042
- const query_1 = __webpack_require__(6120); // Bug: Firefox
10043
- //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
10065
+ const dom_1 = __webpack_require__(3252); // Bug: Firefox
10066
+ //const selector = `:scope > :is(h1, h2, h3, h4, h5, h6, aside.aside)[id]`;
10044
10067
 
10045
10068
 
10046
10069
  const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
@@ -10048,7 +10071,7 @@ const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
10048
10071
  function toc(source) {
10049
10072
  const hs = [];
10050
10073
 
10051
- for (let es = (0, query_1.querySelectorAll)(source, selector), i = 0; i < es.length; ++i) {
10074
+ for (let es = source.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10052
10075
  const el = es[i];
10053
10076
 
10054
10077
  switch (el.tagName) {
@@ -10107,7 +10130,7 @@ function unlink(h) {
10107
10130
  /***/ 3252:
10108
10131
  /***/ (function(module) {
10109
10132
 
10110
- /*! typed-dom v0.0.307 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10133
+ /*! typed-dom v0.0.310 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10111
10134
  (function webpackUniversalModuleDefinition(root, factory) {
10112
10135
  if(true)
10113
10136
  module.exports = factory();
@@ -10539,7 +10562,7 @@ exports.defrag = defrag;
10539
10562
  /***/ 6120:
10540
10563
  /***/ (function(module) {
10541
10564
 
10542
- /*! typed-dom v0.0.307 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10565
+ /*! typed-dom v0.0.310 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
10543
10566
  (function webpackUniversalModuleDefinition(root, factory) {
10544
10567
  if(true)
10545
10568
  module.exports = factory();
@@ -10547,220 +10570,8 @@ exports.defrag = defrag;
10547
10570
  })(this, () => {
10548
10571
  return /******/ (() => { // webpackBootstrap
10549
10572
  /******/ "use strict";
10550
- /******/ var __webpack_modules__ = ({
10551
-
10552
- /***/ 99:
10553
- /***/ ((__unused_webpack_module, exports) => {
10554
-
10555
-
10556
-
10557
- Object.defineProperty(exports, "__esModule", ({
10558
- value: true
10559
- }));
10560
- exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0; // 100,000以上でforより大幅に低速となり実用不可
10561
-
10562
- function duff(count, proc) {
10563
- if (count > 0) {
10564
- let i = 0,
10565
- m = count & 7,
10566
- d = (count - m) / 8;
10567
-
10568
- while (m--) {
10569
- proc(i++);
10570
- }
10571
-
10572
- while (d--) {
10573
- proc(i++);
10574
- proc(i++);
10575
- proc(i++);
10576
- proc(i++);
10577
- proc(i++);
10578
- proc(i++);
10579
- proc(i++);
10580
- proc(i++);
10581
- }
10582
- } else {
10583
- let i = -count,
10584
- m = i & 7,
10585
- d = (i - m) / 8;
10586
-
10587
- while (m--) {
10588
- proc(--i);
10589
- }
10590
-
10591
- while (d--) {
10592
- proc(--i);
10593
- proc(--i);
10594
- proc(--i);
10595
- proc(--i);
10596
- proc(--i);
10597
- proc(--i);
10598
- proc(--i);
10599
- proc(--i);
10600
- }
10601
- }
10602
- }
10603
-
10604
- exports.duff = duff; // 100,000以上でforより大幅に低速となり実用不可
10605
-
10606
- function duffbk(count, proc) {
10607
- if (count > 0) {
10608
- let i = 0,
10609
- m = count & 7,
10610
- d = (count - m) / 8;
10611
-
10612
- while (m--) {
10613
- if (proc(i++) === false) return;
10614
- }
10615
-
10616
- while (d--) {
10617
- switch (false) {
10618
- case proc(i++):
10619
- case proc(i++):
10620
- case proc(i++):
10621
- case proc(i++):
10622
- case proc(i++):
10623
- case proc(i++):
10624
- case proc(i++):
10625
- case proc(i++):
10626
- return;
10627
- }
10628
- }
10629
- } else {
10630
- let i = -count,
10631
- m = i & 7,
10632
- d = (i - m) / 8;
10633
-
10634
- while (m--) {
10635
- if (proc(--i) === false) return;
10636
- }
10637
-
10638
- while (d--) {
10639
- switch (false) {
10640
- case proc(--i):
10641
- case proc(--i):
10642
- case proc(--i):
10643
- case proc(--i):
10644
- case proc(--i):
10645
- case proc(--i):
10646
- case proc(--i):
10647
- case proc(--i):
10648
- return;
10649
- }
10650
- }
10651
- }
10652
- }
10653
-
10654
- exports.duffbk = duffbk;
10655
-
10656
- function duffEach(array, proc) {
10657
- let count = array.length;
10658
- let i = 0,
10659
- m = count & 7,
10660
- d = (count - m) / 8;
10661
-
10662
- while (m--) {
10663
- proc(array[i], i++, array);
10664
- }
10665
-
10666
- while (d--) {
10667
- proc(array[i], i++, array);
10668
- proc(array[i], i++, array);
10669
- proc(array[i], i++, array);
10670
- proc(array[i], i++, array);
10671
- proc(array[i], i++, array);
10672
- proc(array[i], i++, array);
10673
- proc(array[i], i++, array);
10674
- proc(array[i], i++, array);
10675
- }
10676
- }
10677
-
10678
- exports.duffEach = duffEach; // ベンチマークの10,000以上で急激な速度低下が見られる場合があるがNodeListなどでの
10679
- // 実際の使用では速度低下は見られない
10680
-
10681
- function duffReduce(array, proc, initial) {
10682
- let count = array.length;
10683
- let i = 0,
10684
- m = count & 7,
10685
- d = (count - m) / 8;
10686
- let acc = initial;
10687
-
10688
- while (m--) {
10689
- acc = proc(acc, array[i], i++, array);
10690
- }
10691
-
10692
- while (d--) {
10693
- acc = proc(acc, array[i], i++, array);
10694
- acc = proc(acc, array[i], i++, array);
10695
- acc = proc(acc, array[i], i++, array);
10696
- acc = proc(acc, array[i], i++, array);
10697
- acc = proc(acc, array[i], i++, array);
10698
- acc = proc(acc, array[i], i++, array);
10699
- acc = proc(acc, array[i], i++, array);
10700
- acc = proc(acc, array[i], i++, array);
10701
- }
10702
-
10703
- return acc;
10704
- }
10705
-
10706
- exports.duffReduce = duffReduce;
10707
-
10708
- /***/ }),
10709
-
10710
- /***/ 128:
10711
- /***/ ((module, __unused_webpack_exports, __nested_webpack_require_3627__) => {
10712
-
10713
-
10714
-
10715
- __nested_webpack_require_3627__(921);
10716
-
10717
- const global = void 0 || typeof globalThis !== 'undefined' && globalThis // @ts-ignore
10718
- || typeof self !== 'undefined' && self || Function('return this')();
10719
- global.global = global;
10720
- module.exports = global;
10721
-
10722
- /***/ }),
10723
-
10724
- /***/ 921:
10725
- /***/ (() => {
10726
-
10727
- // @ts-ignore
10728
-
10729
- var globalThis; // @ts-ignore
10730
-
10731
- var global = (/* unused pure expression or super */ null && (0));
10732
-
10733
- /***/ })
10734
-
10735
- /******/ });
10736
- /************************************************************************/
10737
- /******/ // The module cache
10738
- /******/ var __webpack_module_cache__ = {};
10739
- /******/
10740
- /******/ // The require function
10741
- /******/ function __nested_webpack_require_4279__(moduleId) {
10742
- /******/ // Check if module is in cache
10743
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
10744
- /******/ if (cachedModule !== undefined) {
10745
- /******/ return cachedModule.exports;
10746
- /******/ }
10747
- /******/ // Create a new module (and put it into the cache)
10748
- /******/ var module = __webpack_module_cache__[moduleId] = {
10749
- /******/ // no module.id needed
10750
- /******/ // no module.loaded needed
10751
- /******/ exports: {}
10752
- /******/ };
10753
- /******/
10754
- /******/ // Execute the module function
10755
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_4279__);
10756
- /******/
10757
- /******/ // Return the exports of the module
10758
- /******/ return module.exports;
10759
- /******/ }
10760
- /******/
10761
- /************************************************************************/
10762
10573
  var __webpack_exports__ = {};
10763
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
10574
+ // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
10764
10575
  (() => {
10765
10576
  var exports = __webpack_exports__;
10766
10577
 
@@ -10770,10 +10581,6 @@ Object.defineProperty(exports, "__esModule", ({
10770
10581
  }));
10771
10582
  exports.querySelectorAll = exports.querySelectorAllWith = exports.querySelectorWith = void 0;
10772
10583
 
10773
- const global_1 = __nested_webpack_require_4279__(128);
10774
-
10775
- const duff_1 = __nested_webpack_require_4279__(99);
10776
-
10777
10584
  function querySelectorWith(node, selector) {
10778
10585
  return 'matches' in node && node.matches(selector) ? node : node.querySelector(selector);
10779
10586
  }
@@ -10787,13 +10594,23 @@ function querySelectorAllWith(node, selector) {
10787
10594
  acc.push(node);
10788
10595
  }
10789
10596
 
10790
- return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, el) => (acc.push(el), acc), acc);
10597
+ for (let es = node.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10598
+ acc.push(es[i]);
10599
+ }
10600
+
10601
+ return acc;
10791
10602
  }
10792
10603
 
10793
10604
  exports.querySelectorAllWith = querySelectorAllWith;
10794
10605
 
10795
10606
  function querySelectorAll(node, selector) {
10796
- return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, el) => (acc.push(el), acc), (0, global_1.Array)());
10607
+ const acc = [];
10608
+
10609
+ for (let es = node.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10610
+ acc.push(es[i]);
10611
+ }
10612
+
10613
+ return acc;
10797
10614
  }
10798
10615
 
10799
10616
  exports.querySelectorAll = querySelectorAll;