@but212/atom-effect-jquery 0.18.0 → 0.19.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.mjs CHANGED
@@ -1,19 +1,19 @@
1
- import l from "jquery";
2
- import { default as Mt } from "jquery";
1
+ import u from "jquery";
2
+ import { default as Vt } from "jquery";
3
3
  const Je = {
4
4
  ONE_SECOND_MS: 1e3
5
- }, _e = {
5
+ }, Ee = {
6
6
  IDLE: "idle",
7
7
  PENDING: "pending",
8
8
  RESOLVED: "resolved",
9
9
  REJECTED: "rejected"
10
- }, De = {
10
+ }, ve = {
11
11
  DISPOSED: 1
12
12
  }, P = {
13
- ...De,
13
+ ...ve,
14
14
  EXECUTING: 8
15
15
  }, d = {
16
- ...De,
16
+ ...ve,
17
17
  DIRTY: 8,
18
18
  IDLE: 16,
19
19
  PENDING: 32,
@@ -22,7 +22,7 @@ const Je = {
22
22
  RECOMPUTING: 256,
23
23
  HAS_ERROR: 512
24
24
  }, H = {
25
- ...De,
25
+ ...ve,
26
26
  SYNC: 8,
27
27
  NOTIFICATION_SCHEDULED: 16
28
28
  }, q = {
@@ -34,75 +34,73 @@ const Je = {
34
34
  MAX_FLUSH_ITERATIONS: 1e3,
35
35
  MIN_FLUSH_ITERATIONS: 10,
36
36
  BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
37
- }, Ne = {
38
- MAX_DEPENDENCIES: 1e3,
37
+ }, Ze = {
39
38
  WARN_INFINITE_LOOP: !0
40
- }, W = 1073741823, T = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, Ze = Object.freeze([]);
41
- class te extends Error {
39
+ }, ie = 1073741823, A = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, et = Object.freeze([]);
40
+ class ee extends Error {
42
41
  constructor(e, t = null, s = !0) {
43
42
  super(e), this.cause = t, this.recoverable = s, this.timestamp = /* @__PURE__ */ new Date(), this.name = "AtomError";
44
43
  }
45
44
  }
46
- class z extends te {
45
+ class z extends ee {
47
46
  constructor(e, t = null) {
48
47
  super(e, t, !0), this.name = "ComputedError";
49
48
  }
50
49
  }
51
- class Q extends te {
50
+ class G extends ee {
52
51
  constructor(e, t = null) {
53
52
  super(e, t, !1), this.name = "EffectError";
54
53
  }
55
54
  }
56
- class ue extends te {
55
+ class ae extends ee {
57
56
  constructor(e, t = null) {
58
57
  super(e, t, !1), this.name = "SchedulerError";
59
58
  }
60
59
  }
61
- const Ae = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), et = /* @__PURE__ */ Symbol("AtomEffect.Id"), we = /* @__PURE__ */ Symbol("AtomEffect.Type"), ge = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), tt = (n) => "dependencies" in n && Array.isArray(n.dependencies);
62
- function Be(n, e, t) {
60
+ const Ne = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), tt = /* @__PURE__ */ Symbol("AtomEffect.Id"), Re = /* @__PURE__ */ Symbol("AtomEffect.Type"), ye = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), nt = (n) => "dependencies" in n && Array.isArray(n.dependencies);
61
+ function Me(n, e, t) {
63
62
  if (n === e)
64
63
  throw new z(
65
64
  "Circular dependency detected: The computation refers to itself explicitly or implicitly."
66
65
  );
67
- if (!t.has(n.id) && (t.add(n.id), tt(n))) {
66
+ if (!t.has(n.id) && (t.add(n.id), nt(n))) {
68
67
  const s = n.dependencies;
69
68
  for (let i = 0; i < s.length; i++) {
70
69
  const o = s[i];
71
- o && Be(o, e, t);
70
+ o && Me(o, e, t);
72
71
  }
73
72
  }
74
73
  }
75
74
  const Y = {
76
75
  // Dev mode flag
77
- enabled: T,
78
- maxDependencies: Ne.MAX_DEPENDENCIES,
79
- warnInfiniteLoop: Ne.WARN_INFINITE_LOOP,
76
+ enabled: A,
77
+ warnInfiniteLoop: Ze.WARN_INFINITE_LOOP,
80
78
  warn(n, e) {
81
- T && this.enabled && n && console.warn(`[Atom Effect] ${e}`);
79
+ A && this.enabled && n && console.warn(`[Atom Effect] ${e}`);
82
80
  },
83
81
  checkCircular(n, e) {
84
82
  if (n === e)
85
83
  throw new z("Direct circular dependency detected");
86
- T && this.enabled && Be(n, e, /* @__PURE__ */ new Set());
84
+ A && this.enabled && Me(n, e, /* @__PURE__ */ new Set());
87
85
  },
88
86
  attachDebugInfo(n, e, t) {
89
- if (!T || !this.enabled) return;
87
+ if (!A || !this.enabled) return;
90
88
  const s = n;
91
- s[Ae] = `${e}_${t}`, s[et] = t, s[we] = e;
89
+ s[Ne] = `${e}_${t}`, s[tt] = t, s[Re] = e;
92
90
  },
93
- getDebugName: (n) => n?.[Ae],
94
- getDebugType: (n) => n?.[we]
91
+ getDebugName: (n) => n?.[Ne],
92
+ getDebugType: (n) => n?.[Re]
95
93
  };
96
- let nt = 1;
97
- const st = () => nt++;
98
- function je(n, e, t) {
94
+ let st = 1;
95
+ const it = () => st++;
96
+ function Be(n, e, t) {
99
97
  if (typeof e == "function") {
100
98
  const i = e;
101
99
  for (let o = 0, r = t.length; o < r; o++) {
102
100
  const c = t[o];
103
101
  if (c && c.fn === i) return;
104
102
  }
105
- t.push(new Ie(i, void 0));
103
+ t.push(new Ce(i, void 0));
106
104
  return;
107
105
  }
108
106
  if ("addDependency" in e) {
@@ -114,9 +112,9 @@ function je(n, e, t) {
114
112
  const r = t[i];
115
113
  if (r && r.sub === s) return;
116
114
  }
117
- t.push(new Ie(void 0, s));
115
+ t.push(new Ce(void 0, s));
118
116
  }
119
- function it(n, e, t) {
117
+ function ot(n, e, t) {
120
118
  for (let s = 0, i = e.length; s < i; s++) {
121
119
  const o = e[s];
122
120
  o && (o.node._tempUnsub = o.unsub);
@@ -135,17 +133,17 @@ function it(n, e, t) {
135
133
  }
136
134
  }
137
135
  }
138
- class be {
136
+ class he {
139
137
  constructor(e, t, s = void 0) {
140
138
  this.node = e, this.version = t, this.unsub = s;
141
139
  }
142
140
  }
143
- class Ie {
141
+ class Ce {
144
142
  constructor(e, t) {
145
143
  this.fn = e, this.sub = t;
146
144
  }
147
145
  }
148
- const v = {
146
+ const D = {
149
147
  // Computed Errors
150
148
  COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
151
149
  COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
@@ -161,10 +159,15 @@ const v = {
161
159
  EFFECT_EXECUTION_FAILED: "Effect execution failed",
162
160
  EFFECT_CLEANUP_FAILED: "Effect cleanup failed",
163
161
  EFFECT_DISPOSED: "Attempted to run disposed effect",
164
- CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler"
162
+ // Scheduler Errors
163
+ SCHEDULER_FLUSH_OVERFLOW: (n, e) => `Maximum flush iterations (${n}) exceeded. ${e} jobs dropped. Possible infinite loop.`,
164
+ // System / Debug
165
+ CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler",
166
+ // Effect frequency
167
+ EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop."
165
168
  };
166
- function ee(n, e, t) {
167
- if (n instanceof te)
169
+ function Z(n, e, t) {
170
+ if (n instanceof ee)
168
171
  return n;
169
172
  const s = n instanceof Error, i = s ? n.message : String(n), o = s ? n : void 0;
170
173
  let r = "Unexpected error";
@@ -172,31 +175,31 @@ function ee(n, e, t) {
172
175
  const c = `${r} (${t}): ${i}`;
173
176
  return new e(c, o);
174
177
  }
175
- class Ve {
178
+ class je {
176
179
  constructor() {
177
- this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this.id = st() & W, this._tempUnsub = void 0;
180
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this.id = it() & ie, this._tempUnsub = void 0;
178
181
  }
179
182
  }
180
- class He extends Ve {
183
+ class Ve extends je {
181
184
  /**
182
185
  * Adds subscriber.
183
186
  */
184
187
  subscribe(e) {
185
188
  const t = typeof e == "function";
186
189
  if (!t && (!e || typeof e.execute != "function"))
187
- throw ee(
190
+ throw Z(
188
191
  new TypeError("Invalid subscriber"),
189
- te,
190
- v.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
192
+ ee,
193
+ D.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
191
194
  );
192
195
  const s = this._subscribers;
193
196
  for (let o = 0, r = s.length; o < r; o++) {
194
197
  const c = s[o];
195
198
  if (c && (t ? c.fn === e : c.sub === e))
196
- return T && console.warn("Duplicate subscription ignored."), () => {
199
+ return A && console.warn("Duplicate subscription ignored."), () => {
197
200
  };
198
201
  }
199
- const i = new Ie(
202
+ const i = new Ce(
200
203
  t ? e : void 0,
201
204
  t ? void 0 : e
202
205
  );
@@ -213,7 +216,7 @@ class He extends Ve {
213
216
  }
214
217
  _notifySubscribers(e, t) {
215
218
  if (this._subscribers.length === 0) return;
216
- const s = [...this._subscribers], i = s.length;
219
+ const s = this._subscribers.slice(0), i = s.length;
217
220
  for (let o = 0; o < i; o++) {
218
221
  const r = s[o];
219
222
  if (r)
@@ -225,18 +228,18 @@ class He extends Ve {
225
228
  }
226
229
  }
227
230
  _handleNotifyError(e) {
228
- console.error(ee(e, te, v.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
231
+ console.error(Z(e, ee, D.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
229
232
  }
230
233
  }
231
- let ae = 0;
232
- const ze = () => (ae = ae + 1 & W || 1, ae), ot = () => ae;
233
- let Ce = 0, Te = 0, fe = !1;
234
- function Re() {
235
- return fe ? (T && console.warn("startFlush() called during flush - ignored"), !1) : (fe = !0, Ce = Ce + 1 & W || 1, Te = 0, !0);
234
+ let fe = 0;
235
+ const He = () => (fe = fe + 1 & ie || 1, fe), rt = () => fe, Ie = (n) => n + 1 & ie;
236
+ let Se = 0, Te = 0, _e = !1;
237
+ function xe() {
238
+ return _e ? (A && console.warn("startFlush() called during flush - ignored"), !1) : (_e = !0, Se = Se + 1 & ie || 1, Te = 0, !0);
236
239
  }
237
- const xe = () => {
238
- fe = !1;
239
- }, rt = () => fe ? ++Te : 0, F = {
240
+ const Ae = () => {
241
+ _e = !1;
242
+ }, ct = () => _e ? ++Te : 0, $ = {
240
243
  /** Queue buffer */
241
244
  _queueBuffer: [[], []],
242
245
  _bufferIndex: 0,
@@ -266,8 +269,8 @@ const xe = () => {
266
269
  * Schedules job.
267
270
  */
268
271
  schedule(n) {
269
- if (T && typeof n != "function")
270
- throw new ue("Scheduler callback must be a function");
272
+ if (A && typeof n != "function")
273
+ throw new ae("Scheduler callback must be a function");
271
274
  if (n._nextEpoch !== this._epoch) {
272
275
  if (n._nextEpoch = this._epoch, this._isBatching || this._isFlushingSync) {
273
276
  this._batchQueue[this._batchQueueSize++] = n;
@@ -287,20 +290,20 @@ const xe = () => {
287
290
  */
288
291
  _runLoop: () => {
289
292
  try {
290
- if (F._size === 0) return;
291
- const n = Re();
292
- F._drainQueue(), n && xe();
293
+ if ($._size === 0) return;
294
+ const n = xe();
295
+ $._drainQueue(), n && Ae();
293
296
  } finally {
294
- F._isProcessing = !1, F._size > 0 && !F._isBatching && F._flush();
297
+ $._isProcessing = !1, $._size > 0 && !$._isBatching && $._flush();
295
298
  }
296
299
  },
297
300
  _flushSync() {
298
301
  this._isFlushingSync = !0;
299
- const n = Re();
302
+ const n = xe();
300
303
  try {
301
304
  this._mergeBatchQueue(), this._drainQueue();
302
305
  } finally {
303
- this._isFlushingSync = !1, n && xe();
306
+ this._isFlushingSync = !1, n && Ae();
304
307
  }
305
308
  },
306
309
  _mergeBatchQueue() {
@@ -330,35 +333,42 @@ const xe = () => {
330
333
  try {
331
334
  e[s]();
332
335
  } catch (i) {
333
- console.error(new ue("Error occurred during scheduler execution", i));
336
+ console.error(new ae("Error occurred during scheduler execution", i));
334
337
  }
335
338
  e.length = 0;
336
339
  },
340
+ /** Overflow callback */
341
+ onOverflow: null,
337
342
  _handleFlushOverflow() {
338
- console.error(
339
- new ue(
340
- `Maximum flush iterations (${this._maxFlushIterations}) exceeded. Possible infinite loop.`
343
+ const n = this._size + this._batchQueueSize;
344
+ if (console.error(
345
+ new ae(
346
+ D.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, n)
341
347
  )
342
- ), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0;
348
+ ), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
349
+ try {
350
+ this.onOverflow(n);
351
+ } catch {
352
+ }
343
353
  },
344
354
  startBatch() {
345
355
  this._batchDepth++, this._isBatching = !0;
346
356
  },
347
357
  endBatch() {
348
358
  if (this._batchDepth === 0) {
349
- T && console.warn("endBatch() called without matching startBatch(). Ignoring.");
359
+ A && console.warn("endBatch() called without matching startBatch(). Ignoring.");
350
360
  return;
351
361
  }
352
362
  --this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
353
363
  },
354
364
  setMaxFlushIterations(n) {
355
365
  if (n < q.MIN_FLUSH_ITERATIONS)
356
- throw new ue(
366
+ throw new ae(
357
367
  `Max flush iterations must be at least ${q.MIN_FLUSH_ITERATIONS}`
358
368
  );
359
369
  this._maxFlushIterations = n;
360
370
  }
361
- }, M = {
371
+ }, B = {
362
372
  /** Active listener. */
363
373
  current: null,
364
374
  /**
@@ -378,35 +388,35 @@ const xe = () => {
378
388
  }
379
389
  }
380
390
  };
381
- function ct(n) {
382
- const e = M.current;
391
+ function at(n) {
392
+ const e = B.current;
383
393
  if (e === null) return n();
384
- M.current = null;
394
+ B.current = null;
385
395
  try {
386
396
  return n();
387
397
  } finally {
388
- M.current = e;
398
+ B.current = e;
389
399
  }
390
400
  }
391
- class ut extends He {
401
+ class ut extends Ve {
392
402
  constructor(e, t) {
393
403
  super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this._value = e, t && (this.flags |= H.SYNC), Y.attachDebugInfo(this, "atom", this.id);
394
404
  }
395
405
  get value() {
396
- const e = M.current;
397
- return e && je(this, e, this._subscribers), this._value;
406
+ const e = B.current;
407
+ return e && Be(this, e, this._subscribers), this._value;
398
408
  }
399
409
  set value(e) {
400
410
  const t = this._value;
401
411
  if (Object.is(t, e)) return;
402
- this._value = e, this.version = this.version + 1 & W;
412
+ this._value = e, this.version = Ie(this.version);
403
413
  const s = this.flags;
404
414
  if (!(this._subscribers.length === 0 || s & H.NOTIFICATION_SCHEDULED)) {
405
- if (this._pendingOldValue = t, this.flags = s | H.NOTIFICATION_SCHEDULED, s & H.SYNC && !F.isBatching) {
415
+ if (this._pendingOldValue = t, this.flags = s | H.NOTIFICATION_SCHEDULED, s & H.SYNC && !$.isBatching) {
406
416
  this._flushNotifications();
407
417
  return;
408
418
  }
409
- this._notifyTask || (this._notifyTask = () => this._flushNotifications()), F.schedule(this._notifyTask);
419
+ this._notifyTask || (this._notifyTask = () => this._flushNotifications()), $.schedule(this._notifyTask);
410
420
  }
411
421
  }
412
422
  /**
@@ -426,16 +436,17 @@ class ut extends He {
426
436
  this.flags & H.DISPOSED || (this._subscribers.length = 0, this.flags |= H.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
427
437
  }
428
438
  }
429
- function qe(n, e = {}) {
439
+ function ze(n, e = {}) {
430
440
  return new ut(n, e.sync ?? !1);
431
441
  }
432
442
  class lt {
433
443
  /**
434
444
  * @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
435
445
  * @param capacity - Max length of an array to accept (default: 256).
446
+ * @param enableStats - Force-enable stats even in production (default: false).
436
447
  */
437
- constructor(e = 50, t = 256) {
438
- this.limit = e, this.capacity = t, this.pool = [], this.stats = T ? {
448
+ constructor(e = 50, t = 256, s = !1) {
449
+ this.limit = e, this.capacity = t, this.pool = [], this.stats = null, this.stats = A || s ? {
439
450
  acquired: 0,
440
451
  released: 0,
441
452
  rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
@@ -445,7 +456,7 @@ class lt {
445
456
  * Acquires array.
446
457
  */
447
458
  acquire() {
448
- return T && this.stats && this.stats.acquired++, this.pool.pop() ?? [];
459
+ return this.stats && this.stats.acquired++, this.pool.pop() ?? [];
449
460
  }
450
461
  /**
451
462
  * Releases array.
@@ -456,25 +467,25 @@ class lt {
456
467
  release(e, t) {
457
468
  if (!(t && e === t)) {
458
469
  if (e.length > this.capacity) {
459
- T && this.stats && this.stats.rejected.tooLarge++;
470
+ this.stats && this.stats.rejected.tooLarge++;
460
471
  return;
461
472
  }
462
473
  if (this.pool.length >= this.limit) {
463
- T && this.stats && this.stats.rejected.poolFull++;
474
+ this.stats && this.stats.rejected.poolFull++;
464
475
  return;
465
476
  }
466
477
  if (Object.isFrozen(e)) {
467
- T && this.stats && this.stats.rejected.frozen++;
478
+ this.stats && this.stats.rejected.frozen++;
468
479
  return;
469
480
  }
470
- e.length = 0, this.pool.push(e), T && this.stats && this.stats.released++;
481
+ e.length = 0, this.pool.push(e), this.stats && this.stats.released++;
471
482
  }
472
483
  }
473
484
  /**
474
485
  * Pool stats.
475
486
  */
476
487
  getStats() {
477
- if (!T || !this.stats) return null;
488
+ if (!this.stats) return null;
478
489
  const { acquired: e, released: t, rejected: s } = this.stats, i = e - t - (s.frozen + s.tooLarge + s.poolFull);
479
490
  return {
480
491
  acquired: e,
@@ -488,7 +499,7 @@ class lt {
488
499
  * Resets pool.
489
500
  */
490
501
  reset() {
491
- this.pool.length = 0, T && this.stats && (this.stats = {
502
+ this.pool.length = 0, this.stats && (this.stats = {
492
503
  acquired: 0,
493
504
  released: 0,
494
505
  rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
@@ -500,33 +511,35 @@ oe([]);
500
511
  oe([]);
501
512
  oe([]);
502
513
  oe([]);
503
- const L = oe([]), X = new lt();
504
- function Se(n) {
514
+ const U = oe([]), X = new lt();
515
+ function De(n) {
505
516
  return n !== null && typeof n == "object" && "value" in n && typeof n.subscribe == "function";
506
517
  }
507
518
  function Le(n) {
508
- return Se(n) && typeof n.invalidate == "function";
519
+ return De(n) && typeof n.invalidate == "function";
509
520
  }
510
- function Xe(n) {
521
+ function qe(n) {
511
522
  return n !== null && typeof n == "object" && typeof n.then == "function";
512
523
  }
513
- const Ge = d.RESOLVED | d.PENDING | d.REJECTED, Ee = Array(Ge + 1).fill(_e.IDLE);
514
- Ee[d.RESOLVED] = _e.RESOLVED;
515
- Ee[d.PENDING] = _e.PENDING;
516
- Ee[d.REJECTED] = _e.REJECTED;
517
- const Ue = 3, Pe = Number.MAX_SAFE_INTEGER - 1;
518
- class Qe extends He {
524
+ const Xe = d.RESOLVED | d.PENDING | d.REJECTED, ge = Array(Xe + 1).fill(Ee.IDLE);
525
+ ge[d.RESOLVED] = Ee.RESOLVED;
526
+ ge[d.PENDING] = Ee.PENDING;
527
+ ge[d.REJECTED] = Ee.REJECTED;
528
+ const ht = 3, Ue = Number.MAX_SAFE_INTEGER - 1, ft = d.REJECTED | d.HAS_ERROR;
529
+ class Qe extends Ve {
519
530
  constructor(e, t = {}) {
520
- if (typeof e != "function") throw new z(v.COMPUTED_MUST_BE_FUNCTION);
521
- if (super(), this._error = null, this._promiseId = 0, this._subscribers = [], this._links = L, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = L, this._trackCount = 0, this._value = void 0, this.flags = d.DIRTY | d.IDLE, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : ge, this._onError = t.onError ?? null, Y.attachDebugInfo(this, "computed", this.id), t.lazy === !1)
531
+ if (typeof e != "function") throw new z(D.COMPUTED_MUST_BE_FUNCTION);
532
+ super(), this._error = null, this._promiseId = 0, this._subscribers = [], this._links = U, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._errorDepCount = 0, this._trackEpoch = -1, this._trackLinks = U, this._trackCount = 0, this._value = void 0, this.flags = d.DIRTY | d.IDLE, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : ye, this._onError = t.onError ?? null;
533
+ const s = t.maxAsyncRetries;
534
+ if (this._maxAsyncRetries = s != null && s >= 0 ? s : ht, Y.attachDebugInfo(this, "computed", this.id), t.lazy === !1)
522
535
  try {
523
536
  this._recompute();
524
537
  } catch {
525
538
  }
526
539
  }
527
540
  _track() {
528
- const e = M.current;
529
- e && je(this, e, this._subscribers);
541
+ const e = B.current;
542
+ e && Be(this, e, this._subscribers);
530
543
  }
531
544
  get value() {
532
545
  this._track();
@@ -534,17 +547,17 @@ class Qe extends He {
534
547
  if ((e & (d.RESOLVED | d.DIRTY | d.IDLE)) === d.RESOLVED)
535
548
  return this._value;
536
549
  if (e & d.DISPOSED)
537
- throw new z(v.COMPUTED_DISPOSED);
550
+ throw new z(D.COMPUTED_DISPOSED);
538
551
  if (e & d.RECOMPUTING) {
539
- if (this._defaultValue !== ge) return this._defaultValue;
540
- throw new z(v.COMPUTED_CIRCULAR_DEPENDENCY);
552
+ if (this._defaultValue !== ye) return this._defaultValue;
553
+ throw new z(D.COMPUTED_CIRCULAR_DEPENDENCY);
541
554
  }
542
555
  if (e & (d.DIRTY | d.IDLE) && (this._recompute(), this.flags & d.RESOLVED))
543
556
  return this._value;
544
- const t = this._defaultValue, s = t !== ge;
557
+ const t = this._defaultValue, s = t !== ye;
545
558
  if (this.flags & d.PENDING) {
546
559
  if (s) return t;
547
- throw new z(v.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
560
+ throw new z(D.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
548
561
  }
549
562
  if (this.flags & d.REJECTED) {
550
563
  if (this._error?.recoverable && s) return t;
@@ -556,10 +569,10 @@ class Qe extends He {
556
569
  return this._value;
557
570
  }
558
571
  get state() {
559
- return this._track(), Ee[this.flags & Ge];
572
+ return this._track(), ge[this.flags & Xe];
560
573
  }
561
574
  get hasError() {
562
- if (this._track(), this.flags & (d.REJECTED | d.HAS_ERROR)) return !0;
575
+ if (this._track(), this.flags & (d.REJECTED | d.HAS_ERROR) || this._errorDepCount > 0) return !0;
563
576
  const e = this._links;
564
577
  for (let t = 0, s = e.length; t < s; t++) {
565
578
  const i = e[t]?.node;
@@ -572,8 +585,8 @@ class Qe extends He {
572
585
  return !this.hasError;
573
586
  }
574
587
  get errors() {
575
- if (this._track(), !this.hasError) return Ze;
576
- const e = ot();
588
+ if (this._track(), !this.hasError) return et;
589
+ const e = rt();
577
590
  if (this._errorCacheEpoch === e && this._cachedErrors) return this._cachedErrors;
578
591
  const t = [];
579
592
  this._error && t.push(this._error);
@@ -581,12 +594,12 @@ class Qe extends He {
581
594
  for (let o = 0, r = s.length; o < r; o++) {
582
595
  const c = s[o].node;
583
596
  if (c.flags & d.HAS_ERROR) {
584
- const a = c;
585
- if (a.errors) {
586
- const f = a.errors;
587
- for (let p = 0; p < f.length; p++) {
588
- const D = f[p];
589
- D && t.indexOf(D) === -1 && t.push(D);
597
+ const l = c;
598
+ if (l.errors) {
599
+ const _ = l.errors;
600
+ for (let g = 0; g < _.length; g++) {
601
+ const v = _[g];
602
+ v && t.indexOf(v) === -1 && t.push(v);
590
603
  }
591
604
  }
592
605
  }
@@ -609,12 +622,12 @@ class Qe extends He {
609
622
  dispose() {
610
623
  if (this.flags & d.DISPOSED) return;
611
624
  const e = this._links;
612
- if (e !== L) {
625
+ if (e !== U) {
613
626
  for (let t = 0, s = e.length; t < s; t++)
614
627
  e[t].unsub?.();
615
- X.release(e), this._links = L;
628
+ X.release(e), this._links = U;
616
629
  }
617
- this._subscribers.length = 0, this.flags = d.DISPOSED | d.DIRTY | d.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % Pe, this._cachedErrors = null, this._errorCacheEpoch = -1;
630
+ this._subscribers.length = 0, this.flags = d.DISPOSED | d.DIRTY | d.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % Ue, this._cachedErrors = null, this._errorCacheEpoch = -1;
618
631
  }
619
632
  addDependency(e) {
620
633
  if (e._lastSeenEpoch !== this._trackEpoch) {
@@ -622,70 +635,82 @@ class Qe extends He {
622
635
  const t = this._trackLinks[this._trackCount];
623
636
  t.node = e, t.version = e.version;
624
637
  } else
625
- this._trackLinks.push(new be(e, e.version));
638
+ this._trackLinks.push(new he(e, e.version));
626
639
  this._trackCount++;
627
640
  }
628
641
  }
629
642
  _commitDeps(e) {
630
- this._trackLinks.length = this._trackCount, it(this._trackLinks, e, this), this._links = this._trackLinks;
643
+ this._trackLinks.length = this._trackCount, ot(this._trackLinks, e, this), this._links = this._trackLinks;
644
+ }
645
+ _updateErrorDepCount() {
646
+ let e = 0;
647
+ const t = this._links;
648
+ for (let s = 0, i = t.length; s < i; s++) {
649
+ const o = t[s]?.node;
650
+ o && o.flags & d.HAS_ERROR && e++;
651
+ }
652
+ this._errorDepCount = e;
631
653
  }
632
654
  _recompute() {
633
655
  if (this.flags & d.RECOMPUTING) return;
634
656
  this.flags |= d.RECOMPUTING;
635
657
  const e = this._links;
636
- this._trackEpoch = ze(), this._trackLinks = X.acquire(), this._trackCount = 0;
658
+ this._trackEpoch = He(), this._trackLinks = X.acquire(), this._trackCount = 0;
637
659
  let t = !1;
638
660
  try {
639
- const s = M.run(this, this._fn);
640
- this._commitDeps(e), t = !0, Xe(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
661
+ const s = B.run(this, this._fn);
662
+ this._commitDeps(e), t = !0, this._updateErrorDepCount(), qe(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
641
663
  } catch (s) {
642
664
  if (!t)
643
665
  try {
644
- this._commitDeps(e), t = !0;
645
- } catch {
666
+ this._commitDeps(e), t = !0, this._updateErrorDepCount();
667
+ } catch (i) {
668
+ A && console.warn("[atom-effect] _commitDeps failed during error recovery:", i);
646
669
  }
647
- this._handleError(s, v.COMPUTED_COMPUTATION_FAILED, !0);
670
+ this._handleError(s, D.COMPUTED_COMPUTATION_FAILED, !0);
648
671
  } finally {
649
- t && e !== L ? X.release(e) : t || X.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = L, this._trackCount = 0, this.flags &= -257;
672
+ t && e !== U ? X.release(e) : t || X.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = U, this._trackCount = 0, this.flags &= -257;
650
673
  }
651
674
  }
652
675
  _handleAsyncComputation(e) {
653
- this.flags = (this.flags | d.PENDING) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Pe;
676
+ this.flags = (this.flags | d.PENDING) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Ue;
654
677
  const t = this._promiseId;
655
678
  e.then(
656
679
  (s) => {
657
680
  if (t === this._promiseId) {
658
681
  if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
659
- return this._asyncRetryCount++ < Ue ? this._markDirty() : this._handleError(
660
- new z(`Async drift threshold exceeded after ${Ue} retries.`),
661
- v.COMPUTED_ASYNC_COMPUTATION_FAILED
682
+ return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
683
+ new z(
684
+ `Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
685
+ ),
686
+ D.COMPUTED_ASYNC_COMPUTATION_FAILED
662
687
  );
663
688
  this._finalizeResolution(s), this._notifySubscribers(s, void 0);
664
689
  }
665
690
  },
666
- (s) => t === this._promiseId && this._handleError(s, v.COMPUTED_ASYNC_COMPUTATION_FAILED)
691
+ (s) => t === this._promiseId && this._handleError(s, D.COMPUTED_ASYNC_COMPUTATION_FAILED)
667
692
  );
668
693
  }
669
694
  _captureVersionSnapshot() {
670
695
  let e = 0;
671
696
  const t = this._links;
672
697
  for (let s = 0, i = t.length; s < i; s++)
673
- e = ((e << 5) - e | 0) + t[s].node.version & W;
698
+ e = ((e << 5) - e | 0) + t[s].node.version & ie;
674
699
  return e;
675
700
  }
676
701
  _handleError(e, t, s = !1) {
677
- const i = ee(e, z, t);
678
- if (!s && !(this.flags & d.REJECTED) && (this.version = this.version + 1 & W), this._error = i, this.flags = this.flags & -121 | (d.REJECTED | d.HAS_ERROR), this._onError)
702
+ const i = Z(e, z, t);
703
+ if (!s && !(this.flags & d.REJECTED) && (this.version = Ie(this.version)), this._error = i, this.flags = this.flags & -121 | ft, this._onError)
679
704
  try {
680
705
  this._onError(i);
681
706
  } catch (o) {
682
- console.error(v.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
707
+ console.error(D.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
683
708
  }
684
709
  if (s) throw i;
685
710
  this._notifySubscribers(void 0, void 0);
686
711
  }
687
712
  _finalizeResolution(e) {
688
- (!(this.flags & d.RESOLVED) || !this._equal(this._value, e)) && (this.version = this.version + 1 & W), this._value = e, this._error = null, this.flags = (this.flags | d.RESOLVED) & -697, this._cachedErrors = null, this._errorCacheEpoch = -1;
713
+ (!(this.flags & d.RESOLVED) || !this._equal(this._value, e)) && (this.version = Ie(this.version)), this._value = e, this._error = null, this.flags = (this.flags | d.RESOLVED) & -697, this._cachedErrors = null, this._errorCacheEpoch = -1;
689
714
  }
690
715
  execute() {
691
716
  this._markDirty();
@@ -696,39 +721,45 @@ class Qe extends He {
696
721
  }
697
722
  }
698
723
  Object.freeze(Qe.prototype);
699
- function at(n, e = {}) {
724
+ function dt(n, e = {}) {
700
725
  return new Qe(n, e);
701
726
  }
702
- class ht extends Ve {
727
+ class _t extends je {
703
728
  constructor(e, t = {}) {
704
- super(), this._cleanup = null, this._links = L, this._nextLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._historyPtr = 0, this._execId = 0, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = t.trackModifications ?? !1;
729
+ super(), this._cleanup = null, this._links = U, this._nextLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._historyPtr = 0, this._execId = 0, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = t.trackModifications ?? !1;
705
730
  const s = Number.isFinite(this._maxExecutions), i = s ? Math.min(this._maxExecutions + 1, q.MAX_EXECUTIONS_PER_SECOND + 1) : 0;
706
- this._historyCapacity = i, this._history = T && s && i > 0 ? new Array(i).fill(0) : null, Y.attachDebugInfo(this, "effect", this.id);
731
+ this._historyCapacity = i, this._history = A && s && i > 0 ? new Array(i).fill(0) : null, Y.attachDebugInfo(this, "effect", this.id);
707
732
  }
708
733
  run() {
709
734
  if (this.flags & P.DISPOSED)
710
- throw new Q(v.EFFECT_DISPOSED);
735
+ throw new G(D.EFFECT_DISPOSED);
711
736
  this.execute(!0);
712
737
  }
713
738
  dispose() {
714
- this.flags & P.DISPOSED || (this.flags |= P.DISPOSED, this._execCleanup(), this._releaseLinks(this._links), this._links = L, this._executeTask = void 0);
739
+ this.flags & P.DISPOSED || (this.flags |= P.DISPOSED, this._execCleanup(), this._releaseLinks(this._links), this._links = U, this._executeTask = void 0);
715
740
  }
716
741
  addDependency(e) {
717
742
  if (!(this.flags & P.EXECUTING) || e._lastSeenEpoch === this._currentEpoch) return;
718
743
  e._lastSeenEpoch = this._currentEpoch;
719
744
  const t = this._nextLinks;
720
745
  if (e._tempUnsub) {
721
- t.push(new be(e, e.version, e._tempUnsub)), e._tempUnsub = void 0;
746
+ t.push(new he(e, e.version, e._tempUnsub)), e._tempUnsub = void 0;
722
747
  return;
723
748
  }
724
749
  try {
725
750
  const s = e.subscribe(() => {
726
751
  if (this._trackModifications && this.flags & P.EXECUTING && (e._modifiedAtEpoch = this._currentEpoch), this._sync) return this.execute();
727
- this._executeTask || (this._executeTask = () => this.execute()), F.schedule(this._executeTask);
752
+ this._executeTask || (this._executeTask = () => this.execute()), $.schedule(this._executeTask);
728
753
  });
729
- t.push(new be(e, e.version, s));
754
+ t.push(new he(e, e.version, s));
730
755
  } catch (s) {
731
- console.error(ee(s, Q, v.EFFECT_EXECUTION_FAILED));
756
+ const i = Z(s, G, D.EFFECT_EXECUTION_FAILED);
757
+ if (console.error(i), this._onError)
758
+ try {
759
+ this._onError(i);
760
+ } catch {
761
+ }
762
+ t.push(new he(e, e.version, void 0));
732
763
  }
733
764
  }
734
765
  /**
@@ -738,17 +769,17 @@ class ht extends Ve {
738
769
  if (this.flags & (P.DISPOSED | P.EXECUTING) || !e && this._links.length > 0 && !this._isDirty()) return;
739
770
  this._checkInfiniteLoops(), this.flags |= P.EXECUTING, this._execCleanup();
740
771
  const t = this._links;
741
- if (t !== L)
772
+ if (t !== U)
742
773
  for (let o = 0, r = t.length; o < r; o++) {
743
774
  const c = t[o];
744
775
  c && (c.node._tempUnsub = c.unsub);
745
776
  }
746
777
  const s = X.acquire();
747
- this._nextLinks = s, this._currentEpoch = ze();
778
+ this._nextLinks = s, this._currentEpoch = He();
748
779
  let i = !1;
749
780
  try {
750
- const o = M.run(this, this._fn);
751
- this._links = s, i = !0, this._checkLoopWarnings(), Xe(o) ? this._handleAsyncResult(o) : this._cleanup = typeof o == "function" ? o : null;
781
+ const o = B.run(this, this._fn);
782
+ this._links = s, i = !0, this._checkLoopWarnings(), qe(o) ? this._handleAsyncResult(o) : this._cleanup = typeof o == "function" ? o : null;
752
783
  } catch (o) {
753
784
  i = !0, this._handleExecutionError(o), this._cleanup = null;
754
785
  } finally {
@@ -764,7 +795,7 @@ class ht extends Ve {
764
795
  try {
765
796
  s();
766
797
  } catch (i) {
767
- this._handleExecutionError(i, v.EFFECT_CLEANUP_FAILED);
798
+ this._handleExecutionError(i, D.EFFECT_CLEANUP_FAILED);
768
799
  }
769
800
  return;
770
801
  }
@@ -775,43 +806,41 @@ class ht extends Ve {
775
806
  }
776
807
  _finalizeDependencies(e, t, s) {
777
808
  if (this._nextLinks = null, e) {
778
- if (t !== L) {
809
+ if (t !== U) {
779
810
  for (let i = 0, o = t.length; i < o; i++) {
780
811
  const r = t[i], c = r?.node._tempUnsub;
781
812
  c && (c(), r && (r.node._tempUnsub = void 0));
782
813
  }
783
814
  X.release(t);
784
815
  }
785
- } else if (this._releaseLinks(s), X.release(s), t !== L)
816
+ } else if (this._releaseLinks(s), X.release(s), t !== U)
786
817
  for (let i = 0, o = t.length; i < o; i++)
787
818
  t[i] && (t[i].node._tempUnsub = void 0);
788
819
  }
789
820
  _releaseLinks(e) {
790
- if (e !== L) {
821
+ if (e !== U) {
791
822
  for (let t = 0, s = e.length; t < s; t++)
792
823
  e[t]?.unsub?.();
793
824
  X.release(e);
794
825
  }
795
826
  }
796
827
  _isDirty() {
797
- const e = this._links, t = M.current;
798
- M.current = null;
828
+ const e = this._links, t = B.current;
829
+ B.current = null;
799
830
  try {
800
831
  for (let s = 0, i = e.length; s < i; s++) {
801
832
  const o = e[s], r = o.node;
802
- if (r.version !== o.version) return !0;
803
- if ("value" in r) {
833
+ if ("value" in r)
804
834
  try {
805
835
  r.value;
806
836
  } catch {
807
- return !0;
837
+ return A && console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`), !0;
808
838
  }
809
- if (r.version !== o.version) return !0;
810
- }
839
+ if (r.version !== o.version) return !0;
811
840
  }
812
841
  return !1;
813
842
  } finally {
814
- M.current = t;
843
+ B.current = t;
815
844
  }
816
845
  }
817
846
  _execCleanup() {
@@ -819,22 +848,20 @@ class ht extends Ve {
819
848
  try {
820
849
  this._cleanup();
821
850
  } catch (e) {
822
- this._handleExecutionError(e, v.EFFECT_CLEANUP_FAILED);
851
+ this._handleExecutionError(e, D.EFFECT_CLEANUP_FAILED);
823
852
  }
824
853
  this._cleanup = null;
825
854
  }
826
855
  }
827
856
  _checkInfiniteLoops() {
828
- const e = Ce;
829
- if (this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), rt() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history) {
857
+ const e = Se;
858
+ if (this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ct() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history) {
830
859
  const t = Date.now();
831
860
  this._history[this._historyPtr] = t, this._historyPtr = (this._historyPtr + 1) % this._historyCapacity;
832
861
  const s = this._history[this._historyPtr] || 0;
833
862
  if (s > 0 && t - s < Je.ONE_SECOND_MS) {
834
- const i = new Q(
835
- "Effect executed too frequently within 1 second. Suspected infinite loop."
836
- );
837
- if (this.dispose(), this._handleExecutionError(i), T) throw i;
863
+ const i = new G(D.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
864
+ if (this.dispose(), this._handleExecutionError(i), A) throw i;
838
865
  }
839
866
  }
840
867
  }
@@ -848,18 +875,18 @@ class ht extends Ve {
848
875
  return (this.flags & P.EXECUTING) !== 0;
849
876
  }
850
877
  _throwInfiniteLoopError(e) {
851
- const t = new Q(
878
+ const t = new G(
852
879
  `Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Te}`
853
880
  );
854
881
  throw this.dispose(), console.error(t), t;
855
882
  }
856
- _handleExecutionError(e, t = v.EFFECT_EXECUTION_FAILED) {
857
- const s = ee(e, Q, t);
883
+ _handleExecutionError(e, t = D.EFFECT_EXECUTION_FAILED) {
884
+ const s = Z(e, G, t);
858
885
  if (console.error(s), this._onError)
859
886
  try {
860
887
  this._onError(s);
861
888
  } catch (i) {
862
- console.error(ee(i, Q, v.CALLBACK_ERROR_IN_ERROR_HANDLER));
889
+ console.error(Z(i, G, D.CALLBACK_ERROR_IN_ERROR_HANDLER));
863
890
  }
864
891
  }
865
892
  _checkLoopWarnings() {
@@ -875,26 +902,26 @@ class ht extends Ve {
875
902
  }
876
903
  }
877
904
  }
878
- function j(n, e = {}) {
905
+ function V(n, e = {}) {
879
906
  if (typeof n != "function")
880
- throw new Q(v.EFFECT_MUST_BE_FUNCTION);
881
- const t = new ht(n, e);
907
+ throw new G(D.EFFECT_MUST_BE_FUNCTION);
908
+ const t = new _t(n, e);
882
909
  return t.execute(), t;
883
910
  }
884
- function ve(n) {
911
+ function Oe(n) {
885
912
  if (typeof n != "function")
886
913
  throw new TypeError("Batch callback must be a function");
887
- F.startBatch();
914
+ $.startBatch();
888
915
  try {
889
916
  return n();
890
917
  } finally {
891
- F.endBatch();
918
+ $.endBatch();
892
919
  }
893
920
  }
894
- function ft(n) {
921
+ function pt(n) {
895
922
  return n !== null && typeof n == "object" && "value" in n && "subscribe" in n;
896
923
  }
897
- function pe(n) {
924
+ function me(n) {
898
925
  if (!n) return "unknown";
899
926
  const e = "jquery" in n ? n[0] : n;
900
927
  if (!e) return "unknown";
@@ -904,14 +931,38 @@ function pe(n) {
904
931
  if (i && i.length > 0) {
905
932
  let o = s;
906
933
  for (let r = 0, c = i.length; r < c; r++) {
907
- const a = i[r];
908
- a && (o += `.${a}`);
934
+ const l = i[r];
935
+ l && (o += `.${l}`);
909
936
  }
910
937
  return o;
911
938
  }
912
939
  return s;
913
940
  }
914
- function dt(n) {
941
+ function Ge(n) {
942
+ let e = String(n ?? "");
943
+ if (e = e.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""), e = e.replace(/<\?[\s\S]*?\?>/g, "").replace(
944
+ /<(script|iframe|object|embed|base|meta|form|applet|link|style|template|noscript|title)\b[^>]*>([\s\S]*?)<\/\1>/gim,
945
+ ""
946
+ ).replace(
947
+ /<(script|iframe|object|embed|base|meta|form|applet|link|style|template|noscript|title)\b[^>]*\/?>/gim,
948
+ ""
949
+ ), ((o) => o.replace(/&#x([0-9a-f]+);?/gi, (r, c) => String.fromCharCode(parseInt(c, 16))).replace(/&#([0-9]+);?/gi, (r, c) => String.fromCharCode(parseInt(c, 10))))(e).match(/(?:java|vb)script:|data:/i)) {
950
+ const o = (r) => new RegExp(
951
+ `${r.split("").map((c) => {
952
+ const l = c.charCodeAt(0);
953
+ return `(?:${c}|&#0*${l};?|&#x0*${l.toString(16)};?)`;
954
+ }).join("\\s*")}\\s*(?::|&colon;|&#x?0*((58)|(3a));?|%3a)`,
955
+ "gi"
956
+ );
957
+ e = e.replace(o("javascript"), "data-unsafe-protocol:").replace(o("vbscript"), "data-unsafe-protocol:");
958
+ } else {
959
+ const o = /((?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*(?::|&colon;|&#x?0*((58)|(3a));?|%3a))/gim;
960
+ e = e.replace(o, "data-unsafe-protocol:");
961
+ }
962
+ const i = /data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript)/gim;
963
+ return e = e.replace(i, "data-unsafe-protocol:"), e = e.replace(/\bon\w+\s*=/gim, "data-unsafe-attr="), e = e.replace(/expression\s*\(/gim, "data-unsafe-css(").replace(/behavior\s*:/gim, "data-unsafe-css:"), e;
964
+ }
965
+ function Et(n) {
915
966
  const e = n.length;
916
967
  if (e === 0) return new Int32Array(0);
917
968
  const t = new Int32Array(e), s = new Int32Array(e);
@@ -919,18 +970,18 @@ function dt(n) {
919
970
  for (let r = 0; r < e; r++) {
920
971
  const c = n[r];
921
972
  if (c === void 0 || c === -1) continue;
922
- const a = i > 0 ? s[i - 1] : void 0;
923
- if (i === 0 || a !== void 0 && (n[a] ?? -1) < c) {
924
- t[r] = a ?? -1, s[i++] = r;
973
+ const l = i > 0 ? s[i - 1] : void 0;
974
+ if (i === 0 || l !== void 0 && (n[l] ?? -1) < c) {
975
+ t[r] = l ?? -1, s[i++] = r;
925
976
  continue;
926
977
  }
927
- let f = 0, p = i - 1;
928
- for (; f < p; ) {
929
- const I = f + p >>> 1, O = s[I];
930
- O !== void 0 && (n[O] ?? -1) < c ? f = I + 1 : p = I;
978
+ let _ = 0, g = i - 1;
979
+ for (; _ < g; ) {
980
+ const C = _ + g >>> 1, k = s[C];
981
+ k !== void 0 && (n[k] ?? -1) < c ? _ = C + 1 : g = C;
931
982
  }
932
- const D = s[f];
933
- D !== void 0 && c < (n[D] ?? Number.MAX_SAFE_INTEGER) && (f > 0 && (t[r] = s[f - 1] ?? -1), s[f] = r);
983
+ const v = s[_];
984
+ v !== void 0 && c < (n[v] ?? Number.MAX_SAFE_INTEGER) && (_ > 0 && (t[r] = s[_ - 1] ?? -1), s[_] = r);
934
985
  }
935
986
  const o = new Int32Array(i);
936
987
  if (i > 0) {
@@ -940,7 +991,7 @@ function dt(n) {
940
991
  }
941
992
  return o;
942
993
  }
943
- function _t() {
994
+ function gt() {
944
995
  if (typeof window < "u") {
945
996
  const n = window.__ATOM_DEBUG__;
946
997
  if (typeof n == "boolean") return n;
@@ -951,19 +1002,19 @@ function _t() {
951
1002
  }
952
1003
  return !1;
953
1004
  }
954
- let G = _t();
955
- const m = {
1005
+ let Q = gt();
1006
+ const b = {
956
1007
  get enabled() {
957
- return G;
1008
+ return Q;
958
1009
  },
959
1010
  set enabled(n) {
960
- G = n;
1011
+ Q = n;
961
1012
  },
962
1013
  log(n, ...e) {
963
- G && console.log(`[atom-effect-jquery] ${n}:`, ...e);
1014
+ Q && console.log(`[atom-effect-jquery] ${n}:`, ...e);
964
1015
  },
965
1016
  atomChanged(n, e, t) {
966
- G && console.log(
1017
+ Q && console.log(
967
1018
  `[atom-effect-jquery] Atom "${n ?? "anonymous"}" changed:`,
968
1019
  e,
969
1020
  "→",
@@ -974,20 +1025,20 @@ const m = {
974
1025
  * Logs DOM updates and triggers visual highlight.
975
1026
  */
976
1027
  domUpdated(n, e, t) {
977
- G && (console.log(`[atom-effect-jquery] DOM updated: ${pe(n)}.${e} =`, t), Et(n));
1028
+ Q && (console.log(`[atom-effect-jquery] DOM updated: ${me(n)}.${e} =`, t), mt(n));
978
1029
  },
979
1030
  cleanup(n) {
980
- G && console.log(`[atom-effect-jquery] Cleanup: ${n}`);
1031
+ Q && console.log(`[atom-effect-jquery] Cleanup: ${n}`);
981
1032
  },
982
1033
  warn(...n) {
983
- G && console.warn("[atom-effect-jquery]", ...n);
1034
+ Q && console.warn("[atom-effect-jquery]", ...n);
984
1035
  }
985
- }, me = /* @__PURE__ */ new WeakMap();
986
- function Et(n) {
1036
+ }, be = /* @__PURE__ */ new WeakMap();
1037
+ function mt(n) {
987
1038
  const e = "jquery" in n ? n[0] : n;
988
1039
  if (!e || !e.isConnected) return;
989
- let t = me.get(e);
990
- if (t || (t = {}, me.set(e, t)), t.timer && clearTimeout(t.timer), t.cleanupTimer && clearTimeout(t.cleanupTimer), !t.orgStyle) {
1040
+ let t = be.get(e);
1041
+ if (t || (t = {}, be.set(e, t)), t.timer && clearTimeout(t.timer), t.cleanupTimer && clearTimeout(t.cleanupTimer), !t.orgStyle) {
991
1042
  const i = e.style;
992
1043
  t.orgStyle = {
993
1044
  outline: i.outline,
@@ -1001,40 +1052,40 @@ function Et(n) {
1001
1052
  if (!e.isConnected) return;
1002
1053
  const i = t?.orgStyle;
1003
1054
  i && (s.outline = i.outline, s.outlineOffset = i.outlineOffset), t.cleanupTimer = setTimeout(() => {
1004
- e.isConnected && t?.orgStyle && (s.transition = t.orgStyle.transition), me.delete(e);
1055
+ e.isConnected && t?.orgStyle && (s.transition = t.orgStyle.transition), be.delete(e);
1005
1056
  }, 500);
1006
1057
  }));
1007
1058
  }, 100);
1008
1059
  }
1009
- const pt = /* @__PURE__ */ new WeakMap();
1060
+ const yt = /* @__PURE__ */ new WeakMap();
1010
1061
  function Ye(n, e = {}) {
1011
- const t = qe(n, e);
1012
- return e.name && pt.set(t, { name: e.name }), t;
1062
+ const t = ze(n, e);
1063
+ return e.name && yt.set(t, { name: e.name }), t;
1013
1064
  }
1014
1065
  Object.defineProperty(Ye, "debug", {
1015
1066
  get() {
1016
- return m.enabled;
1067
+ return b.enabled;
1017
1068
  },
1018
1069
  set(n) {
1019
- m.enabled = n;
1070
+ b.enabled = n;
1020
1071
  }
1021
1072
  });
1022
- function gt() {
1073
+ function bt() {
1023
1074
  return new Promise((n) => setTimeout(n, 0));
1024
1075
  }
1025
- l.extend({
1076
+ u.extend({
1026
1077
  atom: Ye,
1027
- computed: at,
1028
- effect: j,
1029
- batch: ve,
1030
- untracked: ct,
1031
- isAtom: Se,
1078
+ computed: dt,
1079
+ effect: V,
1080
+ batch: Oe,
1081
+ untracked: at,
1082
+ isAtom: De,
1032
1083
  isComputed: Le,
1033
- isReactive: (n) => Se(n) || Le(n),
1034
- nextTick: gt
1084
+ isReactive: (n) => De(n) || Le(n),
1085
+ nextTick: bt
1035
1086
  });
1036
- const le = "_aes-bound";
1037
- class mt {
1087
+ const ue = "_aes-bound";
1088
+ class Ct {
1038
1089
  records = /* @__PURE__ */ new WeakMap();
1039
1090
  boundElements = /* @__PURE__ */ new WeakSet();
1040
1091
  preservedNodes = /* @__PURE__ */ new WeakSet();
@@ -1054,7 +1105,7 @@ class mt {
1054
1105
  }
1055
1106
  _getOrCreateRecord(e) {
1056
1107
  let t = this.records.get(e);
1057
- return t || (t = {}, this.records.set(e, t), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(le))), t;
1108
+ return t || (t = {}, this.records.set(e, t), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(ue))), t;
1058
1109
  }
1059
1110
  trackEffect(e, t) {
1060
1111
  const s = this._getOrCreateRecord(e);
@@ -1071,14 +1122,14 @@ class mt {
1071
1122
  if (!this.boundElements.delete(e)) return;
1072
1123
  const t = this.records.get(e);
1073
1124
  if (!t) return;
1074
- this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(le), m.enabled && m.cleanup(pe(e));
1125
+ this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(ue), b.enabled && b.cleanup(me(e));
1075
1126
  const s = t.effects;
1076
1127
  if (s)
1077
1128
  for (let o = 0, r = s.length; o < r; o++)
1078
1129
  try {
1079
1130
  s[o]?.dispose();
1080
1131
  } catch (c) {
1081
- m.warn("Effect dispose error:", c);
1132
+ b.warn("Effect dispose error:", c);
1082
1133
  }
1083
1134
  const i = t.cleanups;
1084
1135
  if (i)
@@ -1086,24 +1137,24 @@ class mt {
1086
1137
  try {
1087
1138
  i[o]?.();
1088
1139
  } catch (c) {
1089
- m.warn("Cleanup error:", c);
1140
+ b.warn("Cleanup error:", c);
1090
1141
  }
1091
1142
  }
1092
1143
  cleanupDescendants(e) {
1093
- const t = e.querySelectorAll(`.${le}`);
1144
+ const t = e.querySelectorAll(`.${ue}`);
1094
1145
  for (let s = 0, i = t.length; s < i; s++) {
1095
1146
  const o = t[s];
1096
- o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(le);
1147
+ o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(ue);
1097
1148
  }
1098
1149
  }
1099
1150
  cleanupTree(e) {
1100
1151
  this.cleanupDescendants(e), this.cleanup(e);
1101
1152
  }
1102
1153
  }
1103
- const y = new mt();
1104
- let ie = null;
1105
- function yt(n = document.body) {
1106
- ie || (ie = new MutationObserver((e) => {
1154
+ const y = new Ct();
1155
+ let se = null;
1156
+ function It(n = document.body) {
1157
+ se || (se = new MutationObserver((e) => {
1107
1158
  for (let t = 0, s = e.length; t < s; t++) {
1108
1159
  const i = e[t]?.removedNodes;
1109
1160
  if (!i) continue;
@@ -1114,19 +1165,19 @@ function yt(n = document.body) {
1114
1165
  c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
1115
1166
  }
1116
1167
  }
1117
- }), ie.observe(n, { childList: !0, subtree: !0 }));
1168
+ }), se.observe(n, { childList: !0, subtree: !0 }));
1118
1169
  }
1119
- function Ut() {
1120
- ie?.disconnect(), ie = null;
1170
+ function $t() {
1171
+ se?.disconnect(), se = null;
1121
1172
  }
1122
- function k(n, e, t, s) {
1123
- ft(e) ? y.trackEffect(
1173
+ function O(n, e, t, s) {
1174
+ pt(e) ? y.trackEffect(
1124
1175
  n,
1125
- j(() => {
1176
+ V(() => {
1126
1177
  const i = e.value;
1127
- t(i), m.domUpdated(l(n), s, i);
1178
+ t(i), b.domUpdated(u(n), s, i);
1128
1179
  })
1129
- ) : (t(e), m.domUpdated(l(n), s, e));
1180
+ ) : (t(e), b.domUpdated(u(n), s, e));
1130
1181
  }
1131
1182
  var S = /* @__PURE__ */ ((n) => (n[n.None = 0] = "None", n[n.Focused = 1] = "Focused", n[n.Composing = 2] = "Composing", n[n.SyncingToAtom = 4] = "SyncingToAtom", n[n.SyncingToDom = 8] = "SyncingToDom", n[n.Busy = 14] = "Busy", n))(S || {});
1132
1183
  function ke() {
@@ -1140,76 +1191,84 @@ function We(n, e, t = {}) {
1140
1191
  const {
1141
1192
  debounce: s,
1142
1193
  event: i = "input",
1143
- parse: o = (N) => N,
1144
- format: r = (N) => String(N ?? ""),
1194
+ parse: o = (w) => w,
1195
+ format: r = (w) => String(w ?? ""),
1145
1196
  equal: c = Object.is
1146
- } = t, a = ke(), f = n[0], p = () => {
1147
- if (!(a.flags & S.Busy)) {
1148
- a.flags |= S.SyncingToAtom;
1197
+ } = t, l = ke(), _ = n[0], g = () => {
1198
+ if (!(l.flags & S.Busy)) {
1199
+ l.flags |= S.SyncingToAtom;
1149
1200
  try {
1150
- const N = f.value, A = o(N);
1151
- c(e.value, A) || (e.value = A);
1201
+ const w = _.value, N = o(w);
1202
+ c(e.value, N) || (e.value = N);
1152
1203
  } finally {
1153
- a.flags &= ~S.SyncingToAtom;
1204
+ l.flags &= ~S.SyncingToAtom;
1154
1205
  }
1155
1206
  }
1156
- }, D = () => {
1157
- a.timeoutId && (clearTimeout(a.timeoutId), a.timeoutId = null, p()), a.flags &= ~S.Focused;
1158
- const N = r(e.value);
1159
- f.value !== N && (f.value = N);
1160
- }, I = () => {
1161
- a.flags & S.Busy || (s ? (a.timeoutId && clearTimeout(a.timeoutId), a.timeoutId = setTimeout(p, s)) : p());
1162
- }, O = {
1207
+ }, v = () => {
1208
+ l.timeoutId && (clearTimeout(l.timeoutId), l.timeoutId = null, g()), l.flags &= ~S.Focused;
1209
+ const w = r(e.value);
1210
+ _.value !== w && (_.value = w);
1211
+ }, C = () => {
1212
+ l.flags & S.Busy || (s ? (l.timeoutId && clearTimeout(l.timeoutId), l.timeoutId = setTimeout(g, s)) : g());
1213
+ }, k = {
1163
1214
  compositionstart: () => {
1164
- a.flags |= S.Composing;
1215
+ l.flags |= S.Composing;
1165
1216
  },
1166
1217
  compositionend: () => {
1167
- a.flags &= ~S.Composing, p();
1218
+ l.flags &= ~S.Composing, g();
1168
1219
  },
1169
1220
  focus: () => {
1170
- a.flags |= S.Focused;
1221
+ l.flags |= S.Focused;
1171
1222
  },
1172
- blur: D,
1173
- [i]: I,
1174
- change: I
1223
+ blur: v,
1224
+ [i]: C,
1225
+ change: C
1175
1226
  };
1176
- return n.on(O), { effect: () => {
1177
- const N = e.value, A = r(N), R = f.value;
1178
- if (R !== A && !(a.flags & S.Focused && c(o(R), N))) {
1179
- a.flags |= S.SyncingToDom;
1227
+ return n.on(k), { effect: () => {
1228
+ const w = e.value, N = r(w), x = _.value;
1229
+ if (x !== N && !(l.flags & S.Focused && c(o(x), w))) {
1230
+ l.flags |= S.SyncingToDom;
1180
1231
  try {
1181
- if (a.flags & S.Focused) {
1182
- const { selectionStart: x, selectionEnd: K } = f;
1183
- f.value = A;
1184
- const U = A.length;
1185
- f.setSelectionRange(Math.min(x ?? U, U), Math.min(K ?? U, U));
1232
+ if (l.flags & S.Focused) {
1233
+ const { selectionStart: L, selectionEnd: W } = _;
1234
+ _.value = N;
1235
+ const F = N.length;
1236
+ _.setSelectionRange(Math.min(L ?? F, F), Math.min(W ?? F, F));
1186
1237
  } else
1187
- f.value = A;
1188
- m.domUpdated(n, "val", A);
1238
+ _.value = N;
1239
+ b.domUpdated(n, "val", N);
1189
1240
  } finally {
1190
- a.flags &= ~S.SyncingToDom;
1241
+ l.flags &= ~S.SyncingToDom;
1191
1242
  }
1192
1243
  }
1193
1244
  }, cleanup: () => {
1194
- n.off(O), a.timeoutId && clearTimeout(a.timeoutId);
1245
+ n.off(k), l.timeoutId && clearTimeout(l.timeoutId);
1195
1246
  } };
1196
1247
  }
1197
- l.fn.atomText = function(n, e) {
1248
+ u.fn.atomText = function(n, e) {
1198
1249
  return this.each(function() {
1199
- const t = l(this);
1200
- k(this, n, e ? (i) => t.text(e(i)) : (i) => t.text(String(i ?? "")), "text");
1250
+ const t = u(this);
1251
+ O(this, n, e ? (i) => t.text(e(i)) : (i) => t.text(String(i ?? "")), "text");
1201
1252
  });
1202
1253
  };
1203
- l.fn.atomHtml = function(n) {
1254
+ u.fn.atomHtml = function(n) {
1204
1255
  return this.each(function() {
1205
- const e = l(this);
1206
- k(this, n, (t) => e.html(String(t ?? "")), "html");
1256
+ const e = u(this);
1257
+ O(
1258
+ this,
1259
+ n,
1260
+ (t) => {
1261
+ const s = String(t ?? ""), i = Ge(s);
1262
+ i !== s && console.warn("[atomHtml] Unsafe content neutralized during sanitization."), e.html(i);
1263
+ },
1264
+ "html"
1265
+ );
1207
1266
  });
1208
1267
  };
1209
- l.fn.atomClass = function(n, e) {
1268
+ u.fn.atomClass = function(n, e) {
1210
1269
  return this.each(function() {
1211
- const t = l(this);
1212
- k(
1270
+ const t = u(this);
1271
+ O(
1213
1272
  this,
1214
1273
  e,
1215
1274
  (s) => t.toggleClass(n, !!s),
@@ -1217,16 +1276,16 @@ l.fn.atomClass = function(n, e) {
1217
1276
  );
1218
1277
  });
1219
1278
  };
1220
- l.fn.atomCss = function(n, e, t) {
1279
+ u.fn.atomCss = function(n, e, t) {
1221
1280
  return this.each(function() {
1222
- const s = l(this);
1223
- k(this, e, t ? (o) => s.css(n, `${o}${t}`) : (o) => s.css(n, o), `css.${n}`);
1281
+ const s = u(this);
1282
+ O(this, e, t ? (o) => s.css(n, `${o}${t}`) : (o) => s.css(n, o), `css.${n}`);
1224
1283
  });
1225
1284
  };
1226
- l.fn.atomAttr = function(n, e) {
1285
+ u.fn.atomAttr = function(n, e) {
1227
1286
  return this.each(function() {
1228
- const t = l(this);
1229
- k(
1287
+ const t = u(this);
1288
+ O(
1230
1289
  this,
1231
1290
  e,
1232
1291
  (s) => {
@@ -1240,65 +1299,70 @@ l.fn.atomAttr = function(n, e) {
1240
1299
  );
1241
1300
  });
1242
1301
  };
1243
- l.fn.atomProp = function(n, e) {
1302
+ u.fn.atomProp = function(n, e) {
1244
1303
  return this.each(function() {
1245
- const t = l(this);
1246
- k(this, e, (s) => t.prop(n, s), `prop.${n}`);
1304
+ const t = u(this);
1305
+ O(this, e, (s) => t.prop(n, s), `prop.${n}`);
1247
1306
  });
1248
1307
  };
1249
- l.fn.atomShow = function(n) {
1308
+ u.fn.atomShow = function(n) {
1250
1309
  return this.each(function() {
1251
- const e = l(this);
1252
- k(this, n, (t) => e.toggle(!!t), "show");
1310
+ const e = u(this);
1311
+ O(this, n, (t) => e.toggle(!!t), "show");
1253
1312
  });
1254
1313
  };
1255
- l.fn.atomHide = function(n) {
1314
+ u.fn.atomHide = function(n) {
1256
1315
  return this.each(function() {
1257
- const e = l(this);
1258
- k(this, n, (t) => e.toggle(!t), "hide");
1316
+ const e = u(this);
1317
+ O(this, n, (t) => e.toggle(!t), "hide");
1259
1318
  });
1260
1319
  };
1261
- l.fn.atomVal = function(n, e = {}) {
1320
+ u.fn.atomVal = function(n, e = {}) {
1262
1321
  return this.each(function() {
1263
- const { effect: t, cleanup: s } = We(l(this), n, e);
1264
- y.trackEffect(this, j(t)), y.trackCleanup(this, s);
1322
+ const t = this.tagName.toLowerCase();
1323
+ if (!["input", "select", "textarea"].includes(t)) {
1324
+ console.warn(`[atomVal] Element <${t}> is not a valid input element.`);
1325
+ return;
1326
+ }
1327
+ const { effect: s, cleanup: i } = We(u(this), n, e);
1328
+ y.trackEffect(this, V(s)), y.trackCleanup(this, i);
1265
1329
  });
1266
1330
  };
1267
- l.fn.atomChecked = function(n) {
1331
+ u.fn.atomChecked = function(n) {
1268
1332
  return this.each(function() {
1269
- const e = l(this), t = this, s = ke(), i = () => {
1333
+ const e = u(this), t = this, s = ke(), i = () => {
1270
1334
  if (s.flags & S.Busy) return;
1271
1335
  const r = t.checked;
1272
1336
  n.value !== r && (n.value = r);
1273
1337
  };
1274
1338
  e.on("change", i), y.trackCleanup(this, () => e.off("change", i));
1275
- const o = j(() => {
1339
+ const o = V(() => {
1276
1340
  s.flags |= S.SyncingToDom;
1277
1341
  const r = !!n.value;
1278
- t.checked !== r && (t.checked = r, m.domUpdated(e, "checked", r)), s.flags &= ~S.SyncingToDom;
1342
+ t.checked !== r && (t.checked = r, b.domUpdated(e, "checked", r)), s.flags &= ~S.SyncingToDom;
1279
1343
  });
1280
1344
  y.trackEffect(this, o);
1281
1345
  });
1282
1346
  };
1283
- l.fn.atomOn = function(n, e) {
1347
+ u.fn.atomOn = function(n, e) {
1284
1348
  return this.each(function() {
1285
- const t = l(this);
1349
+ const t = u(this);
1286
1350
  t.on(n, e), y.trackCleanup(this, () => t.off(n, e));
1287
1351
  });
1288
1352
  };
1289
- l.fn.atomUnbind = function() {
1353
+ u.fn.atomUnbind = function() {
1290
1354
  return this.each(function() {
1291
1355
  y.cleanupTree(this);
1292
1356
  });
1293
1357
  };
1294
1358
  const Fe = /* @__PURE__ */ Object.create(null);
1295
- function bt(n) {
1359
+ function St(n) {
1296
1360
  let e = Fe[n];
1297
1361
  return e || (e = n.includes("-") ? n.replace(/-./g, (t) => t[1].toUpperCase()) : n, Fe[n] = e, e);
1298
1362
  }
1299
- function It(n, e) {
1363
+ function Dt(n, e) {
1300
1364
  const t = n.el;
1301
- k(
1365
+ O(
1302
1366
  t,
1303
1367
  e,
1304
1368
  (s) => {
@@ -1308,21 +1372,23 @@ function It(n, e) {
1308
1372
  "text"
1309
1373
  );
1310
1374
  }
1311
- function Ct(n, e) {
1375
+ function vt(n, e) {
1312
1376
  const t = n.el;
1313
- k(
1377
+ O(
1314
1378
  t,
1315
1379
  e,
1316
1380
  (s) => {
1317
- const i = String(s ?? "");
1318
- t.innerHTML !== i && (t.innerHTML = i);
1381
+ const i = String(s ?? ""), o = Ge(i);
1382
+ o !== i && console.warn("[atomBind] Unsafe content neutralized during sanitization.");
1383
+ const r = o;
1384
+ t.innerHTML !== r && (t.innerHTML = r);
1319
1385
  },
1320
1386
  "html"
1321
1387
  );
1322
1388
  }
1323
- function St(n, e) {
1389
+ function Tt(n, e) {
1324
1390
  for (const t in e)
1325
- k(
1391
+ O(
1326
1392
  n.el,
1327
1393
  e[t],
1328
1394
  (s) => {
@@ -1331,20 +1397,20 @@ function St(n, e) {
1331
1397
  `class.${t}`
1332
1398
  );
1333
1399
  }
1334
- function Dt(n, e) {
1400
+ function Ot(n, e) {
1335
1401
  const t = n.el, s = t.style;
1336
1402
  for (const i in e) {
1337
1403
  const o = e[i];
1338
1404
  if (o === void 0) continue;
1339
- const r = bt(i);
1340
- Array.isArray(o) ? k(
1405
+ const r = St(i);
1406
+ Array.isArray(o) ? O(
1341
1407
  t,
1342
1408
  o[0],
1343
1409
  (c) => {
1344
1410
  s[r] = `${c}${o[1]}`;
1345
1411
  },
1346
1412
  `css.${i}`
1347
- ) : k(
1413
+ ) : O(
1348
1414
  t,
1349
1415
  o,
1350
1416
  (c) => {
@@ -1354,10 +1420,10 @@ function Dt(n, e) {
1354
1420
  );
1355
1421
  }
1356
1422
  }
1357
- function Tt(n, e) {
1423
+ function kt(n, e) {
1358
1424
  const t = n.el;
1359
1425
  for (const s in e)
1360
- k(
1426
+ O(
1361
1427
  t,
1362
1428
  e[s],
1363
1429
  (i) => {
@@ -1371,10 +1437,10 @@ function Tt(n, e) {
1371
1437
  `attr.${s}`
1372
1438
  );
1373
1439
  }
1374
- function vt(n, e) {
1440
+ function wt(n, e) {
1375
1441
  const t = n.el;
1376
1442
  for (const s in e)
1377
- k(
1443
+ O(
1378
1444
  n.el,
1379
1445
  e[s],
1380
1446
  (i) => {
@@ -1383,35 +1449,40 @@ function vt(n, e) {
1383
1449
  `prop.${s}`
1384
1450
  );
1385
1451
  }
1386
- function kt(n, e) {
1452
+ function Nt(n, e) {
1387
1453
  const t = n.el;
1388
- k(
1454
+ O(
1389
1455
  t,
1390
1456
  e,
1391
1457
  (s) => {
1392
- t.style.display = s ? "" : "none", m.enabled && m.domUpdated(t, "show", s);
1458
+ t.style.display = s ? "" : "none", b.enabled && b.domUpdated(t, "show", s);
1393
1459
  },
1394
1460
  "show"
1395
1461
  );
1396
1462
  }
1397
- function Ot(n, e) {
1463
+ function Rt(n, e) {
1398
1464
  const t = n.el;
1399
- k(
1465
+ O(
1400
1466
  t,
1401
1467
  e,
1402
1468
  (s) => {
1403
- t.style.display = s ? "none" : "", m.enabled && m.domUpdated(t, "hide", s);
1469
+ t.style.display = s ? "none" : "", b.enabled && b.domUpdated(t, "hide", s);
1404
1470
  },
1405
1471
  "hide"
1406
1472
  );
1407
1473
  }
1408
- function Nt(n, e) {
1409
- const t = Array.isArray(e), { effect: s, cleanup: i } = We(
1474
+ function xt(n, e) {
1475
+ const t = n.el.tagName.toLowerCase();
1476
+ if (!["input", "select", "textarea"].includes(t)) {
1477
+ console.warn(`[atomBind] Val binding used on non-input element <${t}>.`);
1478
+ return;
1479
+ }
1480
+ const s = Array.isArray(e), { effect: i, cleanup: o } = We(
1410
1481
  n.$el,
1411
- t ? e[0] : e,
1412
- t ? e[1] : {}
1482
+ s ? e[0] : e,
1483
+ s ? e[1] : {}
1413
1484
  );
1414
- y.trackEffect(n.el, j(s)), n.trackCleanup(i);
1485
+ y.trackEffect(n.el, V(i)), n.trackCleanup(o);
1415
1486
  }
1416
1487
  function At(n, e) {
1417
1488
  const t = n.el, s = ke(), i = () => {
@@ -1420,151 +1491,151 @@ function At(n, e) {
1420
1491
  e.value !== r && (e.value = r);
1421
1492
  };
1422
1493
  t.addEventListener("change", i), n.trackCleanup(() => t.removeEventListener("change", i));
1423
- const o = j(() => {
1494
+ const o = V(() => {
1424
1495
  s.flags |= S.SyncingToDom;
1425
1496
  const r = !!e.value;
1426
- t.checked !== r && (t.checked = r, m.enabled && m.domUpdated(t, "checked", r)), s.flags &= ~S.SyncingToDom;
1497
+ t.checked !== r && (t.checked = r, b.enabled && b.domUpdated(t, "checked", r)), s.flags &= ~S.SyncingToDom;
1427
1498
  });
1428
1499
  y.trackEffect(t, o);
1429
1500
  }
1430
- function wt(n, e) {
1501
+ function Lt(n, e) {
1431
1502
  for (const t in e) {
1432
1503
  const s = e[t];
1433
1504
  if (typeof s != "function") continue;
1434
1505
  const i = (o) => {
1435
- ve(
1506
+ Oe(
1436
1507
  () => s.call(
1437
1508
  n.el,
1438
- l.Event(o.type, { originalEvent: o })
1509
+ u.Event(o.type, { originalEvent: o })
1439
1510
  )
1440
1511
  );
1441
1512
  };
1442
1513
  n.el.addEventListener(t, i), n.trackCleanup(() => n.el.removeEventListener(t, i));
1443
1514
  }
1444
1515
  }
1445
- l.fn.atomBind = function(n) {
1516
+ u.fn.atomBind = function(n) {
1446
1517
  return this.each(function() {
1447
1518
  const e = this;
1448
1519
  let t = null;
1449
1520
  const s = {
1450
1521
  get $el() {
1451
- return t || (t = l(e)), t;
1522
+ return t || (t = u(e)), t;
1452
1523
  },
1453
1524
  el: e,
1454
1525
  trackCleanup: (i) => y.trackCleanup(e, i)
1455
1526
  };
1456
- n.text !== void 0 && It(s, n.text), n.html !== void 0 && Ct(s, n.html), n.class && St(s, n.class), n.css && Dt(s, n.css), n.attr && Tt(s, n.attr), n.prop && vt(s, n.prop), n.show !== void 0 && kt(s, n.show), n.hide !== void 0 && Ot(s, n.hide), n.val !== void 0 && Nt(s, n.val), n.checked !== void 0 && At(s, n.checked), n.on && wt(s, n.on);
1527
+ n.text !== void 0 && Dt(s, n.text), n.html !== void 0 && vt(s, n.html), n.class && Tt(s, n.class), n.css && Ot(s, n.css), n.attr && kt(s, n.attr), n.prop && wt(s, n.prop), n.show !== void 0 && Nt(s, n.show), n.hide !== void 0 && Rt(s, n.hide), n.val !== void 0 && xt(s, n.val), n.checked !== void 0 && At(s, n.checked), n.on && Lt(s, n.on);
1457
1528
  });
1458
1529
  };
1459
- l.fn.atomList = function(n, e) {
1460
- const { key: t, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: a } = e, f = typeof t == "function" ? t : (p, D) => p[t];
1530
+ u.fn.atomList = function(n, e) {
1531
+ const { key: t, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: l } = e, _ = typeof t == "function" ? t : (g, v) => g[t];
1461
1532
  return this.each(function() {
1462
- const p = l(this), D = pe(this), I = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Set();
1463
- let w = [], $ = null;
1464
- const N = j(() => {
1465
- const A = n.value, R = A.length;
1466
- if (R === 0 ? a && !$ && ($ = l(a).appendTo(p)) : $ && ($.remove(), $ = null), R === 0 && I.size === 0) {
1467
- w = [];
1533
+ const g = u(this), v = me(this), C = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
1534
+ let R = [], M = null;
1535
+ const w = V(() => {
1536
+ const N = n.value, x = N.length;
1537
+ if (x === 0 ? l && !M && (M = u(l).appendTo(g)) : M && (M.remove(), M = null), x === 0 && C.size === 0) {
1538
+ R = [];
1468
1539
  return;
1469
1540
  }
1470
- m.log("list", `${D} updating with ${R} items`);
1471
- const x = /* @__PURE__ */ new Map(), K = w.length;
1472
- for (let u = 0; u < K; u++)
1473
- x.set(w[u], u);
1474
- const U = new Array(R), J = /* @__PURE__ */ new Set(), re = new Int32Array(R);
1475
- for (let u = 0; u < R; u++) {
1476
- const E = A[u], _ = f(E, u);
1477
- m.enabled && J.has(_) && console.warn(`[atomList] Duplicate key "${_}" at index ${u}.`), U[u] = _, J.add(_), re[u] = x.get(_) ?? -1;
1541
+ b.log("list", `${v} updating with ${x} items`);
1542
+ const L = /* @__PURE__ */ new Map(), W = R.length;
1543
+ for (let a = 0; a < W; a++)
1544
+ L.set(R[a], a);
1545
+ const F = new Array(x), K = /* @__PURE__ */ new Set(), re = new Int32Array(x);
1546
+ for (let a = 0; a < x; a++) {
1547
+ const E = N[a], f = _(E, a);
1548
+ K.has(f) && console.warn(`[atomList] Duplicate key "${f}" at index ${a}.`), F[a] = f, K.add(f), re[a] = L.get(f) ?? -1;
1478
1549
  }
1479
- if (I.size > 0)
1480
- for (const [u, E] of I) {
1481
- if (J.has(u) || O.has(u)) continue;
1482
- const _ = () => {
1483
- E.$el.remove(), E.$el[0] && y.cleanup(E.$el[0]), O.delete(u), m.log("list", `${D} removed item:`, u);
1550
+ if (C.size > 0)
1551
+ for (const [a, E] of C) {
1552
+ if (K.has(a) || k.has(a)) continue;
1553
+ const f = () => {
1554
+ E.$el.remove(), E.$el[0] && y.cleanup(E.$el[0]), k.delete(a), b.log("list", `${v} removed item:`, a);
1484
1555
  };
1485
- if (I.delete(u), O.add(u), c) {
1486
- const g = c(E.$el);
1487
- g instanceof Promise ? g.then(_) : _();
1556
+ if (C.delete(a), k.add(a), c) {
1557
+ const p = c(E.$el);
1558
+ p instanceof Promise ? p.then(f) : f();
1488
1559
  } else
1489
- _();
1560
+ f();
1490
1561
  }
1491
- if (R === 0) {
1492
- w = [];
1562
+ if (x === 0) {
1563
+ R = [];
1493
1564
  return;
1494
1565
  }
1495
- const ne = dt(re);
1496
- let se = ne.length - 1, h = null;
1497
- for (let u = R - 1; u >= 0; u--) {
1498
- const E = U[u], _ = A[u], g = I.get(E);
1499
- if (g) {
1500
- const C = g.item;
1501
- g.item = _;
1502
- const b = g.$el[0];
1503
- if (!b) continue;
1566
+ const te = Et(re);
1567
+ let ne = te.length - 1, h = null;
1568
+ for (let a = x - 1; a >= 0; a--) {
1569
+ const E = F[a], f = N[a], p = C.get(E);
1570
+ if (p) {
1571
+ const T = p.item;
1572
+ p.item = f;
1573
+ const m = p.$el[0];
1574
+ if (!m) continue;
1504
1575
  if (o)
1505
- o(g.$el, _, u), m.domUpdated(g.$el, "list.update", _);
1506
- else if (C !== _) {
1507
- let V = !0;
1508
- if (typeof C == "object" && C !== null && typeof _ == "object" && _ !== null) {
1509
- V = !1;
1510
- let B = 0;
1511
- const ce = C, Oe = _;
1512
- for (const Z in ce) {
1513
- if (ce[Z] !== Oe[Z]) {
1514
- V = !0;
1576
+ o(p.$el, f, a), b.domUpdated(p.$el, "list.update", f);
1577
+ else if (T !== f) {
1578
+ let I = !0;
1579
+ if (typeof T == "object" && T !== null && typeof f == "object" && f !== null) {
1580
+ I = !1;
1581
+ let j = 0;
1582
+ const ce = T, we = f;
1583
+ for (const J in ce) {
1584
+ if (ce[J] !== we[J]) {
1585
+ I = !0;
1515
1586
  break;
1516
1587
  }
1517
- B++;
1588
+ j++;
1518
1589
  }
1519
- if (!V) {
1520
- let Z = 0;
1521
- for (const xt in Oe)
1522
- if (Z++, Z > B) {
1523
- V = !0;
1590
+ if (!I) {
1591
+ let J = 0;
1592
+ for (const Ft in we)
1593
+ if (J++, J > j) {
1594
+ I = !0;
1524
1595
  break;
1525
1596
  }
1526
- B !== Z && (V = !0);
1597
+ j !== J && (I = !0);
1527
1598
  }
1528
1599
  }
1529
- if (V) {
1530
- const B = l(s(_, u)), ce = h === b;
1531
- g.$el.replaceWith(B), g.$el = B, i && i(B, _, u), m.domUpdated(B, "list.render", _), ce && (h = B[0] || null);
1600
+ if (I) {
1601
+ const j = u(s(f, a)), ce = h === m;
1602
+ p.$el.replaceWith(j), p.$el = j, i && i(j, f, a), b.domUpdated(j, "list.render", f), ce && (h = j[0] || null);
1532
1603
  }
1533
1604
  }
1534
- if (se >= 0 && ne[se] === u)
1535
- se--;
1605
+ if (ne >= 0 && te[ne] === a)
1606
+ ne--;
1536
1607
  else {
1537
- const V = g.$el[0];
1538
- h?.isConnected ? h !== V && g.$el.insertBefore(h) : g.$el.appendTo(p);
1608
+ const I = p.$el[0];
1609
+ h?.isConnected ? h !== I && p.$el.insertBefore(h) : p.$el.appendTo(g);
1539
1610
  }
1540
- h = g.$el[0] || null;
1611
+ h = p.$el[0] || null;
1541
1612
  } else {
1542
- const C = s(_, u), b = l(C);
1543
- I.set(E, { $el: b, item: _ }), h?.isConnected ? b.insertBefore(h) : b.appendTo(p), i && i(b, _, u), r && r(b), m.domUpdated(b, "list.add", _), h = b[0] || null;
1613
+ const T = s(f, a), m = u(T);
1614
+ C.set(E, { $el: m, item: f }), h?.isConnected ? m.insertBefore(h) : m.appendTo(g), i && i(m, f, a), r && r(m), b.domUpdated(m, "list.add", f), h = m[0] || null;
1544
1615
  }
1545
1616
  }
1546
- w = U;
1617
+ R = F;
1547
1618
  });
1548
- y.trackEffect(this, N), y.trackCleanup(this, () => {
1549
- I.clear(), O.clear(), w = [], $?.remove();
1619
+ y.trackEffect(this, w), y.trackCleanup(this, () => {
1620
+ C.clear(), k.clear(), R = [], M?.remove();
1550
1621
  });
1551
1622
  });
1552
1623
  };
1553
- const he = /* @__PURE__ */ new WeakMap();
1554
- l.fn.atomMount = function(n, e = {}) {
1624
+ const de = /* @__PURE__ */ new WeakMap();
1625
+ u.fn.atomMount = function(n, e = {}) {
1555
1626
  return this.each(function() {
1556
- const t = m.enabled, s = t ? pe(this) : "", i = he.get(this);
1557
- i && (t && m.log("mount", `${s} unmounting existing component`), i()), t && m.log("mount", `${s} mounting component`);
1627
+ const t = b.enabled, s = t ? me(this) : "", i = de.get(this);
1628
+ i && (t && b.log("mount", `${s} unmounting existing component`), i()), t && b.log("mount", `${s} mounting component`);
1558
1629
  let o;
1559
1630
  try {
1560
- o = n(l(this), e);
1631
+ o = n(u(this), e);
1561
1632
  } catch (c) {
1562
1633
  console.error("[atom-effect-jquery] Mount error:", c);
1563
1634
  return;
1564
1635
  }
1565
1636
  const r = () => {
1566
- if (he.delete(this)) {
1567
- if (t && m.log("mount", `${s} full cleanup`), typeof o == "function")
1637
+ if (de.delete(this)) {
1638
+ if (t && b.log("mount", `${s} full cleanup`), typeof o == "function")
1568
1639
  try {
1569
1640
  o();
1570
1641
  } catch (c) {
@@ -1573,17 +1644,17 @@ l.fn.atomMount = function(n, e = {}) {
1573
1644
  y.cleanupTree(this);
1574
1645
  }
1575
1646
  };
1576
- he.set(this, r), y.trackCleanup(this, r);
1647
+ de.set(this, r), y.trackCleanup(this, r);
1577
1648
  });
1578
1649
  };
1579
- l.fn.atomUnmount = function() {
1650
+ u.fn.atomUnmount = function() {
1580
1651
  return this.each(function() {
1581
- const n = he.get(this);
1652
+ const n = de.get(this);
1582
1653
  n && n();
1583
1654
  });
1584
1655
  };
1585
- const ye = "[$.route]";
1586
- function Rt(n) {
1656
+ const le = "[$.route]";
1657
+ function Ut(n) {
1587
1658
  const {
1588
1659
  target: e,
1589
1660
  default: t,
@@ -1592,188 +1663,215 @@ function Rt(n) {
1592
1663
  autoBindLinks: o = !1,
1593
1664
  activeClass: r = "active",
1594
1665
  beforeTransition: c,
1595
- afterTransition: a
1666
+ afterTransition: l
1596
1667
  } = n;
1597
- let f = !1, p = null, D = window.location.hash;
1598
- const I = [], O = /* @__PURE__ */ new Set(), w = l(e), $ = () => {
1599
- const h = window.location.hash, u = h.indexOf("?");
1600
- return (u === -1 ? h.substring(1) : h.substring(1, u)) || t;
1601
- }, N = (h) => {
1602
- const u = h.indexOf("?");
1603
- if (u === -1) return {};
1604
- const E = {}, _ = h.length;
1605
- let g = u + 1;
1606
- for (; g < _; ) {
1607
- let C = h.indexOf("&", g);
1608
- if (C === -1 && (C = _), C > g) {
1609
- const b = h.indexOf("=", g);
1610
- b !== -1 && b < C ? E[decodeURIComponent(h.substring(g, b))] = decodeURIComponent(
1611
- h.substring(b + 1, C)
1612
- ) : E[decodeURIComponent(h.substring(g, C))] = "";
1668
+ let _ = !1, g = null, v = window.location.hash;
1669
+ const C = [], k = /* @__PURE__ */ new Set(), R = u(e), M = () => {
1670
+ const h = window.location.hash, a = h.indexOf("?");
1671
+ return (a === -1 ? h.substring(1) : h.substring(1, a)) || t;
1672
+ }, w = (h) => {
1673
+ const a = h.indexOf("?");
1674
+ if (a === -1) return {};
1675
+ const E = {}, f = h.length;
1676
+ let p = a + 1;
1677
+ const T = (m) => {
1678
+ try {
1679
+ return decodeURIComponent(m);
1680
+ } catch {
1681
+ return console.warn(`${le} Malformed URI component: ${m}`), m;
1682
+ }
1683
+ };
1684
+ for (; p < f; ) {
1685
+ let m = h.indexOf("&", p);
1686
+ if (m === -1 && (m = f), m > p) {
1687
+ const I = h.indexOf("=", p);
1688
+ I !== -1 && I < m ? E[T(h.substring(p, I))] = T(
1689
+ h.substring(I + 1, m)
1690
+ ) : E[T(h.substring(p, m))] = "";
1613
1691
  }
1614
- g = C + 1;
1692
+ p = m + 1;
1615
1693
  }
1616
1694
  return E;
1617
- }, A = (h) => {
1618
- let u = s[h];
1619
- return !u && i && (u = s[i]), u || (console.warn(`${ye} Route "${h}" not found and no notFound route configured`), null);
1620
- }, R = (h) => {
1621
- const u = document.querySelector(h);
1622
- if (!u?.content)
1623
- return console.warn(`${ye} Template "${h}" not found`), !1;
1624
- const E = u.content.cloneNode(!0);
1625
- return w.append(E), !0;
1626
- }, x = qe($()), K = (h) => {
1627
- if (f) return;
1628
- const u = w[0];
1629
- if (!u) {
1630
- console.warn(`${ye} Target element "${e}" not found`);
1695
+ }, N = (h) => {
1696
+ let a = s[h];
1697
+ return !a && i && (a = s[i]), a || (console.warn(`${le} Route "${h}" not found and no notFound route configured`), null);
1698
+ }, x = (h) => {
1699
+ const a = document.querySelector(h);
1700
+ if (!a?.content)
1701
+ return console.warn(`${le} Template "${h}" not found`), !1;
1702
+ const E = a.content.cloneNode(!0);
1703
+ return R.append(E), !0;
1704
+ }, L = ze(M()), W = (h) => {
1705
+ if (_) return;
1706
+ const a = R[0];
1707
+ if (!a) {
1708
+ console.warn(`${le} Target element "${e}" not found`);
1631
1709
  return;
1632
1710
  }
1633
- const E = A(h);
1711
+ const E = N(h);
1634
1712
  if (!E) return;
1635
- const _ = N(window.location.hash);
1636
- c && c(p || h, h), w.empty();
1637
- let g = _;
1713
+ const f = w(window.location.hash);
1714
+ c && c(g || h, h), R.empty();
1715
+ let p = f;
1638
1716
  if (E.onEnter) {
1639
- const C = E.onEnter(_);
1640
- C !== void 0 && (g = { ..._, ...C });
1717
+ const T = E.onEnter(f);
1718
+ T !== void 0 && (p = { ...f, ...T });
1641
1719
  }
1642
- E.render ? E.render(u, h, g) : E.template && R(E.template), a && a(p || h, h), p = h;
1643
- }, U = (h) => {
1644
- if (f) return;
1645
- const u = x.value, E = s[u];
1646
- E?.onLeave && E.onLeave() === !1 || (D = `#${h}`, window.location.hash = D, x.value = h);
1647
- }, J = () => {
1648
- if (f) return;
1720
+ E.render ? E.render(a, h, p) : E.template && x(E.template), l && l(g || h, h), g = h;
1721
+ }, F = (h) => {
1722
+ if (_) return;
1723
+ const a = L.value, E = s[a];
1724
+ E?.onLeave && E.onLeave() === !1 || (v = `#${h}`, window.location.hash = v, L.value = h);
1725
+ }, K = () => {
1726
+ if (_) return;
1649
1727
  const h = window.location.hash;
1650
- if (h === D) return;
1651
- const u = $(), E = x.value;
1652
- if (E !== u) {
1653
- const _ = s[E];
1654
- if (_?.onLeave && _.onLeave() === !1) {
1655
- window.location.hash = D;
1728
+ if (h === v) return;
1729
+ const a = M(), E = L.value;
1730
+ if (E !== a) {
1731
+ const f = s[E];
1732
+ if (f?.onLeave && f.onLeave() === !1) {
1733
+ window.location.hash = v;
1656
1734
  return;
1657
1735
  }
1658
- x.value = u;
1736
+ L.value = a;
1659
1737
  } else
1660
- K(u);
1661
- D = h;
1738
+ W(a);
1739
+ v = h;
1662
1740
  }, re = () => {
1663
1741
  if (!o) return;
1664
- l("[data-route]").each(function() {
1665
- const u = this, E = l(u), _ = E.data("route");
1666
- O.add(u);
1667
- const g = (b) => {
1668
- b.preventDefault(), U(_);
1669
- };
1670
- E.on("click", g), y.trackCleanup(u, () => {
1671
- E.off("click", g), O.delete(u);
1742
+ const h = (f) => {
1743
+ f.preventDefault();
1744
+ const p = u(f.currentTarget).data("route");
1745
+ F(p);
1746
+ };
1747
+ u(document).on("click", "[data-route]", h), C.push(() => {
1748
+ u(document).off("click", "[data-route]", h);
1749
+ });
1750
+ const a = (f) => {
1751
+ if (k.has(f)) return;
1752
+ const p = u(f), T = p.data("route");
1753
+ k.add(f);
1754
+ const m = V(() => {
1755
+ const I = L.value === T;
1756
+ p.toggleClass(r, I), I ? p.attr("aria-current", "page") : p.removeAttr("aria-current");
1672
1757
  });
1673
- const C = j(() => {
1674
- const b = x.value === _;
1675
- E.toggleClass(r, b), b ? E.attr("aria-current", "page") : E.removeAttr("aria-current");
1758
+ y.trackEffect(f, m), y.trackCleanup(f, () => {
1759
+ k.delete(f);
1676
1760
  });
1677
- y.trackEffect(u, C);
1761
+ };
1762
+ u("[data-route]").each(function() {
1763
+ a(this);
1678
1764
  });
1679
- }, ne = () => {
1680
- f || (f = !0, I.forEach((h) => h()), I.length = 0, O.forEach((h) => y.cleanup(h)), O.clear());
1765
+ const E = new MutationObserver((f) => {
1766
+ for (const p of f)
1767
+ p.type === "childList" && p.addedNodes.forEach((T) => {
1768
+ if (T.nodeType === 1) {
1769
+ const m = T;
1770
+ m.matches?.("[data-route]") && a(m), m.querySelectorAll && m.querySelectorAll("[data-route]").forEach(
1771
+ (I) => a(I)
1772
+ );
1773
+ }
1774
+ });
1775
+ });
1776
+ E.observe(document.body, { childList: !0, subtree: !0 }), C.push(() => E.disconnect());
1777
+ }, te = () => {
1778
+ _ || (_ = !0, C.forEach((h) => h()), C.length = 0, k.forEach((h) => y.cleanup(h)), k.clear());
1681
1779
  };
1682
- window.addEventListener("hashchange", J), I.push(() => window.removeEventListener("hashchange", J));
1683
- const se = j(() => {
1684
- K(x.value);
1780
+ window.addEventListener("hashchange", K), C.push(() => window.removeEventListener("hashchange", K));
1781
+ const ne = V(() => {
1782
+ W(L.value);
1685
1783
  });
1686
- return I.push(() => se.dispose()), re(), w[0] && y.trackCleanup(w[0], ne), {
1687
- currentRoute: x,
1688
- navigate: U,
1689
- destroy: ne
1784
+ return C.push(() => ne.dispose()), re(), R[0] && y.trackCleanup(R[0], te), {
1785
+ currentRoute: L,
1786
+ navigate: F,
1787
+ destroy: te
1690
1788
  };
1691
1789
  }
1692
- l.extend({
1693
- route: Rt
1790
+ u.extend({
1791
+ route: Ut
1694
1792
  });
1695
- const de = /* @__PURE__ */ new WeakMap();
1696
- let $e = !1;
1697
- const Me = (n) => {
1698
- let e = de.get(n);
1793
+ const pe = /* @__PURE__ */ new WeakMap();
1794
+ let Pe = !1;
1795
+ const $e = (n) => {
1796
+ let e = pe.get(n);
1699
1797
  return e || (e = function(...t) {
1700
- return ve(() => n.apply(this, t));
1701
- }, de.set(n, e)), e;
1798
+ return Oe(() => n.apply(this, t));
1799
+ }, pe.set(n, e)), e;
1702
1800
  };
1703
1801
  function Ke() {
1704
- if ($e) return;
1705
- $e = !0;
1706
- const n = l.fn.on, e = l.fn.off, t = l.fn.remove, s = l.fn.empty, i = l.fn.detach;
1707
- l.fn.remove = function(o) {
1802
+ if (Pe) return;
1803
+ Pe = !0;
1804
+ const n = u.fn.on, e = u.fn.off, t = u.fn.remove, s = u.fn.empty, i = u.fn.detach;
1805
+ u.fn.remove = function(o) {
1708
1806
  const r = o ? this.filter(o) : this;
1709
- for (let c = 0, a = r.length; c < a; c++) {
1710
- const f = r[c];
1711
- f && (y.cleanupTree(f), y.markIgnored(f));
1807
+ for (let c = 0, l = r.length; c < l; c++) {
1808
+ const _ = r[c];
1809
+ _ && (y.cleanupTree(_), y.markIgnored(_));
1712
1810
  }
1713
1811
  return t.call(this, o);
1714
- }, l.fn.empty = function() {
1812
+ }, u.fn.empty = function() {
1715
1813
  for (let o = 0, r = this.length; o < r; o++) {
1716
1814
  const c = this[o];
1717
1815
  c && y.cleanupDescendants(c);
1718
1816
  }
1719
1817
  return s.call(this);
1720
- }, l.fn.detach = function(o) {
1818
+ }, u.fn.detach = function(o) {
1721
1819
  const r = o ? this.filter(o) : this;
1722
- for (let c = 0, a = r.length; c < a; c++) {
1723
- const f = r[c];
1724
- f && y.keep(f);
1820
+ for (let c = 0, l = r.length; c < l; c++) {
1821
+ const _ = r[c];
1822
+ _ && y.keep(_);
1725
1823
  }
1726
1824
  return i.call(this, o);
1727
- }, l.fn.on = function(...o) {
1825
+ }, u.fn.on = function(...o) {
1728
1826
  const r = o[0];
1729
1827
  if (r && typeof r == "object") {
1730
- const c = r, a = {};
1731
- for (const f in c) {
1732
- const p = c[f];
1733
- p && (a[f] = Me(p));
1828
+ const c = r, l = {};
1829
+ for (const _ in c) {
1830
+ const g = c[_];
1831
+ g && (l[_] = $e(g));
1734
1832
  }
1735
- o[0] = a;
1833
+ o[0] = l;
1736
1834
  } else
1737
1835
  for (let c = o.length - 1; c >= 0; c--)
1738
1836
  if (typeof o[c] == "function") {
1739
- o[c] = Me(o[c]);
1837
+ o[c] = $e(o[c]);
1740
1838
  break;
1741
1839
  }
1742
1840
  return n.apply(this, o);
1743
- }, l.fn.off = function(...o) {
1841
+ }, u.fn.off = function(...o) {
1744
1842
  const r = o[0];
1745
1843
  if (r && typeof r == "object") {
1746
- const c = r, a = {};
1747
- for (const f in c) {
1748
- const p = c[f];
1749
- p && (a[f] = de.get(p) || p);
1844
+ const c = r, l = {};
1845
+ for (const _ in c) {
1846
+ const g = c[_];
1847
+ g && (l[_] = pe.get(g) || g);
1750
1848
  }
1751
- o[0] = a;
1849
+ o[0] = l;
1752
1850
  } else
1753
1851
  for (let c = o.length - 1; c >= 0; c--)
1754
1852
  if (typeof o[c] == "function") {
1755
- o[c] = de.get(o[c]) || o[c];
1853
+ o[c] = pe.get(o[c]) || o[c];
1756
1854
  break;
1757
1855
  }
1758
1856
  return e.apply(this, o);
1759
1857
  };
1760
1858
  }
1761
- const Pt = Ke;
1859
+ const Mt = Ke;
1762
1860
  Ke();
1763
- l(() => {
1764
- yt(document.body);
1861
+ u(() => {
1862
+ It(document.body);
1765
1863
  });
1766
1864
  export {
1767
- qe as atom,
1768
- ve as batch,
1769
- at as computed,
1770
- Mt as default,
1771
- Ut as disableAutoCleanup,
1772
- j as effect,
1773
- yt as enableAutoCleanup,
1774
- Pt as enablejQueryBatching,
1865
+ ze as atom,
1866
+ Oe as batch,
1867
+ dt as computed,
1868
+ Vt as default,
1869
+ $t as disableAutoCleanup,
1870
+ V as effect,
1871
+ It as enableAutoCleanup,
1872
+ Mt as enablejQueryBatching,
1775
1873
  Ke as enablejQueryOverrides,
1776
1874
  y as registry,
1777
- ct as untracked
1875
+ at as untracked
1778
1876
  };
1779
1877
  //# sourceMappingURL=index.mjs.map