@but212/atom-effect-jquery 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import u from "jquery";
2
- import { default as Ot } from "jquery";
3
- const je = {
2
+ import { default as wt } from "jquery";
3
+ const Be = {
4
4
  /** One second in milliseconds */
5
5
  ONE_SECOND_MS: 1e3
6
- }, oe = {
6
+ }, ce = {
7
7
  IDLE: "idle",
8
8
  PENDING: "pending",
9
9
  RESOLVED: "resolved",
@@ -48,12 +48,12 @@ const je = {
48
48
  MAX_FLUSH_ITERATIONS: 1e3,
49
49
  /** Minimum allowed value for max flush iterations */
50
50
  MIN_FLUSH_ITERATIONS: 10
51
- }, ye = {
51
+ }, Se = {
52
52
  /** Maximum dependencies before warning about large dependency graphs */
53
53
  MAX_DEPENDENCIES: 1e3,
54
54
  /** Enable infinite loop detection warnings */
55
55
  WARN_INFINITE_LOOP: !0
56
- }, F = 1073741823, fe = 1 << 19, C = typeof process < "u" && process.env && process.env.NODE_ENV !== "production", Be = Object.freeze([]);
56
+ }, F = 1073741823, qe = 20, de = 1 << qe - 1, C = typeof process < "u" && process.env && process.env.NODE_ENV !== "production", ze = Object.freeze([]);
57
57
  class U extends Error {
58
58
  /**
59
59
  * Creates a new AtomError
@@ -147,16 +147,16 @@ const b = {
147
147
  * @remarks This prevents cascading failures from masking the original error.
148
148
  */
149
149
  CALLBACK_ERROR_IN_ERROR_HANDLER: "Error occurred during onError callback execution"
150
- }, ae = /* @__PURE__ */ Symbol("debugName"), qe = /* @__PURE__ */ Symbol("id"), le = /* @__PURE__ */ Symbol("type"), Se = /* @__PURE__ */ Symbol("noDefaultValue");
151
- function ze(t) {
150
+ }, le = /* @__PURE__ */ Symbol("debugName"), Qe = /* @__PURE__ */ Symbol("id"), fe = /* @__PURE__ */ Symbol("type"), De = /* @__PURE__ */ Symbol("noDefaultValue");
151
+ function $e(t) {
152
152
  return "dependencies" in t && Array.isArray(t.dependencies);
153
153
  }
154
- let De = 0;
154
+ let Ie = 0;
155
155
  function ve(t, e, s) {
156
156
  if (t._visitedEpoch !== s) {
157
157
  if (t._visitedEpoch = s, t === e)
158
158
  throw new B("Indirect circular dependency detected");
159
- if (ze(t)) {
159
+ if ($e(t)) {
160
160
  const n = t.dependencies;
161
161
  for (let i = 0; i < n.length; i++) {
162
162
  const r = n[i];
@@ -165,10 +165,10 @@ function ve(t, e, s) {
165
165
  }
166
166
  }
167
167
  }
168
- const N = {
168
+ const v = {
169
169
  enabled: typeof process < "u" && process.env?.NODE_ENV === "development",
170
- maxDependencies: ye.MAX_DEPENDENCIES,
171
- warnInfiniteLoop: ye.WARN_INFINITE_LOOP,
170
+ maxDependencies: Se.MAX_DEPENDENCIES,
171
+ warnInfiniteLoop: Se.WARN_INFINITE_LOOP,
172
172
  warn(t, e) {
173
173
  this.enabled && t && console.warn(`[Atom Effect] ${e}`);
174
174
  },
@@ -180,28 +180,28 @@ const N = {
180
180
  checkCircular(t, e) {
181
181
  if (t === e)
182
182
  throw new B("Direct circular dependency detected");
183
- this.enabled && (De++, ve(t, e, De));
183
+ this.enabled && (Ie++, ve(t, e, Ie));
184
184
  },
185
185
  attachDebugInfo(t, e, s) {
186
186
  if (!this.enabled)
187
187
  return;
188
188
  const n = t;
189
- n[ae] = `${e}_${s}`, n[qe] = s, n[le] = e;
189
+ n[le] = `${e}_${s}`, n[Qe] = s, n[fe] = e;
190
190
  },
191
191
  getDebugName(t) {
192
- if (t != null && ae in t)
193
- return t[ae];
194
- },
195
- getDebugType(t) {
196
192
  if (t != null && le in t)
197
193
  return t[le];
194
+ },
195
+ getDebugType(t) {
196
+ if (t != null && fe in t)
197
+ return t[fe];
198
198
  }
199
199
  };
200
- let Qe = 1;
201
- const $e = () => Qe++;
202
- class Ne {
200
+ let Xe = 1;
201
+ const He = () => Xe++;
202
+ class Ae {
203
203
  constructor() {
204
- this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = $e() & F;
204
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = He() & F;
205
205
  }
206
206
  /**
207
207
  * Rotates the phase by 1, automatically incrementing cycle on overflow.
@@ -243,7 +243,7 @@ class Ne {
243
243
  return this.version - e & F;
244
244
  }
245
245
  }
246
- class Ae extends Ne {
246
+ class Re extends Ae {
247
247
  /**
248
248
  * Subscribes a listener function or Subscriber object to value changes.
249
249
  *
@@ -310,26 +310,138 @@ class Ae extends Ne {
310
310
  }
311
311
  }
312
312
  }
313
- let se = 0;
314
- function Re() {
315
- return se = se + 1 & F || 1, se;
313
+ class pe {
314
+ constructor() {
315
+ this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = C ? {
316
+ acquired: 0,
317
+ released: 0,
318
+ rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
319
+ } : null;
320
+ }
321
+ /** Acquires an array from the pool or creates a new one if the pool is empty. */
322
+ acquire() {
323
+ return C && this.stats && this.stats.acquired++, this.pool.pop() ?? [];
324
+ }
325
+ /**
326
+ * Releases an array back to the pool.
327
+ * Clears the array before storing it.
328
+ * @param arr - The array to release.
329
+ * @param emptyConst - Optional reference to a constant empty array to skip.
330
+ */
331
+ release(e, s) {
332
+ if (!(s && e === s)) {
333
+ if (Object.isFrozen(e)) {
334
+ C && this.stats && this.stats.rejected.frozen++;
335
+ return;
336
+ }
337
+ if (e.length > this.maxReusableCapacity) {
338
+ C && this.stats && this.stats.rejected.tooLarge++;
339
+ return;
340
+ }
341
+ if (this.pool.length >= this.maxPoolSize) {
342
+ C && this.stats && this.stats.rejected.poolFull++;
343
+ return;
344
+ }
345
+ e.length = 0, this.pool.push(e), C && this.stats && this.stats.released++;
346
+ }
347
+ }
348
+ /** Returns current stats for the pool (dev mode only). */
349
+ getStats() {
350
+ if (!C || !this.stats) return null;
351
+ const { acquired: e, released: s, rejected: n } = this.stats, i = n.frozen + n.tooLarge + n.poolFull;
352
+ return {
353
+ acquired: e,
354
+ released: s,
355
+ rejected: n,
356
+ leaked: e - s - i,
357
+ poolSize: this.pool.length
358
+ };
359
+ }
360
+ /** Resets the pool and its stats. */
361
+ reset() {
362
+ this.pool.length = 0, C && this.stats && (this.stats.acquired = 0, this.stats.released = 0, this.stats.rejected = { frozen: 0, tooLarge: 0, poolFull: 0 });
363
+ }
364
+ }
365
+ const y = Object.freeze([]), N = Object.freeze([]), S = Object.freeze([]), w = new pe(), z = new pe(), T = new pe();
366
+ function _e(t) {
367
+ return t !== null && typeof t == "object" && "value" in t && "subscribe" in t && typeof t.subscribe == "function";
316
368
  }
317
- function Xe() {
318
- return se;
369
+ function Ce(t) {
370
+ if (v.enabled && (t == null || typeof t == "object")) {
371
+ const e = v.getDebugType(t);
372
+ if (e)
373
+ return e === "computed";
374
+ }
375
+ return _e(t) && "invalidate" in t && typeof t.invalidate == "function";
376
+ }
377
+ function Oe(t) {
378
+ return t != null && typeof t.then == "function";
379
+ }
380
+ function Ge(t) {
381
+ return typeof t == "object" && t !== null;
382
+ }
383
+ function Ye(t) {
384
+ return (typeof t == "object" || typeof t == "function") && t !== null && typeof t.addDependency == "function";
385
+ }
386
+ function Je(t) {
387
+ return typeof t == "function" && typeof t.addDependency != "function";
319
388
  }
320
- let ie = 0, _e = 0, re = !1;
321
- function Ie() {
322
- return re ? (C && console.warn(
389
+ function Ke(t) {
390
+ return Ge(t) && typeof t.execute == "function";
391
+ }
392
+ function Ue(t, e, s, n) {
393
+ if (e) {
394
+ if (Ye(e)) {
395
+ e.addDependency(t);
396
+ return;
397
+ }
398
+ if (Je(e)) {
399
+ const i = e;
400
+ s.indexOf(i) === -1 && s.push(i);
401
+ return;
402
+ }
403
+ Ke(e) && n.indexOf(e) === -1 && n.push(e);
404
+ }
405
+ }
406
+ function We(t, e, s, n) {
407
+ if (e !== y && s !== N)
408
+ for (let r = 0; r < e.length; r++) {
409
+ const o = e[r];
410
+ o && (o._tempUnsub = s[r]);
411
+ }
412
+ const i = z.acquire();
413
+ i.length = t.length;
414
+ for (let r = 0; r < t.length; r++) {
415
+ const o = t[r];
416
+ o && (o._tempUnsub ? (i[r] = o._tempUnsub, o._tempUnsub = void 0) : (v.checkCircular(o, n), i[r] = o.subscribe(n)));
417
+ }
418
+ if (e !== y)
419
+ for (let r = 0; r < e.length; r++) {
420
+ const o = e[r];
421
+ o?._tempUnsub && (o._tempUnsub(), o._tempUnsub = void 0);
422
+ }
423
+ return s !== N && z.release(s), i;
424
+ }
425
+ let ne = 0;
426
+ function we() {
427
+ return ne = ne + 1 & F || 1, ne;
428
+ }
429
+ function Ze() {
430
+ return ne;
431
+ }
432
+ let re = 0, ge = 0, oe = !1;
433
+ function xe() {
434
+ return oe ? (C && console.warn(
323
435
  "Warning: startFlush() called during flush - ignored to prevent infinite loop detection bypass"
324
- ), !1) : (re = !0, ie = ie + 1 & F, _e = 0, !0);
436
+ ), !1) : (oe = !0, re = re + 1 & F, ge = 0, !0);
325
437
  }
326
- function Ce() {
327
- re = !1;
438
+ function Ne() {
439
+ oe = !1;
328
440
  }
329
- function He() {
330
- return re ? ++_e : 0;
441
+ function et() {
442
+ return oe ? ++ge : 0;
331
443
  }
332
- class Ge {
444
+ class tt {
333
445
  constructor() {
334
446
  this.queueA = [], this.queueB = [], this.queue = this.queueA, this.queueSize = 0, this.urgentQueueA = [], this.urgentQueueB = [], this.urgentQueue = this.urgentQueueA, this.urgentQueueSize = 0, this._epoch = 0, this.isProcessing = !1, this.isBatching = !1, this.batchDepth = 0, this.batchQueue = [], this.batchQueueSize = 0, this.isFlushingSync = !1, this.maxFlushIterations = q.MAX_FLUSH_ITERATIONS;
335
447
  }
@@ -375,14 +487,14 @@ class Ge {
375
487
  if (!s || e._cachedVersion === void 0)
376
488
  return 0;
377
489
  const n = s.getShift(e._cachedVersion);
378
- return fe - 1 - n >>> 31 & 1;
490
+ return de - 1 - n >>> 31 & 1;
379
491
  }
380
492
  flush() {
381
493
  this.isProcessing || this.queueSize === 0 && this.urgentQueueSize === 0 || (this.isProcessing = !0, queueMicrotask(() => {
382
494
  try {
383
495
  if (this.queueSize === 0 && this.urgentQueueSize === 0) return;
384
- const e = Ie();
385
- this._drainQueue(), e && Ce();
496
+ const e = xe();
497
+ this._drainQueue(), e && Ne();
386
498
  } finally {
387
499
  this.isProcessing = !1, (this.queueSize > 0 || this.urgentQueueSize > 0) && !this.isBatching && this.flush();
388
500
  }
@@ -390,11 +502,11 @@ class Ge {
390
502
  }
391
503
  flushSync() {
392
504
  this.isFlushingSync = !0;
393
- const e = Ie();
505
+ const e = xe();
394
506
  try {
395
507
  this._mergeBatchQueue(), this._drainQueue();
396
508
  } finally {
397
- this.isFlushingSync = !1, e && Ce();
509
+ this.isFlushingSync = !1, e && Ne();
398
510
  }
399
511
  }
400
512
  _mergeBatchQueue() {
@@ -482,18 +594,8 @@ class Ge {
482
594
  this.maxFlushIterations = e;
483
595
  }
484
596
  }
485
- const W = new Ge();
486
- function Ye(t) {
487
- if (typeof t != "function")
488
- throw new U("Batch callback must be a function");
489
- W.startBatch();
490
- try {
491
- return t();
492
- } finally {
493
- W.endBatch();
494
- }
495
- }
496
- class Je {
597
+ const W = new tt();
598
+ class st {
497
599
  constructor() {
498
600
  this.current = null;
499
601
  }
@@ -520,8 +622,8 @@ class Je {
520
622
  return this.current;
521
623
  }
522
624
  }
523
- const Q = new Je();
524
- function Oe(t) {
625
+ const Q = new st();
626
+ function Fe(t) {
525
627
  if (typeof t != "function")
526
628
  throw new U("Untracked callback must be a function");
527
629
  const e = Q.current;
@@ -532,121 +634,9 @@ function Oe(t) {
532
634
  Q.current = e;
533
635
  }
534
636
  }
535
- class pe {
536
- constructor() {
537
- this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = C ? {
538
- acquired: 0,
539
- released: 0,
540
- rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
541
- } : null;
542
- }
543
- /** Acquires an array from the pool or creates a new one if the pool is empty. */
544
- acquire() {
545
- return C && this.stats && this.stats.acquired++, this.pool.pop() ?? [];
546
- }
547
- /**
548
- * Releases an array back to the pool.
549
- * Clears the array before storing it.
550
- * @param arr - The array to release.
551
- * @param emptyConst - Optional reference to a constant empty array to skip.
552
- */
553
- release(e, s) {
554
- if (!(s && e === s)) {
555
- if (Object.isFrozen(e)) {
556
- C && this.stats && this.stats.rejected.frozen++;
557
- return;
558
- }
559
- if (e.length > this.maxReusableCapacity) {
560
- C && this.stats && this.stats.rejected.tooLarge++;
561
- return;
562
- }
563
- if (this.pool.length >= this.maxPoolSize) {
564
- C && this.stats && this.stats.rejected.poolFull++;
565
- return;
566
- }
567
- e.length = 0, this.pool.push(e), C && this.stats && this.stats.released++;
568
- }
569
- }
570
- /** Returns current stats for the pool (dev mode only). */
571
- getStats() {
572
- if (!C || !this.stats) return null;
573
- const { acquired: e, released: s, rejected: n } = this.stats, i = n.frozen + n.tooLarge + n.poolFull;
574
- return {
575
- acquired: e,
576
- released: s,
577
- rejected: n,
578
- leaked: e - s - i,
579
- poolSize: this.pool.length
580
- };
581
- }
582
- /** Resets the pool and its stats. */
583
- reset() {
584
- this.pool.length = 0, C && this.stats && (this.stats.acquired = 0, this.stats.released = 0, this.stats.rejected = { frozen: 0, tooLarge: 0, poolFull: 0 });
585
- }
586
- }
587
- const y = Object.freeze([]), T = Object.freeze([]), S = Object.freeze([]), w = new pe(), z = new pe(), v = new pe();
588
- function de(t) {
589
- return t !== null && typeof t == "object" && "value" in t && "subscribe" in t && typeof t.subscribe == "function";
590
- }
591
- function xe(t) {
592
- if (N.enabled && (t == null || typeof t == "object")) {
593
- const e = N.getDebugType(t);
594
- if (e)
595
- return e === "computed";
596
- }
597
- return de(t) && "invalidate" in t && typeof t.invalidate == "function";
598
- }
599
- function Ue(t) {
600
- return t != null && typeof t.then == "function";
601
- }
602
- function Ke(t) {
603
- return typeof t == "object" && t !== null;
604
- }
605
- function We(t) {
606
- return (typeof t == "object" || typeof t == "function") && t !== null && typeof t.addDependency == "function";
607
- }
608
- function Ze(t) {
609
- return typeof t == "function" && typeof t.addDependency != "function";
610
- }
611
- function et(t) {
612
- return Ke(t) && typeof t.execute == "function";
613
- }
614
- function we(t, e, s, n) {
615
- if (e) {
616
- if (We(e)) {
617
- e.addDependency(t);
618
- return;
619
- }
620
- if (Ze(e)) {
621
- const i = e;
622
- s.indexOf(i) === -1 && s.push(i);
623
- return;
624
- }
625
- et(e) && n.indexOf(e) === -1 && n.push(e);
626
- }
627
- }
628
- function tt(t, e, s, n) {
629
- if (e !== y && s !== T)
630
- for (let r = 0; r < e.length; r++) {
631
- const o = e[r];
632
- o && (o._tempUnsub = s[r]);
633
- }
634
- const i = z.acquire();
635
- i.length = t.length;
636
- for (let r = 0; r < t.length; r++) {
637
- const o = t[r];
638
- o && (o._tempUnsub ? (i[r] = o._tempUnsub, o._tempUnsub = void 0) : (N.checkCircular(o, n), i[r] = o.subscribe(n)));
639
- }
640
- if (e !== y)
641
- for (let r = 0; r < e.length; r++) {
642
- const o = e[r];
643
- o?._tempUnsub && (o._tempUnsub(), o._tempUnsub = void 0);
644
- }
645
- return s !== T && z.release(s), i;
646
- }
647
- class st extends Ae {
637
+ class nt extends Re {
648
638
  constructor(e, s) {
649
- super(), this._fnSubs = null, this._objSubs = null, this._value = e, s && (this.flags |= G.SYNC), N.attachDebugInfo(this, "atom", this.id);
639
+ super(), this._fnSubs = null, this._objSubs = null, this._value = e, s && (this.flags |= G.SYNC), v.attachDebugInfo(this, "atom", this.id);
650
640
  }
651
641
  _getFnSubs() {
652
642
  return this._fnSubs ??= [], this._fnSubs;
@@ -659,7 +649,7 @@ class st extends Ae {
659
649
  */
660
650
  get value() {
661
651
  const e = Q.current;
662
- return e && we(this, e, this._getFnSubs(), this._getObjSubs()), this._value;
652
+ return e && Ue(this, e, this._getFnSubs(), this._getObjSubs()), this._value;
663
653
  }
664
654
  /**
665
655
  * Sets a new value and schedules notifications if the value has changed.
@@ -691,8 +681,8 @@ class st extends Ae {
691
681
  this._fnSubs = null, this._objSubs = null, this._value = void 0, this._notifyTask = void 0;
692
682
  }
693
683
  }
694
- function nt(t, e = {}) {
695
- return new st(t, e.sync ?? !1);
684
+ function it(t, e = {}) {
685
+ return new nt(t, e.sync ?? !1);
696
686
  }
697
687
  function J(t, e, s) {
698
688
  if (t instanceof TypeError)
@@ -704,15 +694,15 @@ function J(t, e, s) {
704
694
  const n = t instanceof Error ? t.message : String(t), i = t instanceof Error ? t : null;
705
695
  return new e(`Unexpected error (${s}): ${n}`, i);
706
696
  }
707
- const Fe = l.RESOLVED | l.PENDING | l.REJECTED, ce = Array(Fe + 1).fill(oe.IDLE);
708
- ce[l.RESOLVED] = oe.RESOLVED;
709
- ce[l.PENDING] = oe.PENDING;
710
- ce[l.REJECTED] = oe.REJECTED;
711
- class ke extends Ae {
697
+ const ke = l.RESOLVED | l.PENDING | l.REJECTED, ue = Array(ke + 1).fill(ce.IDLE);
698
+ ue[l.RESOLVED] = ce.RESOLVED;
699
+ ue[l.PENDING] = ce.PENDING;
700
+ ue[l.REJECTED] = ce.REJECTED;
701
+ class Le extends Re {
712
702
  constructor(e, s = {}) {
713
703
  if (typeof e != "function")
714
704
  throw new B(b.COMPUTED_MUST_BE_FUNCTION);
715
- if (super(), this._fnSubs = null, this._objSubs = null, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this.MAX_ASYNC_RETRIES = 3, this._value = void 0, this.flags = l.DIRTY | l.IDLE, this._error = null, this._promiseId = 0, this._equal = s.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in s ? s.defaultValue : Se, this._hasDefaultValue = this._defaultValue !== Se, this._onError = s.onError ?? null, this.MAX_PROMISE_ID = Number.MAX_SAFE_INTEGER - 1, this._dependencies = y, this._dependencyVersions = S, this._unsubscribes = T, this._notifyJob = () => {
705
+ if (super(), this._fnSubs = null, this._objSubs = null, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this.MAX_ASYNC_RETRIES = 3, this._value = void 0, this.flags = l.DIRTY | l.IDLE, this._error = null, this._promiseId = 0, this._equal = s.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in s ? s.defaultValue : De, this._hasDefaultValue = this._defaultValue !== De, this._onError = s.onError ?? null, this.MAX_PROMISE_ID = Number.MAX_SAFE_INTEGER - 1, this._dependencies = y, this._dependencyVersions = S, this._unsubscribes = N, this._notifyJob = () => {
716
706
  const n = this._fnSubs;
717
707
  if (n)
718
708
  for (let r = n.length - 1; r >= 0; r--)
@@ -734,7 +724,7 @@ class ke extends Ae {
734
724
  }, this._trackable = Object.assign(() => this._markDirty(), {
735
725
  addDependency: (n) => {
736
726
  }
737
- }), N.attachDebugInfo(this, "computed", this.id), N.enabled) {
727
+ }), v.attachDebugInfo(this, "computed", this.id), v.enabled) {
738
728
  const n = this;
739
729
  n.subscriberCount = this.subscriberCount.bind(this), n.isDirty = () => this._isDirty(), n.dependencies = this._dependencies, n.stateFlags = this._getFlagsAsString();
740
730
  }
@@ -774,8 +764,8 @@ class ke extends Ae {
774
764
  }
775
765
  get errors() {
776
766
  if (this._registerTracking(), !this.hasError)
777
- return Be;
778
- const e = Xe();
767
+ return ze;
768
+ const e = Ze();
779
769
  if (this._errorCacheEpoch === e && this._cachedErrors !== null)
780
770
  return this._cachedErrors;
781
771
  const s = /* @__PURE__ */ new Set();
@@ -802,17 +792,17 @@ class ke extends Ae {
802
792
  return this._registerTracking(), this._isResolved();
803
793
  }
804
794
  invalidate() {
805
- this._markDirty(), this._dependencyVersions !== S && (v.release(this._dependencyVersions), this._dependencyVersions = S), this._errorCacheEpoch = -1, this._cachedErrors = null;
795
+ this._markDirty(), this._dependencyVersions !== S && (T.release(this._dependencyVersions), this._dependencyVersions = S), this._errorCacheEpoch = -1, this._cachedErrors = null;
806
796
  }
807
797
  dispose() {
808
- if (this._unsubscribes !== T) {
798
+ if (this._unsubscribes !== N) {
809
799
  for (let e = 0; e < this._unsubscribes.length; e++) {
810
800
  const s = this._unsubscribes[e];
811
801
  s && s();
812
802
  }
813
- z.release(this._unsubscribes), this._unsubscribes = T;
803
+ z.release(this._unsubscribes), this._unsubscribes = N;
814
804
  }
815
- this._dependencies !== y && (w.release(this._dependencies), this._dependencies = y), this._dependencyVersions !== S && (v.release(this._dependencyVersions), this._dependencyVersions = S), this._fnSubs = null, this._objSubs = null, this.flags = l.DIRTY | l.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % this.MAX_PROMISE_ID, this._cachedErrors = null, this._errorCacheEpoch = -1;
805
+ this._dependencies !== y && (w.release(this._dependencies), this._dependencies = y), this._dependencyVersions !== S && (T.release(this._dependencyVersions), this._dependencyVersions = S), this._fnSubs = null, this._objSubs = null, this.flags = l.DIRTY | l.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % this.MAX_PROMISE_ID, this._cachedErrors = null, this._errorCacheEpoch = -1;
816
806
  }
817
807
  // State flag operations
818
808
  _isDirty() {
@@ -856,7 +846,7 @@ class ke extends Ae {
856
846
  this.flags = this.flags & ~s | -Number(e) & s;
857
847
  }
858
848
  _getAsyncState() {
859
- return ce[this.flags & Fe];
849
+ return ue[this.flags & ke];
860
850
  }
861
851
  _getFlagsAsString() {
862
852
  const e = [];
@@ -872,7 +862,7 @@ class ke extends Ae {
872
862
  let s = !1;
873
863
  try {
874
864
  const n = Q.run(this._trackable, this._fn);
875
- this._commitDependencies(e), s = !0, Ue(n) ? this._handleAsyncComputation(n) : this._handleSyncResult(n);
865
+ this._commitDependencies(e), s = !0, Oe(n) ? this._handleAsyncComputation(n) : this._handleSyncResult(n);
876
866
  } catch (n) {
877
867
  if (!s)
878
868
  try {
@@ -886,17 +876,17 @@ class ke extends Ae {
886
876
  }
887
877
  }
888
878
  _prepareComputationContext() {
889
- const e = this._dependencies, s = this._dependencyVersions, n = w.acquire(), i = v.acquire(), r = Re(), o = { depCount: 0 }, c = (f) => {
890
- f._lastSeenEpoch !== r && (f._lastSeenEpoch = r, o.depCount < n.length ? (n[o.depCount] = f, i[o.depCount] = f.version) : (n.push(f), i.push(f.version)), o.depCount++);
879
+ const e = this._dependencies, s = this._dependencyVersions, n = w.acquire(), i = T.acquire(), r = we(), o = { depCount: 0 }, c = (d) => {
880
+ d._lastSeenEpoch !== r && (d._lastSeenEpoch = r, o.depCount < n.length ? (n[o.depCount] = d, i[o.depCount] = d.version) : (n.push(d), i.push(d.version)), o.depCount++);
891
881
  }, h = this._trackable.addDependency;
892
882
  return this._trackable.addDependency = c, { prevDeps: e, prevVersions: s, nextDeps: n, nextVersions: i, originalAdd: h, state: o };
893
883
  }
894
884
  _commitDependencies(e) {
895
885
  const { nextDeps: s, nextVersions: n, state: i, prevDeps: r } = e;
896
- s.length = i.depCount, n.length = i.depCount, this._unsubscribes = tt(s, r, this._unsubscribes, this), this._dependencies = s, this._dependencyVersions = n;
886
+ s.length = i.depCount, n.length = i.depCount, this._unsubscribes = We(s, r, this._unsubscribes, this), this._dependencies = s, this._dependencyVersions = n;
897
887
  }
898
888
  _cleanupContext(e, s) {
899
- this._trackable.addDependency = e.originalAdd, s ? (e.prevDeps !== y && w.release(e.prevDeps), e.prevVersions !== S && v.release(e.prevVersions)) : (w.release(e.nextDeps), v.release(e.nextVersions));
889
+ this._trackable.addDependency = e.originalAdd, s ? (e.prevDeps !== y && w.release(e.prevDeps), e.prevVersions !== S && T.release(e.prevVersions)) : (w.release(e.nextDeps), T.release(e.nextVersions));
900
890
  }
901
891
  /**
902
892
  * Calculates aggregate shift from all dependencies.
@@ -923,7 +913,7 @@ class ke extends Ae {
923
913
  * @returns true if aggregate shift exceeds PHASE_THRESHOLD
924
914
  */
925
915
  isUrgent() {
926
- return this._getAggregateShift() >= fe;
916
+ return this._getAggregateShift() >= de;
927
917
  }
928
918
  _handleSyncResult(e) {
929
919
  this._finalizeResolution(e);
@@ -934,7 +924,7 @@ class ke extends Ae {
934
924
  e.then((n) => {
935
925
  if (s !== this._promiseId) return;
936
926
  const i = this._captureVersionSnapshot() - this._asyncStartAggregateVersion & F;
937
- if (fe - 1 - i >>> 31 & 1) {
927
+ if (de - 1 - i >>> 31 & 1) {
938
928
  if (this._asyncRetryCount < this.MAX_ASYNC_RETRIES) {
939
929
  this._asyncRetryCount++, this._markDirty();
940
930
  return;
@@ -1013,14 +1003,14 @@ class ke extends Ae {
1013
1003
  this._isRecomputing() || this._isDirty() || (this._setDirty(), this._notifyJob());
1014
1004
  }
1015
1005
  _registerTracking() {
1016
- we(this, Q.getCurrent(), this._getFnSubs(), this._getObjSubs());
1006
+ Ue(this, Q.getCurrent(), this._getFnSubs(), this._getObjSubs());
1017
1007
  }
1018
1008
  }
1019
- Object.freeze(ke.prototype);
1020
- function it(t, e = {}) {
1021
- return new ke(t, e);
1009
+ Object.freeze(Le.prototype);
1010
+ function rt(t, e = {}) {
1011
+ return new Le(t, e);
1022
1012
  }
1023
- class rt extends Ne {
1013
+ class ot extends Ae {
1024
1014
  /**
1025
1015
  * Creates a new EffectImpl instance.
1026
1016
  * @param fn - The effect function to run.
@@ -1030,17 +1020,17 @@ class rt extends Ne {
1030
1020
  super(), this.run = () => {
1031
1021
  if (this.isDisposed)
1032
1022
  throw new j(b.EFFECT_MUST_BE_FUNCTION);
1033
- this._dependencyVersions !== S && (v.release(this._dependencyVersions), this._dependencyVersions = S), this.execute();
1023
+ this._dependencyVersions !== S && (T.release(this._dependencyVersions), this._dependencyVersions = S), this.execute();
1034
1024
  }, this.dispose = () => {
1035
1025
  if (!this.isDisposed) {
1036
- if (this._setDisposed(), this._safeCleanup(), this._unsubscribes !== T) {
1026
+ if (this._setDisposed(), this._safeCleanup(), this._unsubscribes !== N) {
1037
1027
  for (let i = 0; i < this._unsubscribes.length; i++) {
1038
1028
  const r = this._unsubscribes[i];
1039
1029
  r && r();
1040
1030
  }
1041
- z.release(this._unsubscribes), this._unsubscribes = T;
1031
+ z.release(this._unsubscribes), this._unsubscribes = N;
1042
1032
  }
1043
- this._dependencies !== y && (w.release(this._dependencies), this._dependencies = y), this._dependencyVersions !== S && (v.release(this._dependencyVersions), this._dependencyVersions = S);
1033
+ this._dependencies !== y && (w.release(this._dependencies), this._dependencies = y), this._dependencyVersions !== S && (T.release(this._dependencyVersions), this._dependencyVersions = S);
1044
1034
  }
1045
1035
  }, this.addDependency = (i) => {
1046
1036
  if (this.isExecuting && this._nextDeps && this._nextUnsubs && this._nextVersions) {
@@ -1055,7 +1045,7 @@ class rt extends Ne {
1055
1045
  let r = !1;
1056
1046
  try {
1057
1047
  const o = Q.run(this, this._fn);
1058
- this._commitEffect(i), r = !0, this._checkLoopWarnings(), Ue(o) ? o.then((c) => {
1048
+ this._commitEffect(i), r = !0, this._checkLoopWarnings(), Oe(o) ? o.then((c) => {
1059
1049
  !this.isDisposed && typeof c == "function" && (this._cleanup = c);
1060
1050
  }).catch((c) => {
1061
1051
  this._handleExecutionError(c);
@@ -1065,20 +1055,20 @@ class rt extends Ne {
1065
1055
  } finally {
1066
1056
  this._cleanupEffect(i, r), this._setExecuting(!1);
1067
1057
  }
1068
- }, this._cleanup = null, this._dependencies = y, this._dependencyVersions = S, this._unsubscribes = T, this._nextDeps = null, this._nextVersions = null, this._nextUnsubs = null, this._onError = s.onError ?? null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._fn = e, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = s.trackModifications ?? !1, this._historyPtr = 0;
1058
+ }, this._cleanup = null, this._dependencies = y, this._dependencyVersions = S, this._unsubscribes = N, this._nextDeps = null, this._nextVersions = null, this._nextUnsubs = null, this._onError = s.onError ?? null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._fn = e, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = s.trackModifications ?? !1, this._historyPtr = 0;
1069
1059
  const n = Number.isFinite(this._maxExecutions);
1070
- this._historyCapacity = n ? Math.min(this._maxExecutions + 1, q.MAX_EXECUTIONS_PER_SECOND + 1) : 0, this._history = C && n && this._historyCapacity > 0 ? new Array(this._historyCapacity).fill(0) : null, this._executionCount = 0, N.attachDebugInfo(this, "effect", this.id);
1060
+ this._historyCapacity = n ? Math.min(this._maxExecutions + 1, q.MAX_EXECUTIONS_PER_SECOND + 1) : 0, this._history = C && n && this._historyCapacity > 0 ? new Array(this._historyCapacity).fill(0) : null, this._executionCount = 0, v.attachDebugInfo(this, "effect", this.id);
1071
1061
  }
1072
1062
  /**
1073
1063
  * Prepares the execution context by acquiring pools and setting up epoch.
1074
1064
  * @returns The prepared EffectExecutionContext.
1075
1065
  */
1076
1066
  _prepareEffectExecutionContext() {
1077
- const e = this._dependencies, s = this._dependencyVersions, n = this._unsubscribes, i = w.acquire(), r = v.acquire(), o = z.acquire(), c = Re();
1078
- if (e !== y && n !== T)
1067
+ const e = this._dependencies, s = this._dependencyVersions, n = this._unsubscribes, i = w.acquire(), r = T.acquire(), o = z.acquire(), c = we();
1068
+ if (e !== y && n !== N)
1079
1069
  for (let h = 0; h < e.length; h++) {
1080
- const f = e[h];
1081
- f && (f._tempUnsub = n[h]);
1070
+ const d = e[h];
1071
+ d && (d._tempUnsub = n[h]);
1082
1072
  }
1083
1073
  return this._nextDeps = i, this._nextVersions = r, this._nextUnsubs = o, this._currentEpoch = c, { prevDeps: e, prevVersions: s, prevUnsubs: n, nextDeps: i, nextVersions: r, nextUnsubs: o };
1084
1074
  }
@@ -1104,9 +1094,9 @@ class rt extends Ne {
1104
1094
  }
1105
1095
  w.release(e.prevDeps);
1106
1096
  }
1107
- e.prevUnsubs !== T && z.release(e.prevUnsubs), e.prevVersions !== S && v.release(e.prevVersions);
1097
+ e.prevUnsubs !== N && z.release(e.prevUnsubs), e.prevVersions !== S && T.release(e.prevVersions);
1108
1098
  } else {
1109
- w.release(e.nextDeps), v.release(e.nextVersions);
1099
+ w.release(e.nextDeps), T.release(e.nextVersions);
1110
1100
  for (let n = 0; n < e.nextUnsubs.length; n++)
1111
1101
  e.nextUnsubs[n]?.();
1112
1102
  if (z.release(e.nextUnsubs), e.prevDeps !== y)
@@ -1174,11 +1164,11 @@ class rt extends Ne {
1174
1164
  * @throws {EffectError} If an infinite loop is detected.
1175
1165
  */
1176
1166
  _checkInfiniteLoop() {
1177
- if (this._lastFlushEpoch !== ie && (this._lastFlushEpoch = ie, this._executionsInEpoch = 0), this._executionsInEpoch++, this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), He() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history && this._maxExecutions > 0) {
1167
+ if (this._lastFlushEpoch !== re && (this._lastFlushEpoch = re, this._executionsInEpoch = 0), this._executionsInEpoch++, this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), et() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history && this._maxExecutions > 0) {
1178
1168
  const e = Date.now(), s = this._historyPtr, n = this._historyCapacity;
1179
1169
  this._history[s] = e;
1180
1170
  const i = (s + 1) % n, r = this._history[i] ?? 0;
1181
- if (this._historyPtr = i, r > 0 && e - r < je.ONE_SECOND_MS) {
1171
+ if (this._historyPtr = i, r > 0 && e - r < Be.ONE_SECOND_MS) {
1182
1172
  const o = new j(
1183
1173
  `Effect executed ${n} times within 1 second. Infinite loop suspected`
1184
1174
  );
@@ -1189,7 +1179,7 @@ class rt extends Ne {
1189
1179
  }
1190
1180
  _throwInfiniteLoopError(e) {
1191
1181
  const s = new j(
1192
- `Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${_e}`
1182
+ `Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${ge}`
1193
1183
  );
1194
1184
  throw this.dispose(), console.error(s), s;
1195
1185
  }
@@ -1205,7 +1195,7 @@ class rt extends Ne {
1205
1195
  if (s) {
1206
1196
  if ("value" in s)
1207
1197
  try {
1208
- Oe(() => s.value);
1198
+ Fe(() => s.value);
1209
1199
  } catch {
1210
1200
  return !0;
1211
1201
  }
@@ -1228,13 +1218,13 @@ class rt extends Ne {
1228
1218
  * Only active if trackModifications is enabled and debug is on.
1229
1219
  */
1230
1220
  _checkLoopWarnings() {
1231
- if (this._trackModifications && N.enabled) {
1221
+ if (this._trackModifications && v.enabled) {
1232
1222
  const e = this._dependencies;
1233
1223
  for (let s = 0; s < e.length; s++) {
1234
1224
  const n = e[s];
1235
- n && n._modifiedAtEpoch === this._currentEpoch && N.warn(
1225
+ n && n._modifiedAtEpoch === this._currentEpoch && v.warn(
1236
1226
  !0,
1237
- `Effect is reading a dependency (${N.getDebugName(n) || "unknown"}) that it just modified. Infinite loop may occur`
1227
+ `Effect is reading a dependency (${v.getDebugName(n) || "unknown"}) that it just modified. Infinite loop may occur`
1238
1228
  );
1239
1229
  }
1240
1230
  }
@@ -1243,13 +1233,23 @@ class rt extends Ne {
1243
1233
  function $(t, e = {}) {
1244
1234
  if (typeof t != "function")
1245
1235
  throw new j(b.EFFECT_MUST_BE_FUNCTION);
1246
- const s = new rt(t, e);
1236
+ const s = new ot(t, e);
1247
1237
  return s.execute(), s;
1248
1238
  }
1249
- function ot(t) {
1239
+ function ct(t) {
1240
+ if (typeof t != "function")
1241
+ throw new U("Batch callback must be a function");
1242
+ W.startBatch();
1243
+ try {
1244
+ return t();
1245
+ } finally {
1246
+ W.endBatch();
1247
+ }
1248
+ }
1249
+ function ut(t) {
1250
1250
  return t !== null && typeof t == "object" && "value" in t && "subscribe" in t;
1251
1251
  }
1252
- function ue(t) {
1252
+ function he(t) {
1253
1253
  if (!t) return "unknown";
1254
1254
  const e = "jquery" in t ? t[0] : t;
1255
1255
  if (!e) return "unknown";
@@ -1260,7 +1260,31 @@ function ue(t) {
1260
1260
  }
1261
1261
  return e.tagName.toLowerCase();
1262
1262
  }
1263
- function ct() {
1263
+ function ht(t) {
1264
+ const e = t.length;
1265
+ if (e === 0) return new Int32Array(0);
1266
+ const s = new Int32Array(e), n = new Int32Array(e);
1267
+ let i = 0;
1268
+ for (let o = 0; o < e; o++) {
1269
+ const c = t[o];
1270
+ if (c === -1) continue;
1271
+ if (i === 0 || t[n[i - 1]] < c) {
1272
+ s[o] = i > 0 ? n[i - 1] : -1, n[i++] = o;
1273
+ continue;
1274
+ }
1275
+ let h = 0, d = i - 1;
1276
+ for (; h < d; ) {
1277
+ const m = h + d >>> 1;
1278
+ t[n[m]] < c ? h = m + 1 : d = m;
1279
+ }
1280
+ c < t[n[h]] && (h > 0 && (s[o] = n[h - 1]), n[h] = o);
1281
+ }
1282
+ const r = new Int32Array(i);
1283
+ for (let o = i - 1, c = n[i - 1]; o >= 0; o--)
1284
+ r[o] = c, c = s[c];
1285
+ return r;
1286
+ }
1287
+ function at() {
1264
1288
  if (typeof window < "u") {
1265
1289
  const t = window.__ATOM_DEBUG__;
1266
1290
  if (typeof t == "boolean")
@@ -1273,7 +1297,7 @@ function ct() {
1273
1297
  }
1274
1298
  return !1;
1275
1299
  }
1276
- let M = ct();
1300
+ let M = at();
1277
1301
  const g = {
1278
1302
  get enabled() {
1279
1303
  return M;
@@ -1292,8 +1316,8 @@ const g = {
1292
1316
  */
1293
1317
  domUpdated(t, e, s) {
1294
1318
  if (!M) return;
1295
- const n = ue(t);
1296
- console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s), ut(t);
1319
+ const n = he(t);
1320
+ console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s), lt(t);
1297
1321
  },
1298
1322
  cleanup(t) {
1299
1323
  M && console.log(`[atom-effect-jquery] Cleanup: ${t}`);
@@ -1302,7 +1326,7 @@ const g = {
1302
1326
  M && console.warn("[atom-effect-jquery]", ...t);
1303
1327
  }
1304
1328
  };
1305
- function ut(t) {
1329
+ function lt(t) {
1306
1330
  const e = t[0];
1307
1331
  if (!e || !document.contains(e)) return;
1308
1332
  const s = "atom_debug_timer", n = "atom_debug_cleanup_timer", i = "atom_debug_org_style";
@@ -1331,12 +1355,12 @@ function ut(t) {
1331
1355
  }, 100);
1332
1356
  t.data(s, r);
1333
1357
  }
1334
- const ht = /* @__PURE__ */ new WeakMap();
1335
- function Le(t, e = {}) {
1336
- const s = nt(t, e);
1337
- return e.name && ht.set(s, { name: e.name }), s;
1358
+ const ft = /* @__PURE__ */ new WeakMap();
1359
+ function Pe(t, e = {}) {
1360
+ const s = it(t, e);
1361
+ return e.name && ft.set(s, { name: e.name }), s;
1338
1362
  }
1339
- Object.defineProperty(Le, "debug", {
1363
+ Object.defineProperty(Pe, "debug", {
1340
1364
  get() {
1341
1365
  return g.enabled;
1342
1366
  },
@@ -1344,45 +1368,54 @@ Object.defineProperty(Le, "debug", {
1344
1368
  g.enabled = t;
1345
1369
  }
1346
1370
  });
1347
- function at() {
1371
+ function dt() {
1348
1372
  return new Promise((t) => setTimeout(t, 0));
1349
1373
  }
1350
1374
  u.extend({
1351
- atom: Le,
1352
- computed: it,
1375
+ atom: Pe,
1376
+ computed: rt,
1353
1377
  effect: $,
1354
- batch: Ye,
1355
- untracked: Oe,
1356
- isAtom: de,
1357
- isComputed: xe,
1358
- isReactive: (t) => de(t) || xe(t),
1359
- nextTick: at
1378
+ batch: ct,
1379
+ untracked: Fe,
1380
+ isAtom: _e,
1381
+ isComputed: Ce,
1382
+ isReactive: (t) => _e(t) || Ce(t),
1383
+ nextTick: dt
1360
1384
  });
1361
- class lt {
1385
+ const se = "_aes-bound";
1386
+ class _t {
1362
1387
  effects = /* @__PURE__ */ new WeakMap();
1363
1388
  cleanups = /* @__PURE__ */ new WeakMap();
1364
1389
  boundElements = /* @__PURE__ */ new WeakSet();
1365
1390
  preservedNodes = /* @__PURE__ */ new WeakSet();
1391
+ ignoredNodes = /* @__PURE__ */ new WeakSet();
1392
+ // Prevent redundant cleanup
1366
1393
  keep(e) {
1367
1394
  this.preservedNodes.add(e);
1368
1395
  }
1369
1396
  isKept(e) {
1370
1397
  return this.preservedNodes.has(e);
1371
1398
  }
1399
+ markIgnored(e) {
1400
+ this.ignoredNodes.add(e);
1401
+ }
1402
+ isIgnored(e) {
1403
+ return this.ignoredNodes.has(e);
1404
+ }
1372
1405
  trackEffect(e, s) {
1373
1406
  let n = this.effects.get(e);
1374
- n || (n = [], this.effects.set(e, n), this.boundElements.add(e)), n.push(s);
1407
+ n || (n = [], this.effects.set(e, n), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(se))), n.push(s);
1375
1408
  }
1376
1409
  trackCleanup(e, s) {
1377
1410
  let n = this.cleanups.get(e);
1378
- n || (n = [], this.cleanups.set(e, n), this.boundElements.add(e)), n.push(s);
1411
+ n || (n = [], this.cleanups.set(e, n), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(se))), n.push(s);
1379
1412
  }
1380
1413
  hasBind(e) {
1381
1414
  return this.boundElements.has(e);
1382
1415
  }
1383
1416
  cleanup(e) {
1384
1417
  if (!this.boundElements.delete(e)) return;
1385
- g.cleanup(ue(e));
1418
+ e.classList.remove(se), g.cleanup(he(e));
1386
1419
  const s = this.effects.get(e);
1387
1420
  if (s) {
1388
1421
  this.effects.delete(e);
@@ -1410,18 +1443,20 @@ class lt {
1410
1443
  }
1411
1444
  }
1412
1445
  }
1413
- cleanupTree(e) {
1414
- const s = e.querySelectorAll("*");
1446
+ cleanupDescendants(e) {
1447
+ const s = e.querySelectorAll(`.${se}`);
1415
1448
  for (let n = 0, i = s.length; n < i; n++) {
1416
1449
  const r = s[n];
1417
1450
  r && this.boundElements.has(r) && this.cleanup(r);
1418
1451
  }
1419
- this.cleanup(e);
1452
+ }
1453
+ cleanupTree(e) {
1454
+ this.cleanupDescendants(e), this.cleanup(e);
1420
1455
  }
1421
1456
  }
1422
- const d = new lt();
1457
+ const f = new _t();
1423
1458
  let K = null;
1424
- function ft(t = document.body) {
1459
+ function pt(t = document.body) {
1425
1460
  K || (K = new MutationObserver((e) => {
1426
1461
  for (let s = 0, n = e.length; s < n; s++) {
1427
1462
  const i = e[s];
@@ -1429,40 +1464,40 @@ function ft(t = document.body) {
1429
1464
  const r = i.removedNodes;
1430
1465
  for (let o = 0, c = r.length; o < c; o++) {
1431
1466
  const h = r[o];
1432
- h && (d.isKept(h) || h.isConnected || h.nodeType === 1 && d.cleanupTree(h));
1467
+ h && (f.isKept(h) || f.isIgnored(h) || h.isConnected || h.nodeType === 1 && f.cleanupTree(h));
1433
1468
  }
1434
1469
  }
1435
1470
  }), K.observe(t, { childList: !0, subtree: !0 }));
1436
1471
  }
1437
- function vt() {
1472
+ function At() {
1438
1473
  K?.disconnect(), K = null;
1439
1474
  }
1440
1475
  function _(t, e, s, n) {
1441
1476
  const i = u(t), r = t;
1442
- if (ot(e)) {
1477
+ if (ut(e)) {
1443
1478
  const o = $(() => {
1444
1479
  const c = e.value;
1445
1480
  s(c), g.domUpdated(i, n, c);
1446
1481
  });
1447
- d.trackEffect(r, o);
1482
+ f.trackEffect(r, o);
1448
1483
  } else
1449
1484
  s(e);
1450
1485
  }
1451
- function Pe() {
1486
+ function Ve() {
1452
1487
  return { timeoutId: null, phase: "idle", hasFocus: !1 };
1453
1488
  }
1454
- function Ve(t, e, s = {}) {
1489
+ function Me(t, e, s = {}) {
1455
1490
  const {
1456
1491
  debounce: n,
1457
1492
  event: i = "input",
1458
1493
  parse: r = (D) => D,
1459
1494
  format: o = (D) => String(D ?? "")
1460
- } = s, c = Pe(), h = () => {
1495
+ } = s, c = Ve(), h = () => {
1461
1496
  c.phase = "composing";
1462
- }, f = () => {
1497
+ }, d = () => {
1463
1498
  c.phase = "idle", x();
1464
1499
  };
1465
- t.on("compositionstart", h), t.on("compositionend", f);
1500
+ t.on("compositionstart", h), t.on("compositionend", d);
1466
1501
  const m = () => {
1467
1502
  c.hasFocus = !0;
1468
1503
  }, X = () => {
@@ -1484,7 +1519,7 @@ function Ve(t, e, s = {}) {
1484
1519
  c.phase = "syncing-to-dom", t.val(D), g.domUpdated(t, "val", D), c.phase = "idle";
1485
1520
  }
1486
1521
  }, cleanup: () => {
1487
- t.off(i, A), t.off("change", A), t.off("compositionstart", h), t.off("compositionend", f), t.off("focus", m), t.off("blur", X), c.timeoutId && clearTimeout(c.timeoutId);
1522
+ t.off(i, A), t.off("change", A), t.off("compositionstart", h), t.off("compositionend", d), t.off("focus", m), t.off("blur", X), c.timeoutId && clearTimeout(c.timeoutId);
1488
1523
  } };
1489
1524
  }
1490
1525
  u.fn.atomText = function(t, e) {
@@ -1558,8 +1593,8 @@ u.fn.atomHide = function(t) {
1558
1593
  };
1559
1594
  u.fn.atomVal = function(t, e = {}) {
1560
1595
  return this.each(function() {
1561
- const s = u(this), { effect: n, cleanup: i } = Ve(s, t, e), r = $(n);
1562
- d.trackEffect(this, r), d.trackCleanup(this, i);
1596
+ const s = u(this), { effect: n, cleanup: i } = Me(s, t, e), r = $(n);
1597
+ f.trackEffect(this, r), f.trackCleanup(this, i);
1563
1598
  });
1564
1599
  };
1565
1600
  u.fn.atomChecked = function(t) {
@@ -1569,27 +1604,27 @@ u.fn.atomChecked = function(t) {
1569
1604
  const n = () => {
1570
1605
  s || (t.value = !!e.prop("checked"));
1571
1606
  };
1572
- e.on("change", n), d.trackCleanup(this, () => e.off("change", n));
1607
+ e.on("change", n), f.trackCleanup(this, () => e.off("change", n));
1573
1608
  const i = $(() => {
1574
1609
  s = !0;
1575
1610
  const r = !!t.value;
1576
1611
  e.prop("checked", r), g.domUpdated(e, "checked", r), s = !1;
1577
1612
  });
1578
- d.trackEffect(this, i);
1613
+ f.trackEffect(this, i);
1579
1614
  });
1580
1615
  };
1581
1616
  u.fn.atomOn = function(t, e) {
1582
1617
  return this.each(function() {
1583
1618
  const s = u(this);
1584
- s.on(t, e), d.trackCleanup(this, () => s.off(t, e));
1619
+ s.on(t, e), f.trackCleanup(this, () => s.off(t, e));
1585
1620
  });
1586
1621
  };
1587
1622
  u.fn.atomUnbind = function() {
1588
1623
  return this.each(function() {
1589
- d.cleanupTree(this);
1624
+ f.cleanupTree(this);
1590
1625
  });
1591
1626
  };
1592
- function dt(t, e) {
1627
+ function gt(t, e) {
1593
1628
  _(
1594
1629
  t.el,
1595
1630
  e,
@@ -1599,7 +1634,7 @@ function dt(t, e) {
1599
1634
  "text"
1600
1635
  );
1601
1636
  }
1602
- function _t(t, e) {
1637
+ function Et(t, e) {
1603
1638
  _(
1604
1639
  t.el,
1605
1640
  e,
@@ -1609,7 +1644,7 @@ function _t(t, e) {
1609
1644
  "html"
1610
1645
  );
1611
1646
  }
1612
- function pt(t, e) {
1647
+ function bt(t, e) {
1613
1648
  for (const s in e)
1614
1649
  _(
1615
1650
  t.el,
@@ -1620,7 +1655,7 @@ function pt(t, e) {
1620
1655
  `class.${s}`
1621
1656
  );
1622
1657
  }
1623
- function gt(t, e) {
1658
+ function mt(t, e) {
1624
1659
  const s = t.el.style;
1625
1660
  for (const n in e) {
1626
1661
  const i = e[n];
@@ -1647,7 +1682,7 @@ function gt(t, e) {
1647
1682
  );
1648
1683
  }
1649
1684
  }
1650
- function Et(t, e) {
1685
+ function yt(t, e) {
1651
1686
  const s = t.el;
1652
1687
  for (const n in e) {
1653
1688
  const i = e[n];
@@ -1665,7 +1700,7 @@ function Et(t, e) {
1665
1700
  );
1666
1701
  }
1667
1702
  }
1668
- function bt(t, e) {
1703
+ function St(t, e) {
1669
1704
  const s = t.el;
1670
1705
  for (const n in e)
1671
1706
  _(
@@ -1677,7 +1712,7 @@ function bt(t, e) {
1677
1712
  `prop.${n}`
1678
1713
  );
1679
1714
  }
1680
- function mt(t, e) {
1715
+ function Dt(t, e) {
1681
1716
  _(
1682
1717
  t.el,
1683
1718
  e,
@@ -1687,7 +1722,7 @@ function mt(t, e) {
1687
1722
  "show"
1688
1723
  );
1689
1724
  }
1690
- function yt(t, e) {
1725
+ function It(t, e) {
1691
1726
  _(
1692
1727
  t.el,
1693
1728
  e,
@@ -1697,12 +1732,12 @@ function yt(t, e) {
1697
1732
  "hide"
1698
1733
  );
1699
1734
  }
1700
- function St(t, e) {
1701
- const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: r } = Ve(t.$el, s, n), o = $(i);
1702
- d.trackEffect(t.el, o), t.trackCleanup(r);
1735
+ function Ct(t, e) {
1736
+ const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: r } = Me(t.$el, s, n), o = $(i);
1737
+ f.trackEffect(t.el, o), t.trackCleanup(r);
1703
1738
  }
1704
- function Dt(t, e) {
1705
- const s = Pe(), n = () => {
1739
+ function xt(t, e) {
1740
+ const s = Ve(), n = () => {
1706
1741
  s.phase === "idle" && (e.value = t.$el.prop("checked"));
1707
1742
  };
1708
1743
  t.$el.on("change", n), t.trackCleanup(() => t.$el.off("change", n));
@@ -1711,9 +1746,9 @@ function Dt(t, e) {
1711
1746
  const r = !!e.value;
1712
1747
  t.$el.prop("checked", r), g.domUpdated(t.$el, "checked", r), s.phase = "idle";
1713
1748
  });
1714
- d.trackEffect(t.el, i);
1749
+ f.trackEffect(t.el, i);
1715
1750
  }
1716
- function It(t, e) {
1751
+ function Nt(t, e) {
1717
1752
  const s = t.el;
1718
1753
  for (const n in e) {
1719
1754
  const i = e[n];
@@ -1728,39 +1763,15 @@ u.fn.atomBind = function(t) {
1728
1763
  $el: u(this),
1729
1764
  el: this,
1730
1765
  effects: [],
1731
- trackCleanup: (n) => d.trackCleanup(this, n)
1766
+ trackCleanup: (n) => f.trackCleanup(this, n)
1732
1767
  };
1733
- t.text !== void 0 && dt(s, t.text), t.html !== void 0 && _t(s, t.html), t.class && pt(s, t.class), t.css && gt(s, t.css), t.attr && Et(s, t.attr), t.prop && bt(s, t.prop), t.show !== void 0 && mt(s, t.show), t.hide !== void 0 && yt(s, t.hide), t.val !== void 0 && St(s, t.val), t.checked !== void 0 && Dt(s, t.checked), t.on && It(s, t.on);
1768
+ t.text !== void 0 && gt(s, t.text), t.html !== void 0 && Et(s, t.html), t.class && bt(s, t.class), t.css && mt(s, t.css), t.attr && yt(s, t.attr), t.prop && St(s, t.prop), t.show !== void 0 && Dt(s, t.show), t.hide !== void 0 && It(s, t.hide), t.val !== void 0 && Ct(s, t.val), t.checked !== void 0 && xt(s, t.checked), t.on && Nt(s, t.on);
1734
1769
  });
1735
1770
  };
1736
- function Ct(t) {
1737
- const e = t.length;
1738
- if (e === 0) return new Int32Array(0);
1739
- const s = new Int32Array(e), n = new Int32Array(e);
1740
- let i = 0;
1741
- for (let o = 0; o < e; o++) {
1742
- const c = t[o];
1743
- if (c === -1) continue;
1744
- if (i === 0 || t[n[i - 1]] < c) {
1745
- s[o] = i > 0 ? n[i - 1] : -1, n[i++] = o;
1746
- continue;
1747
- }
1748
- let h = 0, f = i - 1;
1749
- for (; h < f; ) {
1750
- const m = h + f >>> 1;
1751
- t[n[m]] < c ? h = m + 1 : f = m;
1752
- }
1753
- c < t[n[h]] && (h > 0 && (s[o] = n[h - 1]), n[h] = o);
1754
- }
1755
- const r = new Int32Array(i);
1756
- for (let o = i - 1, c = n[i - 1]; o >= 0; o--)
1757
- r[o] = c, c = s[c];
1758
- return r;
1759
- }
1760
1771
  u.fn.atomList = function(t, e) {
1761
- const { key: s, render: n, bind: i, update: r, onAdd: o, onRemove: c, empty: h } = e, f = typeof s == "function" ? s : (m) => m[s];
1772
+ const { key: s, render: n, bind: i, update: r, onAdd: o, onRemove: c, empty: h } = e, d = typeof s == "function" ? s : (m) => m[s];
1762
1773
  return this.each(function() {
1763
- const m = u(this), X = ue(this), x = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set();
1774
+ const m = u(this), X = he(this), x = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set();
1764
1775
  let k = [], L = null;
1765
1776
  const D = $(() => {
1766
1777
  const H = t.value, R = H.length;
@@ -1769,17 +1780,17 @@ u.fn.atomList = function(t, e) {
1769
1780
  return;
1770
1781
  }
1771
1782
  g.log("list", `${X} updating with ${R} items`);
1772
- const Z = new Array(R), ge = /* @__PURE__ */ new Set();
1783
+ const Z = new Array(R), Ee = /* @__PURE__ */ new Set();
1773
1784
  for (let a = 0; a < R; a++) {
1774
- const p = H[a], I = f(p, a);
1775
- Z[a] = I, ge.add(I);
1785
+ const p = H[a], I = d(p, a);
1786
+ Z[a] = I, Ee.add(I);
1776
1787
  }
1777
1788
  for (const [a, p] of x) {
1778
- if (ge.has(a) || A.has(a)) continue;
1789
+ if (Ee.has(a) || A.has(a)) continue;
1779
1790
  const I = () => {
1780
1791
  p.$el.remove();
1781
1792
  const E = p.$el[0];
1782
- E && d.cleanup(E), A.delete(a), g.log("list", `${X} removed item:`, a);
1793
+ E && f.cleanup(E), A.delete(a), g.log("list", `${X} removed item:`, a);
1783
1794
  };
1784
1795
  if (x.delete(a), A.add(a), c) {
1785
1796
  const E = c(p.$el);
@@ -1791,25 +1802,25 @@ u.fn.atomList = function(t, e) {
1791
1802
  k = [];
1792
1803
  return;
1793
1804
  }
1794
- const Ee = /* @__PURE__ */ new Map();
1805
+ const be = /* @__PURE__ */ new Map();
1795
1806
  for (let a = 0; a < k.length; a++) {
1796
1807
  const p = k[a];
1797
- p !== void 0 && Ee.set(p, a);
1808
+ p !== void 0 && be.set(p, a);
1798
1809
  }
1799
- const be = new Int32Array(R);
1810
+ const me = new Int32Array(R);
1800
1811
  for (let a = 0; a < R; a++) {
1801
1812
  const p = Z[a];
1802
- be[a] = p !== void 0 ? Ee.get(p) ?? -1 : -1;
1813
+ me[a] = p !== void 0 ? be.get(p) ?? -1 : -1;
1803
1814
  }
1804
- const me = Ct(be);
1805
- let he = me.length - 1, O = null;
1815
+ const ye = ht(me);
1816
+ let ae = ye.length - 1, O = null;
1806
1817
  for (let a = R - 1; a >= 0; a--) {
1807
1818
  const p = Z[a], I = H[a], E = x.get(p);
1808
1819
  if (E) {
1809
1820
  E.item = I;
1810
1821
  const P = E.$el[0];
1811
1822
  if (!P) continue;
1812
- r && r(E.$el, I, a), he >= 0 && me[he] === a ? (he--, P.nextSibling !== O && (O ? E.$el.insertBefore(O) : E.$el.appendTo(m))) : O ? E.$el.insertBefore(O) : E.$el.appendTo(m), O = P;
1823
+ r && r(E.$el, I, a), ae >= 0 && ye[ae] === a ? (ae--, P.nextSibling !== O && (O ? E.$el.insertBefore(O) : E.$el.appendTo(m))) : O ? E.$el.insertBefore(O) : E.$el.appendTo(m), O = P;
1813
1824
  } else {
1814
1825
  const P = n(I, a), V = P instanceof Element ? u(P) : u(P);
1815
1826
  x.set(p, { $el: V, item: I }), O ? V.insertBefore(O) : V.appendTo(m), i && i(V, I, a), o && o(V), g.log("list", `${X} added item:`, p), O = V[0] || null;
@@ -1817,15 +1828,15 @@ u.fn.atomList = function(t, e) {
1817
1828
  }
1818
1829
  k = Z;
1819
1830
  });
1820
- d.trackEffect(this, D), d.trackCleanup(this, () => {
1831
+ f.trackEffect(this, D), f.trackCleanup(this, () => {
1821
1832
  x.clear(), A.clear(), k = [], L?.remove();
1822
1833
  });
1823
1834
  });
1824
1835
  };
1825
- const ne = /* @__PURE__ */ new WeakMap();
1836
+ const ie = /* @__PURE__ */ new WeakMap();
1826
1837
  u.fn.atomMount = function(t, e = {}) {
1827
1838
  return this.each(function() {
1828
- const s = u(this), n = ue(this), i = ne.get(this);
1839
+ const s = u(this), n = he(this), i = ie.get(this);
1829
1840
  i && (g.log("mount", `${n} unmounting existing component`), i()), g.log("mount", `${n} mounting component`);
1830
1841
  let r;
1831
1842
  try {
@@ -1842,34 +1853,34 @@ u.fn.atomMount = function(t, e = {}) {
1842
1853
  r();
1843
1854
  } catch {
1844
1855
  }
1845
- d.cleanupTree(this), ne.delete(this);
1856
+ f.cleanupTree(this), ie.delete(this);
1846
1857
  }
1847
1858
  };
1848
- ne.set(this, c), d.trackCleanup(this, c);
1859
+ ie.set(this, c), f.trackCleanup(this, c);
1849
1860
  });
1850
1861
  };
1851
1862
  u.fn.atomUnmount = function() {
1852
1863
  return this.each(function() {
1853
- ne.get(this)?.();
1864
+ ie.get(this)?.();
1854
1865
  });
1855
1866
  };
1856
1867
  const Y = /* @__PURE__ */ new WeakMap();
1857
1868
  let Te = !1;
1858
- function Me() {
1869
+ function je() {
1859
1870
  if (Te) return;
1860
1871
  Te = !0;
1861
1872
  const t = u.fn.on, e = u.fn.off, s = u.fn.remove, n = u.fn.empty, i = u.fn.detach;
1862
1873
  u.fn.remove = function(r) {
1863
1874
  return (r ? this.filter(r) : this).each(function() {
1864
- d.cleanupTree(this);
1875
+ f.cleanupTree(this), f.markIgnored(this);
1865
1876
  }), s.call(this, r);
1866
1877
  }, u.fn.empty = function() {
1867
1878
  return this.each(function() {
1868
- this.querySelectorAll("*").forEach((o) => d.cleanup(o));
1879
+ f.cleanupDescendants(this);
1869
1880
  }), n.call(this);
1870
1881
  }, u.fn.detach = function(r) {
1871
1882
  return (r ? this.filter(r) : this).each(function() {
1872
- d.keep(this);
1883
+ f.keep(this);
1873
1884
  }), i.call(this, r);
1874
1885
  }, u.fn.on = function(...r) {
1875
1886
  let o = -1;
@@ -1881,8 +1892,8 @@ function Me() {
1881
1892
  if (o !== -1) {
1882
1893
  const c = r[o];
1883
1894
  let h;
1884
- Y.has(c) ? h = Y.get(c) : (h = function(...f) {
1885
- return c.apply(this, f);
1895
+ Y.has(c) ? h = Y.get(c) : (h = function(...d) {
1896
+ return c.apply(this, d);
1886
1897
  }, Y.set(c, h)), r[o] = h;
1887
1898
  }
1888
1899
  return t.apply(this, r);
@@ -1900,22 +1911,22 @@ function Me() {
1900
1911
  return e.apply(this, r);
1901
1912
  };
1902
1913
  }
1903
- const Nt = Me;
1904
- Me();
1914
+ const Rt = je;
1915
+ je();
1905
1916
  u(() => {
1906
- ft(document.body);
1917
+ pt(document.body);
1907
1918
  });
1908
1919
  export {
1909
- nt as atom,
1910
- Ye as batch,
1911
- it as computed,
1912
- Ot as default,
1913
- vt as disableAutoCleanup,
1920
+ it as atom,
1921
+ ct as batch,
1922
+ rt as computed,
1923
+ wt as default,
1924
+ At as disableAutoCleanup,
1914
1925
  $ as effect,
1915
- ft as enableAutoCleanup,
1916
- Nt as enablejQueryBatching,
1917
- Me as enablejQueryOverrides,
1918
- d as registry,
1919
- Oe as untracked
1926
+ pt as enableAutoCleanup,
1927
+ Rt as enablejQueryBatching,
1928
+ je as enablejQueryOverrides,
1929
+ f as registry,
1930
+ Fe as untracked
1920
1931
  };
1921
1932
  //# sourceMappingURL=index.mjs.map