@but212/atom-effect-jquery 0.30.1 → 0.31.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
@@ -65,38 +65,39 @@ var f = (typeof process < "u" && process.env, typeof __DEV__ < "u" && !!__DEV__
65
65
  super(e), this.cause = t, this.recoverable = n, this.code = r, this.name = "AtomError", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
66
66
  }
67
67
  getChain() {
68
- if (this.cause === null || this.cause === void 0) return [this];
69
- let t = [this], n = /* @__PURE__ */ new Set([this]), r = this.cause;
70
- for (; r != null;) {
71
- let i = n.has(r);
72
- if (t.push(r), i) break;
73
- if (n.add(r), r instanceof e) r = r.cause;
74
- else if (r instanceof Error && "cause" in r) r = r.cause;
68
+ let t = this.cause;
69
+ if (t == null) return [this];
70
+ let n = [this], r = t, i = null;
71
+ for (; r != null && (n.push(r), !(r === this || i?.has(r)));) {
72
+ if (r instanceof e) r = r.cause;
73
+ else if (r instanceof Error) r = r.cause;
75
74
  else break;
75
+ n.length > 3 && (i === null ? i = new Set(n) : i.add(r));
76
76
  }
77
- return t;
77
+ return n;
78
78
  }
79
- toJSON(t = /* @__PURE__ */ new Set()) {
80
- if (t.has(this)) return {
79
+ toJSON(t) {
80
+ let n = t ?? /* @__PURE__ */ new Set();
81
+ if (n.has(this)) return {
81
82
  name: this.name,
82
83
  message: "[Circular Reference]",
83
84
  recoverable: this.recoverable,
84
85
  code: this.code
85
86
  };
86
- t.add(this);
87
- let n = this.cause;
88
- return this.cause instanceof e ? n = this.cause.toJSON(t) : this.cause instanceof Error && (n = {
89
- name: this.cause.name,
90
- message: this.cause.message,
91
- stack: this.cause.stack,
92
- cause: this.cause.cause
87
+ n.add(this);
88
+ let r = this.cause;
89
+ return r instanceof e ? r = r.toJSON(n) : r instanceof Error && (r = {
90
+ name: r.name,
91
+ message: r.message,
92
+ stack: r.stack,
93
+ cause: r.cause
93
94
  }), {
94
95
  name: this.name,
95
96
  message: this.message,
96
97
  code: this.code,
97
98
  recoverable: this.recoverable,
98
99
  stack: this.stack,
99
- cause: n
100
+ cause: r
100
101
  };
101
102
  }
102
103
  static format(e, t, n) {
@@ -135,38 +136,22 @@ var f = (typeof process < "u" && process.env, typeof __DEV__ < "u" && !!__DEV__
135
136
  BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
136
137
  };
137
138
  function y(e, t, n) {
138
- if (e instanceof m) return new t(m.format(e.name, n, e.message), e, e.recoverable, e.code);
139
- if (e instanceof Error) {
140
- let r = e.name || e.constructor.name || "Error";
141
- return new t(m.format(r, n, e.message), e);
142
- }
143
- return new t(m.format("Unexpected error", n, String(e)), e);
139
+ return e instanceof m ? new t(`${e.name} (${n}): ${e.message}`, e, e.recoverable, e.code) : e instanceof Error ? new t(`${e.name || "Error"} (${n}): ${e.message}`, e) : new t(`Unexpected error (${n}): ${String(e)}`, e);
144
140
  }
145
- var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symbol("AtomEffect.Id"), S = /* @__PURE__ */ Symbol("AtomEffect.Type"), C = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), ee = "[Atom Effect]", w = f ? new class {
141
+ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symbol("AtomEffect.Id"), S = /* @__PURE__ */ Symbol("AtomEffect.Type"), C = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), ee = "[Atom Effect]", te = () => {}, w = f ? new class {
146
142
  constructor() {
147
143
  this.enabled = !0, this.warnInfiniteLoop = c.WARN_INFINITE_LOOP, this._updateCounts = /* @__PURE__ */ new Map(), this._nodeRegistry = /* @__PURE__ */ new Map(), this._threshold = c.LOOP_THRESHOLD, this._cleanupScheduled = !1, this.warn = (e, t) => {
148
144
  this.enabled && e && console.warn(`${ee} ${t}`);
149
145
  }, this.registerNode = (e) => {
150
146
  this._nodeRegistry.set(e.id, new WeakRef(e));
151
147
  }, this.attachDebugInfo = (e, t, n, r) => {
152
- this.enabled && (Object.defineProperties(e, {
153
- [b]: {
154
- value: r ?? `${t}_${n}`,
155
- configurable: !0
156
- },
157
- [x]: {
158
- value: n,
159
- configurable: !0
160
- },
161
- [S]: {
162
- value: t,
163
- configurable: !0
164
- }
165
- }), this.registerNode(e));
148
+ if (!this.enabled) return;
149
+ let i = e;
150
+ i[b] = r ?? `${t}_${n}`, i[x] = n, i[S] = t, this.registerNode(e);
166
151
  }, this.trackUpdate = (e, t) => {
167
152
  if (!this.enabled || !this.warnInfiniteLoop) return;
168
153
  let n = this._updateCounts, r = (n.get(e) ?? 0) + 1;
169
- r > this._threshold ? this.warn(!0, `Infinite loop detected for ${t ?? `dependency ${e}`}. Over ${this._threshold} updates in a single execution scope.`) : n.set(e, r), this._cleanupScheduled || (this._cleanupScheduled = !0, Promise.resolve().then(() => {
154
+ r > this._threshold ? this.warn(!0, `Infinite loop detected for ${t ?? `dependency ${e}`}. Over ${this._threshold} updates in a single execution scope.`) : n.set(e, r), this._cleanupScheduled || (this._cleanupScheduled = !0, queueMicrotask(() => {
170
155
  this._updateCounts.clear(), this._cleanupScheduled = !1;
171
156
  }));
172
157
  }, this.dumpGraph = () => {
@@ -182,31 +167,31 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
182
167
  }
183
168
  return e;
184
169
  }, this.getDebugName = (e) => {
185
- if (e) return e[b];
170
+ if (e != null) return e[b];
186
171
  }, this.getDebugType = (e) => {
187
- if (e) return e[S];
172
+ if (e != null) return e[S];
188
173
  };
189
174
  }
190
175
  }() : {
191
176
  enabled: !1,
192
177
  warnInfiniteLoop: !1,
193
- warn: () => {},
194
- registerNode: () => {},
195
- attachDebugInfo: () => {},
196
- trackUpdate: () => {},
178
+ warn: te,
179
+ registerNode: te,
180
+ attachDebugInfo: te,
181
+ trackUpdate: te,
197
182
  dumpGraph: () => [],
198
183
  getDebugName: () => {},
199
184
  getDebugType: () => {}
200
- }, te = 1, ne = () => te++ | 0, re = class {
185
+ }, ne = 1, re = () => ne++ | 0, ie = class {
201
186
  constructor() {
202
- this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._actualCount = 0, this._overflow = null, this._freeIndices = null;
187
+ this._count = 0, this._actualCount = 0, this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._overflow = null, this._freeIndices = null;
203
188
  }
204
189
  _rawWrite(e, t) {
205
190
  if (e < 4) e === 0 ? this._s0 = t : e === 1 ? this._s1 = t : e === 2 ? this._s2 = t : this._s3 = t;
206
191
  else {
207
192
  this._overflow === null && (this._overflow = []);
208
- let n = this._overflow, r = e - 4;
209
- n[r] = t;
193
+ let n = this._overflow;
194
+ n[e - 4] = t;
210
195
  }
211
196
  }
212
197
  _rawAdd(e) {
@@ -220,7 +205,7 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
220
205
  let r = n.pop();
221
206
  return t[r] = e, r + 4;
222
207
  }
223
- return t.push(e), 4 + t.length - 1;
208
+ return t.push(e), 3 + t.length;
224
209
  }
225
210
  _rawSwap(e, t) {
226
211
  if (e === t) return;
@@ -234,17 +219,25 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
234
219
  return this._count;
235
220
  }
236
221
  getAt(e) {
237
- return e < 4 ? e === 0 ? this._s0 : e === 1 ? this._s1 : e === 2 ? this._s2 : this._s3 : this._overflow?.[e - 4] ?? null;
222
+ if (e < 4) return e === 0 ? this._s0 : e === 1 ? this._s1 : e === 2 ? this._s2 : e === 3 ? this._s3 : null;
223
+ let t = this._overflow;
224
+ return t === null ? null : t[e - 4] ?? null;
238
225
  }
239
226
  setAt(e, t) {
240
227
  let n = this.getAt(e);
241
- n !== t && (this._rawWrite(e, t), n === null ? this._actualCount++ : t === null && this._actualCount--, t !== null && e >= this._count ? this._count = e + 1 : t === null && this._shrinkPhysicalSizeFrom(e));
228
+ n !== t && (this._rawWrite(e, t), n === null ? this._actualCount++ : t === null && this._actualCount--, t === null ? this._shrinkPhysicalSizeFrom(e) : e >= this._count && (this._count = e + 1));
242
229
  }
243
230
  _shrinkPhysicalSizeFrom(e) {
244
- if (e === this._count - 1) for (this._count--; this._count > 0 && this.getAt(this._count - 1) == null;) this._count--;
231
+ if (e === this._count - 1) {
232
+ if (this._count--, this._count > 4) {
233
+ let e = this._overflow;
234
+ for (; this._count > 4 && e[this._count - 5] === null;) this._count--;
235
+ }
236
+ this._count === 4 && this._s3 === null && (this._count = 3, this._s2 === null && (this._count = 2, this._s1 === null && (this._count = 1, this._s0 === null && (this._count = 0))));
237
+ }
245
238
  }
246
239
  truncateFrom(e) {
247
- e <= 3 && (e <= 0 && this._s0 !== null && (this._onItemRemoved(this._s0), this._s0 = null, this._actualCount--), e <= 1 && this._s1 !== null && (this._onItemRemoved(this._s1), this._s1 = null, this._actualCount--), e <= 2 && this._s2 !== null && (this._onItemRemoved(this._s2), this._s2 = null, this._actualCount--), e <= 3 && this._s3 !== null && (this._onItemRemoved(this._s3), this._s3 = null, this._actualCount--));
240
+ e <= 3 && (e <= 3 && this._s3 !== null && (this._onItemRemoved(this._s3), this._s3 = null, this._actualCount--), e <= 2 && this._s2 !== null && (this._onItemRemoved(this._s2), this._s2 = null, this._actualCount--), e <= 1 && this._s1 !== null && (this._onItemRemoved(this._s1), this._s1 = null, this._actualCount--), e <= 0 && this._s0 !== null && (this._onItemRemoved(this._s0), this._s0 = null, this._actualCount--));
248
241
  let t = this._overflow;
249
242
  if (t !== null) {
250
243
  let n = e > 4 ? e - 4 : 0, r = t.length;
@@ -283,28 +276,33 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
283
276
  let t = this._actualCount;
284
277
  if (t === 0) return;
285
278
  if (t === this._count) {
286
- this._s0 != null && e(this._s0), this._s1 != null && e(this._s1), this._s2 != null && e(this._s2), this._s3 != null && e(this._s3);
287
- let t = this._overflow;
288
- if (t !== null) for (let n = 0, r = t.length; n < r; n++) {
289
- let r = t[n];
290
- r != null && e(r);
279
+ if (e(this._s0), t > 1 && (e(this._s1), t > 2 && (e(this._s2), t > 3 && (e(this._s3), t > 4)))) {
280
+ let t = this._overflow;
281
+ for (let n = 0, r = t.length; n < r; n++) e(t[n]);
291
282
  }
292
283
  return;
293
284
  }
294
- let n = 0, r = this._count;
295
- for (let i = 0; i < r; i++) {
296
- let r = this.getAt(i);
297
- if (r != null && (e(r), ++n >= t)) break;
285
+ let n = 0;
286
+ if (this._s0 !== null && (e(this._s0), ++n >= t) || this._s1 !== null && (e(this._s1), ++n >= t) || this._s2 !== null && (e(this._s2), ++n >= t) || this._s3 !== null && (e(this._s3), ++n >= t)) return;
287
+ let r = this._overflow;
288
+ if (r !== null) for (let i = 0, a = r.length; i < a; i++) {
289
+ let a = r[i];
290
+ if (a != null && (e(a), ++n >= t)) return;
298
291
  }
299
292
  }
300
293
  compact() {
301
- if (this._actualCount === this._count) return;
302
- let e = 0, t = this._count;
303
- for (let n = 0; n < t; n++) {
304
- let t = this.getAt(n);
305
- t != null && (n !== e && (this._rawWrite(e, t), this._rawWrite(n, null)), e++);
294
+ let e = this._actualCount;
295
+ if (e === this._count) return;
296
+ if (e === 0) {
297
+ this.clear();
298
+ return;
306
299
  }
307
- this._count = this._actualCount, this._overflow !== null && (e <= 4 ? this._overflow = null : this._overflow.length = e - 4), this._freeIndices = null;
300
+ let t = 0, n = this._count;
301
+ for (let r = 0; r < n; r++) {
302
+ let n = this.getAt(r);
303
+ if (n !== null && (r !== t && (this._rawWrite(t, n), this._rawWrite(r, null)), t++, t === e)) break;
304
+ }
305
+ this._count = e, this._overflow !== null && (t <= 4 ? this._overflow = null : this._overflow.length = t - 4), this._freeIndices = null;
308
306
  }
309
307
  clear() {
310
308
  this._s0 = this._s1 = this._s2 = this._s3 = null, this._count = 0, this._actualCount = 0, this._overflow = null, this._freeIndices = null;
@@ -312,7 +310,7 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
312
310
  dispose() {
313
311
  this.clear();
314
312
  }
315
- }, ie = class extends re {
313
+ }, ae = class extends ie {
316
314
  constructor(...e) {
317
315
  super(...e), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1;
318
316
  }
@@ -324,26 +322,40 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
324
322
  }
325
323
  setAt(e, t) {
326
324
  let n = this.getAt(e);
327
- super.setAt(e, t), this._map !== null && (n?.unsub && this._map.delete(n.node), t?.unsub && this._map.set(t.node, e));
325
+ super.setAt(e, t), this._map !== null && (n !== null && this._map.delete(n.node), t !== null && this._map.set(t.node, e));
328
326
  }
329
327
  claimExisting(e, t) {
330
328
  let n = this._count;
331
329
  if (n <= t) return !1;
332
- let r = this.getAt(t);
333
- if (r && r.node === e && r.unsub) return r.version = e.version, !0;
330
+ let r = null;
331
+ if (r = t < 4 ? t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : this._s3 : this._overflow[t - 4] ?? null, r && r.node === e && r.unsub) return r.version = e.version, !0;
334
332
  if (this._map !== null || n - t > this._SCAN_THRESHOLD) return this._claimViaMap(e, t);
335
- for (let r = t + 1; r < n; r++) {
336
- let n = this.getAt(r);
337
- if (n && n.node === e && n.unsub) return n.version = e.version, this._rawSwap(r, t), !0;
333
+ let i = -1, a = null, o = t + 1;
334
+ for (; o < 4 && o < n; o++) {
335
+ let t = o === 1 ? this._s1 : o === 2 ? this._s2 : this._s3;
336
+ if (t && t.node === e && t.unsub) {
337
+ i = o, a = t;
338
+ break;
339
+ }
338
340
  }
339
- return !1;
341
+ if (i === -1 && o < n) {
342
+ let t = this._overflow;
343
+ for (let r = o - 4, s = n - 4; r < s; r++) {
344
+ let n = t[r];
345
+ if (n && n.node === e && n.unsub) {
346
+ i = r + 4, a = n;
347
+ break;
348
+ }
349
+ }
350
+ }
351
+ return i === -1 ? !1 : (a.version = e.version, this._rawWrite(t, a), this._rawWrite(i, r), !0);
340
352
  }
341
353
  _claimViaMap(e, t) {
342
354
  this._map === null && (this._map = this._initMap());
343
355
  let n = this._map, r = n.get(e);
344
356
  if (r === void 0 || r < t) return !1;
345
357
  let i = this.getAt(r);
346
- if (i == null || !i.unsub) return !1;
358
+ if (i === null || !i.unsub) return !1;
347
359
  if (i.version = e.version, r !== t) {
348
360
  let i = this.getAt(t);
349
361
  this._rawSwap(r, t), n.set(e, t), i?.unsub && n.set(i.node, r);
@@ -352,19 +364,27 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
352
364
  }
353
365
  _initMap() {
354
366
  let e = /* @__PURE__ */ new Map();
355
- for (let t = 0; t < this._count; t++) {
356
- let n = this.getAt(t);
357
- n?.unsub && e.set(n.node, t);
367
+ this._s0?.unsub && e.set(this._s0.node, 0), this._s1?.unsub && e.set(this._s1.node, 1), this._s2?.unsub && e.set(this._s2.node, 2), this._s3?.unsub && e.set(this._s3.node, 3);
368
+ let t = this._overflow;
369
+ if (t !== null) for (let n = 0, r = t.length; n < r; n++) {
370
+ let r = t[n];
371
+ r?.unsub && e.set(r.node, n + 4);
358
372
  }
359
373
  return e;
360
374
  }
361
375
  insertNew(e, t) {
362
- let n = this.getAt(e);
376
+ let n = null;
377
+ if (e < 4) e === 0 ? (n = this._s0, this._s0 = t) : e === 1 ? (n = this._s1, this._s1 = t) : e === 2 ? (n = this._s2, this._s2 = t) : (n = this._s3, this._s3 = t);
378
+ else {
379
+ this._overflow === null && (this._overflow = []);
380
+ let r = this._overflow;
381
+ n = r[e - 4] ?? null, r[e - 4] = t;
382
+ }
363
383
  if (n !== null) {
364
384
  let e = this._rawAdd(n);
365
385
  e >= this._count && (this._count = e + 1), this._map !== null && n.unsub && this._map.set(n.node, e);
366
386
  }
367
- this._rawWrite(e, t), e >= this._count && (this._count = e + 1), this._actualCount++, this._map !== null && t.unsub && this._map.set(t.node, e);
387
+ e >= this._count && (this._count = e + 1), this._actualCount++, this._map !== null && t.unsub && this._map.set(t.node, e);
368
388
  }
369
389
  add(e) {
370
390
  let t = super.add(e);
@@ -386,38 +406,40 @@ var b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symb
386
406
  Computed: 4,
387
407
  Effect: 8
388
408
  };
389
- function ae(e, t) {
390
- if (!e) return !1;
391
- let n = typeof e;
392
- return (n === "object" || n === "function") && !!((e[T] ?? 0) & t);
393
- }
394
- function oe(e) {
395
- return ae(e, E.Atom);
409
+ function oe(e, t) {
410
+ return !e || typeof e != "object" && typeof e != "function" ? !1 : !!(e[T] & t);
396
411
  }
397
412
  function se(e) {
398
- return ae(e, E.Computed);
413
+ return oe(e, E.Atom);
399
414
  }
400
415
  function ce(e) {
401
- if (e instanceof Promise) return !0;
402
- if (!e) return !1;
403
- let t = typeof e;
404
- return (t === "object" || t === "function") && typeof e.then == "function";
416
+ return oe(e, E.Computed);
405
417
  }
406
- var le = class {
418
+ function le(e) {
419
+ return e instanceof Promise ? !0 : typeof e != "object" || !e ? !1 : typeof e.then == "function";
420
+ }
421
+ var ue = class {
407
422
  constructor(e, t, n = void 0) {
408
423
  this.node = e, this.version = t, this.unsub = n;
409
424
  }
410
- }, ue = class {
425
+ }, de = class {
411
426
  constructor(e = void 0, t = void 0) {
412
427
  this.fn = e, this.sub = t;
413
428
  }
414
429
  notify(e, t) {
415
- O(() => {
416
- let n = this.fn;
417
- n !== void 0 && n(e, t);
418
- let r = this.sub;
419
- r !== void 0 && r.execute();
420
- });
430
+ let n = this.fn, r = this.sub;
431
+ if (n === void 0 && r === void 0) return;
432
+ let i = D, a = i.current;
433
+ if (a === null) {
434
+ n !== void 0 && n(e, t), r !== void 0 && r.execute();
435
+ return;
436
+ }
437
+ i.current = null;
438
+ try {
439
+ n !== void 0 && n(e, t), r !== void 0 && r.execute();
440
+ } finally {
441
+ i.current = a;
442
+ }
421
443
  }
422
444
  }, D = new class {
423
445
  constructor() {
@@ -428,8 +450,9 @@ var le = class {
428
450
  let n = this.current;
429
451
  this.current = e;
430
452
  try {
453
+ if (!f) return t();
431
454
  let e = t();
432
- return f && w.warn(ce(e), "Detected Promise returned within tracking context. Dependencies accessed after \"await\" will NOT be tracked. Consider using synchronous tracking before the async boundary."), e;
455
+ return w.warn(le(e), "Detected Promise returned within tracking context. Dependencies accessed after \"await\" will NOT be tracked. Consider using synchronous tracking before the async boundary."), e;
433
456
  } finally {
434
457
  this.current = n;
435
458
  }
@@ -445,9 +468,9 @@ function O(e) {
445
468
  t.current = n;
446
469
  }
447
470
  }
448
- var de = class {
471
+ var fe = class {
449
472
  constructor() {
450
- this.flags = 0, this.version = 0, this._lastSeenEpoch = u.UNINITIALIZED, this._nextEpoch = void 0, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = ne() & s;
473
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = u.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this.id = re() & s, this._nextEpoch = void 0, this._slots = null, this._deps = null;
451
474
  }
452
475
  get isDisposed() {
453
476
  return (this.flags & i.DISPOSED) !== 0;
@@ -460,31 +483,39 @@ var de = class {
460
483
  }
461
484
  subscribe(e) {
462
485
  let t = typeof e == "function";
463
- if (!t && (!e || typeof e.execute != "function")) throw y(/* @__PURE__ */ TypeError("Invalid subscriber"), m, v.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
486
+ if (!t && (e === null || typeof e.execute != "function")) throw y(/* @__PURE__ */ TypeError("Invalid subscriber"), m, v.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
464
487
  let n = this._slots;
465
- n || (n = new re(), this._slots = n);
466
- let r = !1;
467
- if (n._s0 != null && (t ? n._s0.fn === e : n._s0.sub === e)) r = !0;
468
- else if (n._s1 != null && (t ? n._s1.fn === e : n._s1.sub === e)) r = !0;
469
- else if (n._s2 != null && (t ? n._s2.fn === e : n._s2.sub === e)) r = !0;
470
- else if (n._s3 != null && (t ? n._s3.fn === e : n._s3.sub === e)) r = !0;
471
- else {
472
- let i = n._overflow;
473
- if (i != null) for (let n = 0, a = i.length; n < a; n++) {
474
- let a = i[n];
475
- if (a != null && (t ? a.fn === e : a.sub === e)) {
476
- r = !0;
477
- break;
488
+ if (n === null && (n = new ie(), this._slots = n), n.size > 0) {
489
+ let r = !1;
490
+ if (n._s0 !== null && (n._s0.fn === e || n._s0.sub === e) || n._s1 !== null && (n._s1.fn === e || n._s1.sub === e) || n._s2 !== null && (n._s2.fn === e || n._s2.sub === e) || n._s3 !== null && (n._s3.fn === e || n._s3.sub === e)) r = !0;
491
+ else {
492
+ let i = n._overflow;
493
+ if (i !== null) {
494
+ let n = i.length;
495
+ if (t) for (let t = 0; t < n; t++) {
496
+ let n = i[t];
497
+ if (n !== null && n?.fn === e) {
498
+ r = !0;
499
+ break;
500
+ }
501
+ }
502
+ else for (let t = 0; t < n; t++) {
503
+ let n = i[t];
504
+ if (n !== null && n?.sub === e) {
505
+ r = !0;
506
+ break;
507
+ }
508
+ }
478
509
  }
479
510
  }
511
+ if (r) return f && console.warn(`[atom-effect] Duplicate subscription ignored on node ${this.id}`), () => {};
480
512
  }
481
- if (r) return f && console.warn(`[atom-effect] Duplicate subscription ignored on node ${this.id}`), () => {};
482
- let i = new ue(t ? e : void 0, t ? void 0 : e);
483
- return n.add(i), () => this._unsubscribe(i);
513
+ let r = new de(t ? e : void 0, t ? void 0 : e);
514
+ return n.add(r), () => this._unsubscribe(r);
484
515
  }
485
516
  _unsubscribe(e) {
486
517
  let t = this._slots;
487
- t && (t.remove(e), this._notifying === 0 && t.compact());
518
+ t !== null && (t.remove(e), this._notifying === 0 && t.compact());
488
519
  }
489
520
  subscriberCount() {
490
521
  let e = this._slots;
@@ -495,32 +526,31 @@ var de = class {
495
526
  if (!(n === null || n.size === 0)) {
496
527
  this._notifying++;
497
528
  try {
498
- let r = n._s0;
499
- if (r != null) try {
500
- r.notify(e, t);
529
+ if (n._s0 !== null) try {
530
+ n._s0.notify(e, t);
501
531
  } catch (e) {
502
532
  this._logNotifyError(e);
503
533
  }
504
- if (r = n._s1, r != null) try {
505
- r.notify(e, t);
534
+ if (n._s1 !== null) try {
535
+ n._s1.notify(e, t);
506
536
  } catch (e) {
507
537
  this._logNotifyError(e);
508
538
  }
509
- if (r = n._s2, r != null) try {
510
- r.notify(e, t);
539
+ if (n._s2 !== null) try {
540
+ n._s2.notify(e, t);
511
541
  } catch (e) {
512
542
  this._logNotifyError(e);
513
543
  }
514
- if (r = n._s3, r != null) try {
515
- r.notify(e, t);
544
+ if (n._s3 !== null) try {
545
+ n._s3.notify(e, t);
516
546
  } catch (e) {
517
547
  this._logNotifyError(e);
518
548
  }
519
- let i = n._overflow;
520
- if (i != null) for (let n = 0, r = i.length; n < r; n++) {
521
- let r = i[n];
522
- if (r != null) try {
523
- r.notify(e, t);
549
+ let r = n._overflow;
550
+ if (r !== null) for (let n = 0, i = r.length; n < i; n++) {
551
+ let i = r[n];
552
+ if (i !== null) try {
553
+ i?.notify(e, t);
524
554
  } catch (e) {
525
555
  this._logNotifyError(e);
526
556
  }
@@ -539,38 +569,38 @@ var de = class {
539
569
  let t = this._hotIndex;
540
570
  if (t !== -1) {
541
571
  let n = e.getAt(t);
542
- if (n != null && n.node.version !== n.version) return !0;
572
+ if (n !== null && n.node.version !== n.version) return !0;
543
573
  }
544
574
  return this._deepDirtyCheck();
545
575
  }
546
- }, fe = 0;
547
- function pe() {
548
- let e = fe + 1 & s;
549
- return fe = e === 0 ? 1 : e, fe;
576
+ }, pe = 0;
577
+ function me() {
578
+ let e = pe + 1 & s;
579
+ return pe = e === 0 ? 1 : e, pe;
550
580
  }
551
- function me(e) {
581
+ function he(e) {
552
582
  let t = e + 1 & s;
553
583
  return t === 0 ? 1 : t;
554
584
  }
555
- var he = 0, ge = !1, _e = 0;
556
- function ve() {
557
- return _e;
558
- }
585
+ var ge = 0, _e = !1, ve = 0;
559
586
  function ye() {
560
- return ge ? (f && console.warn("startFlush() called during flush - ignored"), !1) : (ge = !0, _e = pe(), he = 0, !0);
587
+ return ve;
561
588
  }
562
589
  function be() {
563
- ge = !1;
590
+ return _e ? (f && console.warn("startFlush() called during flush - ignored"), !1) : (_e = !0, ve = me(), ge = 0, !0);
564
591
  }
565
592
  function xe() {
566
- if (!ge) return 0;
567
- let e = ++he;
593
+ _e = !1;
594
+ }
595
+ function Se() {
596
+ if (!_e) return 0;
597
+ let e = ++ge;
568
598
  if (e <= o.MAX_EXECUTIONS_PER_FLUSH) return e;
569
599
  throw Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${o.MAX_EXECUTIONS_PER_FLUSH}`);
570
600
  }
571
601
  var k = new class {
572
602
  constructor() {
573
- this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = o.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
603
+ this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._batchDepth = 0, this._batchQueueSize = 0, this._maxFlushIterations = o.MAX_FLUSH_ITERATIONS, this._isProcessing = !1, this._isFlushingSync = !1, this._buffer0 = [], this._buffer1 = [], this._batchQueue = [], this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
574
604
  }
575
605
  get queueSize() {
576
606
  return this._size + this._batchQueueSize;
@@ -586,17 +616,17 @@ var k = new class {
586
616
  this._batchQueue[this._batchQueueSize++] = e;
587
617
  return;
588
618
  }
589
- let n = this._queueBuffer[this._bufferIndex];
619
+ let n = this._bufferIndex === 0 ? this._buffer0 : this._buffer1;
590
620
  n[this._size++] = e, this._isProcessing || this._flush();
591
621
  }
592
622
  _flush() {
593
- this._isProcessing || this._size === 0 || (this._isProcessing = !0, queueMicrotask(this._boundRunLoop));
623
+ this._isProcessing || this._size === 0 && this._batchQueueSize === 0 || (this._isProcessing = !0, queueMicrotask(this._boundRunLoop));
594
624
  }
595
625
  _runLoop() {
596
626
  try {
597
627
  if (this._size === 0 && this._batchQueueSize === 0) return;
598
- let e = ye();
599
- this._drainQueue(), e && be();
628
+ let e = be();
629
+ this._drainQueue(), e && xe();
600
630
  } finally {
601
631
  this._isProcessing = !1;
602
632
  }
@@ -605,18 +635,17 @@ var k = new class {
605
635
  if (this._size === 0 && this._batchQueueSize === 0) return;
606
636
  let e = this._isFlushingSync;
607
637
  this._isFlushingSync = !0;
608
- let t = ye();
638
+ let t = be();
609
639
  try {
610
640
  this._mergeBatchQueue(), this._drainQueue();
611
641
  } finally {
612
- this._isFlushingSync = e, t && be();
642
+ this._isFlushingSync = e, t && xe();
613
643
  }
614
644
  }
615
645
  _mergeBatchQueue() {
616
646
  let e = this._batchQueueSize;
617
647
  if (e === 0) return;
618
- this._epoch = this._epoch + 1 | 0;
619
- let t = this._epoch, n = this._batchQueue, r = this._queueBuffer[this._bufferIndex], i = this._size;
648
+ let t = ++this._epoch | 0, n = this._batchQueue, r = this._bufferIndex === 0 ? this._buffer0 : this._buffer1, i = this._size;
620
649
  for (let a = 0; a < e; a++) {
621
650
  let e = n[a];
622
651
  e._nextEpoch !== t && (e._nextEpoch = t, r[i++] = e), n[a] = void 0;
@@ -634,7 +663,7 @@ var k = new class {
634
663
  }
635
664
  }
636
665
  _processQueue() {
637
- let e = this._bufferIndex, t = this._queueBuffer[e], n = this._size;
666
+ let e = this._bufferIndex, t = e === 0 ? this._buffer0 : this._buffer1, n = this._size;
638
667
  this._bufferIndex = e ^ 1, this._size = 0, this._epoch = this._epoch + 1 | 0;
639
668
  for (let e = 0; e < n; e++) {
640
669
  let n = t[e];
@@ -648,7 +677,7 @@ var k = new class {
648
677
  }
649
678
  _handleFlushOverflow() {
650
679
  let e = this._size + this._batchQueueSize;
651
- console.error(new _(v.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, e))), this._size = 0, this._queueBuffer[0].length = 0, this._queueBuffer[1].length = 0, this._batchQueueSize = 0, this._batchQueue.length = 0;
680
+ console.error(new _(v.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, e))), this._size = 0, this._buffer0.length = 0, this._buffer1.length = 0, this._batchQueueSize = 0, this._batchQueue.length = 0;
652
681
  let t = this.onOverflow;
653
682
  if (t) try {
654
683
  t(e);
@@ -669,7 +698,7 @@ var k = new class {
669
698
  this._maxFlushIterations = e;
670
699
  }
671
700
  }();
672
- function Se(e) {
701
+ function Ce(e) {
673
702
  if (f && typeof e != "function") throw TypeError(v.BATCH_CALLBACK_MUST_BE_FUNCTION);
674
703
  k.startBatch();
675
704
  try {
@@ -678,9 +707,25 @@ function Se(e) {
678
707
  k.endBatch();
679
708
  }
680
709
  }
681
- var Ce = class extends de {
710
+ var we = null;
711
+ function Te(e) {
712
+ return e ? new Promise((t, n) => {
713
+ k.schedule(() => {
714
+ try {
715
+ e(), t();
716
+ } catch (e) {
717
+ n(e);
718
+ }
719
+ });
720
+ }) : we || (we = new Promise((e) => {
721
+ k.schedule(() => {
722
+ we = null, e();
723
+ });
724
+ }), we);
725
+ }
726
+ var Ee = class extends fe {
682
727
  constructor(e, t) {
683
- super(), this[T] = E.Atom | E.Writable, this._value = e, this._equal = t.equal ?? Object.is, t.sync && (this.flags |= a.SYNC), w.attachDebugInfo(this, "atom", this.id, t.name);
728
+ super(), this[T] = E.Atom | E.Writable, this._value = e, this._equal = t.equal ?? Object.is, t.sync && (this.flags |= a.SYNC), f && w.attachDebugInfo(this, "atom", this.id, t.name);
684
729
  }
685
730
  get isNotificationScheduled() {
686
731
  return (this.flags & a.NOTIFICATION_SCHEDULED) !== 0;
@@ -693,41 +738,50 @@ var Ce = class extends de {
693
738
  }
694
739
  set value(e) {
695
740
  let t = this._value;
696
- if (this._equal(t, e) || (this._value = e, this.version = me(this.version), w.trackUpdate(this.id, w.getDebugName(this)), (this.flags & a.NOTIFICATION_SCHEDULED) !== 0)) return;
697
- let n = this._slots;
698
- n == null || n.size === 0 || (this._pendingOldValue = t, this.flags |= a.NOTIFICATION_SCHEDULED, (this.flags & a.SYNC) !== 0 && !k.isBatching ? this._notifying === 0 && this._flushNotifications() : k.schedule(this));
741
+ if (this._equal(t, e)) return;
742
+ this._value = e, this.version = he(this.version), f && w.trackUpdate(this.id, w.getDebugName(this));
743
+ let n = this.flags, r = a.NOTIFICATION_SCHEDULED;
744
+ if ((n & r) !== 0) return;
745
+ let i = this._slots;
746
+ if (i === null || i.size === 0) return;
747
+ this._pendingOldValue = t;
748
+ let o = n | r;
749
+ if (this.flags = o, (o & a.SYNC) !== 0 && !k.isBatching) {
750
+ this._notifying === 0 && this._flushNotifications();
751
+ return;
752
+ }
753
+ k.schedule(this);
699
754
  }
700
755
  execute() {
701
756
  this._flushNotifications();
702
757
  }
703
758
  _flushNotifications() {
704
- let e = a.NOTIFICATION_SCHEDULED, t = a.DISPOSED, n = a.SYNC;
705
- for (; (this.flags & (e | t)) === e;) {
759
+ let e = a.NOTIFICATION_SCHEDULED, t = a.DISPOSED, n = a.SYNC, r = e | t, i = this.flags;
760
+ for (; (i & r) === e;) {
706
761
  let t = this._pendingOldValue;
707
- if (this._pendingOldValue = void 0, this.flags &= ~e, this._equal(this._value, t) || this._notifySubscribers(this._value, t), (this.flags & n) === 0 || k.isBatching) break;
762
+ this._pendingOldValue = void 0, this.flags = i &= ~e;
763
+ let r = this._value;
764
+ if (this._equal(r, t) || this._notifySubscribers(r, t), i = this.flags, (i & n) === 0 || k.isBatching) break;
708
765
  }
709
766
  }
710
767
  peek() {
711
768
  return this._value;
712
769
  }
713
770
  dispose() {
714
- let e = this.flags;
715
- (e & a.DISPOSED) === 0 && (this._slots?.clear(), this.flags = e | a.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._equal = Object.is);
771
+ let e = this.flags, t = a.DISPOSED;
772
+ (e & t) === 0 && (this.flags = e | t, this._slots?.clear(), this._value = void 0, this._pendingOldValue = void 0, this._equal = Object.is);
716
773
  }
717
774
  _deepDirtyCheck() {
718
775
  return !1;
719
776
  }
720
- [Symbol.dispose]() {
721
- this.dispose();
722
- }
723
777
  };
724
- function we(e, t = {}) {
725
- return new Ce(e, t);
778
+ function De(e, t = {}) {
779
+ return new Ee(e, t);
726
780
  }
727
- var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RECOMPUTING: F, DISPOSED: Ee, IS_COMPUTED: I, FORCE_COMPUTE: De } = i, Oe = class extends de {
781
+ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Oe, RECOMPUTING: F, DISPOSED: ke, IS_COMPUTED: I, FORCE_COMPUTE: Ae } = i, je = class extends fe {
728
782
  constructor(e, t = {}) {
729
783
  if (typeof e != "function") throw new h(v.COMPUTED_MUST_BE_FUNCTION);
730
- if (super(), this[T] = E.Atom | E.Computed, this._error = null, this._promiseId = 0, this._deps = new ie(), this._trackEpoch = u.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = I | j | A, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : C, this._onError = t.onError ?? null, w.attachDebugInfo(this, "computed", this.id, t.name), t.lazy === !1) try {
784
+ if (super(), this[T] = E.Atom | E.Computed, this._promiseId = 0, this._trackEpoch = u.UNINITIALIZED, this._trackCount = 0, this._error = null, this._deps = new ae(), this._value = void 0, this.flags = I | j | A, this._equal = t.equal ?? Object.is, this._computation = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : C, this._onError = t.onError ?? null, w.attachDebugInfo(this, "computed", this.id, t.name), t.lazy === !1) try {
731
785
  this._recompute();
732
786
  } catch {}
733
787
  }
@@ -740,33 +794,28 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RE
740
794
  get isRecomputing() {
741
795
  return (this.flags & F) !== 0;
742
796
  }
743
- get _hasErrorInternal() {
744
- return (this.flags & Te) !== 0;
745
- }
746
- _track() {
747
- D.current?.addDependency(this);
748
- }
749
797
  get value() {
750
- D.current?.addDependency(this);
751
- let e = this.flags;
752
- if ((e & (N | j | A)) === N) return this._value;
753
- if ((e & Ee) !== 0) throw new h(v.COMPUTED_DISPOSED);
754
- if ((e & F) !== 0) {
798
+ let e = D.current;
799
+ e !== null && e.addDependency(this);
800
+ let t = this.flags;
801
+ if ((t & (N | j | A | ke | F)) === N) return this._value;
802
+ if ((t & ke) !== 0) throw new h(v.COMPUTED_DISPOSED);
803
+ if ((t & F) !== 0) {
755
804
  let e = this._defaultValue;
756
805
  if (e !== C) return e;
757
806
  throw new h(v.COMPUTED_CIRCULAR_DEPENDENCY);
758
807
  }
759
- if ((e & (j | A)) !== 0) {
760
- let t = this._deps;
761
- if ((e & A) === 0 && (e & De) === 0 && t.size > 0 && !this._isDirty() ? e = this.flags &= ~j : (this._recompute(), e = this.flags), (e & N) !== 0) return this._value;
808
+ if ((t & (j | A)) !== 0) {
809
+ let e = this._deps;
810
+ if ((t & (A | Ae)) !== 0 || e.size === 0 || this._isDirty() ? this._recompute() : this.flags &= ~j, (this.flags & N) !== 0) return this._value;
762
811
  }
763
- let t = this._defaultValue, n = t !== C;
764
- if ((e & M) !== 0) {
765
- if (n) return t;
812
+ let n = this._defaultValue, r = n !== C;
813
+ if ((this.flags & M) !== 0) {
814
+ if (r) return n;
766
815
  throw new h(v.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
767
816
  }
768
- if ((e & P) !== 0) {
769
- if (n) return t;
817
+ if ((this.flags & P) !== 0) {
818
+ if (r) return n;
770
819
  throw this._error;
771
820
  }
772
821
  return this._value;
@@ -775,16 +824,18 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RE
775
824
  return this._value;
776
825
  }
777
826
  get state() {
778
- D.current?.addDependency(this);
779
- let e = this.flags;
780
- return (e & N) === 0 ? (e & M) === 0 ? (e & P) === 0 ? n.IDLE : n.REJECTED : n.PENDING : n.RESOLVED;
827
+ let e = D.current;
828
+ e !== null && e.addDependency(this);
829
+ let t = this.flags;
830
+ return (t & N) === 0 ? (t & M) === 0 ? (t & P) === 0 ? n.IDLE : n.REJECTED : n.PENDING : n.RESOLVED;
781
831
  }
782
832
  get hasError() {
783
- if (D.current?.addDependency(this), (this.flags & (P | Te)) !== 0) return !0;
784
- let e = this._deps;
785
- return e.hasComputeds ? O(() => {
786
- let t = e.size;
787
- for (let n = 0; n < t; n++) if (e.getAt(n)?.node.hasError) return !0;
833
+ let e = D.current;
834
+ if (e !== null && e.addDependency(this), (this.flags & (P | Oe)) !== 0) return !0;
835
+ let t = this._deps;
836
+ return t.hasComputeds ? O(() => {
837
+ let e = t.size;
838
+ for (let n = 0; n < e; n++) if (t.getAt(n)?.node.hasError) return !0;
788
839
  return !1;
789
840
  }) : !1;
790
841
  }
@@ -792,66 +843,72 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RE
792
843
  return !this.hasError;
793
844
  }
794
845
  get errors() {
795
- D.current?.addDependency(this);
796
- let e = this._error, t = this._deps;
797
- if (!t.hasComputeds) return e == null ? p : Object.freeze([e]);
798
- let n = [];
799
- return e != null && n.push(e), O(() => {
800
- let e = t.size;
801
- for (let r = 0; r < e; r++) {
802
- let e = t.getAt(r)?.node;
803
- e != null && (e.flags & I) !== 0 && this._accumulateErrors(e, n);
846
+ let e = D.current;
847
+ e !== null && e.addDependency(this);
848
+ let t = this._error, n = this._deps;
849
+ if (!n.hasComputeds) return t === null ? p : Object.freeze([t]);
850
+ let r = [];
851
+ return t !== null && r.push(t), O(() => {
852
+ let e = n.size;
853
+ for (let t = 0; t < e; t++) {
854
+ let e = n.getAt(t)?.node;
855
+ e !== void 0 && (e.flags & I) !== 0 && this._accumulateErrors(e, r);
804
856
  }
805
- }), n.length === 0 ? p : Object.freeze(n);
857
+ }), r.length === 0 ? p : Object.freeze(r);
806
858
  }
807
859
  _accumulateErrors(e, t) {
808
860
  let n = e._error;
809
- n != null && !t.includes(n) && t.push(n);
861
+ n !== null && !t.includes(n) && t.push(n);
810
862
  let r = e._deps;
811
863
  if (!r.hasComputeds) return;
812
864
  let i = r.size;
813
865
  for (let e = 0; e < i; e++) {
814
866
  let n = r.getAt(e)?.node;
815
- n != null && (n.flags & I) !== 0 && this._accumulateErrors(n, t);
867
+ n !== void 0 && (n.flags & I) !== 0 && this._accumulateErrors(n, t);
816
868
  }
817
869
  }
818
870
  get lastError() {
819
- return D.current?.addDependency(this), this._error;
871
+ let e = D.current;
872
+ return e !== null && e.addDependency(this), this._error;
820
873
  }
821
874
  get isPending() {
822
- return D.current?.addDependency(this), (this.flags & M) !== 0;
875
+ let e = D.current;
876
+ return e !== null && e.addDependency(this), (this.flags & M) !== 0;
823
877
  }
824
878
  get isResolved() {
825
- return D.current?.addDependency(this), (this.flags & N) !== 0;
879
+ let e = D.current;
880
+ return e !== null && e.addDependency(this), (this.flags & N) !== 0;
826
881
  }
827
882
  invalidate() {
828
- this.flags |= De, this._markDirty();
883
+ this.flags |= Ae, this._markDirty();
829
884
  }
830
885
  dispose() {
831
- (this.flags & Ee) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = Ee | j | A, this._error = null, this._value = void 0, this._hotIndex = -1);
832
- }
833
- [Symbol.dispose]() {
834
- this.dispose();
886
+ (this.flags & ke) === 0 && (this._deps.disposeAll(), this._slots !== null && this._slots.clear(), this.flags = ke | j | A, this._error = null, this._value = void 0, this._hotIndex = -1);
835
887
  }
836
888
  addDependency(e) {
837
889
  let t = this._trackEpoch;
838
890
  if (e._lastSeenEpoch === t) return;
839
891
  e._lastSeenEpoch = t;
840
- let n = this._trackCount++, r = this._deps, i = r.getAt(n);
841
- if (i != null && i.node === e) i.version = e.version;
892
+ let n = this._trackCount++, r = this._deps, i = null;
893
+ if (n < 4) i = n === 0 ? r._s0 : n === 1 ? r._s1 : n === 2 ? r._s2 : r._s3;
894
+ else {
895
+ let e = r._overflow;
896
+ e !== null && (i = e[n - 4] ?? null);
897
+ }
898
+ if (i !== null && i.node === e) i.version = e.version;
842
899
  else if (!r.claimExisting(e, n)) {
843
- let t = new le(e, e.version, e.subscribe(this));
900
+ let t = new ue(e, e.version, e.subscribe(this));
844
901
  r.insertNew(n, t);
845
902
  }
846
903
  (e.flags & I) !== 0 && (r.hasComputeds = !0);
847
904
  }
848
905
  _recompute() {
849
- if (this.isRecomputing) return;
850
- this.flags = (this.flags | F) & ~De, this._trackEpoch = pe(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
906
+ if ((this.flags & F) !== 0) return;
907
+ this.flags = (this.flags | F) & ~Ae, this._trackEpoch = me(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
851
908
  let e = !1;
852
909
  try {
853
- let t = D.run(this, this._fn);
854
- this._deps.truncateFrom(this._trackCount), e = !0, ce(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
910
+ let t = D.run(this, this._computation);
911
+ this._deps.truncateFrom(this._trackCount), e = !0, le(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
855
912
  } catch (t) {
856
913
  if (!e) try {
857
914
  this._deps.truncateFrom(this._trackCount);
@@ -875,7 +932,7 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RE
875
932
  }
876
933
  _handleError(e, t, n = !1) {
877
934
  let r = y(e, h, t);
878
- if ((!this.isRejected || this._error !== r) && (this.version = me(this.version)), this._error = r, this.flags = this.flags & ~(A | j | M | N) | P | Te, this._onError) try {
935
+ if ((!this.isRejected || this._error !== r) && (this.version = he(this.version)), this._error = r, this.flags = this.flags & ~(A | j | M | N) | P | Oe, this._onError) try {
879
936
  this._onError(r);
880
937
  } catch (e) {
881
938
  console.error(v.CALLBACK_ERROR_IN_ERROR_HANDLER, e);
@@ -884,7 +941,7 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RE
884
941
  }
885
942
  _finalizeResolution(e) {
886
943
  let t = this.flags;
887
- ((t & N) === 0 || !this._equal(this._value, e)) && (this.version = me(this.version)), this._value = e, this._error = null, this.flags = (t | N) & ~(A | j | M | P | Te);
944
+ ((t & N) === 0 || !this._equal(this._value, e)) && (this.version = he(this.version)), this._value = e, this._error = null, this.flags = (t | N) & ~(A | j | M | P | Oe);
888
945
  }
889
946
  execute() {
890
947
  this._markDirty();
@@ -894,30 +951,36 @@ var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: Te, RE
894
951
  (e & (F | j)) === 0 && (this.flags = e | j, w.trackUpdate(this.id, w.getDebugName(this)), this._notifySubscribers(void 0, void 0));
895
952
  }
896
953
  _deepDirtyCheck() {
897
- let e = this._deps;
954
+ let e = this._deps, t = e.size, n = this._hotIndex;
898
955
  return O(() => {
899
- let t = e.size;
900
- for (let n = 0; n < t; n++) {
956
+ if (n !== -1 && n < t) {
901
957
  let t = e.getAt(n);
902
- if (t == null) continue;
903
- let r = t.node;
904
- if ((r.flags & I) !== 0) try {
905
- r.value;
906
- } catch {
907
- f && console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`);
908
- }
909
- if (r.version !== t.version) return this._hotIndex = n, !0;
958
+ if (t !== null && this._checkLinkDirty(t)) return !0;
959
+ }
960
+ for (let r = 0; r < t; r++) {
961
+ if (r === n) continue;
962
+ let t = e.getAt(r);
963
+ if (t !== null && this._checkLinkDirty(t)) return this._hotIndex = r, !0;
910
964
  }
911
965
  return this._hotIndex = -1, !1;
912
966
  });
913
967
  }
968
+ _checkLinkDirty(e) {
969
+ let t = e.node;
970
+ if ((t.flags & I) !== 0) try {
971
+ t.value;
972
+ } catch {
973
+ f && console.warn(`[atom-effect] Dependency #${t.id} threw during check`);
974
+ }
975
+ return t.version !== e.version;
976
+ }
914
977
  };
915
- function L(e, t = {}) {
916
- return new Oe(e, t);
978
+ function Me(e, t = {}) {
979
+ return new je(e, t);
917
980
  }
918
- var ke = class extends de {
981
+ var Ne = class extends fe {
919
982
  constructor(e, t = {}) {
920
- super(), this[T] = E.Effect, this._cleanup = null, this._deps = new ie(), this._currentEpoch = u.UNINITIALIZED, this._lastFlushEpoch = u.UNINITIALIZED, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? o.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? o.MAX_EXECUTIONS_PER_EFFECT, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => k.schedule(this), w.attachDebugInfo(this, "effect", this.id, t.name);
983
+ super(), this[T] = E.Effect, this._currentEpoch = u.UNINITIALIZED, this._lastFlushEpoch = u.UNINITIALIZED, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._cleanup = null, this._deps = new ae(), this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? o.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? o.MAX_EXECUTIONS_PER_EFFECT, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => k.schedule(this), w.attachDebugInfo(this, "effect", this.id, t.name);
921
984
  }
922
985
  run() {
923
986
  if (this.isDisposed) throw new g(v.EFFECT_DISPOSED);
@@ -926,56 +989,40 @@ var ke = class extends de {
926
989
  dispose() {
927
990
  this.isDisposed || (this.flags |= r.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
928
991
  }
929
- [Symbol.dispose]() {
930
- this.dispose();
931
- }
932
992
  addDependency(e) {
933
- if ((this.flags & r.EXECUTING) === 0) return;
934
- let t = this._currentEpoch;
935
- if (e._lastSeenEpoch === t) return;
936
- e._lastSeenEpoch = t;
937
- let n = this._trackCount++, i = this._deps, a;
938
- switch (n) {
939
- case 0:
940
- a = i._s0;
941
- break;
942
- case 1:
943
- a = i._s1;
944
- break;
945
- case 2:
946
- a = i._s2;
947
- break;
948
- case 3:
949
- a = i._s3;
950
- break;
951
- default: a = i.getAt(n);
993
+ if ((this.flags & r.EXECUTING) === 0 || e._lastSeenEpoch === this._currentEpoch) return;
994
+ e._lastSeenEpoch = this._currentEpoch;
995
+ let t = this._trackCount++, n = this._deps, i = e.version, a = null;
996
+ if (t < 4) a = t === 0 ? n._s0 : t === 1 ? n._s1 : t === 2 ? n._s2 : n._s3;
997
+ else {
998
+ let e = n._overflow;
999
+ e !== null && (a = e[t - 4] ?? null);
952
1000
  }
953
- a != null && a.node === e ? a.version = e.version : i.claimExisting(e, n) || this._insertNewDependency(e, n), e.isComputed && (i.hasComputeds = !0);
1001
+ a !== null && a.node === e ? a.version = i : n.claimExisting(e, t) || this._insertNewDependency(e, t, i), e.isComputed && !n.hasComputeds && (n.hasComputeds = !0);
954
1002
  }
955
- _insertNewDependency(e, t) {
956
- let n;
1003
+ _insertNewDependency(e, t, n) {
1004
+ let r;
957
1005
  try {
958
- let t = e.subscribe(this._notifyCallback);
959
- n = new le(e, e.version, t);
1006
+ r = new ue(e, n, e.subscribe(this._notifyCallback));
960
1007
  } catch (t) {
961
- let r = y(t, g, v.EFFECT_EXECUTION_FAILED);
962
- if (console.error(r), this._onError) try {
963
- this._onError(r);
1008
+ let i = y(t, g, v.EFFECT_EXECUTION_FAILED);
1009
+ if (console.error(i), this._onError) try {
1010
+ this._onError(i);
964
1011
  } catch {}
965
- n = new le(e, e.version, void 0);
1012
+ r = new ue(e, n, void 0);
966
1013
  }
967
- this._deps.insertNew(t, n);
1014
+ this._deps.insertNew(t, r);
968
1015
  }
969
1016
  execute(e = !1) {
970
1017
  let t = this.flags;
971
1018
  if ((t & (r.DISPOSED | r.EXECUTING)) !== 0) return;
972
1019
  let n = this._deps;
973
- if (!e && n.size > 0 && !this._isDirty()) return;
974
- this._checkInfiniteLoops(), w.trackUpdate(this.id, w.getDebugName(this)), this.flags = t | r.EXECUTING, this._execCleanup(), this._currentEpoch = pe(), this._trackCount = 0, n.prepareTracking(), this._hotIndex = -1;
1020
+ if (!e && n.physicalSize > 0 && !this._isDirty()) return;
1021
+ this._checkInfiniteLoops(), w.trackUpdate(this.id, w.getDebugName(this)), this.flags = t | r.EXECUTING, this._execCleanup(), this._currentEpoch = me(), this._trackCount = 0, n.prepareTracking(), this._hotIndex = -1;
975
1022
  let i = !1;
976
1023
  try {
977
1024
  let e = D.run(this, this._fn);
978
- n.truncateFrom(this._trackCount), i = !0, ce(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
1025
+ n.truncateFrom(this._trackCount), i = !0, typeof e == "function" ? this._cleanup = e : le(e) ? this._handleAsyncResult(e) : this._cleanup = null;
979
1026
  } catch (e) {
980
1027
  if (!i) try {
981
1028
  n.truncateFrom(this._trackCount);
@@ -990,7 +1037,7 @@ var ke = class extends de {
990
1037
  _handleAsyncResult(e) {
991
1038
  let t = ++this._execId;
992
1039
  e.then((e) => {
993
- if (t !== this._execId || this.isDisposed) {
1040
+ if (t !== this._execId || (this.flags & r.DISPOSED) !== 0) {
994
1041
  if (typeof e == "function") try {
995
1042
  e();
996
1043
  } catch (e) {
@@ -1001,28 +1048,38 @@ var ke = class extends de {
1001
1048
  typeof e == "function" && (this._cleanup = e);
1002
1049
  }, (e) => t === this._execId && this._handleExecutionError(e));
1003
1050
  }
1051
+ _isDirty() {
1052
+ let e = this._deps, t = e.size;
1053
+ if (t === 0) return !1;
1054
+ let n = this._hotIndex;
1055
+ if (n !== -1 && n < t) {
1056
+ let t = e.getAt(n);
1057
+ if (t !== null) {
1058
+ let e = t.node;
1059
+ if (!e.isComputed && e.version !== t.version) return !0;
1060
+ }
1061
+ }
1062
+ return this._deepDirtyCheck();
1063
+ }
1004
1064
  _deepDirtyCheck() {
1005
- let e = D.current;
1065
+ let e = this._deps, t = e.size, n = this._hotIndex, r = D.current;
1006
1066
  D.current = null;
1007
- let t = this._deps;
1008
1067
  try {
1009
- let e = t.size;
1010
- for (let n = 0; n < e; n++) {
1011
- let e = t.getAt(n);
1012
- if (e == null) continue;
1013
- let r = e.node;
1014
- if (r.isComputed && this._tryPullComputed(r), r.version !== e.version) return this._hotIndex = n, !0;
1068
+ for (let r = 0; r < t; r++) {
1069
+ if (r === n) continue;
1070
+ let t = e.getAt(r);
1071
+ if (t === null) continue;
1072
+ let i = t.node;
1073
+ if (i.isComputed) try {
1074
+ i.value;
1075
+ } catch {
1076
+ f && console.warn(`[atom-effect] Dependency #${i.id} error in check`);
1077
+ }
1078
+ if (i.version !== t.version) return this._hotIndex = r, !0;
1015
1079
  }
1016
- return !1;
1080
+ return this._hotIndex = -1, !1;
1017
1081
  } finally {
1018
- D.current = e;
1019
- }
1020
- }
1021
- _tryPullComputed(e) {
1022
- try {
1023
- e.value;
1024
- } catch {
1025
- f && console.warn(`[atom-effect] Dependency #${e.id} threw during dirty check`);
1082
+ D.current = r;
1026
1083
  }
1027
1084
  }
1028
1085
  _execCleanup() {
@@ -1037,8 +1094,8 @@ var ke = class extends de {
1037
1094
  }
1038
1095
  }
1039
1096
  _checkInfiniteLoops() {
1040
- let e = ve();
1041
- this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), xe() > o.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, f && this._checkFrequencyLimit();
1097
+ let e = ye();
1098
+ this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Se() > o.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, f && this._checkFrequencyLimit();
1042
1099
  }
1043
1100
  _checkFrequencyLimit() {
1044
1101
  if (!Number.isFinite(this._maxExecutions)) return;
@@ -1059,7 +1116,7 @@ var ke = class extends de {
1059
1116
  return (this.flags & r.EXECUTING) !== 0;
1060
1117
  }
1061
1118
  _throwInfiniteLoopError(e) {
1062
- let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${he}`);
1119
+ let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${ge}`);
1063
1120
  throw this.dispose(), console.error(t), t;
1064
1121
  }
1065
1122
  _handleExecutionError(e, t = v.EFFECT_EXECUTION_FAILED) {
@@ -1071,301 +1128,230 @@ var ke = class extends de {
1071
1128
  }
1072
1129
  }
1073
1130
  };
1074
- function R(e, t = {}) {
1131
+ function L(e, t = {}) {
1075
1132
  if (typeof e != "function") throw new g(v.EFFECT_MUST_BE_FUNCTION);
1076
- let n = new ke(e, t);
1133
+ let n = new Ne(e, t);
1077
1134
  return n.execute(), n;
1078
1135
  }
1079
- var Ae = /^(?:__proto__|constructor|prototype)$/;
1080
- function je(e, t, n, r) {
1136
+ function Pe(e, t, n, r) {
1081
1137
  if (n === t.length) return r;
1082
1138
  let i = t[n];
1083
- if (Ae.test(i)) return e;
1084
- let a = typeof e == "object" && e ? e : {}, o = a[i], s = je(o, t, n + 1, r);
1139
+ if (i === "__proto__" || i === "constructor" || i === "prototype") return e;
1140
+ let a = typeof e == "object" && e ? e : {}, o = a[i], s = Pe(o, t, n + 1, r);
1085
1141
  if (Object.is(o, s)) return e;
1086
1142
  if (Array.isArray(a)) {
1087
- let e = a.slice(), t = Number(i);
1088
- return i.trim() !== "" && Number.isInteger(t) && t >= 0 ? e[t] = s : e[i] = s, e;
1143
+ let e = a.slice(), t = +i;
1144
+ return i.trim() !== "" && t >= 0 && t % 1 == 0 ? e[t] = s : e[i] = s, e;
1089
1145
  }
1090
- return {
1091
- ...a,
1092
- [i]: s
1093
- };
1146
+ let c = { ...a };
1147
+ return c[i] = s, c;
1094
1148
  }
1095
- function z(e, t) {
1149
+ function Fe(e, t) {
1096
1150
  let n = e, r = t.length;
1097
1151
  for (let e = 0; e < r; e++) {
1098
1152
  if (n == null) return;
1099
1153
  let r = t[e];
1100
- if (Ae.test(r)) return;
1154
+ if (r === "__proto__" || r === "constructor" || r === "prototype") return;
1101
1155
  n = n[r];
1102
1156
  }
1103
1157
  return n;
1104
1158
  }
1105
- function Me(e, t) {
1106
- let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set(), i = () => {
1107
- r.forEach((e) => e()), r.clear();
1108
- };
1159
+ function Ie(e, t) {
1160
+ let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set();
1109
1161
  return {
1110
1162
  get value() {
1111
- return z(e.value, n);
1163
+ return Fe(e.value, n);
1112
1164
  },
1113
1165
  set value(t) {
1114
- let r = e.peek(), i = je(r, n, 0, t);
1166
+ let r = e.peek(), i = Pe(r, n, 0, t);
1115
1167
  i !== r && (e.value = i);
1116
1168
  },
1117
- peek: () => z(e.peek(), n),
1169
+ peek: () => Fe(e.peek(), n),
1118
1170
  subscribe(t) {
1119
- let i = e.subscribe((e, r) => {
1120
- let i = z(e, n), a = z(r, n);
1121
- Object.is(i, a) || t(i, a);
1171
+ let i = Fe(e.peek(), n), a = e.subscribe((e) => {
1172
+ let r = Fe(e, n);
1173
+ if (!Object.is(r, i)) {
1174
+ let e = i;
1175
+ i = r, t(r, e);
1176
+ }
1122
1177
  });
1123
- return r.add(i), () => {
1124
- i(), r.delete(i);
1178
+ return r.add(a), () => {
1179
+ a(), r.delete(a);
1125
1180
  };
1126
1181
  },
1127
1182
  subscriberCount: () => r.size,
1128
- dispose: i,
1129
- [Symbol.dispose]: i,
1183
+ dispose: () => {
1184
+ r.forEach((e) => e()), r.clear();
1185
+ },
1130
1186
  [T]: E.Atom | E.Writable
1131
1187
  };
1132
1188
  }
1133
- var Ne = (e, t) => Me(e, t), Pe = (e) => (t) => Me(e, t), Fe = (e) => typeof e == "object" && !!e, Ie = (e) => oe(e), Le = (e) => (Fe(e) || typeof e == "function") && typeof e.then == "function";
1134
- function Re(e) {
1189
+ var Le = (e, t) => Ie(e, t), Re = (e) => (t) => Ie(e, t), ze = { ERRORS: { EFFECT_DISPOSE_ERROR: (e) => `Dispose error${e ? `: ${e}` : ""}` } }, Be = {
1190
+ PREFIX: "[atom-route]",
1191
+ DEFAULTS: Object.freeze({
1192
+ mode: "hash",
1193
+ basePath: "",
1194
+ autoBindLinks: !1,
1195
+ activeClass: "active"
1196
+ }),
1197
+ ERRORS: {
1198
+ NOT_FOUND: (e) => `Route "${e}" not found`,
1199
+ TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
1200
+ TARGET_NOT_FOUND: (e) => `Target "${e}" not found`,
1201
+ MALFORMED_URI: (e) => `Malformed URI: ${e}`
1202
+ }
1203
+ }, Ve = {
1204
+ PREFIX: "[atom-binding]",
1205
+ INPUT_DEFAULTS: Object.freeze({
1206
+ EVENT: "input",
1207
+ DEBOUNCE: 0
1208
+ }),
1209
+ VALID_INPUT_TAGS: [
1210
+ "input",
1211
+ "select",
1212
+ "textarea"
1213
+ ],
1214
+ ERRORS: {
1215
+ INVALID_INPUT_ELEMENT: (e) => `Invalid element <${e}> for val.`,
1216
+ MISSING_SOURCE: (e) => `[${e}] source required.`,
1217
+ MISSING_CONDITION: (e) => `[${e}] condition required.`,
1218
+ UPDATER_ERROR: (e, t) => `Updater failed: "${e}"${t ? " (static)" : ""}`,
1219
+ CLEANUP_ERROR: (e) => `Binding cleanup error${e ? `: ${e}` : ""}`,
1220
+ PARSE_ERROR: (e) => `Parse error${e ? `: ${e}` : ""}`
1221
+ }
1222
+ }, He = {
1223
+ DANGEROUS_PROPS: [
1224
+ "innerHTML",
1225
+ "outerHTML",
1226
+ "srcdoc",
1227
+ "__proto__",
1228
+ "constructor",
1229
+ "prototype"
1230
+ ],
1231
+ URL_PROPS: [
1232
+ "src",
1233
+ "href",
1234
+ "action",
1235
+ "formaction",
1236
+ "data",
1237
+ "poster",
1238
+ "background",
1239
+ "cite",
1240
+ "longdesc",
1241
+ "profile",
1242
+ "usemap",
1243
+ "classid",
1244
+ "codebase",
1245
+ "xlink:href"
1246
+ ],
1247
+ DANGEROUS_PROTOCOL_PATTERN: "(?:javascript|vbscript)",
1248
+ ERRORS: {
1249
+ UNSAFE_CONTENT: () => "Unsafe content neutralized.",
1250
+ BLOCKED_CSS_VALUE: (e) => `Blocked CSS: "${e}".`,
1251
+ BLOCKED_EVENT_HANDLER: (e) => `Blocked handler: "${e}".`,
1252
+ BLOCKED_PROTOCOL: (e) => `Blocked protocol: "${e}".`,
1253
+ BLOCKED_PROP: (e) => `Blocked prop: "${e}".`
1254
+ }
1255
+ }, Ue = {
1256
+ PREFIX: "[atom-list]",
1257
+ ERRORS: { DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.` }
1258
+ }, We = {
1259
+ PREFIX: "[atom-mount]",
1260
+ ERRORS: {
1261
+ ERROR: (e) => `Mount error${e ? ` in <${e}>` : ""}`,
1262
+ CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in <${e}>` : ""}`
1263
+ }
1264
+ }, Ge = { DEFAULTS: Object.freeze({ HIGHLIGHT_DURATION_MS: 500 }) }, R = {
1265
+ ROUTE: Be.PREFIX,
1266
+ BINDING: Ve.PREFIX,
1267
+ LIST: Ue.PREFIX,
1268
+ MOUNT: We.PREFIX
1269
+ }, z = {
1270
+ ROUTE: Be.ERRORS,
1271
+ SECURITY: He.ERRORS,
1272
+ BINDING: Ve.ERRORS,
1273
+ LIST: Ue.ERRORS,
1274
+ MOUNT: We.ERRORS,
1275
+ CORE: ze.ERRORS
1276
+ }, Ke = Be.DEFAULTS, qe = Ve.INPUT_DEFAULTS, Je = Ge.DEFAULTS, Ye = Ve.VALID_INPUT_TAGS;
1277
+ He.URL_PROPS;
1278
+ var Xe = He.DANGEROUS_PROPS, Ze = He.DANGEROUS_PROTOCOL_PATTERN, Qe = (e) => e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
1279
+ function B(e) {
1135
1280
  let { localName: t, id: n, className: r } = e, i = t;
1136
1281
  n && (i += `#${n}`);
1137
- let a = typeof r == "string" ? r : r.baseVal;
1138
- if (typeof a == "string") {
1139
- let e = a.trim();
1140
- e && (i += `.${e.replace(/\s+/g, ".")}`);
1282
+ let a = typeof r == "string" ? r : r?.baseVal;
1283
+ if (a) {
1284
+ let e = a.trim().replace(/\s+/g, ".");
1285
+ e && (i += `.${e}`);
1141
1286
  }
1142
1287
  let o = e.type;
1143
- return o && typeof o == "string" && o !== "text" && (i += `.${o}`), i;
1288
+ return o && o !== "text" && (i += `.${o}`), i;
1144
1289
  }
1145
- var B = Object.prototype.hasOwnProperty;
1146
- function ze(e, t) {
1290
+ var $e = Object.prototype.hasOwnProperty;
1291
+ function et(e, t) {
1147
1292
  if (e === t) return !0;
1148
- if (!Fe(e) || !Fe(t)) return !1;
1149
- let n = e, r = t, i = Object.keys(n), a = Object.keys(r);
1150
- if (i.length !== a.length) return !1;
1151
- for (let e of i) if (!B.call(r, e) || !Object.is(n[e], r[e])) return !1;
1293
+ if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
1294
+ let n = e, r = t, i = Object.keys(n);
1295
+ if (i.length !== Object.keys(r).length) return !1;
1296
+ for (let e of i) if (!$e.call(r, e) || !Object.is(n[e], r[e])) return !1;
1152
1297
  return !0;
1153
1298
  }
1154
1299
  //#endregion
1155
- //#region src/constants.ts
1156
- var V = {
1157
- ROUTE: "[atom-route]",
1158
- BINDING: "[atom-binding]",
1159
- LIST: "[atom-list]",
1160
- MOUNT: "[atom-mount]"
1161
- }, Be = Object.freeze({
1162
- mode: "hash",
1163
- basePath: "",
1164
- autoBindLinks: !1,
1165
- activeClass: "active"
1166
- }), Ve = Object.freeze({
1167
- EVENT: "input",
1168
- DEBOUNCE: 0
1169
- }), He = Object.freeze({ HIGHLIGHT_DURATION_MS: 500 }), Ue = new Set([
1170
- "input",
1171
- "select",
1172
- "textarea"
1173
- ]), We = new Set([
1174
- "innerHTML",
1175
- "outerHTML",
1176
- "srcdoc",
1177
- "__proto__",
1178
- "constructor",
1179
- "prototype"
1180
- ]), Ge = "(?: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)", H = {
1181
- ROUTE: {
1182
- NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
1183
- TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
1184
- TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
1185
- MALFORMED_URI: (e) => `Malformed URI component: ${e}`
1186
- },
1187
- SECURITY: {
1188
- UNSAFE_CONTENT: () => "Unsafe content neutralized during sanitization.",
1189
- BLOCKED_CSS_VALUE: (e) => `Blocked dangerous value in CSS style property "${e}".`,
1190
- BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute/property "${e}".`,
1191
- BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}".`,
1192
- BLOCKED_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`
1193
- },
1194
- BINDING: {
1195
- INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
1196
- MISSING_SOURCE: (e) => `[${e}] source is required when prop/name is a string.`,
1197
- MISSING_CONDITION: (e) => `[${e}] condition is required when className is a string.`,
1198
- UPDATER_ERROR: (e, t) => `Updater threw in binding "${e}"${t ? " (static)" : ""}`,
1199
- CLEANUP_ERROR: (e) => `Binding cleanup error${e ? `: ${e}` : ""}`,
1200
- PARSE_ERROR: (e) => `parse() threw during DOM→Atom sync${e ? `: ${e}` : ""}`
1201
- },
1202
- LIST: { DUPLICATE_KEY: (e, t, n) => `Duplicate key "${e}" at index ${t} in atomList <${n}>.` },
1203
- MOUNT: {
1204
- ERROR: (e) => `Mount error${e ? ` in component <${e}>` : ""}`,
1205
- CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in component <${e}>` : ""}`
1206
- },
1207
- CORE: { EFFECT_DISPOSE_ERROR: (e) => `Effect dispose error${e ? `: ${e}` : ""}` }
1208
- }, Ke = "atom-debug-highlight", U = "data-atom-debug", qe = typeof window < "u", Je = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), Xe = !1, Ze = () => `${He.HIGHLIGHT_DURATION_MS / 1e3}s`, Qe = () => `
1209
- [${U}] {
1210
- transition: outline ${Ze()} ease-out;
1211
- }
1212
- .${Ke} {
1213
- outline: 2px solid rgba(255, 68, 68, 0.8);
1214
- outline-offset: 1px;
1215
- }
1216
- `.replace(/\s+/g, " ");
1217
- function $e() {
1218
- if (Xe || !qe) return;
1219
- if (document.querySelector(`style[${U}]`)) {
1220
- Xe = !0;
1221
- return;
1222
- }
1300
+ //#region src/utils/debug.ts
1301
+ var tt = "atom-debug-highlight", nt = "data-atom-debug", rt = typeof window < "u", it = /* @__PURE__ */ new WeakMap(), at = /* @__PURE__ */ new WeakMap(), ot = !1;
1302
+ function st() {
1303
+ if (ot || !rt) return;
1223
1304
  let e = document.createElement("style");
1224
- e.setAttribute(U, ""), e.textContent = Qe(), document.head.appendChild(e), Xe = !0;
1305
+ e.setAttribute(nt, ""), e.textContent = `
1306
+ [${nt}] { transition: outline ${Je.HIGHLIGHT_DURATION_MS / 1e3}s ease-out; }
1307
+ .${tt} { outline: 2px solid rgba(255, 68, 68, 0.8); outline-offset: 1px; }
1308
+ `.replace(/\s+/g, " "), document.head.appendChild(e), ot = !0;
1225
1309
  }
1226
- function et() {
1310
+ function ct() {
1227
1311
  let e = globalThis;
1228
- if (e.__ATOM_DEBUG__ !== void 0) return !!e.__ATOM_DEBUG__;
1229
- try {
1230
- if (typeof sessionStorage < "u" && sessionStorage.getItem("__ATOM_DEBUG__") === "true") return !0;
1231
- } catch {}
1232
- return e.process?.env?.NODE_ENV !== "production" && e.process?.env?.NODE_ENV !== void 0 ? !0 : e.__DEV__ === void 0 ? !1 : !!e.__DEV__;
1312
+ return e.__ATOM_DEBUG__ === void 0 ? e.process?.env?.NODE_ENV !== "production" && e.process?.env?.NODE_ENV !== void 0 : !!e.__ATOM_DEBUG__;
1233
1313
  }
1234
- var tt = class {
1235
- constructor() {
1236
- this.enabled = !0;
1237
- }
1238
- log(e, ...t) {
1239
- this.enabled && console.log(e, ...t);
1240
- }
1241
- atomChanged(e, t, n, r) {
1242
- this.enabled && console.log(`${e} Atom "${t ?? "anonymous"}" changed:`, n, "→", r);
1243
- }
1244
- cleanup(e, t) {
1245
- this.enabled && console.log(`${e} Cleanup: ${t}`);
1246
- }
1247
- warn(e, t, ...n) {
1248
- console.warn(`${e} ${t}`, ...n);
1249
- }
1250
- error(e, t, n) {
1251
- console.error(`${e} ${t}`, n);
1252
- }
1314
+ var V = {
1315
+ enabled: ct(),
1316
+ warn: (e, t, ...n) => console.warn(`${e} ${t}`, ...n),
1317
+ error: (e, t, n) => console.error(`${e} ${t}`, n),
1253
1318
  domUpdated(e, t, n, r) {
1254
1319
  if (!this.enabled) return;
1255
1320
  let i = "jquery" in t ? t[0] : t;
1256
- i && i.nodeType === 1 && i.isConnected && (console.log(`${e} DOM updated: ${Re(i)}.${n} =`, r), this._triggerVisualHighlight(i));
1257
- }
1258
- _triggerVisualHighlight(e) {
1259
- let t = globalThis, n = t.requestAnimationFrame, r = t.cancelAnimationFrame;
1260
- if (!qe || typeof n != "function") return;
1261
- $e();
1262
- let i = Ye.get(e), a = Je.get(e);
1263
- i !== void 0 && typeof r == "function" && r(i), a !== void 0 && (clearTimeout(a), Je.delete(e)), e.hasAttribute(U) || e.setAttribute(U, ""), Ye.set(e, n(() => {
1264
- Ye.delete(e), e.isConnected && (e.classList.add(Ke), Je.set(e, setTimeout(() => {
1265
- e.classList.remove(Ke), Je.delete(e);
1266
- }, He.HIGHLIGHT_DURATION_MS)));
1267
- }));
1321
+ i && i.nodeType === 1 && i.isConnected && (console.log(`${e} DOM updated: ${B(i)}.${n} =`, r), lt(i));
1268
1322
  }
1269
- }, W = et() ? new tt() : {
1270
- enabled: !1,
1271
- log: () => {},
1272
- atomChanged: () => {},
1273
- domUpdated: () => {},
1274
- cleanup: () => {},
1275
- warn: (e, t, ...n) => console.warn(`${e} ${t}`, ...n),
1276
- error: (e, t, n) => console.error(`${e} ${t}`, n)
1277
1323
  };
1324
+ function lt(e) {
1325
+ let t = globalThis;
1326
+ if (!rt || typeof t.requestAnimationFrame != "function") return;
1327
+ st();
1328
+ let n = at.get(e), r = it.get(e);
1329
+ n !== void 0 && t.cancelAnimationFrame(n), r !== void 0 && clearTimeout(r), e.hasAttribute(nt) || e.setAttribute(nt, ""), at.set(e, t.requestAnimationFrame(() => {
1330
+ at.delete(e), e.isConnected && (e.classList.add(tt), it.set(e, setTimeout(() => {
1331
+ e.classList.remove(tt), it.delete(e);
1332
+ }, Je.HIGHLIGHT_DURATION_MS)));
1333
+ }));
1334
+ }
1278
1335
  //#endregion
1279
1336
  //#region src/core/namespace.ts
1280
- function nt(e, t) {
1281
- return we(e, t);
1282
- }
1283
- Object.defineProperty(nt, "debug", {
1284
- enumerable: !0,
1285
- configurable: !0,
1286
- get: () => W.enabled,
1287
- set: (e) => {
1288
- W.enabled = e;
1289
- }
1290
- });
1291
- var rt = () => Promise.resolve();
1337
+ var ut = () => Te();
1292
1338
  e.extend({
1293
- atom: nt,
1294
- computed: L,
1295
- effect: R,
1296
- batch: Se,
1339
+ atom: De,
1340
+ computed: Me,
1341
+ effect: L,
1342
+ batch: Ce,
1297
1343
  untracked: O,
1298
- isAtom: oe,
1299
- isComputed: se,
1300
- isReactive: Ie,
1301
- nextTick: rt,
1302
- atomLens: Me,
1303
- composeLens: Ne,
1304
- lensFor: Pe
1344
+ isAtom: se,
1345
+ isComputed: ce,
1346
+ nextTick: ut,
1347
+ atomLens: Ie,
1348
+ composeLens: Le,
1349
+ lensFor: Re,
1350
+ debug: V
1305
1351
  });
1306
1352
  //#endregion
1307
- //#region src/utils/pool.ts
1308
- var it = class {
1309
- constructor(e = 50, t = 256) {
1310
- this.limit = e, this.capacity = t, this.pool = [];
1311
- }
1312
- acquire() {
1313
- return this.pool.pop() ?? [];
1314
- }
1315
- release(e) {
1316
- if (Object.isFrozen(e)) return;
1317
- let t = e.length;
1318
- e.length = 0, this.pool.length < this.limit && t <= this.capacity && this.pool.indexOf(e) === -1 && this.pool.push(e);
1319
- }
1320
- reset() {
1321
- this.pool.length = 0;
1322
- }
1323
- }, at = class {
1324
- constructor(e, t, n = 64) {
1325
- this.factory = e, this.reset = t, this.limit = n, this.pool = [];
1326
- }
1327
- acquire() {
1328
- return this.pool.pop() ?? this.factory();
1329
- }
1330
- release(e) {
1331
- Object.isFrozen(e) || (this.reset(e), this.pool.length < this.limit && this.pool.indexOf(e) === -1 && this.pool.push(e));
1332
- }
1333
- drain() {
1334
- this.pool.length > 0 && (this.pool.length = 0);
1335
- }
1336
- get size() {
1337
- return this.pool.length;
1338
- }
1339
- }, ot = 128, st = new it(ot), ct = new it(ot), lt = new at(() => ({
1340
- effects: void 0,
1341
- cleanups: void 0,
1342
- componentCleanup: void 0
1343
- }), (e) => {
1344
- if (e.effects) {
1345
- let t = e.effects.length;
1346
- for (let n = 0; n < t; n++) try {
1347
- e.effects[n].dispose();
1348
- } catch {}
1349
- st.release(e.effects), e.effects = void 0;
1350
- }
1351
- if (e.cleanups) {
1352
- let t = e.cleanups.length;
1353
- for (let n = 0; n < t; n++) try {
1354
- e.cleanups[n]();
1355
- } catch {}
1356
- ct.release(e.cleanups), e.cleanups = void 0;
1357
- }
1358
- if (e.componentCleanup) {
1359
- try {
1360
- e.componentCleanup();
1361
- } catch {}
1362
- e.componentCleanup = void 0;
1363
- }
1364
- }, ot), ut = !1;
1365
- function dt() {
1366
- ut || typeof document < "u" && document.body && (ut = !0, pt(document.body));
1367
- }
1368
- var G = "_aes-bound", K = new class {
1353
+ //#region src/core/registry.ts
1354
+ var dt = !1, ft = "_aes-bound", H = new class {
1369
1355
  constructor() {
1370
1356
  this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
1371
1357
  }
@@ -1382,17 +1368,33 @@ var G = "_aes-bound", K = new class {
1382
1368
  return this.ignoredNodes.has(e);
1383
1369
  }
1384
1370
  getOrCreateRecord(e) {
1385
- dt();
1371
+ !dt && typeof document < "u" && document.body && (dt = !0, mt(document.body));
1386
1372
  let t = this.records.get(e);
1387
- return t || (t = lt.acquire(), this.records.set(e, t), e.classList.add(G)), t;
1373
+ return t || (t = {}, this.records.set(e, t), e.classList.add(ft)), t;
1388
1374
  }
1389
- trackEffect(e, t) {
1375
+ addCleanup(e, t) {
1390
1376
  let n = this.getOrCreateRecord(e);
1391
- n.effects ||= st.acquire(), n.effects.push(t);
1377
+ n.cleanups ||= [], n.cleanups.push(t);
1378
+ }
1379
+ trackEffect(e, t) {
1380
+ let n = B(e);
1381
+ this.addCleanup(e, () => {
1382
+ try {
1383
+ t.dispose();
1384
+ } catch (e) {
1385
+ V.error(R.BINDING, z.CORE.EFFECT_DISPOSE_ERROR(n), e);
1386
+ }
1387
+ });
1392
1388
  }
1393
1389
  trackCleanup(e, t) {
1394
- let n = this.getOrCreateRecord(e);
1395
- n.cleanups ||= ct.acquire(), n.cleanups.push(t);
1390
+ let n = B(e);
1391
+ this.addCleanup(e, () => {
1392
+ try {
1393
+ t();
1394
+ } catch (e) {
1395
+ V.error(R.BINDING, z.BINDING.CLEANUP_ERROR(n), e);
1396
+ }
1397
+ });
1396
1398
  }
1397
1399
  setComponentCleanup(e, t) {
1398
1400
  this.getOrCreateRecord(e).componentCleanup = t;
@@ -1403,144 +1405,86 @@ var G = "_aes-bound", K = new class {
1403
1405
  cleanup(e) {
1404
1406
  if (this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.nodeType !== 1) return;
1405
1407
  let t = e, n = this.records.get(t);
1406
- if (!n) {
1407
- t.classList.remove(G);
1408
- return;
1409
- }
1410
- this.records.delete(t), t.classList.remove(G);
1411
- let r = Re(t);
1412
- if (W.cleanup(V.BINDING, r), n.componentCleanup) {
1413
- try {
1408
+ if (this.records.delete(t), t.classList.remove(ft), n) {
1409
+ if (n.componentCleanup) try {
1414
1410
  n.componentCleanup();
1415
1411
  } catch (e) {
1416
- W.error(V.MOUNT, H.MOUNT.CLEANUP_ERROR(r), e);
1417
- }
1418
- n.componentCleanup = void 0;
1419
- }
1420
- if (n.effects) {
1421
- for (let e of n.effects) try {
1422
- e.dispose();
1423
- } catch (e) {
1424
- W.error(V.BINDING, H.CORE.EFFECT_DISPOSE_ERROR(r), e);
1425
- }
1426
- st.release(n.effects), n.effects = void 0;
1427
- }
1428
- if (n.cleanups) {
1429
- for (let e of n.cleanups) try {
1430
- e();
1431
- } catch (e) {
1432
- W.error(V.BINDING, H.BINDING.CLEANUP_ERROR(r), e);
1412
+ let n = B(t);
1413
+ V.error(R.MOUNT, z.MOUNT.CLEANUP_ERROR(n), e);
1433
1414
  }
1434
- ct.release(n.cleanups), n.cleanups = void 0;
1415
+ if (n.cleanups) for (let e of n.cleanups) e();
1435
1416
  }
1436
- lt.release(n);
1437
1417
  }
1438
1418
  cleanupDescendants(e) {
1439
- let t = "getElementsByClassName" in e ? e.getElementsByClassName(G) : e.querySelectorAll(`.${G}`), n = t.length;
1440
- if (n === 0) return;
1441
- let r = Array(n);
1442
- for (let e = 0; e < n; e++) r[e] = t[e];
1443
- for (let e = n - 1; e >= 0; e--) {
1444
- let t = r[e];
1445
- this.records.has(t) ? this.cleanup(t) : t.classList.remove(G);
1419
+ let t = e.querySelectorAll(`.${ft}`);
1420
+ for (let e = 0, n = t.length; e < n; e++) {
1421
+ let n = t[e];
1422
+ n && this.cleanup(n);
1446
1423
  }
1447
1424
  }
1448
1425
  cleanupTree(e) {
1449
1426
  (e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
1450
1427
  }
1451
- }(), ft = /* @__PURE__ */ new Map();
1452
- function pt(e) {
1453
- if (ft.has(e)) return;
1428
+ }(), pt = /* @__PURE__ */ new Map();
1429
+ function mt(e) {
1430
+ if (pt.has(e)) return;
1454
1431
  let t = new MutationObserver((e) => {
1455
- let t = K;
1456
- for (let n = 0, r = e.length; n < r; n++) {
1457
- let r = e[n].removedNodes;
1458
- for (let e = 0, n = r.length; e < n; e++) {
1459
- let n = r[e];
1460
- if (n.nodeType !== 1 || n.isConnected) continue;
1461
- let i = n;
1462
- t.isKept(i) || t.isIgnored(i) || t.cleanupTree(i);
1432
+ for (let t = 0, n = e.length; t < n; t++) {
1433
+ let n = e[t].removedNodes;
1434
+ for (let e = 0, t = n.length; e < t; e++) {
1435
+ let t = n[e];
1436
+ if (t.nodeType !== 1 || t.isConnected) continue;
1437
+ let r = t;
1438
+ H.isKept(r) || H.isIgnored(r) || H.cleanupTree(r);
1463
1439
  }
1464
1440
  }
1465
1441
  });
1466
1442
  t.observe(e, {
1467
1443
  childList: !0,
1468
1444
  subtree: !0
1469
- }), ft.set(e, t);
1470
- }
1471
- function mt() {
1472
- ft.forEach((e) => e.disconnect()), ft.clear();
1473
- }
1474
- //#endregion
1475
- //#region src/core/dom.ts
1476
- function ht(e) {
1477
- return {
1478
- el: e,
1479
- trackCleanup: (t) => K.trackCleanup(e, t)
1480
- };
1481
- }
1482
- function q(e, t, n = {}) {
1483
- let r = !!n.needsCtx, i = e.length;
1484
- for (let n = 0; n < i; n++) {
1485
- let i = e[n];
1486
- if (i?.nodeType === 1) {
1487
- let e = i;
1488
- t(r ? ht(e) : null, e);
1489
- } else i && W.log(V.BINDING, `Skipping non-Element node (nodeType=${i.nodeType})`);
1490
- }
1491
- return e;
1445
+ }), pt.set(e, t);
1492
1446
  }
1493
- function gt(e) {
1494
- if (!Array.isArray(e) || e.length !== 2) return [e];
1495
- let t = e[1];
1496
- return typeof t == "function" || typeof t == "object" && t && !Array.isArray(t) && !("value" in t) && !("then" in t) ? e : [e];
1447
+ function ht() {
1448
+ pt.forEach((e) => e.disconnect()), pt.clear();
1497
1449
  }
1498
1450
  //#endregion
1499
1451
  //#region src/core/jquery-patch.ts
1500
- var J = Symbol.for("atom-effect-internal"), _t = Symbol.for("atom-effect-wrapped"), vt = /* @__PURE__ */ new WeakMap(), Y = null, yt = (e) => {
1501
- let t = e;
1502
- if (t[J]) return e;
1503
- let n = t[_t];
1504
- if (n) return n;
1505
- if (n = vt.get(e), !n) {
1506
- n = function(...t) {
1507
- return Se(() => e.apply(this, t));
1508
- }, n[J] = !0, vt.set(e, n);
1509
- try {
1510
- t[_t] = n;
1511
- } catch {}
1512
- }
1513
- return n;
1514
- }, bt = (e) => e[_t] ?? vt.get(e) ?? e;
1515
- function xt(e) {
1452
+ var U = Symbol.for("atom-effect-internal"), gt = /* @__PURE__ */ new WeakMap(), W = null, _t = (e) => {
1453
+ if (e[U]) return e;
1454
+ let t = gt.get(e);
1455
+ return t || (t = function(...t) {
1456
+ return Ce(() => e.apply(this, t));
1457
+ }, t[U] = !0, gt.set(e, t)), t;
1458
+ }, vt = (e) => gt.get(e) ?? e;
1459
+ function yt(e) {
1516
1460
  let t = {};
1517
1461
  for (let n in e) {
1518
1462
  let r = e[n];
1519
- typeof r == "function" ? t[n] = yt(r) : r !== void 0 && (t[n] = r);
1463
+ t[n] = typeof r == "function" ? _t(r) : r;
1520
1464
  }
1521
1465
  return t;
1522
1466
  }
1523
- function St(e) {
1467
+ function bt(e) {
1524
1468
  let t = {};
1525
1469
  for (let n in e) {
1526
1470
  let r = e[n];
1527
- typeof r == "function" ? t[n] = bt(r) : t[n] = r;
1471
+ t[n] = typeof r == "function" ? vt(r) : r;
1528
1472
  }
1529
1473
  return t;
1530
1474
  }
1531
- function Ct(e, t, n) {
1475
+ function xt(e, t, n) {
1532
1476
  let r = e[0];
1533
1477
  if (r && typeof r == "object") e[0] = t(r);
1534
1478
  else for (let t = 1; t < e.length; t++) typeof e[t] == "function" && (e[t] = n(e[t]));
1535
1479
  }
1536
- function wt(e) {
1480
+ function St(e) {
1537
1481
  return function(...t) {
1538
- return Ct(t, xt, yt), e.apply(this, t) ?? this;
1482
+ return xt(t, yt, _t), e.apply(this, t) ?? this;
1539
1483
  };
1540
1484
  }
1541
- function Tt() {
1542
- if (Y !== null) return;
1543
- Y = {
1485
+ function Ct() {
1486
+ if (W !== null) return;
1487
+ W = {
1544
1488
  on: e.fn.on,
1545
1489
  one: e.fn.one,
1546
1490
  off: e.fn.off,
@@ -1548,285 +1492,200 @@ function Tt() {
1548
1492
  empty: e.fn.empty,
1549
1493
  detach: e.fn.detach
1550
1494
  };
1551
- let t = Y;
1495
+ let t = W;
1552
1496
  e.fn.remove = function(e) {
1553
1497
  let n = e ? this.filter(e) : this, r = n.length;
1554
1498
  for (let e = 0; e < r; e++) {
1555
1499
  let t = n[e];
1556
- t && (K.markIgnored(t), K.cleanupTree(t));
1500
+ t && (H.markIgnored(t), H.cleanupTree(t));
1557
1501
  }
1558
1502
  return t.remove.call(this, e) ?? this;
1559
1503
  }, e.fn.empty = function() {
1560
1504
  let e = this.length;
1561
1505
  for (let t = 0; t < e; t++) {
1562
1506
  let e = this[t];
1563
- e?.hasChildNodes() && K.cleanupDescendants(e);
1507
+ e?.hasChildNodes() && H.cleanupDescendants(e);
1564
1508
  }
1565
1509
  return t.empty.call(this) ?? this;
1566
1510
  }, e.fn.detach = function(e) {
1567
1511
  let n = e ? this.filter(e) : this, r = n.length;
1568
1512
  for (let e = 0; e < r; e++) {
1569
1513
  let t = n[e];
1570
- t && K.keep(t);
1514
+ t && H.keep(t);
1571
1515
  }
1572
1516
  return t.detach.call(this, e) ?? this;
1573
- }, e.fn.on = wt(t.on), e.fn.one = wt(t.one), e.fn.off = function(...e) {
1574
- return Ct(e, St, bt), t.off.apply(this, e) ?? this;
1517
+ }, e.fn.on = St(t.on), e.fn.one = St(t.one), e.fn.off = function(...e) {
1518
+ return xt(e, bt, vt), t.off.apply(this, e) ?? this;
1575
1519
  };
1576
1520
  }
1577
- function Et() {
1578
- Y !== null && (e.fn.on = Y.on, e.fn.one = Y.one, e.fn.off = Y.off, e.fn.remove = Y.remove, e.fn.empty = Y.empty, e.fn.detach = Y.detach, Y = null);
1521
+ function wt() {
1522
+ W !== null && (e.fn.on = W.on, e.fn.one = W.one, e.fn.off = W.off, e.fn.remove = W.remove, e.fn.empty = W.empty, e.fn.detach = W.detach, W = null);
1579
1523
  }
1580
1524
  //#endregion
1581
1525
  //#region src/types.ts
1582
- var X = /* @__PURE__ */ function(e) {
1526
+ var G = /* @__PURE__ */ function(e) {
1583
1527
  return e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e;
1584
- }({}), Dt = 0;
1585
- function Ot(e) {
1586
- e[J] = !0;
1528
+ }({}), Tt = 0;
1529
+ function Et(e) {
1530
+ e[U] = !0;
1587
1531
  }
1588
- var kt = class {
1532
+ var Dt = class {
1589
1533
  constructor(e, t, n) {
1590
- this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
1591
- this.flags |= X.Composing;
1534
+ this.$element = e, this.atom = t, this.options = n, this.namespace = `.atomBind-${++Tt}`, this.flags = G.None, this.handleFocus = () => {
1535
+ this.flags |= G.Focused;
1536
+ }, this.handleCompositionStart = () => {
1537
+ this.flags |= G.Composing;
1592
1538
  }, this.handleCompositionEnd = () => {
1593
- this.flags &= ~X.Composing, this.handleInput();
1594
- }, this.handleFocus = () => {
1595
- this.flags |= X.Focused;
1539
+ this.flags &= ~G.Composing, this.syncToAtom();
1596
1540
  }, this.handleBlur = () => {
1597
- this.flags &= ~X.Focused;
1598
- let e = !!(this.flags & X.Composing);
1599
- this.flags &= ~X.Composing;
1600
- let t = this.flushPendingDebounce();
1601
- e && !t && this.syncAtomFromDom(), this.normalizeDomValue();
1602
- }, this.syncDomFromAtom = () => {
1541
+ let e = !!(this.flags & G.Composing);
1542
+ this.flags &= ~(G.Focused | G.Composing), this.debounceTimer ? (clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this.syncToAtom()) : e && this.syncToAtom();
1543
+ let t = this.atom.peek();
1544
+ this.isDomUpToDate(t) || this.writeToDom(t, this.formatValue(t));
1545
+ }, this.syncToDom = () => {
1603
1546
  let e = this.atom.value;
1604
- this.flags & X.Busy || O(() => {
1605
- if (this.isDomUpToDate(e)) return;
1606
- let t = this.format(e);
1607
- this.flags |= X.SyncingToDom;
1608
- try {
1609
- this.writeDom(e, t), W.domUpdated(V.BINDING, this.$el, "val", t);
1610
- } finally {
1611
- this.flags &= ~X.SyncingToDom;
1547
+ this.flags & G.Busy || O(() => {
1548
+ if (!this.isDomUpToDate(e)) {
1549
+ this.flags |= G.SyncingToDom;
1550
+ try {
1551
+ let t = this.formatValue(e);
1552
+ this.writeToDom(e, t), V.domUpdated(R.BINDING, this.$element, "val", t);
1553
+ } finally {
1554
+ this.flags &= ~G.SyncingToDom;
1555
+ }
1612
1556
  }
1613
1557
  });
1614
- }, this.cleanup = () => {
1615
- this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
1616
- }, this.$el = e, this.el = e[0], this.atom = t;
1617
- let r = this.el.tagName;
1618
- this.isMultipleSelect = r === "SELECT" && this.el.multiple, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++Dt}`;
1619
- let { parse: i, format: a, equal: o, readDom: s, getRawDom: c, writeDom: l } = this.initStrategies(n);
1620
- this.parse = i, this.format = a, this.equal = o, this.readDom = s, this.getRawDom = c, this.writeDom = l;
1621
- let u = n.debounce ?? 0;
1622
- u > 0 ? this.handleInput = () => {
1623
- this.flags & X.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), u));
1624
- } : this.handleInput = () => {
1625
- this.flags & X.Composing || this.syncAtomFromDom();
1626
- }, [
1558
+ };
1559
+ let r = e[0], i = r.tagName === "SELECT" && r.multiple, a = r.tagName === "INPUT" || r.tagName === "TEXTAREA", o = n.parse ?? ((e) => e), s = n.equal ?? Object.is;
1560
+ i ? (this.readValue = () => e.val() || [], this.writeToDom = (t) => {
1561
+ e.val(t);
1562
+ }, this.areEqual = (e, t) => s(e, t) ? !0 : Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((e, n) => Object.is(e, t[n])), this.formatValue = n.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(","))) : (this.readValue = () => o(r.value), this.writeToDom = (e, t) => {
1563
+ if (a && document.activeElement === r) {
1564
+ let e = r;
1565
+ try {
1566
+ let { selectionStart: n, selectionEnd: r } = e;
1567
+ if (e.value = t, n !== null && r !== null) {
1568
+ let i = t.length;
1569
+ e.setSelectionRange(Math.min(n, i), Math.min(r, i));
1570
+ }
1571
+ } catch {
1572
+ e.value = t;
1573
+ }
1574
+ } else r.value = t;
1575
+ }, this.areEqual = s, this.formatValue = n.format ?? ((e) => String(e ?? ""))), this.initializeEvents();
1576
+ }
1577
+ initializeEvents() {
1578
+ let e = this.namespace, t = this.options.debounce ?? 0, n = () => {
1579
+ this.flags & G.Composing || this.syncToAtom();
1580
+ }, r = t > 0 ? () => {
1581
+ clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(n, t);
1582
+ } : n;
1583
+ [
1627
1584
  this.handleFocus,
1628
1585
  this.handleBlur,
1629
1586
  this.handleCompositionStart,
1630
1587
  this.handleCompositionEnd,
1631
- this.handleInput
1632
- ].forEach(Ot), this.bindEvents(n.event ?? Ve.EVENT);
1633
- }
1634
- initStrategies(e) {
1635
- let t = e.parse ?? ((e) => e), n = e.equal ?? Object.is;
1636
- return this.isMultipleSelect ? {
1637
- parse: t,
1638
- format: e.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(",")),
1639
- getRawDom: () => this.$el.val() || [],
1640
- readDom: () => this.$el.val() || [],
1641
- writeDom: (e) => {
1642
- this.$el.val(e);
1643
- },
1644
- equal: (e, t) => {
1645
- if (n(e, t)) return !0;
1646
- if (Array.isArray(e) && Array.isArray(t)) {
1647
- let n = e.length;
1648
- if (n !== t.length) return !1;
1649
- for (let r = 0; r < n; r++) if (!Object.is(e[r], t[r])) return !1;
1650
- return !0;
1651
- }
1652
- return !1;
1653
- }
1654
- } : {
1655
- parse: t,
1656
- format: e.format ?? ((e) => String(e ?? "")),
1657
- equal: n,
1658
- readDom: () => t(this.el.value),
1659
- getRawDom: () => this.el.value,
1660
- writeDom: this.isTextControl ? (e, t) => this.writeTextValue(t) : (e, t) => {
1661
- this.el.value = t;
1662
- }
1663
- };
1664
- }
1665
- writeTextValue(e) {
1666
- let t = this.el;
1667
- if (this.flags & X.Focused) try {
1668
- let n = t.selectionStart, r = t.selectionEnd;
1669
- t.value = e;
1670
- let i = e.length;
1671
- n !== null && r !== null && t.setSelectionRange(Math.min(n, i), Math.min(r, i));
1672
- } catch {
1673
- t.value = e;
1674
- }
1675
- else t.value = e;
1676
- }
1677
- flushPendingDebounce() {
1678
- return this.timeoutId === void 0 ? !1 : (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom(), !0);
1679
- }
1680
- normalizeDomValue() {
1681
- let e = this.atom.peek(), t = this.format(e), n = this.getRawDom();
1682
- this.isMultipleSelect ? this.equal(n, e) || this.writeDom(e, t) : n !== t && this.writeDom(e, t);
1683
- }
1684
- syncAtomFromDom() {
1685
- if (!(this.flags & X.Busy)) {
1686
- this.flags |= X.SyncingToAtom;
1588
+ r
1589
+ ].forEach(Et);
1590
+ let i = (this.options.event ?? qe.EVENT).trim().split(/\s+/).map((t) => `${t}${e}`).join(" ");
1591
+ this.$element.on(`focus${e}`, this.handleFocus).on(`blur${e}`, this.handleBlur).on(`compositionstart${e}`, this.handleCompositionStart).on(`compositionend${e}`, this.handleCompositionEnd).on(i, r);
1592
+ }
1593
+ syncToAtom() {
1594
+ if (!(this.flags & G.Busy)) {
1595
+ this.flags |= G.SyncingToAtom;
1687
1596
  try {
1688
- let e = this.readDom();
1689
- this.equal(this.atom.peek(), e) || (this.atom.value = e);
1690
- } catch (e) {
1691
- W.warn(V.BINDING, H.BINDING.PARSE_ERROR(e instanceof Error ? e.message : String(e)), e);
1597
+ let e = this.readValue();
1598
+ this.areEqual(this.atom.peek(), e) || (this.atom.value = e);
1692
1599
  } finally {
1693
- this.flags &= ~X.SyncingToAtom;
1600
+ this.flags &= ~G.SyncingToAtom;
1694
1601
  }
1695
1602
  }
1696
1603
  }
1697
1604
  isDomUpToDate(e) {
1698
- let t = this.getRawDom();
1699
- if (this.isMultipleSelect) return this.equal(t, e);
1700
- if (t === this.format(e)) return !0;
1701
- if (this.flags & X.Focused) try {
1702
- return this.equal(this.readDom(), e);
1703
- } catch {}
1704
- return !1;
1605
+ if (!this.areEqual(this.readValue(), e)) return !1;
1606
+ if (this.flags & G.Focused) return !0;
1607
+ let t = this.$element[0];
1608
+ return this.formatValue(e) === t.value;
1705
1609
  }
1706
- bindEvents(e) {
1707
- let t = this.ns, n = e.trim().split(/\s+/).map((e) => `${e}${t}`).join(" ");
1708
- this.$el.on(`focus${t}`, this.handleFocus).on(`blur${t}`, this.handleBlur).on(`compositionstart${t}`, this.handleCompositionStart).on(`compositionend${t}`, this.handleCompositionEnd).on(n, this.handleInput);
1610
+ cleanup() {
1611
+ this.$element.off(this.namespace), clearTimeout(this.debounceTimer);
1709
1612
  }
1710
1613
  };
1711
- function At(e, t, n) {
1712
- let r = new kt(e, t, n);
1614
+ function Ot(e, t, n) {
1615
+ let r = new Dt(e, t, n);
1713
1616
  return {
1714
- fx: R(r.syncDomFromAtom),
1715
- cleanup: () => {
1716
- r &&= (r.cleanup(), null);
1717
- }
1617
+ reactiveEffect: L(r.syncToDom),
1618
+ cleanup: () => r.cleanup()
1718
1619
  };
1719
1620
  }
1720
1621
  //#endregion
1721
1622
  //#region src/core/effect-factory.ts
1722
- function jt(e, t, n, r) {
1723
- let i = {
1724
- latestId: 0,
1725
- isDisposed: !1
1726
- };
1727
- K.trackCleanup(e, () => {
1728
- i.isDisposed = !0;
1729
- });
1730
- let a = (t) => {
1731
- if (!Le(t)) {
1732
- i.latestId++, O(() => {
1623
+ function kt(e, t, n) {
1624
+ let r = 0, i = !1;
1625
+ return H.trackCleanup(e, () => {
1626
+ i = !0;
1627
+ }), (a) => {
1628
+ let o = ++r;
1629
+ if (!Qe(a)) {
1630
+ O(() => {
1733
1631
  try {
1734
- n(t), W.domUpdated(V.BINDING, e, r, t);
1632
+ n(a), V.domUpdated(R.BINDING, e, t, a);
1735
1633
  } catch (e) {
1736
- W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r, !0), e);
1634
+ V.error(R.BINDING, z.BINDING.UPDATER_ERROR(t, !0), e);
1737
1635
  }
1738
1636
  });
1739
1637
  return;
1740
1638
  }
1741
- let a = ++i.latestId;
1742
- t.then((t) => {
1743
- a === i.latestId && !i.isDisposed && O(() => {
1639
+ a.then((a) => {
1640
+ o === r && !i && O(() => {
1744
1641
  try {
1745
- n(t), W.domUpdated(V.BINDING, e, `${r} (async)`, t);
1642
+ n(a), V.domUpdated(R.BINDING, e, `${t} (async)`, a);
1746
1643
  } catch (e) {
1747
- W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
1644
+ V.error(R.BINDING, z.BINDING.UPDATER_ERROR(t), e);
1748
1645
  }
1749
1646
  });
1750
1647
  }).catch((e) => {
1751
- a === i.latestId && !i.isDisposed && W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
1648
+ o === r && !i && V.error(R.BINDING, z.BINDING.UPDATER_ERROR(t), e);
1752
1649
  });
1753
- }, o = Ie(t);
1754
- o || typeof t == "function" ? K.trackEffect(e, R(() => {
1755
- a(o ? t.value : t());
1756
- }, { name: r })) : a(t);
1757
- }
1758
- function Mt(e, t, n, r) {
1759
- let i = Object.keys(t), a = [], o = [], s = [], c = {};
1760
- for (let e = 0, n = i.length; e < n; e++) {
1761
- let n = i[e], r = t[n], l = Ie(r);
1762
- l || typeof r == "function" ? (a.push(n), o.push(r), s.push(l)) : c[n] = r;
1763
- }
1764
- let l = {
1765
- latestId: 0,
1766
- isDisposed: !1,
1767
- cache: {}
1768
1650
  };
1769
- K.trackCleanup(e, () => {
1770
- l.isDisposed = !0;
1771
- });
1772
- let u = (t) => {
1773
- let a = [], o = {}, s = i.length;
1774
- for (let e = 0; e < s; e++) {
1775
- let n = i[e], r = t[n];
1776
- if (Le(r) && B.call(l.cache, n)) {
1777
- let e = l.cache[n];
1778
- if (e.p === r) {
1779
- o[n] = e.v;
1780
- continue;
1781
- }
1782
- }
1783
- Le(r) ? a.push(r.then((e) => (l.cache[n] = {
1784
- p: r,
1785
- v: e
1786
- }, {
1787
- key: n,
1651
+ }
1652
+ function At(e, t, n, r) {
1653
+ let i = kt(e, r, n), a = se(t);
1654
+ a || typeof t == "function" ? H.trackEffect(e, L(() => {
1655
+ i(a ? t.value : t());
1656
+ }, { name: r })) : i(t);
1657
+ }
1658
+ function jt(e, t, n, r) {
1659
+ let i = kt(e, r, n), a = Object.entries(t), o = !1;
1660
+ for (let e = 0, t = a.length; e < t; e++) {
1661
+ let t = a[e][1];
1662
+ if (se(t) || typeof t == "function") {
1663
+ o = !0;
1664
+ break;
1665
+ }
1666
+ }
1667
+ let s = () => {
1668
+ let e = [], t = {};
1669
+ for (let n = 0, r = a.length; n < r; n++) {
1670
+ let [r, i] = a[n], o = se(i) ? i.value : typeof i == "function" ? i() : i;
1671
+ Qe(o) ? e.push(o.then((e) => ({
1672
+ key: r,
1788
1673
  val: e
1789
- }))) : o[n] = r;
1790
- }
1791
- if (a.length > 0) {
1792
- let t = ++l.latestId;
1793
- Promise.all(a).then((i) => {
1794
- if (t === l.latestId && !l.isDisposed) {
1795
- for (let e = 0, t = i.length; e < t; e++) {
1796
- let t = i[e];
1797
- o[t.key] = t.val;
1798
- }
1799
- O(() => {
1800
- try {
1801
- n(o), W.domUpdated(V.BINDING, e, `${r} (async)`, o);
1802
- } catch (e) {
1803
- W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
1804
- }
1805
- });
1806
- }
1807
- }, (e) => {
1808
- t === l.latestId && !l.isDisposed && W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
1809
- });
1810
- } else l.latestId++, O(() => {
1811
- try {
1812
- n(o), W.domUpdated(V.BINDING, e, r, o);
1813
- } catch (e) {
1814
- W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r, !0), e);
1674
+ }))) : t[r] = o;
1675
+ }
1676
+ return e.length > 0 ? Promise.all(e).then((e) => {
1677
+ for (let n = 0, r = e.length; n < r; n++) {
1678
+ let r = e[n];
1679
+ t[r.key] = r.val;
1815
1680
  }
1816
- });
1681
+ return t;
1682
+ }) : t;
1817
1683
  };
1818
- a.length > 0 ? K.trackEffect(e, R(() => {
1819
- let e = { ...c };
1820
- for (let t = 0, n = a.length; t < n; t++) {
1821
- let n = o[t];
1822
- e[a[t]] = s[t] ? n.value : n();
1823
- }
1824
- u(e);
1825
- }, { name: r })) : u(c);
1684
+ o ? H.trackEffect(e, L(() => i(s()), { name: r })) : i(s());
1826
1685
  }
1827
1686
  //#endregion
1828
1687
  //#region src/utils/sanitize.ts
1829
- var Nt = new Set([
1688
+ var Mt = [
1830
1689
  "href",
1831
1690
  "src",
1832
1691
  "action",
@@ -1848,223 +1707,261 @@ var Nt = new Set([
1848
1707
  "marker-mid",
1849
1708
  "marker-end",
1850
1709
  "clip-path",
1851
- "srcdoc"
1852
- ]), Pt = {
1710
+ "srcdoc",
1711
+ "srcset"
1712
+ ], Nt = [
1713
+ "script",
1714
+ "iframe",
1715
+ "object",
1716
+ "embed",
1717
+ "base",
1718
+ "meta",
1719
+ "applet",
1720
+ "noscript",
1721
+ "form",
1722
+ "style",
1723
+ "link",
1724
+ "title"
1725
+ ], Pt = [
1726
+ /expression\s*\(/i,
1727
+ /behavior\s*:/i,
1728
+ /-moz-binding\s*:/i,
1729
+ /@import/i,
1730
+ RegExp(`url\\s*\\(\\s*["']?\\s*${Ze}\\s*:`, "i"),
1731
+ /data\s*:\s*(?!image\/)/i
1732
+ ], Ft = {
1853
1733
  colon: ":",
1854
1734
  tab: " ",
1855
1735
  newline: "\n"
1856
- }, Ft = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, It = /&(colon|tab|newline);?/gi, Lt = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, Rt = /[<&\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/, zt = /<\?[\s\S]*?\?>/g, Bt = /(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi, Vt = /\bon\w+\s*=/gim, Ht = `${Ge}\\s*:`, Ut = new RegExp(Ht, "gi"), Wt = RegExp(`(?:^|url\\s*\\(\\s*["']?)\\s*${Ht}`, "i"), Gt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Kt = `(?:expression\\s*\\(|behavior\\s*:|-moz-binding\\s*:|url\\s*\\(\\s*["']?\\s*${Ht}(?!image\\/)|data\\s*:\\s*(?!image\\/))`, qt = new RegExp(Kt, "gim"), Jt = new RegExp(Kt, "im");
1857
- function Yt(e) {
1858
- return typeof e == "string" ? e.replace(Ft, (e, t, n) => {
1736
+ }, It = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, Lt = /&(colon|tab|newline);?/gi, Rt = /[\x00-\x1f\x7f]/g, zt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/i, Bt = RegExp(`(?:^|url\\s*\\(\\s*["']?)\\s*${Ze}\\s*:`, "i"), Vt = new RegExp([
1737
+ `(<(${Nt.join("|")})\\b[^>]*>([\\s\\S]*?)<\\/\\2>|<(${Nt.join("|")})\\b[^>]*\\/?>)`,
1738
+ "\\bon\\w+\\s*=",
1739
+ `${Ze}\\s*:`,
1740
+ zt.source
1741
+ ].join("|"), "i"), K = {
1742
+ getAttributes: (e) => Object.getOwnPropertyDescriptor(Element.prototype, "attributes").get.call(e),
1743
+ setAttribute: (e, t, n) => Element.prototype.setAttribute.call(e, t, n),
1744
+ removeAttribute: (e, t) => Element.prototype.removeAttribute.call(e, t),
1745
+ replaceElement: (e, t) => Element.prototype.replaceWith.call(e, t),
1746
+ getLocalName: (e) => Object.getOwnPropertyDescriptor(Element.prototype, "localName").get.call(e),
1747
+ getFirstChild: (e) => Object.getOwnPropertyDescriptor(Node.prototype, "firstChild").get.call(e)
1748
+ };
1749
+ function q(e) {
1750
+ return typeof e == "string" ? e.replace(It, (e, t, n) => {
1859
1751
  let r = t ? parseInt(t, 16) : parseInt(n, 10);
1860
1752
  return r >= 0 && r <= 1114111 ? String.fromCodePoint(r) : "";
1861
- }).replace(It, (e, t) => Pt[t.toLowerCase()] ?? "").replace(Lt, "") : "";
1753
+ }).replace(Lt, (e, t) => Ft[t.toLowerCase()] ?? "").replace(Rt, "") : "";
1862
1754
  }
1863
- function Xt(e) {
1864
- return Wt.test(e) || Gt.test(e);
1755
+ function Ht(e) {
1756
+ let t = e.replace(/\s+/g, "");
1757
+ return Bt.test(t) || zt.test(t);
1865
1758
  }
1866
- function Zt(e) {
1867
- return Bt.test(e) || Vt.test(e) || Ut.test(e);
1759
+ function Ut(e) {
1760
+ return e.split(",").map((e) => {
1761
+ let t = e.trim();
1762
+ if (!t) return e;
1763
+ let [n, ...r] = t.split(/\s+/), i = q(n);
1764
+ return Ht(i) ? ["data-unsafe-protocol:", ...r].join(" ") : [i, ...r].join(" ");
1765
+ }).join(",");
1766
+ }
1767
+ function Wt(e) {
1768
+ return q(e).replace(/\/\*[\s\S]*?\*\//g, "");
1769
+ }
1770
+ function Gt(e) {
1771
+ let t = Wt(e);
1772
+ return Pt.some((e) => e.test(t));
1773
+ }
1774
+ var Kt = {
1775
+ srcdoc: (e, t, n) => {
1776
+ let r = q(n);
1777
+ K.setAttribute(e, t, J(r));
1778
+ },
1779
+ srcset: (e, t, n) => {
1780
+ K.setAttribute(e, t, Ut(n));
1781
+ },
1782
+ style: (e, t, n) => {
1783
+ Gt(n) && K.setAttribute(e, "style", "data-unsafe-css:");
1784
+ }
1785
+ };
1786
+ function qt(e) {
1787
+ let t = K.getAttributes(e);
1788
+ if (!t) return;
1789
+ let n = [];
1790
+ for (let r = t.length - 1; r >= 0; r--) {
1791
+ let i = t[r], a = i.name, o = a.toLowerCase(), s = i.value;
1792
+ if (o.startsWith("on")) {
1793
+ K.removeAttribute(e, a), n.push(a);
1794
+ continue;
1795
+ }
1796
+ Kt[o] ? Kt[o](e, a, s) : Mt.includes(o) && Ht(q(s)) && K.setAttribute(e, a, "data-unsafe-protocol:");
1797
+ }
1798
+ n.length > 0 && K.setAttribute(e, "data-unsafe-attr", n.join(","));
1868
1799
  }
1869
- function Qt(e) {
1870
- if (Rt.test(e) || e.includes(":")) return !0;
1871
- let t = e.toLowerCase(), n = t.indexOf("on");
1872
- for (; n !== -1 && n < e.length - 2;) {
1873
- let e = t.charCodeAt(n + 2);
1874
- if (e >= 97 && e <= 122) return !0;
1875
- n = t.indexOf("on", n + 1);
1800
+ function Jt(e) {
1801
+ if (!Nt.includes(K.getLocalName(e))) return;
1802
+ let t = document.createElement("span"), n = K.getAttributes(e);
1803
+ for (let e = 0; e < n.length; e++) {
1804
+ let r = n[e];
1805
+ r && t.setAttribute(r.name, r.value);
1876
1806
  }
1877
- return !1;
1807
+ qt(t);
1808
+ let r = K.getFirstChild(e);
1809
+ for (; r;) t.appendChild(r), r = K.getFirstChild(e);
1810
+ K.replaceElement(e, t);
1878
1811
  }
1879
- function Z(e) {
1812
+ function Yt(e) {
1813
+ let t = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT), n = [], r = t.nextNode();
1814
+ for (; r;) n.push(r), K.getLocalName(r) === "template" && Yt(r.content), r = t.nextNode();
1815
+ for (let e of n) qt(e), Jt(e);
1816
+ }
1817
+ function J(e) {
1880
1818
  if (!e) return "";
1881
- let t = String(e);
1882
- if (!Qt(t)) return t;
1883
- let n = Yt(t);
1884
- if (n.includes("<")) {
1885
- n = n.replace(zt, "");
1886
- let e;
1887
- do
1888
- e = n, n = n.replace(Bt, "");
1889
- while (n !== e);
1890
- }
1891
- return n.replace(qt, "data-unsafe-css:").replace(Ut, "data-unsafe-protocol:").replace(Gt, "data-unsafe-protocol:").replace(Vt, "data-unsafe-attr=");
1892
- }
1893
- var $t = (e, t) => {
1819
+ let t = document.createElement("template");
1820
+ return t.innerHTML = String(e), Yt(t.content), t.innerHTML;
1821
+ }
1822
+ var Xt = (e, t) => {
1894
1823
  let n = e.toLowerCase();
1895
- if (!Nt.has(n)) return !1;
1896
- let r = Yt(t);
1897
- return n === "srcdoc" ? Zt(r) : Xt(r);
1898
- }, en = (e) => Jt.test(Yt(e)), tn = /* @__PURE__ */ new Map();
1899
- function nn(e) {
1900
- let t = tn.get(e);
1901
- return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, tn.set(e, t), t) : t;
1902
- }
1903
- var rn = /* @__PURE__ */ new WeakMap();
1904
- function an(e) {
1905
- let t = rn.get(e);
1906
- return t || (t = L(() => {
1907
- let t = e.value;
1908
- return Le(t) ? t.then((e) => Z(e)) : Z(t);
1909
- }), rn.set(e, t)), t;
1824
+ if (!Mt.includes(n)) return !1;
1825
+ let r = q(t);
1826
+ return n === "srcdoc" ? Vt.test(r) : Ht(r);
1827
+ }, Zt = (e) => {
1828
+ let t = q(e).replace(/\/\*[\s\S]*?\*\//g, "");
1829
+ return Pt.some((e) => e.test(t));
1830
+ };
1831
+ //#endregion
1832
+ //#region src/bindings/unified.ts
1833
+ function Qt(e) {
1834
+ return e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e;
1910
1835
  }
1911
- function on(e, t) {
1912
- return e.toLowerCase().startsWith("on") ? (console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_EVENT_HANDLER(e)}`), !1) : t && We.has(e) ? (console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROP(e)}`), !1) : !0;
1836
+ function $t(e, t) {
1837
+ return e.toLowerCase().startsWith("on") ? (console.warn(`${R.BINDING} ${z.SECURITY.BLOCKED_EVENT_HANDLER(e)}`), !1) : t && Xe.includes(e) ? (console.warn(`${R.BINDING} ${z.SECURITY.BLOCKED_PROP(e)}`), !1) : !0;
1913
1838
  }
1914
- function sn({ el: e }, t, n) {
1915
- jt(e, t, (t) => {
1839
+ function en(e, t, n) {
1840
+ At(e, t, (t) => {
1916
1841
  let r = n ? n(t) : String(t ?? "");
1917
1842
  e.textContent !== r && (e.textContent = r);
1918
1843
  }, "text");
1919
1844
  }
1920
- function cn({ el: e }, t) {
1921
- let n = oe(t) ? an(t) : t, r = null;
1922
- jt(e, n, (i) => {
1923
- let a = n === t ? Z(i) : i;
1924
- r !== a && (K.cleanupDescendants(e), e.innerHTML = a, r = a);
1845
+ function tn(e, t) {
1846
+ let n = null;
1847
+ At(e, t, (t) => {
1848
+ let r = J(t);
1849
+ n !== r && (H.cleanupDescendants(e), e.innerHTML = r, n = r);
1925
1850
  }, "html");
1926
1851
  }
1927
- function ln({ el: e }, t) {
1928
- let n = {}, r = {};
1929
- for (let e in t) if (B.call(t, e)) {
1852
+ function nn(e, t) {
1853
+ let n = {}, r = /* @__PURE__ */ new Set();
1854
+ for (let e of Object.keys(t)) {
1930
1855
  let t = e.trim();
1931
- n[e] = /\s/.test(t) ? t.split(/\s+/).filter(Boolean) : [t];
1932
- }
1933
- Mt(e, t, (t) => {
1934
- for (let i in t) {
1935
- let a = !!t[i];
1936
- if (r[i] === a) continue;
1937
- let o = n[i];
1938
- if (a) e.classList.add(...o);
1939
- else for (let r of o) {
1940
- let a = !1;
1941
- for (let e in t) if (e !== i && t[e] && n[e].includes(r)) {
1942
- a = !0;
1943
- break;
1944
- }
1945
- a || e.classList.remove(r);
1946
- }
1947
- r[i] = a;
1948
- }
1856
+ n[e] = t.includes(" ") ? t.split(/\s+/).filter(Boolean) : [t];
1857
+ }
1858
+ jt(e, t, (t) => {
1859
+ let i = /* @__PURE__ */ new Set();
1860
+ for (let [e, r] of Object.entries(t)) if (r) for (let t of n[e]) i.add(t);
1861
+ for (let t of i) r.has(t) || e.classList.add(t);
1862
+ for (let t of r) i.has(t) || e.classList.remove(t);
1863
+ r = i;
1949
1864
  }, "class");
1950
1865
  }
1951
- function un({ el: e }, t) {
1866
+ function rn(e, t) {
1952
1867
  let n = e.style, r = {}, i = {}, a = {};
1953
- for (let e in t) if (B.call(t, e)) {
1954
- let n = t[e], [a, o] = Array.isArray(n) ? n : [n, ""];
1955
- r[e] = a, i[e] = {
1956
- camel: nn(e),
1957
- unit: o
1868
+ for (let [e, n] of Object.entries(t)) {
1869
+ let [t, a] = Array.isArray(n) ? n : [n, ""];
1870
+ r[e] = t, i[e] = {
1871
+ camelCase: Qt(e),
1872
+ unit: a
1958
1873
  };
1959
1874
  }
1960
- Mt(e, r, (e) => {
1961
- for (let t in e) {
1962
- let r = i[t], o = e[t], s = r.unit ? `${o}${r.unit}` : String(o), c = r.camel;
1963
- a[t] !== s && (en(s) || (n[c] = s), a[t] = s);
1875
+ jt(e, r, (e) => {
1876
+ for (let [t, r] of Object.entries(e)) {
1877
+ let e = i[t], o = e.unit ? `${r}${e.unit}` : String(r);
1878
+ a[t] !== o && (Zt(o) || (n[e.camelCase] = o), a[t] = o);
1964
1879
  }
1965
1880
  }, "css");
1966
1881
  }
1967
- function dn({ el: e }, t) {
1968
- let n = {}, r = {}, i = {};
1969
- for (let a in t) {
1970
- if (!B.call(t, a) || !on(a, !1)) continue;
1971
- let o = a.toLowerCase();
1972
- n[a] = t[a], r[a] = { isAria: o.startsWith("aria-") }, i[a] = e.getAttribute(a);
1973
- }
1974
- Mt(e, n, (t) => {
1975
- for (let n in t) {
1976
- let a = r[n], o = t[n];
1977
- if (o == null || o === !1 && !a.isAria) {
1978
- i[n] !== null && e.removeAttribute(n), i[n] = null;
1882
+ function an(e, t) {
1883
+ let n = Object.entries(t).filter(([e]) => $t(e, !1)), r = Object.fromEntries(n), i = {}, a = {};
1884
+ for (let [t] of n) i[t] = { isAria: t.toLowerCase().startsWith("aria-") }, a[t] = e.getAttribute(t);
1885
+ jt(e, r, (t) => {
1886
+ for (let [n, r] of Object.entries(t)) {
1887
+ let t = i[n], o = r;
1888
+ if (o == null || o === !1 && !t.isAria) {
1889
+ a[n] !== null && e.removeAttribute(n), a[n] = null;
1979
1890
  continue;
1980
1891
  }
1981
- let s = o === !0 ? a.isAria ? "true" : n : String(o);
1982
- if ($t(n, s)) {
1983
- console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(n)}`);
1892
+ let s = o === !0 ? t.isAria ? "true" : n : String(o);
1893
+ if (Xt(n, s)) {
1894
+ console.warn(`${R.BINDING} ${z.SECURITY.BLOCKED_PROTOCOL(n)}`);
1984
1895
  continue;
1985
1896
  }
1986
- i[n] !== s && (e.setAttribute(n, s), i[n] = s);
1897
+ a[n] !== s && (e.setAttribute(n, s), a[n] = s);
1987
1898
  }
1988
1899
  }, "attr");
1989
1900
  }
1990
- function fn(e, t) {
1991
- let n = e.el, r = {}, i = {};
1992
- for (let e in t) B.call(t, e) && on(e, !0) && (r[e] = t[e]);
1993
- Mt(e.el, r, (e) => {
1994
- for (let t in e) {
1995
- let r = e[t];
1996
- if (i[t] !== r) {
1997
- if (typeof r == "string" && $t(t, r)) {
1998
- console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);
1999
- continue;
2000
- }
2001
- n[t] = r, i[t] = r;
1901
+ function on(e, t) {
1902
+ let n = e, r = Object.entries(t).filter(([e]) => $t(e, !0)), i = Object.fromEntries(r), a = {};
1903
+ jt(e, i, (e) => {
1904
+ for (let [t, r] of Object.entries(e)) if (a[t] !== r) {
1905
+ if (typeof r == "string" && Xt(t, r)) {
1906
+ console.warn(`${R.BINDING} ${z.SECURITY.BLOCKED_PROTOCOL(t)}`);
1907
+ continue;
2002
1908
  }
1909
+ n[t] = r, a[t] = r;
2003
1910
  }
2004
1911
  }, "prop");
2005
1912
  }
2006
- function pn({ el: e }, t, n) {
1913
+ function sn(e, t, n) {
2007
1914
  let r = e.style.display === "none" ? "" : e.style.display;
2008
- jt(e, t, (t) => {
1915
+ At(e, t, (t) => {
2009
1916
  n === !!t ? e.style.display !== "none" && (r = e.style.display, e.style.display = "none") : e.style.display === "none" && (e.style.display = r);
2010
1917
  }, n ? "hide" : "show");
2011
1918
  }
2012
- function mn(t, n, r = {}) {
2013
- let i = t.el.tagName.toLowerCase();
2014
- if (!Ue.has(i)) {
2015
- console.warn(`${V.BINDING} ${H.BINDING.INVALID_INPUT_ELEMENT(i)}`);
1919
+ function cn(t, n, r = {}) {
1920
+ let i = t.tagName.toLowerCase();
1921
+ if (!Ye.includes(i)) {
1922
+ console.warn(`${R.BINDING} ${z.BINDING.INVALID_INPUT_ELEMENT(i)}`);
2016
1923
  return;
2017
1924
  }
2018
- let { fx: a, cleanup: o } = At(e(t.el), n, r);
2019
- K.trackEffect(t.el, a), t.trackCleanup(o);
1925
+ let { reactiveEffect: a, cleanup: o } = Ot(e(t), n, r);
1926
+ H.trackEffect(t, a), H.trackCleanup(t, o);
2020
1927
  }
2021
- function hn(t) {
1928
+ function ln(t) {
2022
1929
  t.type === "radio" && t.name && (t.form ? e(t.form) : e(document)).find(`input[type="radio"][name="${e.escapeSelector(t.name)}"]`).not(t).trigger("change.atomRadioSync");
2023
1930
  }
2024
- function gn(t, n) {
2025
- let r = t.el, i = e(r), a = () => {
2026
- n.peek() !== r.checked && (n.value = r.checked, hn(r));
1931
+ function un(t, n) {
1932
+ if (!(t instanceof HTMLInputElement)) {
1933
+ console.warn(`${R.BINDING} atomChecked called on non-input element`);
1934
+ return;
1935
+ }
1936
+ let r = t, i = e(r), a = () => {
1937
+ n.peek() !== r.checked && (n.value = r.checked, ln(r));
2027
1938
  };
2028
- a[J] = !0, i.on("change change.atomRadioSync", a), t.trackCleanup(() => i.off("change change.atomRadioSync", a)), K.trackEffect(r, R(() => {
1939
+ a[U] = !0, i.on("change change.atomRadioSync", a), H.trackCleanup(r, () => i.off("change change.atomRadioSync", a)), H.trackEffect(r, L(() => {
2029
1940
  let e = !!n.value;
2030
1941
  O(() => {
2031
- r.checked !== e && (r.checked = e, W.domUpdated(V.BINDING, r, "checked", e), e && hn(r));
1942
+ r.checked !== e && (r.checked = e, V.domUpdated(R.BINDING, r, "checked", e), e && ln(r));
2032
1943
  });
2033
1944
  }));
2034
1945
  }
2035
- function _n(t, n) {
2036
- let r = e(t.el);
2037
- r.on(n), t.trackCleanup(() => r.off(n));
2038
- }
2039
- function vn({ el: t, trackCleanup: n }, r, i) {
2040
- let a = e(t);
2041
- a.on(r, i), n(() => a.off(r, i));
1946
+ function dn(t, n) {
1947
+ let r = e(t);
1948
+ r.on(n), H.trackCleanup(t, () => r.off(n));
2042
1949
  }
2043
- function yn(e) {
2044
- K.cleanupTree(e);
1950
+ function fn(t, n, r) {
1951
+ let i = e(t);
1952
+ i.on(n, r), H.trackCleanup(t, () => i.off(n, r));
2045
1953
  }
2046
1954
  //#endregion
2047
1955
  //#region src/bindings/form.ts
2048
- var bn = "input, select, textarea", xn = class {
1956
+ var pn = "input, select, textarea", mn = class {
2049
1957
  constructor(e, t, n = {}) {
2050
- this.form = e, this.atom = t, this.options = n, this.fieldMap = /* @__PURE__ */ new Map(), this.fields = [], this.elementNames = /* @__PURE__ */ new WeakMap(), this.isSyncingFromLeaf = !1, this.init();
1958
+ this.form = e, this.atom = t, this.options = n, this.fieldMap = /* @__PURE__ */ new Map(), this.fields = [], this.elementNames = /* @__PURE__ */ new WeakMap(), this.init();
2051
1959
  }
2052
1960
  init() {
2053
- let e = R(() => {
2054
- let e = this.atom.value;
2055
- this.isSyncingFromLeaf || !this.fields.length || Se(() => {
2056
- O(() => {
2057
- for (let t = 0; t < this.fields.length; t++) {
2058
- let n = this.fields[t], r = z(e, n.parts);
2059
- Object.is(n.atom.peek(), r) || (n.atom.value = r);
2060
- }
2061
- });
2062
- });
2063
- });
2064
- K.trackEffect(this.form, e), this.bindElement(this.form), this.setupObserver();
1961
+ this.bindElement(this.form), this.setupObserver();
2065
1962
  }
2066
1963
  bindElement(e) {
2067
- let t = e.matches?.(bn) ? [e] : e.querySelectorAll?.(bn) || [];
1964
+ let t = e.matches?.(pn) ? [e] : e.querySelectorAll?.(pn) || [];
2068
1965
  for (let e = 0, n = t.length; e < n; e++) this.bindControl(t[e]);
2069
1966
  }
2070
1967
  bindControl(e) {
@@ -2072,56 +1969,50 @@ var bn = "input, select, textarea", xn = class {
2072
1969
  let t = e, n = t.name;
2073
1970
  if (!n) return;
2074
1971
  let r = this.elementNames.get(t);
2075
- if (r !== void 0 && r !== n && K.cleanup(t), this.elementNames.has(t) && r === n) return;
1972
+ if (r !== void 0 && r !== n && H.cleanup(t), this.elementNames.has(t) && r === n) return;
2076
1973
  let i = this.acquireField(n);
2077
- this.elementNames.set(t, n);
2078
- let a = ht(t);
2079
- a.trackCleanup(() => this.releaseField(t, n)), t instanceof HTMLInputElement && (t.type === "radio" || t.type === "checkbox") ? this.bindToggle(a, i.atom, t.value, t.type === "checkbox") : mn(a, i.atom, this.options);
1974
+ this.elementNames.set(t, n), H.trackCleanup(t, () => this.releaseField(t, n)), t instanceof HTMLInputElement && (t.type === "radio" || t.type === "checkbox") ? this.bindToggle(t, i.atom, t.value, t.type === "checkbox") : cn(t, i.atom, this.options);
2080
1975
  }
2081
1976
  bindToggle(t, n, r, i) {
2082
- let a = t.el, o = () => {
1977
+ let a = () => {
2083
1978
  let e = n.peek();
2084
1979
  if (i && Array.isArray(e)) {
2085
- let t = new Set(e.map(String));
2086
- a.checked ? t.add(r) : t.delete(r), n.value = Array.from(t);
2087
- } else n.value = i ? a.checked : r;
1980
+ let i = new Set(e.map(String));
1981
+ t.checked ? i.add(r) : i.delete(r), n.value = Array.from(i);
1982
+ } else n.value = i ? t.checked : r;
2088
1983
  };
2089
- o[J] = !0, e(a).on("change", o), t.trackCleanup(() => e(a).off("change", o)), K.trackEffect(a, R(() => {
2090
- let e = n.value, t = i ? Array.isArray(e) ? e.some((e) => String(e) === r) : !!e : String(e) === r;
2091
- a.checked !== t && (a.checked = t);
1984
+ a[U] = !0, e(t).on("change", a), H.trackCleanup(t, () => e(t).off("change", a)), H.trackEffect(t, L(() => {
1985
+ let e = n.value, a = i ? Array.isArray(e) ? e.some((e) => String(e) === r) : !!e : String(e) === r;
1986
+ t.checked !== a && (t.checked = a);
2092
1987
  }));
2093
1988
  }
2094
1989
  acquireField(e) {
2095
1990
  let t = this.fieldMap.get(e);
2096
1991
  if (t) return t.refCount++, t;
2097
- let n = e.replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean), r = we(z(this.atom.peek(), n));
2098
- return t = {
2099
- atom: r,
2100
- parts: n,
2101
- name: e,
2102
- refCount: 1,
2103
- effect: null
2104
- }, t.effect = R(() => {
2105
- let t = r.value;
2106
- this.options.transform && (t = this.options.transform(e, t));
2107
- let i = this.atom.peek(), a = je(i, n, 0, t);
2108
- if (a !== i) {
2109
- this.isSyncingFromLeaf = !0;
2110
- try {
2111
- this.atom.value = a, this.options.onChange && O(() => this.options.onChange(e, t));
2112
- } finally {
2113
- this.isSyncingFromLeaf = !1;
2114
- }
1992
+ let n = e.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, ""), r = Ie(this.atom, n), i = Object.create(r), { transform: a, onChange: o } = this.options;
1993
+ return Object.defineProperty(i, "value", {
1994
+ get() {
1995
+ return r.value;
1996
+ },
1997
+ set(t) {
1998
+ let n = a ? a(e, t) : t;
1999
+ r.value = n, o && O(() => o(e, n));
2115
2000
  }
2116
- }), this.fieldMap.set(e, t), this.fields.push(t), t;
2001
+ }), t = {
2002
+ atom: i,
2003
+ name: e,
2004
+ refCount: 1
2005
+ }, this.fieldMap.set(e, t), this.fields.push(t), t;
2117
2006
  }
2118
2007
  releaseField(e, t) {
2119
2008
  let n = this.fieldMap.get(t);
2120
2009
  if (n && --n.refCount <= 0) {
2121
2010
  let e = this.fields.indexOf(n);
2122
- e !== -1 && this.fields.splice(e, 1), n.effect?.dispose(), this.fieldMap.delete(t);
2011
+ e !== -1 && this.fields.splice(e, 1);
2012
+ let r = n.atom;
2013
+ typeof r.dispose == "function" && r.dispose(), this.fieldMap.delete(t);
2123
2014
  }
2124
- K.cleanup(e);
2015
+ H.cleanup(e);
2125
2016
  }
2126
2017
  setupObserver() {
2127
2018
  let e = new MutationObserver((e) => {
@@ -2139,77 +2030,135 @@ var bn = "input, select, textarea", xn = class {
2139
2030
  subtree: !0,
2140
2031
  attributes: !0,
2141
2032
  attributeFilter: ["name"]
2142
- }), K.trackCleanup(this.form, () => e.disconnect());
2033
+ }), H.trackCleanup(this.form, () => e.disconnect());
2143
2034
  }
2144
2035
  };
2145
- function Sn(e, t, n = {}) {
2146
- new xn(e, t, n);
2036
+ function hn(e, t, n = {}) {
2037
+ new mn(e, t, n);
2038
+ }
2039
+ //#endregion
2040
+ //#region src/core/dom.ts
2041
+ function Y(e, t) {
2042
+ for (let n = 0, r = e.length; n < r; n++) {
2043
+ let r = e[n];
2044
+ r?.nodeType === 1 && t(r);
2045
+ }
2046
+ return e;
2047
+ }
2048
+ function gn(e) {
2049
+ if (!Array.isArray(e) || e.length !== 2) return [e];
2050
+ let t = e[1];
2051
+ return typeof t == "function" || typeof t == "object" && t && !("value" in t) && !("then" in t) ? e : [e];
2052
+ }
2053
+ //#endregion
2054
+ //#region src/bindings/chainable.ts
2055
+ function _n(e, t, n, r = z.BINDING.MISSING_SOURCE(n)) {
2056
+ return (typeof e == "string" ? t === void 0 ? null : { [e]: t } : e) || (console.warn(`${R.BINDING} ${r}`), null);
2147
2057
  }
2148
2058
  e.fn.atomText = function(e, t) {
2149
- return q(this, (n) => sn(n, e, t), { needsCtx: !0 });
2059
+ return Y(this, (n) => en(n, e, t));
2150
2060
  }, e.fn.atomHtml = function(e) {
2151
- return q(this, (t) => cn(t, e), { needsCtx: !0 });
2061
+ return Y(this, (t) => tn(t, e));
2152
2062
  }, e.fn.atomClass = function(e, t) {
2153
- let n = typeof e == "string" ? t === void 0 ? null : { [e]: t } : e;
2154
- return n ? q(this, (e) => ln(e, n), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_CONDITION("atomClass")}`), this);
2063
+ let n = _n(e, t, "atomClass", z.BINDING.MISSING_CONDITION("atomClass"));
2064
+ return n ? Y(this, (e) => nn(e, n)) : this;
2155
2065
  }, e.fn.atomCss = function(e, t, n) {
2156
- let r = typeof e == "string" ? t === void 0 ? null : { [e]: n ? [t, n] : t } : e;
2157
- return r ? q(this, (e) => un(e, r), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_SOURCE("atomCss")}`), this);
2066
+ let r = _n(e, t !== void 0 && n ? [t, n] : t, "atomCss");
2067
+ return r ? Y(this, (e) => rn(e, r)) : this;
2158
2068
  }, e.fn.atomAttr = function(e, t) {
2159
- let n = typeof e == "string" ? t === void 0 ? null : { [e]: t } : e;
2160
- return n ? q(this, (e) => dn(e, n), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_SOURCE("atomAttr")}`), this);
2069
+ let n = _n(e, t, "atomAttr");
2070
+ return n ? Y(this, (e) => an(e, n)) : this;
2161
2071
  }, e.fn.atomProp = function(e, t) {
2162
- let n = typeof e == "string" ? t === void 0 ? null : { [e]: t } : e;
2163
- return n ? q(this, (e) => fn(e, n), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_SOURCE("atomProp")}`), this);
2072
+ let n = _n(e, t, "atomProp");
2073
+ return n ? Y(this, (e) => on(e, n)) : this;
2164
2074
  }, e.fn.atomShow = function(e) {
2165
- return q(this, (t) => pn(t, e, !1), { needsCtx: !0 });
2075
+ return Y(this, (t) => sn(t, e, !1));
2166
2076
  }, e.fn.atomHide = function(e) {
2167
- return q(this, (t) => pn(t, e, !0), { needsCtx: !0 });
2077
+ return Y(this, (t) => sn(t, e, !0));
2168
2078
  }, e.fn.atomVal = function(e, t = {}) {
2169
- return q(this, (n) => mn(n, e, t), { needsCtx: !0 });
2079
+ return Y(this, (n) => cn(n, e, t));
2170
2080
  }, e.fn.atomChecked = function(e) {
2171
- return q(this, (t) => gn(t, e), { needsCtx: !0 });
2081
+ return Y(this, (t) => un(t, e));
2172
2082
  }, e.fn.atomForm = function(e, t = {}) {
2173
- return q(this, (n, r) => {
2174
- r instanceof HTMLFormElement ? Sn(r, e, t) : W.log(V.BINDING, "Skipping non-Form element for atomForm");
2175
- }, { needsCtx: !1 });
2083
+ return Y(this, (n) => {
2084
+ n instanceof HTMLFormElement ? hn(n, e, t) : V.warn(R.BINDING, "Skipping non-Form element for atomForm");
2085
+ });
2176
2086
  }, e.fn.atomOn = function(e, t) {
2177
- return q(this, (n) => vn(n, e, t), { needsCtx: !0 });
2087
+ return Y(this, (n) => fn(n, e, t));
2178
2088
  };
2179
- var Cn = [
2180
- (e, t) => sn(e, ...gt(t.text)),
2181
- (e, t) => cn(e, t.html),
2182
- (e, t) => ln(e, t.class),
2183
- (e, t) => un(e, t.css),
2184
- (e, t) => dn(e, t.attr),
2185
- (e, t) => fn(e, t.prop),
2186
- (e, t) => pn(e, t.show, !1),
2187
- (e, t) => pn(e, t.hide, !0),
2188
- (e, t) => mn(e, ...gt(t.val)),
2189
- (e, t) => gn(e, t.checked),
2190
- (e, t) => {
2191
- e.el instanceof HTMLFormElement && Sn(e.el, ...gt(t.form));
2089
+ var vn = [
2090
+ {
2091
+ key: "text",
2092
+ run: (e, t) => en(e, ...gn(t))
2093
+ },
2094
+ {
2095
+ key: "html",
2096
+ run: (e, t) => tn(e, t)
2097
+ },
2098
+ {
2099
+ key: "class",
2100
+ run: (e, t) => nn(e, t)
2101
+ },
2102
+ {
2103
+ key: "css",
2104
+ run: (e, t) => rn(e, t)
2105
+ },
2106
+ {
2107
+ key: "attr",
2108
+ run: (e, t) => an(e, t)
2109
+ },
2110
+ {
2111
+ key: "prop",
2112
+ run: (e, t) => on(e, t)
2113
+ },
2114
+ {
2115
+ key: "show",
2116
+ run: (e, t) => sn(e, t, !1)
2117
+ },
2118
+ {
2119
+ key: "hide",
2120
+ run: (e, t) => sn(e, t, !0)
2121
+ },
2122
+ {
2123
+ key: "val",
2124
+ run: (e, t) => cn(e, ...gn(t))
2125
+ },
2126
+ {
2127
+ key: "checked",
2128
+ run: (e, t) => un(e, t)
2129
+ },
2130
+ {
2131
+ key: "form",
2132
+ run: (e, t) => {
2133
+ e instanceof HTMLFormElement && hn(e, ...gn(t));
2134
+ }
2192
2135
  },
2193
- (e, t) => _n(e, t.on)
2136
+ {
2137
+ key: "on",
2138
+ run: (e, t) => dn(e, t)
2139
+ }
2194
2140
  ];
2195
2141
  e.fn.atomBind = function(e) {
2196
- let t = 0;
2197
- return e.text !== void 0 && (t |= 1), e.html !== void 0 && (t |= 2), e.class !== void 0 && (t |= 4), e.css !== void 0 && (t |= 8), e.attr !== void 0 && (t |= 16), e.prop !== void 0 && (t |= 32), e.show !== void 0 && (t |= 64), e.hide !== void 0 && (t |= 128), e.val !== void 0 && (t |= 256), e.checked !== void 0 && (t |= 512), e.form !== void 0 && (t |= 1024), e.on !== void 0 && (t |= 2048), t === 0 ? this : q(this, (n) => {
2198
- let r = t;
2199
- for (; r > 0;) {
2200
- let t = r & -r;
2201
- Cn[31 - Math.clz32(t)](n, e), r ^= t;
2202
- }
2203
- }, { needsCtx: !0 });
2142
+ let t = e, n = !1;
2143
+ for (let e = 0, r = vn.length; e < r; e++) if (t[vn[e].key] !== void 0) {
2144
+ n = !0;
2145
+ break;
2146
+ }
2147
+ return n ? Y(this, (e) => {
2148
+ for (let n = 0, r = vn.length; n < r; n++) {
2149
+ let r = vn[n], i = t[r.key];
2150
+ i !== void 0 && r.run(e, i);
2151
+ }
2152
+ }) : this;
2204
2153
  }, e.fn.atomUnbind = function() {
2205
- return q(this, (e, t) => yn(t), { needsCtx: !1 });
2154
+ return Y(this, (e) => H.cleanupTree(e));
2206
2155
  };
2207
2156
  //#endregion
2208
2157
  //#region src/bindings/list/utils.ts
2209
- function Q(t) {
2158
+ function yn(t) {
2210
2159
  return t instanceof Element ? e(t) : t;
2211
2160
  }
2212
- function wn(e, t) {
2161
+ function bn(e, t) {
2213
2162
  if (e instanceof Element) t === null ? e.removeAttribute("data-atom-key") : e.setAttribute("data-atom-key", t);
2214
2163
  else if (!e.nodeType) {
2215
2164
  let n = e;
@@ -2219,93 +2168,91 @@ function wn(e, t) {
2219
2168
  }
2220
2169
  }
2221
2170
  }
2222
- function Tn(e) {
2223
- if (e instanceof Element) K.cleanupTree(e);
2171
+ function xn(e) {
2172
+ if (e instanceof Element) H.cleanupTree(e);
2224
2173
  else for (let t = 0, n = e.length; t < n; t++) {
2225
2174
  let n = e[t];
2226
- n instanceof Element && K.cleanupTree(n);
2175
+ n instanceof Element && H.cleanupTree(n);
2227
2176
  }
2228
2177
  }
2229
2178
  //#endregion
2230
2179
  //#region src/bindings/list/context.ts
2231
- var En = class {
2180
+ var Sn = class {
2232
2181
  constructor(e, t, n) {
2233
- this.$container = e, this.containerSelector = t, this.onRemove = n, this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.removingKeys = /* @__PURE__ */ new Set(), this.$emptyEl = null, this.keyToIndex = /* @__PURE__ */ new Map(), this.statesBuffer = new Uint8Array(256), this.indicesBuffer = new Int32Array(256);
2182
+ this.$container = e, this.containerSelector = t, this.onRemove = n, this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.removingKeys = /* @__PURE__ */ new Set(), this.$emptyEl = null, this.keyToIndex = /* @__PURE__ */ new Map();
2234
2183
  }
2235
2184
  scheduleRemoval(e, t) {
2236
2185
  let n = () => {
2237
- this.fx?.isDisposed || t[0] instanceof Element && t[0].hasAttribute("data-atom-key") || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e), W.log(V.LIST, `${this.containerSelector} removed item:`, e));
2186
+ this.fx?.isDisposed || t[0] instanceof Element && t[0].hasAttribute("data-atom-key") || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e));
2238
2187
  }, r = this.onRemove?.(t);
2239
2188
  r instanceof Promise ? r.then(n, n) : n();
2240
2189
  }
2241
2190
  removeItem(e, t) {
2242
- wn(t, null), this.removingKeys.add(e), this.scheduleRemoval(e, t);
2191
+ bn(t, null), this.removingKeys.add(e), this.scheduleRemoval(e, t);
2243
2192
  }
2244
2193
  dispose() {
2245
- this.removingKeys.clear(), this.oldKeys.length = 0, this.oldItems.length = 0, this.oldNodes.length = 0, this.keyToIndex.clear(), this.$emptyEl?.remove(), this.$container.off(".atomList"), this.statesBuffer = new Uint8Array(), this.indicesBuffer = new Int32Array();
2246
- }
2247
- ensureBuffers(e) {
2248
- this.statesBuffer.length < e && (this.statesBuffer = new Uint8Array(Math.max(e, this.statesBuffer.length * 2))), this.indicesBuffer.length < e && (this.indicesBuffer = new Int32Array(Math.max(e, this.indicesBuffer.length * 2)));
2194
+ this.removingKeys.clear(), this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.keyToIndex.clear(), this.$emptyEl?.remove(), this.$container.off(".atomList");
2249
2195
  }
2196
+ }, X = {
2197
+ Unchanged: 0,
2198
+ Existing: 1,
2199
+ New: 2,
2200
+ ForceReplace: 4
2250
2201
  };
2251
2202
  //#endregion
2252
2203
  //#region src/bindings/list/diff.ts
2253
- function Dn(e, t, n, r, i, a, o) {
2254
- let { oldKeys: s, oldItems: c, oldNodes: l, removingKeys: u, keyToIndex: d } = e, f = s.length, p = 0, m = f - 1, h = n - 1, g = a || ze;
2204
+ function Cn(e, t, n, r, i, a) {
2205
+ let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = a || et, p = 0, m = d - 1, h = n - 1, g = /* @__PURE__ */ new Set(), _ = Array(n), v = Array(n), y = Array(n), b = Array(n), x = Array(n), S = [];
2255
2206
  for (; p <= m && p <= h;) {
2256
2207
  let e = t[p], n = r(e, p);
2257
- if (s[p] !== n || !g(c[p], e) || !l[p]) break;
2258
- d.set(n, p++);
2208
+ if (o[p] !== n || !f(s[p], e) || !c[p]) break;
2209
+ u.set(n, p++);
2259
2210
  }
2260
2211
  for (; m >= p && h >= p;) {
2261
2212
  let e = t[h], n = r(e, h);
2262
- if (s[m] !== n || !g(c[m], e) || !l[m]) break;
2263
- d.set(n, h--), m--;
2264
- }
2265
- let _ = o.map.acquire();
2266
- for (let e = p; e <= m; e++) _.set(s[e], e);
2267
- let v = o.set.acquire();
2268
- e.ensureBuffers(n);
2269
- let y = o.array.acquire();
2270
- y.length = n;
2271
- let b = o.array.acquire();
2272
- b.length = n;
2273
- let x = o.array.acquire();
2274
- x.length = n;
2275
- let S = e.statesBuffer, C = e.indicesBuffer, ee = o.array.acquire(), w = o.array.acquire(), te = o.array.acquire();
2276
- for (let e = 0; e < p; e++) {
2277
- let n = s[e];
2278
- y[e] = n, b[e] = t[e], x[e] = l[e], S[e] = 3, C[e] = e, v.add(n);
2213
+ if (o[m] !== n || !f(s[m], e) || !c[m]) break;
2214
+ u.set(n, h--), m--;
2279
2215
  }
2280
- for (let e = f - 1, r = n - 1; r > h; r--, e--) {
2281
- let n = s[e];
2282
- y[r] = n, b[r] = t[r], x[r] = l[e], S[r] = 3, C[r] = e, v.add(n);
2216
+ for (let e = 0; e < p; e++) {
2217
+ let n = o[e];
2218
+ _[e] = n, v[e] = t[e], y[e] = c[e], b[e] = X.Unchanged, x[e] = e, g.add(n);
2283
2219
  }
2284
- for (let n = p; n <= h; n++) {
2285
- let o = t[n], s = r(o, n);
2286
- if (y[n] = s, b[n] = o, d.set(s, n), v.has(s)) {
2287
- W.warn(V.LIST, H.LIST.DUPLICATE_KEY(s, n, e.containerSelector)), C[n] = -1;
2220
+ for (let e = d - 1, r = n - 1; r > h; r--, e--) {
2221
+ let n = o[e];
2222
+ _[r] = n, v[r] = t[r], y[r] = c[e], b[r] = X.Unchanged, x[r] = e, g.add(n);
2223
+ }
2224
+ let C = /* @__PURE__ */ new Map();
2225
+ for (let e = p; e <= m; e++) C.set(o[e], e);
2226
+ for (let e = p; e <= h; e++) {
2227
+ let n = t[e], a = r(n, e);
2228
+ if (_[e] = a, v[e] = n, u.set(a, e), g.has(a)) {
2229
+ V.warn(R.LIST, z.LIST.DUPLICATE_KEY(a, e)), x[e] = -1;
2288
2230
  continue;
2289
2231
  }
2290
- v.add(s);
2291
- let f = _.get(s);
2292
- if (f === void 0) {
2293
- ee.push(s), w.push(o), te.push(n), C[n] = -1, S[n] = 1;
2232
+ g.add(a);
2233
+ let o = C.get(a), d = o !== void 0 && !l.has(a) ? o : void 0;
2234
+ if (d === void 0) {
2235
+ S.push({
2236
+ key: a,
2237
+ item: n,
2238
+ index: e
2239
+ }), x[e] = -1, b[e] = X.New;
2294
2240
  continue;
2295
2241
  }
2296
- let p = c[f];
2297
- x[n] = l[f], !i && p !== o && !(a ? a(p, o) : ze(p, o)) ? (ee.push(s), w.push(o), te.push(n), S[n] = 2) : S[n] = 0, C[n] = u.has(s) ? -1 : f;
2298
- }
2299
- return o.map.release(_), {
2300
- newKeys: y,
2301
- newKeySet: v,
2302
- newItems: b,
2303
- newNodes: x,
2304
- newStates: S,
2305
- newIndices: C,
2306
- trKeys: ee,
2307
- trItems: w,
2308
- trIdxs: te,
2242
+ y[e] = c[d], !i && !f(s[d], n) ? (S.push({
2243
+ key: a,
2244
+ item: n,
2245
+ index: e
2246
+ }), b[e] = X.ForceReplace) : b[e] = X.Existing, x[e] = d;
2247
+ }
2248
+ return {
2249
+ newKeys: _,
2250
+ newKeySet: g,
2251
+ newItems: v,
2252
+ newNodes: y,
2253
+ newStates: b,
2254
+ newIndices: x,
2255
+ toRender: S,
2309
2256
  startIndex: p,
2310
2257
  oldEndIndex: m,
2311
2258
  newEndIndex: h
@@ -2313,106 +2260,104 @@ function Dn(e, t, n, r, i, a, o) {
2313
2260
  }
2314
2261
  //#endregion
2315
2262
  //#region src/bindings/list/dom.ts
2316
- var On = 0;
2317
- function kn(e, t, n) {
2263
+ function wn(e, t, n) {
2318
2264
  if (!e) return;
2319
2265
  if (e instanceof Element) {
2320
2266
  n.insertBefore(e, t);
2321
2267
  return;
2322
2268
  }
2323
- let r = e.length;
2324
- for (let i = 0; i < r; i++) {
2325
- let r = e[i];
2326
- r && n.insertBefore(r, t);
2269
+ let r = e;
2270
+ for (let e = 0, i = r.length; e < i; e++) {
2271
+ let i = r[e];
2272
+ i && n.insertBefore(i, t);
2327
2273
  }
2328
2274
  }
2329
- function An(t, n, r, i, a) {
2275
+ function Tn(t, n, r, i) {
2330
2276
  if (t.$emptyEl && n > 0 && (t.$emptyEl.remove(), t.$emptyEl = null), n !== 0) return;
2331
- let { oldKeys: o, oldNodes: s, onRemove: c } = t;
2332
- if (c) for (let e = 0, n = o.length; e < n; e++) {
2333
- let n = o[e];
2334
- s[e] && t.removeItem(n, Q(s[e]));
2335
- }
2336
- else {
2337
- for (let e = 0, n = o.length; e < n; e++) t.removingKeys.delete(o[e]);
2338
- r.empty();
2339
- }
2340
- i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? Z(i) : i), t.$emptyEl.appendTo(r)), a.release(t.oldKeys), a.release(t.oldItems), a.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
2341
- }
2342
- function jn(t, n, r) {
2343
- let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u = Array(l), d = [], f = 0;
2344
- for (let e = 0; e < l; e++) {
2345
- let t = n.render(a[e], o[e]);
2346
- u[e] = t, typeof t == "string" && (d.push(t), f++);
2347
- }
2348
- let p = null;
2349
- if (d.length > 0) if (d.length === 1) p = [Z(d[0])];
2350
- else {
2351
- let e = `<template data-atom-sep="${(On++).toString(36)}"></template>`;
2352
- p = Z(d.join(e)).split(e);
2353
- }
2354
- if (r && p && f === l && !n.bind && !n.onAdd && !n.onRemove && !n.events && e.parseHTML(p.join("")).length === l) return p;
2355
- let m = 0;
2356
- for (let t = 0; t < l; t++) {
2357
- let n = u[t], r = e(typeof n == "string" ? e.parseHTML(p[m++]) : n), a = o[t];
2358
- if (wn(r, String(i[t])), c[a] === 2 && s[a]) {
2359
- let e = s[a];
2360
- Tn(e);
2361
- let t = Q(e);
2362
- t.first().before(r), t.remove();
2363
- }
2364
- s[a] = r.length === 1 ? r[0] : r;
2277
+ let { oldKeys: a, oldNodes: o, onRemove: s } = t;
2278
+ if (!s) r.empty();
2279
+ else for (let e = 0, n = a.length; e < n; e++) {
2280
+ let n = a[e], r = o[e];
2281
+ r && t.removeItem(n, yn(r));
2282
+ }
2283
+ i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? e.parseHTML(J(i)) : i), t.$emptyEl.appendTo(r)), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
2284
+ }
2285
+ function En(t, n, r) {
2286
+ let { toRender: i, newNodes: a, newStates: o } = t, s = i.length;
2287
+ if (s === 0) return null;
2288
+ let c = Array(s), l = [], u = !0;
2289
+ for (let e = 0; e < s; e++) {
2290
+ let t = n.render(i[e].item, i[e].index);
2291
+ c[e] = t, typeof t == "string" ? l.push(t) : u = !1;
2292
+ }
2293
+ let d = null;
2294
+ if (l.length > 0 && (d = Dn(l)), r && u && d && !n.bind && !n.onAdd && !n.events && e.parseHTML(d.join("")).length === s) return d;
2295
+ let f = 0;
2296
+ for (let t = 0; t < s; t++) {
2297
+ let { key: n, index: r } = i[t], s = c[t], l = e(typeof s == "string" ? e.parseHTML(d[f++]) : s);
2298
+ if (bn(l, String(n)), o[r] === X.ForceReplace && a[r]) {
2299
+ let e = a[r];
2300
+ xn(e);
2301
+ let t = yn(e);
2302
+ t.first().before(l), t.remove();
2303
+ }
2304
+ a[r] = l.length === 1 ? l[0] : l;
2365
2305
  }
2366
2306
  return null;
2367
2307
  }
2368
- function Mn(e, t) {
2308
+ function Dn(e) {
2309
+ if (e.length === 1) return [J(e[0])];
2310
+ let t = `<template data-atom-sep="s${Math.random().toString(36).slice(2)}"></template>`;
2311
+ return J(e.join(t)).split(t);
2312
+ }
2313
+ function On(e, t) {
2369
2314
  let { startIndex: n, oldEndIndex: r, newKeySet: i } = t;
2370
2315
  for (let t = n; t <= r; t++) {
2371
2316
  let n = e.oldKeys[t];
2372
- !i.has(n) && e.oldNodes[t] && e.removeItem(n, Q(e.oldNodes[t]));
2317
+ !i.has(n) && e.oldNodes[t] && e.removeItem(n, yn(e.oldNodes[t]));
2373
2318
  }
2374
2319
  }
2375
- function Nn(t, n, r, i, a) {
2320
+ function kn(t, n, r, i, a) {
2376
2321
  let { newKeys: o, newItems: s, newNodes: c, newStates: l, newIndices: u } = n, d = o.length;
2377
- if (a !== null) {
2322
+ if (a) {
2378
2323
  r.innerHTML = a.join("");
2379
- let n = r.firstElementChild;
2380
- for (let r = 0; r < d && n; r++) n.setAttribute("data-atom-key", String(o[r])), c[r] = n, l[r] = 0, t.removingKeys.delete(o[r]), W.domUpdated(V.LIST, e(n), "list.add", s[r]), n = n.nextElementSibling;
2324
+ let t = r.firstElementChild;
2325
+ for (let n = 0; n < d && t; n++) t.setAttribute("data-atom-key", String(o[n])), c[n] = t, l[n] = X.Existing, V.domUpdated(R.LIST, e(t), "list.add", s[n]), t = t.nextElementSibling;
2381
2326
  return;
2382
2327
  }
2383
2328
  if (t.oldKeys.length === 0 && t.removingKeys.size === 0) {
2384
2329
  let e = document.createDocumentFragment();
2385
- for (let t = 0; t < d; t++) {
2386
- let n = c[t];
2387
- if (n) if (n instanceof Element) e.appendChild(n);
2388
- else for (let t = 0; t < n.length; t++) e.appendChild(n[t]);
2330
+ for (let t of c) if (t) if (t instanceof Element) e.appendChild(t);
2331
+ else {
2332
+ let n = t;
2333
+ for (let t = 0; t < n.length; t++) {
2334
+ let r = n[t];
2335
+ r && e.appendChild(r);
2336
+ }
2389
2337
  }
2390
2338
  r.innerHTML = "", r.appendChild(e);
2391
2339
  } else {
2392
- let e = null, t = 2147483647;
2340
+ let e = null, t = Infinity;
2393
2341
  for (let n = d - 1; n >= 0; n--) {
2394
2342
  let i = u[n], a = c[n];
2395
- a && (i !== -1 && i < t ? t = i : kn(a, e, r), e = a instanceof Element ? a : a[0] ?? null);
2343
+ if (!a) continue;
2344
+ let o = a instanceof Element ? a : a[0];
2345
+ o && (i !== -1 && i < t ? t = i : wn(a, e, r), e = o);
2396
2346
  }
2397
2347
  }
2398
2348
  for (let e = 0; e < d; e++) {
2399
2349
  let n = l[e];
2400
- if (n !== 3) {
2401
- let r = c[e];
2402
- if (!r) continue;
2403
- let a = Q(r), l = s[e];
2404
- n === 0 ? i.update?.(a, l, e) : i.bind?.(a, l, e), n === 1 && (i.onAdd?.(a), t.removingKeys.delete(o[e]), W.domUpdated(V.LIST, a, "list.add", l));
2405
- }
2350
+ if (n === X.Unchanged) continue;
2351
+ let r = c[e];
2352
+ if (!r) continue;
2353
+ let a = yn(r), u = s[e];
2354
+ n === X.Existing ? i.update?.(a, u, e) : (i.bind?.(a, u, e), n === X.New && (i.onAdd?.(a), t.removingKeys.delete(o[e]), V.domUpdated(R.LIST, a, "list.add", u)));
2406
2355
  }
2407
2356
  }
2408
2357
  //#endregion
2409
2358
  //#region src/bindings/list/index.ts
2410
- var Pn = /* @__PURE__ */ new WeakMap(), Fn = new at(() => /* @__PURE__ */ new Map(), (e) => e.clear()), In = new at(() => /* @__PURE__ */ new Set(), (e) => e.clear()), $ = new it(100, 1024), Ln = {
2411
- map: Fn,
2412
- set: In,
2413
- array: $
2414
- };
2415
- function Rn(t, n) {
2359
+ var An = /* @__PURE__ */ new WeakMap();
2360
+ function jn(t, n) {
2416
2361
  let r = typeof n.key == "function" ? n.key : (e) => e[n.key], i = {
2417
2362
  bind: n.bind,
2418
2363
  update: n.update,
@@ -2421,327 +2366,625 @@ function Rn(t, n) {
2421
2366
  events: n.events
2422
2367
  };
2423
2368
  for (let a = 0, o = this.length; a < o; a++) {
2424
- let o = this[a], s = e(o);
2425
- s.off(".atomList");
2426
- let c = Pn.get(o);
2369
+ let o = this[a], s = e(o), c = An.get(o);
2427
2370
  c && (c.fx.dispose(), c.ctx.dispose());
2428
- let l = new En(s, Re(o), n.onRemove), u = R(() => {
2371
+ let l = new Sn(s, B(o), n.onRemove), u = L(() => {
2429
2372
  let e = t.value, a = e.length;
2430
2373
  O(() => {
2431
- if (An(l, a, s, n.empty, $), a === 0) return;
2432
- W.log(V.LIST, `${l.containerSelector} updating with ${a} items`);
2433
- let t = Dn(l, e, a, r, n.update, n.isEqual, Ln), c = jn(t, n, l.oldKeys.length === 0);
2434
- if (Mn(l, t), Nn(l, t, o, i, c), n.events) for (let e = t.startIndex; e <= t.oldEndIndex; e++) t.newKeySet.has(l.oldKeys[e]) || l.keyToIndex.delete(l.oldKeys[e]);
2435
- $.release(l.oldKeys), $.release(l.oldItems), $.release(l.oldNodes), l.oldKeys = t.newKeys, l.oldItems = t.newItems, l.oldNodes = t.newNodes, In.release(t.newKeySet), $.release(t.trKeys), $.release(t.trItems), $.release(t.trIdxs);
2374
+ if (Tn(l, a, s, n.empty), a === 0) return;
2375
+ let t = l.oldKeys.length === 0 && l.removingKeys.size === 0;
2376
+ l.keyToIndex.clear();
2377
+ let c = Cn(l, e, a, r, n.update, n.isEqual), u = En(c, n, t);
2378
+ On(l, c), kn(l, c, o, i, u), l.oldKeys = c.newKeys, l.oldItems = c.newItems, l.oldNodes = c.newNodes;
2436
2379
  });
2437
2380
  });
2438
- if (l.fx = u, n.events) for (let e in n.events) {
2439
- if (!B.call(n.events, e)) continue;
2440
- let t = e.indexOf(" "), r = t === -1 ? e : e.slice(0, t), i = t === -1 ? "> *" : e.slice(t + 1).trim(), a = n.events[e];
2441
- s.on(`${r}.atomList`, i, function(e) {
2442
- let t = e.target.closest?.("[data-atom-key]"), n = t?.getAttribute("data-atom-key");
2443
- if (n == null) return;
2444
- let r = n;
2445
- if (!l.keyToIndex.has(n)) {
2446
- let e = Number(n);
2447
- !Number.isNaN(e) && l.keyToIndex.has(e) && (r = e);
2448
- }
2449
- let i = l.keyToIndex.get(r);
2450
- i !== void 0 && a.call(t, l.oldItems[i], i, e);
2451
- });
2452
- }
2453
- K.trackEffect(o, u), Pn.set(o, {
2381
+ l.fx = u, n.events && Mn(l, s, n.events), H.trackEffect(o, u), An.set(o, {
2454
2382
  fx: u,
2455
2383
  ctx: l
2456
- }), K.trackCleanup(o, () => {
2457
- l.dispose(), Pn.delete(o);
2384
+ }), H.trackCleanup(o, () => {
2385
+ l.dispose(), An.delete(o);
2458
2386
  });
2459
2387
  }
2460
2388
  return this;
2461
2389
  }
2462
- e.fn.atomList = Rn;
2390
+ function Mn(e, t, n) {
2391
+ for (let r in n) {
2392
+ if (!$e.call(n, r)) continue;
2393
+ let i = r.indexOf(" "), a = i === -1 ? r : r.slice(0, i), o = i === -1 ? "> *" : r.slice(i + 1).trim(), s = n[r];
2394
+ t.on(`${a}.atomList`, o, function(t) {
2395
+ let n = t.target.closest?.("[data-atom-key]"), r = n?.getAttribute("data-atom-key");
2396
+ if (r == null) return;
2397
+ let i = r;
2398
+ if (!e.keyToIndex.has(r)) {
2399
+ let t = Number(r);
2400
+ !Number.isNaN(t) && e.keyToIndex.has(t) && (i = t);
2401
+ }
2402
+ let a = e.keyToIndex.get(i);
2403
+ a !== void 0 && s.call(n, e.oldItems[a], a, t);
2404
+ });
2405
+ }
2406
+ }
2407
+ e.fn.atomList = jn;
2463
2408
  //#endregion
2464
2409
  //#region src/bindings/mount.ts
2465
- var zn = Object.freeze({});
2410
+ var Nn = Object.freeze({});
2466
2411
  e.fn.atomMount = function(t, n) {
2467
- let r = n ?? zn, i = t.name || "Component";
2468
- return q(this, (n, a) => {
2469
- K.cleanupTree(a);
2470
- try {
2471
- let n = O(() => Se(() => t(e(a), r)));
2472
- typeof n == "function" && K.setComponentCleanup(a, n);
2473
- } catch (e) {
2474
- W.error(V.MOUNT, H.MOUNT.ERROR(i), e);
2412
+ let r = n ?? Nn;
2413
+ return Y(this, (n) => {
2414
+ H.cleanupTree(n);
2415
+ let i = O(() => Ce(() => t(e(n), r)));
2416
+ if (i) {
2417
+ let e = typeof i == "function" ? i : i.unmount;
2418
+ H.setComponentCleanup(n, e);
2475
2419
  }
2476
2420
  });
2477
2421
  }, e.fn.atomUnmount = function() {
2478
- return q(this, (e, t) => yn(t));
2422
+ return Y(this, (e) => H.cleanupTree(e));
2479
2423
  };
2480
2424
  //#endregion
2481
2425
  //#region src/features/route.ts
2482
- function Bn(e, t) {
2483
- try {
2484
- history.pushState(e, "", t);
2485
- } catch (e) {
2486
- W.warn(V.ROUTE, "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.", e);
2426
+ var Z = {
2427
+ normalize: (e) => e.replace(/(^\/+|\/+$)/g, ""),
2428
+ split: (e) => {
2429
+ let [t, n] = e.split("?");
2430
+ return {
2431
+ route: Z.normalize(t || ""),
2432
+ query: n
2433
+ };
2434
+ },
2435
+ isSameParams: (e, t) => {
2436
+ if (e === t) return !0;
2437
+ let n = Object.keys(e), r = Object.keys(t);
2438
+ return n.length === r.length && n.every((n) => e[n] === t[n]);
2487
2439
  }
2488
- }
2489
- var Vn = class {
2490
- parseQueryParams(e) {
2491
- let t = {};
2492
- return e && new URLSearchParams(e).forEach((e, n) => {
2440
+ };
2441
+ function Pn(e) {
2442
+ let t = {};
2443
+ if (!e) return t;
2444
+ try {
2445
+ new URLSearchParams(e).forEach((e, n) => {
2493
2446
  t[n] = e;
2494
- }), t;
2495
- }
2496
- constructor(t) {
2497
- this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.routeCleanups = [], this.lastRawQuery = "", this.cachedParams = {}, this.config = {
2498
- mode: Be.mode,
2499
- basePath: Be.basePath,
2500
- autoBindLinks: Be.autoBindLinks,
2501
- activeClass: Be.activeClass,
2502
- notFound: t.notFound || "",
2503
- beforeTransition: t.beforeTransition || (() => {}),
2504
- afterTransition: t.afterTransition || (() => {}),
2505
- ...t
2506
- }, this.isHistoryMode = this.config.mode === "history", this.basePath = this.config.basePath.replace(/\/$/, ""), this.activeClass = this.config.activeClass, this.$target = e(this.config.target), this.previousUrl = this.isHistoryMode ? location.pathname + location.search : location.hash, this.currentRouteAtom = we(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = we(this.getQueryParams()), this.queryParams = L(() => this.queryParamsAtom.value), this.init();
2507
- }
2508
- init() {
2509
- let e = this.isHistoryMode ? "popstate" : "hashchange", t = this.handleUrlChange.bind(this);
2510
- window.addEventListener(e, t), this.cleanups.push(() => window.removeEventListener(e, t));
2511
- let n = R(() => {
2512
- let e = this.currentRouteAtom.value;
2513
- O(() => {
2514
- for (let e of this.routeCleanups) try {
2515
- e();
2516
- } catch {}
2517
- this.routeCleanups.length = 0;
2518
- }), this.renderRoute(e);
2519
2447
  });
2520
- this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] && K.trackCleanup(this.$target[0], () => this.destroy());
2521
- }
2522
- getRouteName() {
2523
- let { default: e } = this.config;
2524
- if (this.isHistoryMode) {
2525
- let t = this.basePath, n = location.pathname;
2526
- return t && (n === t || n.startsWith(`${t}/`)) && (n = n.substring(t.length)), n.replace(/^\/+/, "") || e;
2527
- }
2528
- let t = location.hash, { route: n } = this.splitPath(t.startsWith("#") ? t.substring(1) : t);
2529
- return n || e;
2530
- }
2531
- getQueryParams() {
2532
- let e = this.getCurrentRawQuery();
2533
- if (e === this.lastRawQuery) return this.cachedParams;
2534
- this.lastRawQuery = e;
2535
- let t = this.parseQueryParams(e);
2536
- return this.areParamsEqual(t, this.cachedParams) ? this.cachedParams : (e.indexOf("%"), this.cachedParams = t, t);
2537
- }
2538
- getCurrentRawQuery() {
2539
- if (this.isHistoryMode) return location.search.substring(1);
2540
- let e = location.hash, t = e.indexOf("?");
2541
- return t === -1 ? "" : e.substring(t + 1);
2542
- }
2543
- areParamsEqual(e, t) {
2544
- let n = Object.keys(e);
2545
- if (n.length !== Object.keys(t).length) return !1;
2546
- for (let r of n) if (e[r] !== t[r]) return !1;
2547
- return !0;
2548
- }
2549
- splitPath(e) {
2550
- let t = e.indexOf("?"), n = t === -1 ? e : e.slice(0, t), r = t === -1 ? void 0 : e.slice(t + 1);
2448
+ } catch {}
2449
+ return t;
2450
+ }
2451
+ var Fn = (e) => {
2452
+ let t = e ? `/${Z.normalize(e)}` : "", n = `${location.origin}${t}/`.replace(/\/+$/, "/");
2453
+ return {
2454
+ getBrowserState: () => {
2455
+ let e = location.pathname;
2456
+ return t && e.startsWith(t) && (e = e.substring(t.length)), {
2457
+ path: Z.normalize(e),
2458
+ query: Pn(location.search.substring(1)),
2459
+ url: location.pathname + location.search
2460
+ };
2461
+ },
2462
+ commit: (e) => {
2463
+ let { route: t, query: r } = Z.split(e), i = new URL(t, n);
2464
+ r && (i.search = r);
2465
+ let a = i.pathname + i.search;
2466
+ try {
2467
+ history.pushState(null, "", a);
2468
+ } catch {}
2469
+ return {
2470
+ path: Z.normalize(t),
2471
+ query: Pn(r || ""),
2472
+ url: a
2473
+ };
2474
+ },
2475
+ revert: (e) => {
2476
+ if (location.pathname + location.search !== e) try {
2477
+ history.replaceState(null, "", e);
2478
+ } catch {}
2479
+ },
2480
+ resolveAnchor: (e) => {
2481
+ let n = e.pathname;
2482
+ return t && n.startsWith(t) && (n = n.substring(t.length)), Z.normalize(n) + e.search;
2483
+ },
2484
+ setupListener: (e) => (window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e))
2485
+ };
2486
+ }, In = () => ({
2487
+ getBrowserState: () => {
2488
+ let e = location.hash, t = e.startsWith("#") ? e.substring(1) : e, { route: n, query: r } = Z.split(t);
2551
2489
  return {
2552
- route: n.replace(/^\/+/, ""),
2553
- query: r
2490
+ path: n,
2491
+ query: Pn(r || ""),
2492
+ url: e
2554
2493
  };
2494
+ },
2495
+ commit: (e) => {
2496
+ let { route: t, query: n } = Z.split(e), r = `#${n ? `${t}?${n}` : t}`;
2497
+ return location.hash = r, {
2498
+ path: Z.normalize(t),
2499
+ query: Pn(n || ""),
2500
+ url: r
2501
+ };
2502
+ },
2503
+ revert: (e) => {
2504
+ location.hash !== e && (location.hash = e);
2505
+ },
2506
+ resolveAnchor: (e) => e.hash.startsWith("#") ? Z.normalize(e.hash.substring(1)) : "",
2507
+ setupListener: (e) => (window.addEventListener("hashchange", e), () => window.removeEventListener("hashchange", e))
2508
+ }), Ln = class {
2509
+ constructor(e) {
2510
+ this.routes = [], Object.entries(e).forEach(([e, t]) => {
2511
+ let n = Z.normalize(e);
2512
+ if (!n.includes(":")) this.routes.push({
2513
+ kind: "exact",
2514
+ pattern: n,
2515
+ def: t
2516
+ });
2517
+ else {
2518
+ let e = [], r = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/:(\w+)/g, (t, n) => (e.push(n), "([^/]+)"));
2519
+ this.routes.push({
2520
+ kind: "dynamic",
2521
+ pattern: n,
2522
+ regex: RegExp(`^${r}$`),
2523
+ paramNames: e,
2524
+ def: t
2525
+ });
2526
+ }
2527
+ });
2555
2528
  }
2556
- setUrl(e) {
2557
- let { route: t, query: n } = this.splitPath(e), r = n ? `${t}?${n}` : t, i = this.isHistoryMode ? `${this.basePath}/${r}` : `#${r}`;
2558
- this.isHistoryMode ? Bn(null, i) : location.hash = i, this.previousUrl = this.isHistoryMode ? i : location.hash;
2559
- }
2560
- restoreUrl() {
2561
- try {
2562
- this.isHistoryMode ? history.replaceState(null, "", this.previousUrl) : location.hash = this.previousUrl;
2563
- } catch (e) {
2564
- W.warn(V.ROUTE, "Restore URL failed", e);
2529
+ match(e) {
2530
+ let t = Z.normalize(e);
2531
+ for (let e of this.routes) if (e.kind === "exact") {
2532
+ if (e.pattern === t) return {
2533
+ kind: "found",
2534
+ route: e,
2535
+ params: {}
2536
+ };
2537
+ } else {
2538
+ let n = t.match(e.regex);
2539
+ if (n) return {
2540
+ kind: "found",
2541
+ route: e,
2542
+ params: e.paramNames.reduce((e, t, r) => {
2543
+ try {
2544
+ e[t] = decodeURIComponent(n[r + 1] || "");
2545
+ } catch {
2546
+ e[t] = n[r + 1] || "";
2547
+ }
2548
+ return e;
2549
+ }, {})
2550
+ };
2565
2551
  }
2552
+ return { kind: "not-found" };
2566
2553
  }
2567
- renderRoute(e) {
2568
- if (this.isDestroyed || !this.$target[0]) return;
2569
- let { routes: t, notFound: n, beforeTransition: r, afterTransition: i } = this.config, a = t[e] ?? (n ? t[n] : void 0);
2570
- if (!a) {
2571
- W.warn(V.ROUTE, H.ROUTE.NOT_FOUND(e));
2572
- return;
2573
- }
2574
- let o = this.getQueryParams(), s = this.previousRoute;
2575
- r && O(() => r(s, e)), this.$target.empty();
2576
- let c = o;
2577
- if (a.onEnter) {
2578
- let e = O(() => a.onEnter(o, this));
2579
- e && (c = {
2580
- ...o,
2581
- ...e
2554
+ }, Rn = class {
2555
+ constructor(t) {
2556
+ this.isDestroyed = !1, this.previousPath = "", this.previousUrl = "", this.cleanups = [], this.routeCleanups = [], this.config = this.parseConfig(t), this.activeClass = this.config.activeClass;
2557
+ let n = this.config.target;
2558
+ typeof n == "string" || n instanceof HTMLElement ? this.$target = e(n) : this.$target = n, this.urlAdapter = this.config.mode === "history" ? Fn(this.config.basePath) : In(), this.discoverRoutesFromDOM(), this.matcher = new Ln(this.config.routes);
2559
+ let r = this.urlAdapter.getBrowserState();
2560
+ this.previousUrl = r.url;
2561
+ let i = r.path || this.config.default;
2562
+ this.currentRouteAtom = De(i), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = De(r.query), this.queryParams = Me(() => this.queryParamsAtom.value);
2563
+ let a = this.matcher.match(i), o = a.kind === "found" ? a.params : {};
2564
+ this.paramsAtom = De({
2565
+ ...r.query,
2566
+ ...o
2567
+ }), this.params = Me(() => this.paramsAtom.value), this.setupLifecycle();
2568
+ }
2569
+ parseConfig(e) {
2570
+ return {
2571
+ mode: Ke.mode,
2572
+ basePath: Ke.basePath,
2573
+ autoBindLinks: Ke.autoBindLinks,
2574
+ activeClass: Ke.activeClass,
2575
+ notFound: e.notFound || "",
2576
+ beforeTransition: e.beforeTransition || (() => {}),
2577
+ afterTransition: e.afterTransition || (() => {}),
2578
+ default: e.default || "",
2579
+ ...e,
2580
+ routes: e.routes || {}
2581
+ };
2582
+ }
2583
+ setupLifecycle() {
2584
+ this.cleanups.push(this.urlAdapter.setupListener(() => this.handleBrowserSync()));
2585
+ let e = L(() => {
2586
+ let e = this.currentRouteAtom.value;
2587
+ this.queryParamsAtom.value, O(() => {
2588
+ this.runRouteCleanups(), this.render(e);
2582
2589
  });
2583
- }
2584
- let l = (e) => this.routeCleanups.push(e);
2585
- if (a.render) a.render(this.$target[0], e, c, l, this);
2586
- else if (a.template) {
2587
- let e = this.templateCache.get(a.template);
2588
- if (!e) {
2589
- let t = document.querySelector(a.template);
2590
- if (t instanceof HTMLTemplateElement) e = t, this.templateCache.set(a.template, e);
2591
- else {
2592
- W.warn(V.ROUTE, H.ROUTE.TEMPLATE_NOT_FOUND(a.template));
2593
- return;
2594
- }
2595
- }
2596
- this.$target.append(e.content.cloneNode(!0)), a.onMount && a.onMount(this.$target.children(), l, this);
2597
- }
2598
- i && O(() => i(s, e)), this.previousRoute = e;
2590
+ });
2591
+ this.cleanups.push(() => e.dispose()), this.config.autoBindLinks && this.setupInterception(), this.$target[0] && H.trackCleanup(this.$target[0], () => this.destroy());
2592
+ }
2593
+ navigate(e) {
2594
+ if (this.isDestroyed || !this.canLeave()) return;
2595
+ let { route: t, query: n } = Z.split(e), r = t || this.config.default;
2596
+ if (!r) return;
2597
+ let i = n ? `${r}?${n}` : r;
2598
+ Ce(() => {
2599
+ let e = this.urlAdapter.commit(i);
2600
+ this.previousUrl = e.url, Z.isSameParams(this.queryParamsAtom.peek(), e.query) || (this.queryParamsAtom.value = e.query), this.currentRouteAtom.peek() !== e.path && (this.currentRouteAtom.value = e.path);
2601
+ });
2599
2602
  }
2600
- handleUrlChange() {
2603
+ handleBrowserSync() {
2601
2604
  if (this.isDestroyed) return;
2602
- let e = this.isHistoryMode ? location.pathname + location.search : location.hash;
2603
- if (e === this.previousUrl) return;
2604
- let t = this.getRouteName(), n = this.currentRouteAtom.peek();
2605
- if (n !== t) {
2606
- if (O(() => this.config.routes[n]?.onLeave?.(this)) === !1) {
2607
- this.restoreUrl();
2605
+ let e = this.urlAdapter.getBrowserState();
2606
+ if (e.url === this.previousUrl) return;
2607
+ let t = e.path || this.config.default;
2608
+ if (this.currentRouteAtom.peek() !== t) {
2609
+ if (!this.canLeave()) {
2610
+ this.urlAdapter.revert(this.previousUrl);
2608
2611
  return;
2609
2612
  }
2610
2613
  this.currentRouteAtom.value = t;
2611
2614
  }
2612
- this.queryParamsAtom.value = this.getQueryParams(), this.previousUrl = e;
2615
+ this.queryParamsAtom.value = e.query, this.previousUrl = e.url;
2613
2616
  }
2614
- setupAutoBindLinks() {
2615
- if (!this.config.autoBindLinks) return;
2617
+ render(e) {
2618
+ let t = this.matcher.match(e), n = t.kind === "found" ? t.route.def : this.config.routes[this.config.notFound];
2619
+ if (!n) {
2620
+ V.warn(R.ROUTE, z.ROUTE.NOT_FOUND(e));
2621
+ return;
2622
+ }
2623
+ let r = t.kind === "found" ? t.route.pattern : e, i = t.kind === "found" ? t.params : {}, a = {
2624
+ ...this.queryParamsAtom.peek(),
2625
+ ...i
2626
+ };
2627
+ if (O(() => this.config.beforeTransition(this.previousPath, r)), n.onEnter) {
2628
+ let e = O(() => n.onEnter(a, this));
2629
+ if (e === !1) {
2630
+ this.urlAdapter.revert(this.previousUrl);
2631
+ return;
2632
+ }
2633
+ e && Object.assign(a, e);
2634
+ }
2635
+ Z.isSameParams(this.paramsAtom.peek(), a) || (this.paramsAtom.value = a), n.title && (document.title = n.title), this.updateDom(n, r, a), O(() => this.config.afterTransition(this.previousPath, r)), this.finalizeNavigation(r, a);
2636
+ }
2637
+ updateDom(t, n, r) {
2638
+ let i = this.$target[0];
2639
+ if (!i) return;
2640
+ i.replaceChildren();
2641
+ let a = (e) => this.routeCleanups.push(e);
2642
+ if (t.render) t.render(i, n, r, a, this);
2643
+ else if (t.template) {
2644
+ let n = this.getTemplate(t.template);
2645
+ n && (i.appendChild(n.content.cloneNode(!0)), t.onMount?.(e(i).children(), a, this));
2646
+ }
2647
+ }
2648
+ discoverRoutesFromDOM() {
2649
+ document.querySelectorAll("template[data-path]").forEach((e) => {
2650
+ let t = Z.normalize(e.getAttribute("data-path") || ""), n = e.getAttribute("title") || e.getAttribute("data-title"), r = this.config.routes[t];
2651
+ r ? n && !r.title && (r.title = n) : (e.id ||= `route-${Math.random().toString(36).substring(2, 9)}`, this.config.routes[t] = {
2652
+ template: `#${e.id}`,
2653
+ ...n ? { title: n } : {}
2654
+ }), e.hasAttribute("data-default") && !this.config.default && (this.config.default = t);
2655
+ });
2656
+ }
2657
+ setupInterception() {
2616
2658
  let t = (e) => {
2617
- e.preventDefault();
2618
- let t = e.currentTarget.dataset.route;
2619
- t != null && this.navigate(t);
2659
+ let t = e.originalEvent;
2660
+ if (t && (t.ctrlKey || t.metaKey || t.altKey || t.shiftKey || t.button !== 0)) return;
2661
+ let n = e.currentTarget;
2662
+ if (n.hasAttribute("data-ignore")) return;
2663
+ let r = this.resolvePathFromElement(n);
2664
+ r && this.shouldIntercept(r, n) && (e.preventDefault(), this.navigate(r));
2620
2665
  };
2621
- e(document).on("click", "[data-route]", t), this.cleanups.push(() => e(document).off("click", "[data-route]", t));
2622
- let n = [], r = R(() => {
2623
- let e = this.currentRouteAtom.value, t = this.activeClass;
2666
+ e(document).on("click", "a, [data-route]", t), this.cleanups.push(() => e(document).off("click", "a, [data-route]", t)), this.setupActiveEffect();
2667
+ }
2668
+ setupActiveEffect() {
2669
+ let e = L(() => {
2670
+ let e = this.currentRouteAtom.value, t = this.matcher.match(e), n = t.kind === "found" ? t.route.pattern : "";
2624
2671
  O(() => {
2625
- for (let e of n) e.classList.remove(t), e.removeAttribute("aria-current");
2626
- try {
2627
- let r = `[data-route="${e.replace(/"/g, "\\\"")}"]`, i = Array.from(document.querySelectorAll(r));
2628
- for (let e of i) e.classList.add(t), e.setAttribute("aria-current", "page");
2629
- n = i;
2630
- } catch {
2631
- n = [];
2632
- }
2672
+ document.querySelectorAll("a, [data-route]").forEach((t) => {
2673
+ let r = this.resolvePathFromElement(t, !0), i = r === e || r === n;
2674
+ t.classList.toggle(this.activeClass, i), i ? t.setAttribute("aria-current", "page") : t.removeAttribute("aria-current");
2675
+ });
2633
2676
  });
2634
2677
  });
2635
- this.cleanups.push(() => {
2636
- r.dispose(), n.length = 0;
2637
- });
2678
+ this.cleanups.push(() => e.dispose());
2638
2679
  }
2639
- navigate(t) {
2640
- if (this.isDestroyed) return;
2641
- let n = this.currentRouteAtom.peek();
2642
- if (this.config.routes[n]?.onLeave?.(this) === !1) return;
2643
- let { route: r, query: i } = this.splitPath(t), a = r || this.config.default || "";
2644
- a && e.batch(() => {
2645
- this.setUrl(t);
2646
- let e = i ? this.parseQueryParams(i) : {};
2647
- this.areParamsEqual(e, this.queryParamsAtom.peek()) || (this.queryParamsAtom.value = e), this.currentRouteAtom.value = a;
2648
- });
2680
+ resolvePathFromElement(e, t = !1) {
2681
+ let n = e.dataset.route || "";
2682
+ return !n && e instanceof HTMLAnchorElement && (n = this.urlAdapter.resolveAnchor(e)), t ? Z.split(n).route : n;
2683
+ }
2684
+ shouldIntercept(e, t) {
2685
+ if (t instanceof HTMLAnchorElement && (t.rel === "external" || t.target && t.target !== "_self" || t.hasAttribute("download") || t.origin !== location.origin || (e.split("/").pop() || "").includes(".") && this.matcher.match(Z.split(e).route).kind === "not-found")) return !1;
2686
+ let { route: n } = Z.split(e);
2687
+ return this.matcher.match(n).kind === "found" || !!this.config.notFound;
2688
+ }
2689
+ canLeave() {
2690
+ let e = this.matcher.match(this.currentRouteAtom.peek()), t = e.kind === "found" ? e.route.def : this.config.routes[this.config.notFound];
2691
+ return t?.onLeave ? O(() => t.onLeave(this)) !== !1 : !0;
2692
+ }
2693
+ getTemplate(e) {
2694
+ let t = document.querySelector(e);
2695
+ return t instanceof HTMLTemplateElement ? t : null;
2696
+ }
2697
+ runRouteCleanups() {
2698
+ this.routeCleanups.forEach((e) => {
2699
+ try {
2700
+ e();
2701
+ } catch {}
2702
+ }), this.routeCleanups = [];
2703
+ }
2704
+ finalizeNavigation(e, t) {
2705
+ window.dispatchEvent(new CustomEvent("route-change", { detail: {
2706
+ from: this.previousPath,
2707
+ to: e,
2708
+ params: t
2709
+ } }));
2710
+ let n = this.$target[0];
2711
+ if (!n) return;
2712
+ let r = n.querySelector("h1, [role=\"heading\"]"), i = r instanceof HTMLElement ? r : n;
2713
+ i.tabIndex = -1, i.focus(), this.previousPath = e;
2649
2714
  }
2650
2715
  destroy() {
2651
- if (!this.isDestroyed) {
2652
- this.isDestroyed = !0;
2653
- for (let e of this.cleanups) try {
2716
+ this.isDestroyed || (this.isDestroyed = !0, this.runRouteCleanups(), this.cleanups.forEach((e) => {
2717
+ try {
2654
2718
  e();
2655
2719
  } catch {}
2656
- this.cleanups.length = 0, this.templateCache.clear();
2657
- }
2720
+ }), this.cleanups = []);
2658
2721
  }
2659
2722
  };
2660
- function Hn(e) {
2661
- return new Vn(e);
2723
+ function zn(e) {
2724
+ return new Rn(e);
2662
2725
  }
2663
- e.extend({ route: Hn });
2726
+ e.extend({ route: zn });
2664
2727
  //#endregion
2665
2728
  //#region src/features/fetch.ts
2666
- var Un = class {
2667
- constructor(t, n) {
2668
- this.abortController = null, this.execute = async () => {
2669
- this.abort();
2670
- let t = new AbortController();
2671
- this.abortController = t;
2672
- let { signal: n } = t, r;
2673
- try {
2674
- let t = this.prepareSettings(), i = e.ajax(t);
2675
- r = () => i.abort(), n.addEventListener("abort", r), n.aborted && i.abort();
2676
- let a = await i;
2677
- return this.transformFn ? this.transformFn(a) : a;
2678
- } catch (e) {
2679
- if (n.aborted) throw this.createAbortError();
2680
- return this.handleError(e);
2681
- } finally {
2682
- r && n.removeEventListener("abort", r), this.abortController === t && (this.abortController = null);
2683
- }
2684
- };
2685
- let r = typeof t == "string";
2686
- this.isStaticUrl = r, r ? (this.staticUrl = t, this.getUrl = () => this.staticUrl) : this.getUrl = t, this.ajaxOptionsFn = typeof n.ajaxOptions == "function" ? n.ajaxOptions : void 0;
2687
- let i = typeof n.ajaxOptions == "object" ? n.ajaxOptions : {};
2688
- this.staticOptions = {
2689
- ...i,
2690
- headers: {
2691
- ...i?.headers,
2692
- ...n.headers
2729
+ function Bn(e, t) {
2730
+ let n = typeof t.ajaxOptions == "object" ? t.ajaxOptions : {}, r = typeof t.ajaxOptions == "function" ? t.ajaxOptions() : {};
2731
+ return {
2732
+ ...n,
2733
+ ...r,
2734
+ url: e(),
2735
+ method: t.method || r.method || n.method,
2736
+ headers: {
2737
+ ...n?.headers,
2738
+ ...t.headers,
2739
+ ...r.headers
2740
+ },
2741
+ success: void 0,
2742
+ error: void 0,
2743
+ complete: void 0
2744
+ };
2745
+ }
2746
+ function Vn(e, t) {
2747
+ let n;
2748
+ if (e && e.readyState !== void 0) {
2749
+ let t = e;
2750
+ n = /* @__PURE__ */ Error(`Network Error: ${t.statusText || "Unknown"} (${t.status})`), n.jqXHR = t;
2751
+ } else n = e instanceof Error ? e : Error(String(e ?? "Unknown error"));
2752
+ if (t) try {
2753
+ t(n);
2754
+ } catch {}
2755
+ throw n;
2756
+ }
2757
+ function Hn(t, n) {
2758
+ let r = typeof t == "string" ? () => t : t, i = null, a = Me(async () => {
2759
+ i?.abort();
2760
+ let t = new AbortController();
2761
+ i = t;
2762
+ let { signal: a } = t, o = Bn(r, n), s, c;
2763
+ try {
2764
+ s = e.ajax(o);
2765
+ let t = s;
2766
+ c = () => t.abort(), a.addEventListener("abort", c), a.aborted && t.abort();
2767
+ let r = await t;
2768
+ return n.transform ? n.transform(r, t) : r;
2769
+ } catch (e) {
2770
+ if (a.aborted) {
2771
+ let e = /* @__PURE__ */ Error("AbortError");
2772
+ throw e.name = "AbortError", e;
2693
2773
  }
2694
- }, n.method && (this.staticOptions.method = n.method), this.transformFn = n.transform, this.onErrorFn = n.onError;
2695
- }
2696
- abort() {
2697
- this.abortController?.abort();
2698
- }
2699
- handleError(e) {
2700
- let t;
2701
- if (e && e.readyState !== void 0) {
2702
- let n = e;
2703
- t = /* @__PURE__ */ Error(`Network Error: ${n.statusText || "Unknown"} (${n.status})`), t.jqXHR = n;
2704
- } else t = e instanceof Error ? e : Error(String(e ?? "Unknown error"));
2705
- if (this.onErrorFn) try {
2706
- this.onErrorFn(t);
2707
- } catch {}
2708
- throw t;
2774
+ return Vn(e, n.onError);
2775
+ } finally {
2776
+ c && a.removeEventListener("abort", c), i === t && (i = null);
2777
+ }
2778
+ }, {
2779
+ defaultValue: n.defaultValue,
2780
+ lazy: n.eager === !1,
2781
+ ...n.name === void 0 ? {} : { name: n.name }
2782
+ }), o = a.dispose.bind(a);
2783
+ return a.dispose = () => {
2784
+ i?.abort(), o();
2785
+ }, Object.assign(a, { abort: () => i?.abort() });
2786
+ }
2787
+ e.extend({ atomFetch: Hn });
2788
+ //#endregion
2789
+ //#region src/features/nav.ts
2790
+ function Q(e, t) {
2791
+ try {
2792
+ return new URL(e, t);
2793
+ } catch {
2794
+ return new URL(e, "http://localhost");
2795
+ }
2796
+ }
2797
+ function Un(e) {
2798
+ let { pathname: t, search: n, hash: r } = e.location;
2799
+ return (t || "/") + (n || "") + (r || "");
2800
+ }
2801
+ function $(e) {
2802
+ return e.pathname + e.search;
2803
+ }
2804
+ function Wn(e, t, n) {
2805
+ let r = new DOMParser().parseFromString(e, "text/html"), i = r.querySelector("title")?.textContent?.trim() || null, a = t ? r.querySelector(t) : null, o = a ? a.innerHTML : r.body?.innerHTML || e, s = {};
2806
+ if (a) for (let { name: e, value: t } of Array.from(a.attributes)) e !== "id" && (s[e] = t);
2807
+ let c = {}, l = (e) => r.querySelector(e)?.getAttribute("content"), u = l("meta[name=\"description\"]"), d = l("meta[name=\"keywords\"]"), f = r.querySelector("link[rel=\"canonical\"]")?.getAttribute("href");
2808
+ return u && (c.description = u), d && (c.keywords = d), f && (c.canonical = f), {
2809
+ html: J(o).trim(),
2810
+ title: i,
2811
+ attributes: s,
2812
+ redirectUrl: n?.getResponseHeader?.("X-PJAX-URL") || void 0,
2813
+ meta: c
2814
+ };
2815
+ }
2816
+ function Gn(e, t) {
2817
+ let n = e.document, r = n.head, i = (e, t, i, a = !1) => {
2818
+ let o = r.querySelector(e);
2819
+ if (!t) {
2820
+ o?.remove();
2821
+ return;
2822
+ }
2823
+ let s = o || n.createElement(a ? "link" : "meta");
2824
+ o || (a ? s.setAttribute("rel", "canonical") : s.setAttribute("name", i), r.appendChild(s));
2825
+ let c = a ? "href" : "content";
2826
+ s.getAttribute(c) !== t && s.setAttribute(c, t);
2827
+ };
2828
+ i("meta[name=\"description\"]", t?.description, "description"), i("meta[name=\"keywords\"]", t?.keywords, "keywords"), i("link[rel=\"canonical\"]", t?.canonical, "canonical", !0);
2829
+ }
2830
+ function Kn(e, t) {
2831
+ for (let n of Array.from(e.attributes)) {
2832
+ let { name: r } = n;
2833
+ r !== "id" && r !== "data-atom-nav-target" && !(r in t) && e.removeAttribute(r);
2834
+ }
2835
+ for (let [n, r] of Object.entries(t)) e.getAttribute(n) !== r && e.setAttribute(n, r);
2836
+ }
2837
+ function qn(e, t, n = !1) {
2838
+ if (t) {
2839
+ let r = e.document.getElementById(decodeURIComponent(t));
2840
+ if (r) {
2841
+ r.scrollIntoView({
2842
+ behavior: "auto",
2843
+ block: "start"
2844
+ });
2845
+ return;
2846
+ }
2847
+ if (!n) return;
2709
2848
  }
2710
- prepareSettings() {
2711
- let e = this.ajaxOptionsFn?.() ?? {};
2849
+ e.scrollTo(0, 0);
2850
+ }
2851
+ function Jn(t) {
2852
+ let { target: n, selector: r = "a[data-nav]", headers: i = {}, syncTitle: a = !0 } = t, o = t.window ?? window, s = e(n);
2853
+ s.attr("data-atom-nav-target", "true");
2854
+ let c = Un(o), l = $(Q(c, o.location.href)), u = e.atom({
2855
+ url: c,
2856
+ type: "init"
2857
+ }, { name: "nav:state" }), d = e.atom(0, { name: "nav:hook-pending-count" }), f = e.atom({
2858
+ url: c,
2859
+ path: l
2860
+ }, { name: "nav:rendered" }), p = e.computed(() => {
2861
+ let { url: e, type: t } = u.value, n = Q(e, o.location.href);
2712
2862
  return {
2713
- ...this.staticOptions,
2714
- ...e,
2715
- headers: {
2716
- ...this.staticOptions.headers,
2717
- ...e.headers
2718
- },
2719
- url: this.isStaticUrl ? this.staticUrl : this.getUrl(),
2720
- success: void 0,
2721
- error: void 0,
2722
- complete: void 0
2863
+ url: e,
2864
+ pathAndSearch: $(n),
2865
+ hash: n.hash.slice(1),
2866
+ type: t
2723
2867
  };
2868
+ }, { name: "nav:normalized" }), m = typeof n == "string" ? n : s.attr("id") ? `#${e.escapeSelector(s.attr("id"))}` : void 0, h = e.atomFetch(() => p.value.pathAndSearch, {
2869
+ name: "nav:content",
2870
+ defaultValue: {
2871
+ html: "",
2872
+ title: null
2873
+ },
2874
+ headers: {
2875
+ "X-PJAX": "true",
2876
+ ...i
2877
+ },
2878
+ eager: !1,
2879
+ transform: (e, t) => Wn(String(e), m, t)
2880
+ }), g = new AbortController(), _ = null;
2881
+ function v() {
2882
+ _?.abort(), h.abort?.();
2883
+ let e = new AbortController();
2884
+ return _ = e, e;
2885
+ }
2886
+ function y(n, r, i) {
2887
+ e.untracked(() => {
2888
+ let e = o.document;
2889
+ a && n.title !== null && e.title !== n.title && (e.title = n.title), Gn(o, n.meta), t.onUnmount?.(s, i), s.children().atomUnbind();
2890
+ let c = s[0];
2891
+ c && n.attributes && Kn(c, n.attributes), s.html(n.html), t.onMount?.(s, r);
2892
+ });
2724
2893
  }
2725
- createAbortError() {
2726
- let e = /* @__PURE__ */ Error("AbortError");
2727
- return e.name = "AbortError", e;
2894
+ function b() {
2895
+ let { url: n, pathAndSearch: r, hash: i, type: a } = p.value, c = f.value;
2896
+ if (a === "init" && r === c.path) {
2897
+ i && qn(o, i), t.onMount?.(s, n);
2898
+ return;
2899
+ }
2900
+ if (h.hasError) {
2901
+ let e = h.lastError;
2902
+ if (e instanceof Error && e.name === "AbortError") return;
2903
+ t.onError?.(e, n) !== !1 && o.location.assign(n);
2904
+ return;
2905
+ }
2906
+ let l = h.value;
2907
+ if (!h.isResolved || h.isPending) return;
2908
+ let u = l.redirectUrl && l.redirectUrl !== n, d = c.url, m = u ? l.redirectUrl : n, g = u ? Q(m, o.location.href) : null, _ = g ? $(g) : r, v = _ !== c.path;
2909
+ e.batch(() => {
2910
+ u && o.history.replaceState(null, "", m), (v || u) && y(l, m, d);
2911
+ let { scrollToTop: e = !0 } = t, n = Q(f.value.url, o.location.href), r = !i && n.hash !== "", s = a === "pop";
2912
+ (i || !s && (r || v && e)) && qn(o, i, !s && v && e), f.value = {
2913
+ url: m,
2914
+ path: _
2915
+ };
2916
+ });
2728
2917
  }
2729
- };
2918
+ let x = e.effect(() => b(), { name: "nav:sync-effect" });
2919
+ o.document.addEventListener("click", (t) => {
2920
+ let n = t.target.closest(r);
2921
+ if (!n) return;
2922
+ let i = n.dataset.target, a = s.attr("id"), c = i && a && i === `#${a}`;
2923
+ if (i && !c) return;
2924
+ let l = e(n).closest("[data-atom-nav-target=\"true\"]")[0], u = l && l !== s[0];
2925
+ if (!c && u) return;
2926
+ let d = t;
2927
+ if (t.defaultPrevented || t.isDefaultPrevented?.() || t.originalEvent?.defaultPrevented || d.ctrlKey || d.metaKey || d.shiftKey || d.button > 0) return;
2928
+ let f = n.getAttribute("href");
2929
+ if (f && !f.startsWith("#") && n.target !== "_blank" && !n.hasAttribute("download") && n.getAttribute("rel") !== "external" && n.dataset.nav !== "false" && (n.protocol === "http:" || n.protocol === "https:")) try {
2930
+ (n.origin ?? new URL(n.href, n.ownerDocument.location?.href ?? o.location.origin).origin) === o.location.origin && (t.preventDefault(), S.navigate(n.href));
2931
+ } catch {}
2932
+ }, { signal: g.signal }), o.addEventListener("popstate", () => {
2933
+ v(), u.value = {
2934
+ url: Un(o),
2935
+ type: "pop"
2936
+ };
2937
+ }, { signal: g.signal });
2938
+ let S = {
2939
+ currentUrl: e.computed(() => f.value.url, { name: "nav:public-url" }),
2940
+ isPending: e.computed(() => h.isPending || d.value > 0, { name: "nav:isPending" }),
2941
+ hasError: e.computed(() => h.hasError, { name: "nav:hasError" }),
2942
+ async navigate(n, r = {}) {
2943
+ let { signal: i } = v();
2944
+ if (t.onBeforeLoad) {
2945
+ d.value++;
2946
+ try {
2947
+ let e = await t.onBeforeLoad(n, i);
2948
+ if (i.aborted || e === !1) return;
2949
+ } finally {
2950
+ d.value = Math.max(0, d.value - 1);
2951
+ }
2952
+ }
2953
+ let a = o.document.baseURI ?? o.location.href, s = Q(n, a);
2954
+ if (s.origin !== o.location.origin) {
2955
+ o.location.assign(n);
2956
+ return;
2957
+ }
2958
+ let c = $(s), l = $(Q(o.location.href, a)), f = c + s.hash;
2959
+ !(c === l && s.hash === (o.location.hash || "")) || r.replace ? e.batch(() => {
2960
+ let e = r.replace ? "replaceState" : "pushState";
2961
+ o.history[e](null, "", f), u.value = {
2962
+ url: f,
2963
+ type: r.replace ? "replace" : "push"
2964
+ };
2965
+ }) : (n.includes("#") || s.hash) && qn(o, s.hash.slice(1), !0);
2966
+ },
2967
+ destroy() {
2968
+ g.abort(), _?.abort(), x.dispose(), h.dispose(), s.removeAttr("data-atom-nav-target"), [
2969
+ u,
2970
+ d,
2971
+ f,
2972
+ p,
2973
+ S.currentUrl,
2974
+ S.isPending,
2975
+ S.hasError
2976
+ ].forEach((e) => e.dispose?.());
2977
+ }
2978
+ };
2979
+ return S;
2980
+ }
2730
2981
  //#endregion
2731
2982
  //#region src/index.ts
2732
- e.extend({ atomFetch(e, t) {
2733
- let n = new Un(e, t), r = L(n.execute, {
2734
- defaultValue: t.defaultValue,
2735
- lazy: t.eager === !1
2736
- }), i = r.dispose.bind(r);
2737
- return r.dispose = () => {
2738
- n.abort(), i();
2739
- }, Object.assign(r, { abort: () => n.abort() });
2740
- } }), e(() => {
2741
- Tt(), document.body && pt(document.body);
2983
+ e.extend({ atomNav: Jn }), e(() => {
2984
+ Ct(), document.body && mt(document.body);
2742
2985
  });
2743
- var Wn = e;
2986
+ var Yn = e;
2744
2987
  //#endregion
2745
- export { Wn as default, mt as disableAutoCleanup, Et as disablejQueryOverrides, pt as enableAutoCleanup, Tt as enablejQueryOverrides, Ie as isReactive, rt as nextTick, K as registry };
2988
+ export { Yn as default, ht as disableAutoCleanup, wt as disablejQueryOverrides, mt as enableAutoCleanup, Ct as enablejQueryOverrides, ut as nextTick, H as registry };
2746
2989
 
2747
2990
  //# sourceMappingURL=index.mjs.map