@aevantec/litevue 0.5.6 → 0.5.7

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.
@@ -0,0 +1,2103 @@
1
+ var LiteVue = (function(exports) {
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ //#region node_modules/.pnpm/@vue+shared@3.4.38/node_modules/@vue/shared/dist/shared.esm-bundler.js
4
+ /**
5
+ * @vue/shared v3.4.38
6
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
7
+ * @license MIT
8
+ **/
9
+ /*! #__NO_SIDE_EFFECTS__ */
10
+ // @__NO_SIDE_EFFECTS__
11
+ function makeMap(str, expectsLowerCase) {
12
+ const set = new Set(str.split(","));
13
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
14
+ }
15
+ Object.freeze({});
16
+ Object.freeze([]);
17
+ var NOOP = () => {};
18
+ var extend = Object.assign;
19
+ var remove = (arr, el) => {
20
+ const i = arr.indexOf(el);
21
+ if (i > -1) arr.splice(i, 1);
22
+ };
23
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
24
+ var hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
25
+ var isArray = Array.isArray;
26
+ var isMap = (val) => toTypeString(val) === "[object Map]";
27
+ var isDate = (val) => toTypeString(val) === "[object Date]";
28
+ var isFunction = (val) => typeof val === "function";
29
+ var isString = (val) => typeof val === "string";
30
+ var isSymbol = (val) => typeof val === "symbol";
31
+ var isObject = (val) => val !== null && typeof val === "object";
32
+ var objectToString = Object.prototype.toString;
33
+ var toTypeString = (value) => objectToString.call(value);
34
+ var toRawType = (value) => {
35
+ return toTypeString(value).slice(8, -1);
36
+ };
37
+ var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
38
+ var cacheStringFunction = (fn) => {
39
+ const cache = /* @__PURE__ */ Object.create(null);
40
+ return (str) => {
41
+ return cache[str] || (cache[str] = fn(str));
42
+ };
43
+ };
44
+ var camelizeRE = /-(\w)/g;
45
+ var camelize = cacheStringFunction((str) => {
46
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
47
+ });
48
+ var hyphenateRE = /\B([A-Z])/g;
49
+ var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
50
+ var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
51
+ var toNumber = (val) => {
52
+ const n = isString(val) ? Number(val) : NaN;
53
+ return isNaN(n) ? val : n;
54
+ };
55
+ function normalizeStyle(value) {
56
+ if (isArray(value)) {
57
+ const res = {};
58
+ for (let i = 0; i < value.length; i++) {
59
+ const item = value[i];
60
+ const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
61
+ if (normalized) for (const key in normalized) res[key] = normalized[key];
62
+ }
63
+ return res;
64
+ } else if (isString(value) || isObject(value)) return value;
65
+ }
66
+ var listDelimiterRE = /;(?![^(]*\))/g;
67
+ var propertyDelimiterRE = /:([^]+)/;
68
+ var styleCommentRE = /\/\*[^]*?\*\//g;
69
+ function parseStringStyle(cssText) {
70
+ const ret = {};
71
+ cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
72
+ if (item) {
73
+ const tmp = item.split(propertyDelimiterRE);
74
+ tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
75
+ }
76
+ });
77
+ return ret;
78
+ }
79
+ function normalizeClass(value) {
80
+ let res = "";
81
+ if (isString(value)) res = value;
82
+ else if (isArray(value)) for (let i = 0; i < value.length; i++) {
83
+ const normalized = normalizeClass(value[i]);
84
+ if (normalized) res += normalized + " ";
85
+ }
86
+ else if (isObject(value)) {
87
+ for (const name in value) if (value[name]) res += name + " ";
88
+ }
89
+ return res.trim();
90
+ }
91
+ function looseCompareArrays(a, b) {
92
+ if (a.length !== b.length) return false;
93
+ let equal = true;
94
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
95
+ return equal;
96
+ }
97
+ function looseEqual(a, b) {
98
+ if (a === b) return true;
99
+ let aValidType = isDate(a);
100
+ let bValidType = isDate(b);
101
+ if (aValidType || bValidType) return aValidType && bValidType ? a.getTime() === b.getTime() : false;
102
+ aValidType = isSymbol(a);
103
+ bValidType = isSymbol(b);
104
+ if (aValidType || bValidType) return a === b;
105
+ aValidType = isArray(a);
106
+ bValidType = isArray(b);
107
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
108
+ aValidType = isObject(a);
109
+ bValidType = isObject(b);
110
+ if (aValidType || bValidType) {
111
+ if (!aValidType || !bValidType) return false;
112
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
113
+ for (const key in a) {
114
+ const aHasKey = a.hasOwnProperty(key);
115
+ const bHasKey = b.hasOwnProperty(key);
116
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
117
+ }
118
+ }
119
+ return String(a) === String(b);
120
+ }
121
+ function looseIndexOf(arr, val) {
122
+ return arr.findIndex((item) => looseEqual(item, val));
123
+ }
124
+ //#endregion
125
+ //#region node_modules/.pnpm/@vue+reactivity@3.4.38/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
126
+ /**
127
+ * @vue/reactivity v3.4.38
128
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
129
+ * @license MIT
130
+ **/
131
+ function warn$1(msg, ...args) {
132
+ console.warn(`[Vue warn] ${msg}`, ...args);
133
+ }
134
+ var activeEffectScope;
135
+ function recordEffectScope(effect, scope = activeEffectScope) {
136
+ if (scope && scope.active) scope.effects.push(effect);
137
+ }
138
+ var activeEffect;
139
+ var ReactiveEffect = class {
140
+ constructor(fn, trigger, scheduler, scope) {
141
+ this.fn = fn;
142
+ this.trigger = trigger;
143
+ this.scheduler = scheduler;
144
+ this.active = true;
145
+ this.deps = [];
146
+ /**
147
+ * @internal
148
+ */
149
+ this._dirtyLevel = 4;
150
+ /**
151
+ * @internal
152
+ */
153
+ this._trackId = 0;
154
+ /**
155
+ * @internal
156
+ */
157
+ this._runnings = 0;
158
+ /**
159
+ * @internal
160
+ */
161
+ this._shouldSchedule = false;
162
+ /**
163
+ * @internal
164
+ */
165
+ this._depsLength = 0;
166
+ recordEffectScope(this, scope);
167
+ }
168
+ get dirty() {
169
+ if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
170
+ this._dirtyLevel = 1;
171
+ pauseTracking();
172
+ for (let i = 0; i < this._depsLength; i++) {
173
+ const dep = this.deps[i];
174
+ if (dep.computed) {
175
+ triggerComputed(dep.computed);
176
+ if (this._dirtyLevel >= 4) break;
177
+ }
178
+ }
179
+ if (this._dirtyLevel === 1) this._dirtyLevel = 0;
180
+ resetTracking();
181
+ }
182
+ return this._dirtyLevel >= 4;
183
+ }
184
+ set dirty(v) {
185
+ this._dirtyLevel = v ? 4 : 0;
186
+ }
187
+ run() {
188
+ this._dirtyLevel = 0;
189
+ if (!this.active) return this.fn();
190
+ let lastShouldTrack = shouldTrack;
191
+ let lastEffect = activeEffect;
192
+ try {
193
+ shouldTrack = true;
194
+ activeEffect = this;
195
+ this._runnings++;
196
+ preCleanupEffect(this);
197
+ return this.fn();
198
+ } finally {
199
+ postCleanupEffect(this);
200
+ this._runnings--;
201
+ activeEffect = lastEffect;
202
+ shouldTrack = lastShouldTrack;
203
+ }
204
+ }
205
+ stop() {
206
+ if (this.active) {
207
+ preCleanupEffect(this);
208
+ postCleanupEffect(this);
209
+ this.onStop && this.onStop();
210
+ this.active = false;
211
+ }
212
+ }
213
+ };
214
+ function triggerComputed(computed) {
215
+ return computed.value;
216
+ }
217
+ function preCleanupEffect(effect2) {
218
+ effect2._trackId++;
219
+ effect2._depsLength = 0;
220
+ }
221
+ function postCleanupEffect(effect2) {
222
+ if (effect2.deps.length > effect2._depsLength) {
223
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) cleanupDepEffect(effect2.deps[i], effect2);
224
+ effect2.deps.length = effect2._depsLength;
225
+ }
226
+ }
227
+ function cleanupDepEffect(dep, effect2) {
228
+ const trackId = dep.get(effect2);
229
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
230
+ dep.delete(effect2);
231
+ if (dep.size === 0) dep.cleanup();
232
+ }
233
+ }
234
+ function effect$1(fn, options) {
235
+ if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn;
236
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
237
+ if (_effect.dirty) _effect.run();
238
+ });
239
+ if (options) {
240
+ extend(_effect, options);
241
+ if (options.scope) recordEffectScope(_effect, options.scope);
242
+ }
243
+ if (!options || !options.lazy) _effect.run();
244
+ const runner = _effect.run.bind(_effect);
245
+ runner.effect = _effect;
246
+ return runner;
247
+ }
248
+ function stop(runner) {
249
+ runner.effect.stop();
250
+ }
251
+ var shouldTrack = true;
252
+ var pauseScheduleStack = 0;
253
+ var trackStack = [];
254
+ function pauseTracking() {
255
+ trackStack.push(shouldTrack);
256
+ shouldTrack = false;
257
+ }
258
+ function resetTracking() {
259
+ const last = trackStack.pop();
260
+ shouldTrack = last === void 0 ? true : last;
261
+ }
262
+ function pauseScheduling() {
263
+ pauseScheduleStack++;
264
+ }
265
+ function resetScheduling() {
266
+ pauseScheduleStack--;
267
+ while (!pauseScheduleStack && queueEffectSchedulers.length) queueEffectSchedulers.shift()();
268
+ }
269
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
270
+ var _a;
271
+ if (dep.get(effect2) !== effect2._trackId) {
272
+ dep.set(effect2, effect2._trackId);
273
+ const oldDep = effect2.deps[effect2._depsLength];
274
+ if (oldDep !== dep) {
275
+ if (oldDep) cleanupDepEffect(oldDep, effect2);
276
+ effect2.deps[effect2._depsLength++] = dep;
277
+ } else effect2._depsLength++;
278
+ (_a = effect2.onTrack) == null || _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
279
+ }
280
+ }
281
+ var queueEffectSchedulers = [];
282
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
283
+ var _a;
284
+ pauseScheduling();
285
+ for (const effect2 of dep.keys()) {
286
+ let tracking;
287
+ if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
288
+ effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
289
+ effect2._dirtyLevel = dirtyLevel;
290
+ }
291
+ if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
292
+ (_a = effect2.onTrigger) == null || _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
293
+ effect2.trigger();
294
+ if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
295
+ effect2._shouldSchedule = false;
296
+ if (effect2.scheduler) queueEffectSchedulers.push(effect2.scheduler);
297
+ }
298
+ }
299
+ }
300
+ resetScheduling();
301
+ }
302
+ var createDep = (cleanup, computed) => {
303
+ const dep = /* @__PURE__ */ new Map();
304
+ dep.cleanup = cleanup;
305
+ dep.computed = computed;
306
+ return dep;
307
+ };
308
+ var targetMap = /* @__PURE__ */ new WeakMap();
309
+ var ITERATE_KEY = Symbol("iterate");
310
+ var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
311
+ function track(target, type, key) {
312
+ if (shouldTrack && activeEffect) {
313
+ let depsMap = targetMap.get(target);
314
+ if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
315
+ let dep = depsMap.get(key);
316
+ if (!dep) depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
317
+ trackEffect(activeEffect, dep, {
318
+ target,
319
+ type,
320
+ key
321
+ });
322
+ }
323
+ }
324
+ function trigger$1(target, type, key, newValue, oldValue, oldTarget) {
325
+ const depsMap = targetMap.get(target);
326
+ if (!depsMap) return;
327
+ let deps = [];
328
+ if (type === "clear") deps = [...depsMap.values()];
329
+ else if (key === "length" && isArray(target)) {
330
+ const newLength = Number(newValue);
331
+ depsMap.forEach((dep, key2) => {
332
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) deps.push(dep);
333
+ });
334
+ } else {
335
+ if (key !== void 0) deps.push(depsMap.get(key));
336
+ switch (type) {
337
+ case "add":
338
+ if (!isArray(target)) {
339
+ deps.push(depsMap.get(ITERATE_KEY));
340
+ if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
341
+ } else if (isIntegerKey(key)) deps.push(depsMap.get("length"));
342
+ break;
343
+ case "delete":
344
+ if (!isArray(target)) {
345
+ deps.push(depsMap.get(ITERATE_KEY));
346
+ if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
347
+ }
348
+ break;
349
+ case "set": if (isMap(target)) deps.push(depsMap.get(ITERATE_KEY));
350
+ }
351
+ }
352
+ pauseScheduling();
353
+ for (const dep of deps) if (dep) triggerEffects(dep, 4, {
354
+ target,
355
+ type,
356
+ key,
357
+ newValue,
358
+ oldValue,
359
+ oldTarget
360
+ });
361
+ resetScheduling();
362
+ }
363
+ var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
364
+ var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
365
+ var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
366
+ function createArrayInstrumentations() {
367
+ const instrumentations = {};
368
+ [
369
+ "includes",
370
+ "indexOf",
371
+ "lastIndexOf"
372
+ ].forEach((key) => {
373
+ instrumentations[key] = function(...args) {
374
+ const arr = toRaw(this);
375
+ for (let i = 0, l = this.length; i < l; i++) track(arr, "get", i + "");
376
+ const res = arr[key](...args);
377
+ if (res === -1 || res === false) return arr[key](...args.map(toRaw));
378
+ else return res;
379
+ };
380
+ });
381
+ [
382
+ "push",
383
+ "pop",
384
+ "shift",
385
+ "unshift",
386
+ "splice"
387
+ ].forEach((key) => {
388
+ instrumentations[key] = function(...args) {
389
+ pauseTracking();
390
+ pauseScheduling();
391
+ const res = toRaw(this)[key].apply(this, args);
392
+ resetScheduling();
393
+ resetTracking();
394
+ return res;
395
+ };
396
+ });
397
+ return instrumentations;
398
+ }
399
+ function hasOwnProperty(key) {
400
+ if (!isSymbol(key)) key = String(key);
401
+ const obj = toRaw(this);
402
+ track(obj, "has", key);
403
+ return obj.hasOwnProperty(key);
404
+ }
405
+ var BaseReactiveHandler = class {
406
+ constructor(_isReadonly = false, _isShallow = false) {
407
+ this._isReadonly = _isReadonly;
408
+ this._isShallow = _isShallow;
409
+ }
410
+ get(target, key, receiver) {
411
+ const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
412
+ if (key === "__v_isReactive") return !isReadonly2;
413
+ else if (key === "__v_isReadonly") return isReadonly2;
414
+ else if (key === "__v_isShallow") return isShallow2;
415
+ else if (key === "__v_raw") {
416
+ if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target;
417
+ return;
418
+ }
419
+ const targetIsArray = isArray(target);
420
+ if (!isReadonly2) {
421
+ if (targetIsArray && hasOwn(arrayInstrumentations, key)) return Reflect.get(arrayInstrumentations, key, receiver);
422
+ if (key === "hasOwnProperty") return hasOwnProperty;
423
+ }
424
+ const res = Reflect.get(target, key, receiver);
425
+ if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res;
426
+ if (!isReadonly2) track(target, "get", key);
427
+ if (isShallow2) return res;
428
+ if (isRef(res)) return targetIsArray && isIntegerKey(key) ? res : res.value;
429
+ if (isObject(res)) return isReadonly2 ? readonly(res) : reactive(res);
430
+ return res;
431
+ }
432
+ };
433
+ var MutableReactiveHandler = class extends BaseReactiveHandler {
434
+ constructor(isShallow2 = false) {
435
+ super(false, isShallow2);
436
+ }
437
+ set(target, key, value, receiver) {
438
+ let oldValue = target[key];
439
+ if (!this._isShallow) {
440
+ const isOldValueReadonly = isReadonly(oldValue);
441
+ if (!isShallow(value) && !isReadonly(value)) {
442
+ oldValue = toRaw(oldValue);
443
+ value = toRaw(value);
444
+ }
445
+ if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
446
+ if (isOldValueReadonly) return false;
447
+ else {
448
+ oldValue.value = value;
449
+ return true;
450
+ }
451
+ }
452
+ }
453
+ const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
454
+ const result = Reflect.set(target, key, value, receiver);
455
+ if (target === toRaw(receiver)) {
456
+ if (!hadKey) trigger$1(target, "add", key, value);
457
+ else if (hasChanged(value, oldValue)) trigger$1(target, "set", key, value, oldValue);
458
+ }
459
+ return result;
460
+ }
461
+ deleteProperty(target, key) {
462
+ const hadKey = hasOwn(target, key);
463
+ const oldValue = target[key];
464
+ const result = Reflect.deleteProperty(target, key);
465
+ if (result && hadKey) trigger$1(target, "delete", key, void 0, oldValue);
466
+ return result;
467
+ }
468
+ has(target, key) {
469
+ const result = Reflect.has(target, key);
470
+ if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key);
471
+ return result;
472
+ }
473
+ ownKeys(target) {
474
+ track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
475
+ return Reflect.ownKeys(target);
476
+ }
477
+ };
478
+ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
479
+ constructor(isShallow2 = false) {
480
+ super(true, isShallow2);
481
+ }
482
+ set(target, key) {
483
+ warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
484
+ return true;
485
+ }
486
+ deleteProperty(target, key) {
487
+ warn$1(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
488
+ return true;
489
+ }
490
+ };
491
+ var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
492
+ var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
493
+ var reactiveMap = /* @__PURE__ */ new WeakMap();
494
+ var shallowReactiveMap = /* @__PURE__ */ new WeakMap();
495
+ var readonlyMap = /* @__PURE__ */ new WeakMap();
496
+ var shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
497
+ function targetTypeMap(rawType) {
498
+ switch (rawType) {
499
+ case "Object":
500
+ case "Array": return 1;
501
+ default: return 0;
502
+ }
503
+ }
504
+ function getTargetType(value) {
505
+ return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
506
+ }
507
+ function reactive(target) {
508
+ if (isReadonly(target)) return target;
509
+ return createReactiveObject(target, false, mutableHandlers, null, reactiveMap);
510
+ }
511
+ function readonly(target) {
512
+ return createReactiveObject(target, true, readonlyHandlers, null, readonlyMap);
513
+ }
514
+ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
515
+ if (!isObject(target)) {
516
+ warn$1(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
517
+ return target;
518
+ }
519
+ if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) return target;
520
+ const existingProxy = proxyMap.get(target);
521
+ if (existingProxy) return existingProxy;
522
+ const targetType = getTargetType(target);
523
+ if (targetType === 0) return target;
524
+ const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
525
+ proxyMap.set(target, proxy);
526
+ return proxy;
527
+ }
528
+ function isReadonly(value) {
529
+ return !!(value && value["__v_isReadonly"]);
530
+ }
531
+ function isShallow(value) {
532
+ return !!(value && value["__v_isShallow"]);
533
+ }
534
+ function toRaw(observed) {
535
+ const raw = observed && observed["__v_raw"];
536
+ return raw ? toRaw(raw) : observed;
537
+ }
538
+ var COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
539
+ var ComputedRefImpl = class {
540
+ constructor(getter, _setter, isReadonly, isSSR) {
541
+ this.getter = getter;
542
+ this._setter = _setter;
543
+ this.dep = void 0;
544
+ this.__v_isRef = true;
545
+ this["__v_isReadonly"] = false;
546
+ this.effect = new ReactiveEffect(() => getter(this._value), () => triggerRefValue(this, this.effect._dirtyLevel === 2 ? 2 : 3));
547
+ this.effect.computed = this;
548
+ this.effect.active = this._cacheable = !isSSR;
549
+ this["__v_isReadonly"] = isReadonly;
550
+ }
551
+ get value() {
552
+ const self = toRaw(this);
553
+ if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) triggerRefValue(self, 4);
554
+ trackRefValue(self);
555
+ if (self.effect._dirtyLevel >= 2) {
556
+ if (this._warnRecursive) warn$1(COMPUTED_SIDE_EFFECT_WARN, `
557
+
558
+ getter: `, this.getter);
559
+ triggerRefValue(self, 2);
560
+ }
561
+ return self._value;
562
+ }
563
+ set value(newValue) {
564
+ this._setter(newValue);
565
+ }
566
+ get _dirty() {
567
+ return this.effect.dirty;
568
+ }
569
+ set _dirty(v) {
570
+ this.effect.dirty = v;
571
+ }
572
+ };
573
+ function computed(getterOrOptions, debugOptions, isSSR = false) {
574
+ let getter;
575
+ let setter;
576
+ const onlyGetter = isFunction(getterOrOptions);
577
+ if (onlyGetter) {
578
+ getter = getterOrOptions;
579
+ setter = () => {
580
+ warn$1("Write operation failed: computed value is readonly");
581
+ };
582
+ } else {
583
+ getter = getterOrOptions.get;
584
+ setter = getterOrOptions.set;
585
+ }
586
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
587
+ if (debugOptions && !isSSR) {
588
+ cRef.effect.onTrack = debugOptions.onTrack;
589
+ cRef.effect.onTrigger = debugOptions.onTrigger;
590
+ }
591
+ return cRef;
592
+ }
593
+ function trackRefValue(ref2) {
594
+ var _a;
595
+ if (shouldTrack && activeEffect) {
596
+ ref2 = toRaw(ref2);
597
+ trackEffect(activeEffect, (_a = ref2.dep) != null ? _a : ref2.dep = createDep(() => ref2.dep = void 0, ref2 instanceof ComputedRefImpl ? ref2 : void 0), {
598
+ target: ref2,
599
+ type: "get",
600
+ key: "value"
601
+ });
602
+ }
603
+ }
604
+ function triggerRefValue(ref2, dirtyLevel = 4, newVal, oldVal) {
605
+ ref2 = toRaw(ref2);
606
+ const dep = ref2.dep;
607
+ if (dep) triggerEffects(dep, dirtyLevel, {
608
+ target: ref2,
609
+ type: "set",
610
+ key: "value",
611
+ newValue: newVal,
612
+ oldValue: oldVal
613
+ });
614
+ }
615
+ function isRef(r) {
616
+ return !!(r && r.__v_isRef === true);
617
+ }
618
+ //#endregion
619
+ //#region src/magics.ts
620
+ var uid = 0;
621
+ /**
622
+ * $id('name') — unique ids for accessibility attributes. Stable within a scope
623
+ * so label/input pairs match, unique across scopes.
624
+ */
625
+ var createId = () => {
626
+ const memo = Object.create(null);
627
+ return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
628
+ };
629
+ /**
630
+ * $watch(source, callback) — watches a dot-path string or getter and calls
631
+ * back with (value, oldValue). Tied to the owning scope's effects, so it stops
632
+ * when the scope unmounts.
633
+ */
634
+ var createWatch = (ctx) => (source, cb) => {
635
+ const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
636
+ let oldValue;
637
+ let init = false;
638
+ ctx.effect(() => {
639
+ const value = getter();
640
+ const previous = oldValue;
641
+ oldValue = value;
642
+ if (init && value !== previous) {
643
+ pauseTracking();
644
+ try {
645
+ cb(value, previous);
646
+ } finally {
647
+ resetTracking();
648
+ }
649
+ }
650
+ init = true;
651
+ });
652
+ };
653
+ //#endregion
654
+ //#region src/devtools.ts
655
+ var scopes = /* @__PURE__ */ new Map();
656
+ var exps = /* @__PURE__ */ new Map();
657
+ var names = /* @__PURE__ */ new Map();
658
+ var storeMap = /* @__PURE__ */ new Map();
659
+ var componentNames = /* @__PURE__ */ new Set();
660
+ var disabled = false;
661
+ var isDisabled = () => disabled || typeof window !== "undefined" && window.__LITE_VUE_DEVTOOLS__ === false;
662
+ var listeners = {
663
+ "scope:mount": /* @__PURE__ */ new Set(),
664
+ "scope:unmount": /* @__PURE__ */ new Set(),
665
+ "store:register": /* @__PURE__ */ new Set(),
666
+ flush: /* @__PURE__ */ new Set()
667
+ };
668
+ var emit = (event, ...args) => {
669
+ listeners[event].forEach((fn) => fn(...args));
670
+ };
671
+ var noop = () => {};
672
+ var registerScope = (el, scope, exp, name) => {
673
+ if (isDisabled()) return noop;
674
+ scopes.set(el, scope);
675
+ if (exp) exps.set(el, exp);
676
+ if (name) names.set(el, name);
677
+ emit("scope:mount", el, scope);
678
+ return () => {
679
+ if (scopes.delete(el)) {
680
+ exps.delete(el);
681
+ names.delete(el);
682
+ emit("scope:unmount", el);
683
+ }
684
+ };
685
+ };
686
+ var registerStore = (name, store) => {
687
+ if (isDisabled()) return;
688
+ storeMap.set(name, store);
689
+ emit("store:register", name, store);
690
+ };
691
+ var registerComponent = (name) => {
692
+ if (!isDisabled()) componentNames.add(name);
693
+ };
694
+ var emitFlush = () => {
695
+ if (listeners.flush.size && !isDisabled()) emit("flush");
696
+ };
697
+ var devtools = {
698
+ scopes,
699
+ exps,
700
+ names,
701
+ stores: storeMap,
702
+ components: componentNames,
703
+ getScopeByName(name) {
704
+ for (const [el, n] of names) if (n === name) return scopes.get(el);
705
+ },
706
+ getScope(node) {
707
+ let el = node.nodeType === 1 ? node : node.parentElement;
708
+ while (el) {
709
+ const scope = scopes.get(el);
710
+ if (scope) return scope;
711
+ el = el.parentElement;
712
+ }
713
+ },
714
+ on(event, fn) {
715
+ listeners[event].add(fn);
716
+ return () => listeners[event].delete(fn);
717
+ },
718
+ off(event, fn) {
719
+ listeners[event].delete(fn);
720
+ }
721
+ };
722
+ /**
723
+ * Turn devtools off for production: stops scope registration, clears
724
+ * everything already registered, and removes window.__LITE_VUE__. For
725
+ * script-tag users, setting window.__LITE_VUE_DEVTOOLS__ = false before the
726
+ * library loads has the same effect.
727
+ */
728
+ var disableDevtools = () => {
729
+ disabled = true;
730
+ scopes.clear();
731
+ exps.clear();
732
+ names.clear();
733
+ storeMap.clear();
734
+ componentNames.clear();
735
+ for (const event in listeners) listeners[event].clear();
736
+ if (typeof window !== "undefined" && window.__LITE_VUE__ === devtools) delete window.__LITE_VUE__;
737
+ };
738
+ if (typeof window !== "undefined" && !isDisabled()) window.__LITE_VUE__ = devtools;
739
+ //#endregion
740
+ //#region src/errors.ts
741
+ /** Levenshtein, bounded — only used to rank candidate names in DEV. */
742
+ var distance = (a, b) => {
743
+ const m = a.length;
744
+ const n = b.length;
745
+ if (!m || !n) return m || n;
746
+ let prev = Array.from({ length: n + 1 }, (_, i) => i);
747
+ const curr = [];
748
+ for (let i = 1; i <= m; i++) {
749
+ curr[0] = i;
750
+ for (let j = 1; j <= n; j++) curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
751
+ prev = curr.slice();
752
+ }
753
+ return prev[n];
754
+ };
755
+ /** Every name in scope, up the prototype chain that nested `v-scope`s inherit. */
756
+ var scopeNames = (scope) => {
757
+ const names = /* @__PURE__ */ new Set();
758
+ let cur = scope;
759
+ while (cur && cur !== Object.prototype) {
760
+ for (const key of Object.getOwnPropertyNames(cur)) if (key !== "__v_skip" && !key.startsWith("__v_")) names.add(key);
761
+ cur = Object.getPrototypeOf(cur);
762
+ }
763
+ return [...names];
764
+ };
765
+ /** `count is not defined` → the closest name actually in scope. */
766
+ var suggestName = (err, scope) => {
767
+ if (!scope || !(err instanceof ReferenceError)) return;
768
+ const missing = /^(\w+) is not defined$/.exec(err.message)?.[1];
769
+ if (!missing) return;
770
+ const candidates = scopeNames(scope).filter((n) => !n.startsWith("$"));
771
+ let best;
772
+ let bestScore = Infinity;
773
+ for (const name of candidates) {
774
+ const d = distance(missing.toLowerCase(), name.toLowerCase());
775
+ if (d < bestScore) {
776
+ bestScore = d;
777
+ best = name;
778
+ }
779
+ }
780
+ const limit = Math.max(1, Math.floor(missing.length / 3));
781
+ return best && bestScore <= limit ? {
782
+ missing,
783
+ suggestion: best
784
+ } : { missing };
785
+ };
786
+ /** A short, recognisable rendering of the element — not its whole subtree. */
787
+ var describeEl = (el) => {
788
+ if (!el) return;
789
+ if (!(el instanceof Element)) return el.nodeType === 3 ? `text node "${el.nodeValue?.trim().slice(0, 40)}"` : void 0;
790
+ return `<${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}${el.classList.length ? `.${[...el.classList].join(".")}` : ""}>`;
791
+ };
792
+ var handlers = [];
793
+ /** Registered by `app.onError()`. Shared across apps, like the store registry. */
794
+ var addErrorHandler = (fn) => {
795
+ handlers.push(fn);
796
+ return () => {
797
+ const i = handlers.indexOf(fn);
798
+ if (i > -1) handlers.splice(i, 1);
799
+ };
800
+ };
801
+ var PHASES = {
802
+ expression: "evaluating",
803
+ handler: "handling an event in",
804
+ directive: "setting up",
805
+ compile: "compiling",
806
+ effect: "re-running an effect",
807
+ teardown: "tearing down"
808
+ };
809
+ var handleError = (err, info) => {
810
+ for (const fn of handlers) try {
811
+ fn(err, info);
812
+ } catch (inner) {
813
+ console.error("[litevue] an onError handler itself threw:", inner);
814
+ }
815
+ const where = info.source ? ` ${info.source}` : "";
816
+ const parts = [`[litevue] error ${PHASES[info.phase]}${where}`];
817
+ if (info.expression) parts.push(`\n expression: ${info.expression.trim()}`);
818
+ const el = describeEl(info.el);
819
+ if (el) parts.push(`\n element: ${el}`);
820
+ const named = suggestName(err, info.scope);
821
+ if (named?.suggestion) parts.push(`\n "${named.missing}" is not in scope — did you mean "${named.suggestion}"?`);
822
+ else if (named) {
823
+ const names = scopeNames(info.scope).filter((n) => !n.startsWith("$"));
824
+ parts.push(`\n "${named.missing}" is not in scope.` + (names.length ? ` Available: ${names.slice(0, 12).join(", ")}${names.length > 12 ? ", …" : ""}` : " This scope declares nothing — is the v-scope on the right element?"));
825
+ }
826
+ console.error(parts.join(""), "\n ", err);
827
+ if (info.el) console.error(info.el);
828
+ };
829
+ //#endregion
830
+ //#region src/scheduler.ts
831
+ /**
832
+ * Effects this library has stopped.
833
+ *
834
+ * The scheduler must know whether a queued runner is still live, and
835
+ * @vue/reactivity offers no supported way to ask: 3.4's `ReactiveEffect.active`
836
+ * became an undeclared `flags` bitfield in 3.5. Since every stop here goes
837
+ * through `stopEffect`, tracking them ourselves is version-proof. Weak, so a
838
+ * stopped effect stays collectable.
839
+ */
840
+ var stopped = /* @__PURE__ */ new WeakSet();
841
+ /** Stops an effect and remembers that it is stopped. Use instead of `stop`. */
842
+ var stopEffect = (runner) => {
843
+ stopped.add(runner);
844
+ stop(runner);
845
+ };
846
+ var queued = false;
847
+ var queue = [];
848
+ var p = Promise.resolve();
849
+ var nextTick = (fn) => p.then(fn);
850
+ var queueJob = (job) => {
851
+ if (!queue.includes(job)) queue.push(job);
852
+ if (!queued) {
853
+ queued = true;
854
+ nextTick(flushJobs);
855
+ }
856
+ };
857
+ var flushJobs = () => {
858
+ for (const job of queue) {
859
+ if (stopped.has(job)) continue;
860
+ try {
861
+ job();
862
+ } catch (e) {
863
+ handleError(e, { phase: "effect" });
864
+ }
865
+ }
866
+ queue.length = 0;
867
+ queued = false;
868
+ emitFlush();
869
+ };
870
+ //#endregion
871
+ //#region src/directives/bind.ts
872
+ var forceAttrRE = /^(spellcheck|draggable|form|list|type)$/;
873
+ var bind = ({ el, get, effect, arg, modifiers }) => {
874
+ let prevValue;
875
+ if (arg === "class") el._class = el.className;
876
+ effect(() => {
877
+ let value = get();
878
+ if (arg) {
879
+ if (modifiers?.camel) arg = camelize(arg);
880
+ setProp(el, arg, value, prevValue);
881
+ } else {
882
+ for (const key in value) setProp(el, key, value[key], prevValue && prevValue[key]);
883
+ for (const key in prevValue) if (!value || !(key in value)) setProp(el, key, null);
884
+ }
885
+ prevValue = value;
886
+ });
887
+ };
888
+ var setProp = (el, key, value, prevValue) => {
889
+ if (key === "class") el.setAttribute("class", normalizeClass(el._class ? [el._class, value] : value) || "");
890
+ else if (key === "style") {
891
+ value = normalizeStyle(value);
892
+ const { style } = el;
893
+ if (!value) el.removeAttribute("style");
894
+ else if (isString(value)) {
895
+ if (value !== prevValue) style.cssText = value;
896
+ } else {
897
+ for (const key in value) setStyle(style, key, value[key]);
898
+ if (prevValue && !isString(prevValue)) {
899
+ for (const key in prevValue) if (value[key] == null) setStyle(style, key, "");
900
+ }
901
+ }
902
+ } else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key)) {
903
+ el[key] = value;
904
+ if (key === "value") el._value = value;
905
+ } else if (key === "true-value") el._trueValue = value;
906
+ else if (key === "false-value") el._falseValue = value;
907
+ else if (value != null) el.setAttribute(key, value);
908
+ else el.removeAttribute(key);
909
+ };
910
+ var importantRE = /\s*!important$/;
911
+ var setStyle = (style, name, val) => {
912
+ if (isArray(val)) val.forEach((v) => setStyle(style, name, v));
913
+ else if (name.startsWith("--")) style.setProperty(name, val);
914
+ else if (importantRE.test(val)) style.setProperty(hyphenate(name), val.replace(importantRE, ""), "important");
915
+ else style[name] = val;
916
+ };
917
+ //#endregion
918
+ //#region src/warn.ts
919
+ /**
920
+ * Development warnings.
921
+ *
922
+ * Every call site is guarded by `import.meta.env.DEV`; the production build
923
+ * replaces that constant and terser drops the branch, so neither these
924
+ * functions nor their strings ship. Messages are therefore free to be wordy —
925
+ * say what to do instead.
926
+ */
927
+ var seen = /* @__PURE__ */ new Set();
928
+ var warn = (msg) => {
929
+ console.warn(`[litevue] ${msg}`);
930
+ };
931
+ /**
932
+ * Warns once per `key`. Most callers are effects, which re-run on every
933
+ * relevant change — one mistake would otherwise print on every keystroke.
934
+ */
935
+ var warnOnce = (key, msg) => {
936
+ if (seen.has(key)) return;
937
+ seen.add(key);
938
+ warn(msg);
939
+ };
940
+ //#endregion
941
+ //#region src/directives/on.ts
942
+ /**
943
+ * Can `exp` stand as a single expression, or is it a statement list?
944
+ * Memoised: it compiles a throwaway function, which a `v-for` pays per row.
945
+ */
946
+ var expressionCache = Object.create(null);
947
+ var isExpression = (exp) => {
948
+ const hit = expressionCache[exp];
949
+ if (hit !== void 0) return hit;
950
+ try {
951
+ new Function(`return (${exp})`);
952
+ return expressionCache[exp] = true;
953
+ } catch {
954
+ return expressionCache[exp] = false;
955
+ }
956
+ };
957
+ var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
958
+ var systemModifiers = [
959
+ "ctrl",
960
+ "shift",
961
+ "alt",
962
+ "meta"
963
+ ];
964
+ var modifierGuards = {
965
+ stop: (e) => e.stopPropagation(),
966
+ prevent: (e) => e.preventDefault(),
967
+ self: (e) => e.target !== e.currentTarget,
968
+ ctrl: (e) => !e.ctrlKey,
969
+ shift: (e) => !e.shiftKey,
970
+ alt: (e) => !e.altKey,
971
+ meta: (e) => !e.metaKey,
972
+ left: (e) => "button" in e && e.button !== 0,
973
+ middle: (e) => "button" in e && e.button !== 1,
974
+ right: (e) => "button" in e && e.button !== 2,
975
+ exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers[m])
976
+ };
977
+ var keyAliases = {
978
+ esc: "escape",
979
+ space: " ",
980
+ up: "arrow-up",
981
+ down: "arrow-down",
982
+ left: "arrow-left",
983
+ right: "arrow-right",
984
+ delete: "backspace"
985
+ };
986
+ var nonKeyModifierRE = /^(stop|prevent|self|ctrl|shift|alt|meta|left|middle|right|exact|once|capture|passive|window|document|outside|debounce(-\d+)?|throttle(-\d+)?|prop-.+|name-.+)$/;
987
+ var on = ({ el, get, ctx, exp, arg, modifiers }) => {
988
+ if (!arg) {
989
+ console.error(`v-on="obj" syntax is not supported in LiteVue.`);
990
+ return;
991
+ }
992
+ const raw = simplePathRE.test(exp) ? get(`(e => ${exp}(e))`) : isExpression(exp) ? get(`($event => (${exp}))`) : get(`($event => { ${exp} })`);
993
+ let handler = (...args) => {
994
+ try {
995
+ const result = raw(...args);
996
+ if (result instanceof Promise) result.catch(fail);
997
+ return result;
998
+ } catch (e) {
999
+ fail(e);
1000
+ }
1001
+ };
1002
+ function fail(e) {
1003
+ handleError(e, {
1004
+ phase: "handler",
1005
+ source: `@${arg}`,
1006
+ expression: exp,
1007
+ el,
1008
+ scope: ctx.scope
1009
+ });
1010
+ }
1011
+ if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
1012
+ if (arg === "mounted" || arg === "vue:mounted") {
1013
+ let live = true;
1014
+ nextTick(() => {
1015
+ if (live) handler();
1016
+ });
1017
+ return () => {
1018
+ live = false;
1019
+ };
1020
+ } else if (arg === "unmounted" || arg === "vue:unmounted") return () => handler();
1021
+ let debounceTimer;
1022
+ if (modifiers) {
1023
+ if (arg === "click") {
1024
+ if (modifiers.right) arg = "contextmenu";
1025
+ if (modifiers.middle) arg = "mouseup";
1026
+ }
1027
+ let invoke = handler;
1028
+ for (const key in modifiers) {
1029
+ let m = /^debounce(?:-(\d+))?$/.exec(key);
1030
+ if (m) {
1031
+ const fn = invoke;
1032
+ const ms = m[1] ? +m[1] : 250;
1033
+ invoke = (e) => {
1034
+ clearTimeout(debounceTimer);
1035
+ debounceTimer = setTimeout(fn, ms, e);
1036
+ };
1037
+ continue;
1038
+ }
1039
+ m = /^throttle(?:-(\d+))?$/.exec(key);
1040
+ if (m) {
1041
+ const fn = invoke;
1042
+ const ms = m[1] ? +m[1] : 250;
1043
+ let last = 0;
1044
+ invoke = (e) => {
1045
+ const now = Date.now();
1046
+ if (now - last >= ms) {
1047
+ last = now;
1048
+ fn(e);
1049
+ }
1050
+ };
1051
+ }
1052
+ }
1053
+ const keyFilter = Object.keys(modifiers).filter((k) => !nonKeyModifierRE.test(k) || k in keyAliases);
1054
+ if (!arg.startsWith("key")) for (const k of keyFilter) {
1055
+ if (k in keyAliases) continue;
1056
+ const ms = /^(\d+)ms$/.exec(k);
1057
+ warnOnce(`modifier:${arg}.${k}`, `@${arg}.${k}: .${k} is not a modifier LiteVue knows, so it is ignored.` + (ms ? ` Timings are written with a dash — .debounce-${ms[1]} or .throttle-${ms[1]}.` : ` Key names only filter keyboard events.`));
1058
+ }
1059
+ handler = (e) => {
1060
+ if (modifiers.outside && el.contains(e.target)) return;
1061
+ if ("key" in e && keyFilter.length) {
1062
+ const key = hyphenate(e.key);
1063
+ if (!keyFilter.some((k) => k === key || keyAliases[k] === key)) return;
1064
+ }
1065
+ for (const key in modifiers) {
1066
+ const guard = modifierGuards[key];
1067
+ if (guard && guard(e, modifiers)) return;
1068
+ if (key.startsWith("prop-") && "propertyName" in e && e.propertyName !== key.slice(5)) return;
1069
+ if (key.startsWith("name-") && "animationName" in e && e.animationName !== key.slice(5)) return;
1070
+ }
1071
+ return invoke(e);
1072
+ };
1073
+ }
1074
+ const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
1075
+ const event = arg;
1076
+ target.addEventListener(event, handler, modifiers);
1077
+ return () => {
1078
+ clearTimeout(debounceTimer);
1079
+ target.removeEventListener(event, handler, modifiers);
1080
+ };
1081
+ };
1082
+ //#endregion
1083
+ //#region src/directives/show.ts
1084
+ var show = ({ el, get, effect }) => {
1085
+ const initialDisplay = el.style.display;
1086
+ effect(() => {
1087
+ el.style.display = get() ? initialDisplay : "none";
1088
+ });
1089
+ };
1090
+ //#endregion
1091
+ //#region src/directives/text.ts
1092
+ var text = ({ el, get, effect }) => {
1093
+ effect(() => {
1094
+ el.textContent = toDisplayString(get());
1095
+ });
1096
+ };
1097
+ var toDisplayString = (value) => value == null ? "" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);
1098
+ //#endregion
1099
+ //#region src/directives/html.ts
1100
+ var html = ({ el, get, effect }) => {
1101
+ effect(() => {
1102
+ el.innerHTML = get();
1103
+ });
1104
+ };
1105
+ //#endregion
1106
+ //#region src/utils.ts
1107
+ var checkAttr = (el, name) => {
1108
+ const val = el.getAttribute(name);
1109
+ if (val != null) el.removeAttribute(name);
1110
+ return val;
1111
+ };
1112
+ /**
1113
+ * Adds a listener and returns a remover. Callers are expected to use it:
1114
+ * `app.unmount(el)` leaves elements in the document, so a listener left behind
1115
+ * would keep driving markup meant to be inert.
1116
+ */
1117
+ var listen = (el, event, handler, options) => {
1118
+ el.addEventListener(event, handler, options);
1119
+ return () => el.removeEventListener(event, handler, options);
1120
+ };
1121
+ //#endregion
1122
+ //#region src/directives/model.ts
1123
+ var model = ({ el, exp, get, effect, modifiers }) => {
1124
+ const type = el.type;
1125
+ const assign = get(`(val) => { ${exp} = val }`);
1126
+ const { trim, number = type === "number", lazy, fill } = modifiers || {};
1127
+ const off = [];
1128
+ const on = (event, handler) => off.push(listen(el, event, handler));
1129
+ if (el.tagName === "SELECT") {
1130
+ const sel = el;
1131
+ on("change", () => {
1132
+ const selectedVal = Array.prototype.filter.call(sel.options, (o) => o.selected).map((o) => number ? toNumber(getValue(o)) : getValue(o));
1133
+ assign(sel.multiple ? selectedVal : selectedVal[0]);
1134
+ });
1135
+ effect(() => {
1136
+ const value = get();
1137
+ const isMultiple = sel.multiple;
1138
+ for (let i = 0, l = sel.options.length; i < l; i++) {
1139
+ const option = sel.options[i];
1140
+ const optionValue = getValue(option);
1141
+ if (isMultiple) {
1142
+ if (isArray(value)) option.selected = looseIndexOf(value, optionValue) > -1;
1143
+ else option.selected = value.has(optionValue);
1144
+ } else if (looseEqual(getValue(option), value)) {
1145
+ if (sel.selectedIndex !== i) sel.selectedIndex = i;
1146
+ return;
1147
+ }
1148
+ }
1149
+ if (!isMultiple && sel.selectedIndex !== -1) sel.selectedIndex = -1;
1150
+ });
1151
+ } else if (type === "checkbox") {
1152
+ on("change", () => {
1153
+ const modelValue = get();
1154
+ const checked = el.checked;
1155
+ if (isArray(modelValue)) {
1156
+ const elementValue = getValue(el);
1157
+ const index = looseIndexOf(modelValue, elementValue);
1158
+ const found = index !== -1;
1159
+ if (checked && !found) assign(modelValue.concat(elementValue));
1160
+ else if (!checked && found) {
1161
+ const filtered = [...modelValue];
1162
+ filtered.splice(index, 1);
1163
+ assign(filtered);
1164
+ }
1165
+ } else assign(getCheckboxValue(el, checked));
1166
+ });
1167
+ effect(() => {
1168
+ const value = get();
1169
+ if (isArray(value)) el.checked = looseIndexOf(value, getValue(el)) > -1;
1170
+ else el.checked = looseEqual(value, getCheckboxValue(el, true));
1171
+ });
1172
+ } else if (type === "radio") {
1173
+ on("change", () => {
1174
+ assign(getValue(el));
1175
+ });
1176
+ effect(() => {
1177
+ el.checked = looseEqual(get(), getValue(el));
1178
+ });
1179
+ } else {
1180
+ const resolveValue = (val) => {
1181
+ if (trim) return val.trim();
1182
+ if (number) return toNumber(val);
1183
+ return val;
1184
+ };
1185
+ let write = assign;
1186
+ let debounceTimer;
1187
+ for (const key in modifiers || {}) {
1188
+ const m = /^debounce(?:-(\d+))?$/.exec(key);
1189
+ if (m) {
1190
+ const ms = m[1] ? +m[1] : 250;
1191
+ write = (val) => {
1192
+ clearTimeout(debounceTimer);
1193
+ debounceTimer = setTimeout(assign, ms, val);
1194
+ };
1195
+ off.push(() => clearTimeout(debounceTimer));
1196
+ }
1197
+ }
1198
+ on("compositionstart", onCompositionStart);
1199
+ on("compositionend", onCompositionEnd);
1200
+ on(lazy ? "change" : "input", () => {
1201
+ if (el.composing) return;
1202
+ write(resolveValue(el.value));
1203
+ });
1204
+ if (trim) on("change", () => {
1205
+ el.value = el.value.trim();
1206
+ });
1207
+ if (fill) {
1208
+ const cur = get();
1209
+ if ((cur == null || cur === "") && el.value) assign(resolveValue(el.value));
1210
+ }
1211
+ effect(() => {
1212
+ if (el.composing) return;
1213
+ const curVal = el.value;
1214
+ const newVal = get();
1215
+ if (document.activeElement === el && resolveValue(curVal) === newVal) return;
1216
+ if (curVal !== newVal) el.value = newVal;
1217
+ });
1218
+ }
1219
+ return () => off.forEach((remove) => remove());
1220
+ };
1221
+ var getValue = (el) => "_value" in el ? el._value : el.value;
1222
+ var getCheckboxValue = (el, checked) => {
1223
+ const key = checked ? "_trueValue" : "_falseValue";
1224
+ return key in el ? el[key] : checked;
1225
+ };
1226
+ var onCompositionStart = (e) => {
1227
+ e.target.composing = true;
1228
+ };
1229
+ var onCompositionEnd = (e) => {
1230
+ const target = e.target;
1231
+ if (target.composing) {
1232
+ target.composing = false;
1233
+ trigger(target, "input");
1234
+ }
1235
+ };
1236
+ var trigger = (el, type) => {
1237
+ const e = document.createEvent("HTMLEvents");
1238
+ e.initEvent(type, true, true);
1239
+ el.dispatchEvent(e);
1240
+ };
1241
+ //#endregion
1242
+ //#region src/eval.ts
1243
+ var evalCache = Object.create(null);
1244
+ var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
1245
+ detail,
1246
+ bubbles: true
1247
+ }));
1248
+ var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
1249
+ var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
1250
+ var execute = (scope, exp, el, meta) => {
1251
+ const fn = evalCache[exp] || (evalCache[exp] = toFunction(exp, el, meta));
1252
+ try {
1253
+ return fn(scope, el, el && mkDispatch(el));
1254
+ } catch (e) {
1255
+ handleError(e, {
1256
+ phase: "expression",
1257
+ expression: meta?.expression ?? unwrap(exp),
1258
+ source: meta?.source,
1259
+ el: meta?.el ?? el,
1260
+ scope
1261
+ });
1262
+ }
1263
+ };
1264
+ var toFunction = (exp, el, meta) => {
1265
+ try {
1266
+ return new Function(`$data`, `$el`, `$dispatch`, `with($data){${exp}}`);
1267
+ } catch (e) {
1268
+ handleError(e, {
1269
+ phase: "compile",
1270
+ expression: meta?.expression ?? unwrap(exp),
1271
+ source: meta?.source,
1272
+ el: meta?.el ?? el
1273
+ });
1274
+ return () => {};
1275
+ }
1276
+ };
1277
+ //#endregion
1278
+ //#region src/ownership.ts
1279
+ var owned = /* @__PURE__ */ new WeakMap();
1280
+ /**
1281
+ * The node currently being walked. A module-level cursor suffices because the
1282
+ * walk is synchronous and depth-first, and it keeps `owner` out of every
1283
+ * directive signature.
1284
+ */
1285
+ var owner;
1286
+ var setOwner = (node) => {
1287
+ const previous = owner;
1288
+ owner = node;
1289
+ return previous;
1290
+ };
1291
+ /**
1292
+ * Registers a disposer against `node`, defaulting to the node being walked.
1293
+ * Pass `node` explicitly for a directive that outlives its element: `v-if` and
1294
+ * `v-for` detach the template and render from an anchor, so they must own to
1295
+ * the anchor.
1296
+ */
1297
+ var own = (dispose, node = owner) => {
1298
+ if (!node) return;
1299
+ const list = owned.get(node);
1300
+ if (list) list.push(dispose);
1301
+ else owned.set(node, [dispose]);
1302
+ };
1303
+ /**
1304
+ * Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
1305
+ * the record is dropped as it runs.
1306
+ */
1307
+ var disposeSubtree = (node) => {
1308
+ const list = owned.get(node);
1309
+ if (list) {
1310
+ owned.delete(node);
1311
+ for (const fn of list) fn();
1312
+ }
1313
+ let child = node.firstChild;
1314
+ while (child) {
1315
+ const next = child.nextSibling;
1316
+ disposeSubtree(child);
1317
+ child = next;
1318
+ }
1319
+ };
1320
+ //#endregion
1321
+ //#region src/directives/effect.ts
1322
+ var effect = ({ el, ctx, exp, effect }) => {
1323
+ let live = true;
1324
+ nextTick(() => {
1325
+ if (!live) return;
1326
+ const previous = setOwner(el);
1327
+ try {
1328
+ effect(() => execute(ctx.scope, exp, el, {
1329
+ source: "v-effect",
1330
+ el
1331
+ }));
1332
+ } finally {
1333
+ setOwner(previous);
1334
+ }
1335
+ });
1336
+ return () => {
1337
+ live = false;
1338
+ };
1339
+ };
1340
+ //#endregion
1341
+ //#region src/directives/index.ts
1342
+ var builtInDirectives = {
1343
+ bind,
1344
+ on,
1345
+ show,
1346
+ text,
1347
+ html,
1348
+ model,
1349
+ effect
1350
+ };
1351
+ //#endregion
1352
+ //#region src/directives/if.ts
1353
+ var _if = (el, exp, ctx) => {
1354
+ if (!exp.trim()) console.warn(`v-if expression cannot be empty.`);
1355
+ const parent = el.parentElement;
1356
+ const anchor = new Comment("v-if");
1357
+ parent.insertBefore(anchor, el);
1358
+ const branches = [{
1359
+ exp,
1360
+ el
1361
+ }];
1362
+ let elseEl;
1363
+ let elseExp;
1364
+ while (elseEl = el.nextElementSibling) {
1365
+ elseExp = null;
1366
+ if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if"))) {
1367
+ parent.removeChild(elseEl);
1368
+ branches.push({
1369
+ exp: elseExp,
1370
+ el: elseEl
1371
+ });
1372
+ } else break;
1373
+ }
1374
+ const nextNode = el.nextSibling;
1375
+ parent.removeChild(el);
1376
+ setOwner(anchor);
1377
+ let block;
1378
+ let activeBranchIndex = -1;
1379
+ const removeActiveBlock = () => {
1380
+ if (block) {
1381
+ if (block.el.parentNode === parent) parent.insertBefore(anchor, block.el);
1382
+ block.remove();
1383
+ block = void 0;
1384
+ }
1385
+ };
1386
+ let branchEffect;
1387
+ const stopBranches = () => stopEffect(branchEffect);
1388
+ branchEffect = ctx.effect(() => {
1389
+ for (let i = 0; i < branches.length; i++) {
1390
+ const { exp, el } = branches[i];
1391
+ if (!exp || evaluate(ctx.scope, exp, el, {
1392
+ source: "v-if",
1393
+ el
1394
+ })) {
1395
+ if (i !== activeBranchIndex) {
1396
+ removeActiveBlock();
1397
+ block = new Block(el, ctx);
1398
+ block.insert(parent, anchor);
1399
+ own(stopBranches, block.el);
1400
+ if (block.el.parentNode === parent) parent.removeChild(anchor);
1401
+ activeBranchIndex = i;
1402
+ }
1403
+ return;
1404
+ }
1405
+ }
1406
+ activeBranchIndex = -1;
1407
+ removeActiveBlock();
1408
+ });
1409
+ own(stopBranches, anchor);
1410
+ return nextNode;
1411
+ };
1412
+ //#endregion
1413
+ //#region src/directives/for.ts
1414
+ var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
1415
+ var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
1416
+ var stripParensRE = /^\(|\)$/g;
1417
+ var destructureRE = /^[{[]\s*((?:[\w_$]+\s*,?\s*)+)[\]}]$/;
1418
+ var _for = (el, exp, ctx) => {
1419
+ const inMatch = exp.match(forAliasRE);
1420
+ if (!inMatch) {
1421
+ console.warn(`invalid v-for expression: ${exp}`);
1422
+ return;
1423
+ }
1424
+ const nextNode = el.nextSibling;
1425
+ const parent = el.parentElement;
1426
+ const anchor = new Text("");
1427
+ parent.insertBefore(anchor, el);
1428
+ parent.removeChild(el);
1429
+ setOwner(anchor);
1430
+ const sourceExp = inMatch[2].trim();
1431
+ let valueExp = inMatch[1].trim().replace(stripParensRE, "").trim();
1432
+ let destructureBindings;
1433
+ let isArrayDestructure = false;
1434
+ let indexExp;
1435
+ let objIndexExp;
1436
+ let keyAttr = "key";
1437
+ let keyExp = el.getAttribute(keyAttr) || el.getAttribute(keyAttr = ":key") || el.getAttribute(keyAttr = "v-bind:key");
1438
+ if (keyExp) {
1439
+ el.removeAttribute(keyAttr);
1440
+ if (keyAttr === "key") keyExp = JSON.stringify(keyExp);
1441
+ }
1442
+ let match;
1443
+ if (match = valueExp.match(forIteratorRE)) {
1444
+ valueExp = valueExp.replace(forIteratorRE, "").trim();
1445
+ indexExp = match[1].trim();
1446
+ if (match[2]) objIndexExp = match[2].trim();
1447
+ }
1448
+ if (match = valueExp.match(destructureRE)) {
1449
+ destructureBindings = match[1].split(",").map((s) => s.trim());
1450
+ isArrayDestructure = valueExp[0] === "[";
1451
+ }
1452
+ let mounted = false;
1453
+ let blocks;
1454
+ let childCtxs;
1455
+ let keyToIndexMap;
1456
+ const createChildContexts = (source) => {
1457
+ const map = /* @__PURE__ */ new Map();
1458
+ const ctxs = [];
1459
+ if (isArray(source)) for (let i = 0; i < source.length; i++) ctxs.push(createChildContext(map, source[i], i));
1460
+ else if (typeof source === "number") for (let i = 0; i < source; i++) ctxs.push(createChildContext(map, i + 1, i));
1461
+ else if (isObject(source)) {
1462
+ let i = 0;
1463
+ for (const key in source) ctxs.push(createChildContext(map, source[key], i++, key));
1464
+ }
1465
+ return [ctxs, map];
1466
+ };
1467
+ const createChildContext = (map, value, index, objKey) => {
1468
+ const data = {};
1469
+ if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
1470
+ else data[valueExp] = value;
1471
+ if (objKey) {
1472
+ indexExp && (data[indexExp] = objKey);
1473
+ objIndexExp && (data[objIndexExp] = index);
1474
+ } else indexExp && (data[indexExp] = index);
1475
+ const childCtx = createScopedContext(ctx, data);
1476
+ const key = keyExp ? evaluate(childCtx.scope, keyExp, el, {
1477
+ source: ":key",
1478
+ el
1479
+ }) : index;
1480
+ map.set(key, index);
1481
+ childCtx.key = key;
1482
+ return childCtx;
1483
+ };
1484
+ const mountBlock = (ctx, ref) => {
1485
+ const block = new Block(el, ctx);
1486
+ block.key = ctx.key;
1487
+ block.insert(parent, ref);
1488
+ return block;
1489
+ };
1490
+ let prevItems;
1491
+ ctx.effect(() => {
1492
+ const source = evaluate(ctx.scope, sourceExp, el, {
1493
+ source: "v-for",
1494
+ el
1495
+ });
1496
+ const prevKeyToIndexMap = keyToIndexMap;
1497
+ [childCtxs, keyToIndexMap] = createChildContexts(source);
1498
+ if (keyToIndexMap.size !== childCtxs.length) {
1499
+ const counts = /* @__PURE__ */ new Map();
1500
+ let dup;
1501
+ for (const child of childCtxs) {
1502
+ const n = (counts.get(child.key) || 0) + 1;
1503
+ counts.set(child.key, n);
1504
+ if (n > 1 && dup === void 0) dup = child.key;
1505
+ }
1506
+ warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, one item's element and its scope state are silently dropped. Key by something stable and unique, such as a record id.`);
1507
+ }
1508
+ if (!keyExp && isArray(source)) {
1509
+ const items = [...source];
1510
+ if (prevItems) {
1511
+ if (items.some((item, i) => {
1512
+ const was = prevItems.indexOf(item);
1513
+ return was > -1 && was !== i;
1514
+ })) warnOnce(`for-no-key:${exp}`, `v-for="${exp}" has no :key and its items were reordered. Without a key the list reconciles by position, so elements are reused for different items — losing focus, cursor position, scroll offset and any state held on those nodes. Add :key with a value that identifies the item.`);
1515
+ }
1516
+ prevItems = items;
1517
+ }
1518
+ if (!mounted) {
1519
+ blocks = childCtxs.map((s) => mountBlock(s, anchor));
1520
+ mounted = true;
1521
+ } else {
1522
+ for (let i = 0; i < blocks.length; i++) if (!keyToIndexMap.has(blocks[i].key)) blocks[i].remove();
1523
+ const nextBlocks = [];
1524
+ let i = childCtxs.length;
1525
+ let nextBlock;
1526
+ let prevMovedBlock;
1527
+ while (i--) {
1528
+ const childCtx = childCtxs[i];
1529
+ const oldIndex = prevKeyToIndexMap.get(childCtx.key);
1530
+ let block;
1531
+ if (oldIndex == null) block = mountBlock(childCtx, nextBlock ? nextBlock.el : anchor);
1532
+ else {
1533
+ block = blocks[oldIndex];
1534
+ Object.assign(block.ctx.scope, childCtx.scope);
1535
+ if (oldIndex !== i) {
1536
+ if (blocks[oldIndex + 1] !== nextBlock || prevMovedBlock === nextBlock) {
1537
+ prevMovedBlock = block;
1538
+ block.insert(parent, nextBlock ? nextBlock.el : anchor);
1539
+ }
1540
+ }
1541
+ }
1542
+ nextBlocks.unshift(nextBlock = block);
1543
+ }
1544
+ blocks = nextBlocks;
1545
+ }
1546
+ });
1547
+ return nextNode;
1548
+ };
1549
+ //#endregion
1550
+ //#region src/directives/ref.ts
1551
+ var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
1552
+ let prevRef;
1553
+ effect(() => {
1554
+ const ref = get();
1555
+ {
1556
+ const existing = $refs[ref];
1557
+ if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name, or key off the item inside v-for rather than using a ref.`);
1558
+ }
1559
+ $refs[ref] = el;
1560
+ if (prevRef && ref !== prevRef) delete $refs[prevRef];
1561
+ prevRef = ref;
1562
+ });
1563
+ return () => {
1564
+ prevRef && delete $refs[prevRef];
1565
+ };
1566
+ };
1567
+ //#endregion
1568
+ //#region src/walk.ts
1569
+ var dirRE = /^(?:v-|:|@)/;
1570
+ var modifierRE = /\.([\w-]+)/g;
1571
+ var inOnce = false;
1572
+ /**
1573
+ * Registers a cleanup on both owners: the context, for whole-region teardown,
1574
+ * and the walked node, for a subtree detached on its own. Dropping the entry
1575
+ * when the node goes keeps a re-mounted region from accumulating spent ones.
1576
+ *
1577
+ * The `indexOf` guard also makes this run-once. A subtree can reach the same
1578
+ * cleanup twice — via the block root, whose teardown drains `ctx.cleanups`,
1579
+ * and via the node — and a second run would remove a listener the next mount
1580
+ * installed.
1581
+ */
1582
+ var addCleanup = (ctx, cleanup) => {
1583
+ ctx.cleanups.push(cleanup);
1584
+ own(() => {
1585
+ const i = ctx.cleanups.indexOf(cleanup);
1586
+ if (i > -1) {
1587
+ ctx.cleanups.splice(i, 1);
1588
+ cleanup();
1589
+ }
1590
+ });
1591
+ };
1592
+ var walk = (node, ctx) => {
1593
+ const previousOwner = setOwner(node);
1594
+ try {
1595
+ return walkNode(node, ctx);
1596
+ } finally {
1597
+ setOwner(previousOwner);
1598
+ }
1599
+ };
1600
+ var walkNode = (node, ctx) => {
1601
+ const type = node.nodeType;
1602
+ if (type === 1) {
1603
+ const el = node;
1604
+ if (el.hasAttribute("v-pre")) return;
1605
+ checkAttr(el, "v-cloak");
1606
+ let exp;
1607
+ if (exp = checkAttr(el, "v-if")) return _if(el, exp, ctx);
1608
+ if (exp = checkAttr(el, "v-for")) return _for(el, exp, ctx);
1609
+ const name = checkAttr(el, "v-name");
1610
+ let teleportNext;
1611
+ if (exp = checkAttr(el, "v-teleport")) {
1612
+ const target = document.querySelector(exp);
1613
+ if (target) {
1614
+ teleportNext = el.nextSibling;
1615
+ el.__teleported = true;
1616
+ target.appendChild(el);
1617
+ ctx.cleanups.push(() => el.remove());
1618
+ } else console.error(`v-teleport target "${exp}" not found.`);
1619
+ }
1620
+ if ((exp = checkAttr(el, "v-scope")) || exp === "") {
1621
+ const scope = (exp ? evaluate(ctx.scope, exp, el, {
1622
+ source: "v-scope",
1623
+ el
1624
+ }) : {}) || {};
1625
+ ctx = createScopedContext(ctx, scope);
1626
+ el.__ctx = ctx;
1627
+ addCleanup(ctx, registerScope(el, ctx.scope, exp || void 0, name || void 0));
1628
+ if (scope.$template) resolveTemplate(el, scope.$template);
1629
+ }
1630
+ const hasVOnce = checkAttr(el, "v-once") != null;
1631
+ if (hasVOnce) inOnce = true;
1632
+ if (exp = checkAttr(el, "ref")) applyDirective(el, ref, `"${exp}"`, ctx);
1633
+ walkChildren(el, ctx);
1634
+ const deferred = [];
1635
+ for (const { name, value } of [...el.attributes]) if (dirRE.test(name) && name !== "v-cloak") {
1636
+ if (name === "v-model" || name.startsWith("v-model.")) deferred.unshift([name, value]);
1637
+ else if (name[0] === "@" || /^v-on\b/.test(name)) deferred.push([name, value]);
1638
+ else processDirective(el, name, value, ctx);
1639
+ }
1640
+ for (const [name, value] of deferred) processDirective(el, name, value, ctx);
1641
+ if (hasVOnce) inOnce = false;
1642
+ return teleportNext;
1643
+ } else if (type === 3) {
1644
+ const data = node.data;
1645
+ if (data.includes(ctx.delimiters[0])) {
1646
+ let segments = [];
1647
+ let lastIndex = 0;
1648
+ let match;
1649
+ while (match = ctx.delimitersRE.exec(data)) {
1650
+ const leading = data.slice(lastIndex, match.index);
1651
+ if (leading) segments.push(JSON.stringify(leading));
1652
+ segments.push(`$s(${match[1]})`);
1653
+ lastIndex = match.index + match[0].length;
1654
+ }
1655
+ if (lastIndex < data.length) segments.push(JSON.stringify(data.slice(lastIndex)));
1656
+ applyDirective(node, text, segments.join("+"), ctx, void 0, void 0, "{{ }}", data.trim());
1657
+ }
1658
+ } else if (type === 11) walkChildren(node, ctx);
1659
+ };
1660
+ var walkChildren = (node, ctx) => {
1661
+ let child = node.firstChild;
1662
+ while (child) child = walk(child, ctx) || child.nextSibling;
1663
+ };
1664
+ var processDirective = (el, raw, exp, ctx) => {
1665
+ let dir;
1666
+ let arg;
1667
+ let modifiers;
1668
+ const source = raw;
1669
+ raw = raw.replace(modifierRE, (_, m) => {
1670
+ (modifiers || (modifiers = {}))[m] = true;
1671
+ return "";
1672
+ });
1673
+ if (raw[0] === ":") {
1674
+ dir = bind;
1675
+ arg = raw.slice(1);
1676
+ } else if (raw[0] === "@") {
1677
+ dir = on;
1678
+ arg = raw.slice(1);
1679
+ } else {
1680
+ const argIndex = raw.indexOf(":");
1681
+ const dirName = argIndex > 0 ? raw.slice(2, argIndex) : raw.slice(2);
1682
+ dir = builtInDirectives[dirName] || ctx.dirs[dirName];
1683
+ arg = argIndex > 0 ? raw.slice(argIndex + 1) : void 0;
1684
+ }
1685
+ if (dir) {
1686
+ if (dir === bind && arg === "ref") dir = ref;
1687
+ applyDirective(el, dir, exp, ctx, arg, modifiers, source);
1688
+ el.removeAttribute(source);
1689
+ } else {
1690
+ const known = [
1691
+ "v-scope",
1692
+ "v-if",
1693
+ "v-for",
1694
+ "v-once",
1695
+ "v-pre",
1696
+ "v-cloak",
1697
+ "v-teleport",
1698
+ "v-name",
1699
+ "ref",
1700
+ ...Object.keys(builtInDirectives).map((d) => "v-" + d),
1701
+ ...Object.keys(ctx.dirs).map((d) => "v-" + d)
1702
+ ].sort();
1703
+ console.error(`[litevue] unknown directive ${source} on ${describeEl(el)}.\n Known directives: ${known.join(", ")}.\n A directive from a plugin needs app.use(...) before mount().`);
1704
+ }
1705
+ };
1706
+ var applyDirective = (el, dir, exp, ctx, arg, modifiers, source, displayExp) => {
1707
+ const meta = {
1708
+ source,
1709
+ el,
1710
+ expression: displayExp
1711
+ };
1712
+ const get = (e = exp) => evaluate(ctx.scope, e, el, meta);
1713
+ let cleanup;
1714
+ try {
1715
+ cleanup = dir({
1716
+ el,
1717
+ get,
1718
+ effect: ctx.effect,
1719
+ ctx,
1720
+ exp,
1721
+ arg,
1722
+ modifiers
1723
+ });
1724
+ } catch (e) {
1725
+ handleError(e, {
1726
+ phase: "directive",
1727
+ source,
1728
+ el,
1729
+ expression: exp
1730
+ });
1731
+ return;
1732
+ }
1733
+ if (cleanup) addCleanup(ctx, cleanup);
1734
+ };
1735
+ var resolveTemplate = (el, template) => {
1736
+ if (template[0] === "#") {
1737
+ const templateEl = document.querySelector(template);
1738
+ if (!templateEl) {
1739
+ console.error(`template selector ${template} has no matching <template> element.`);
1740
+ return;
1741
+ }
1742
+ el.appendChild(templateEl.content.cloneNode(true));
1743
+ return;
1744
+ }
1745
+ el.innerHTML = template;
1746
+ };
1747
+ //#endregion
1748
+ //#region src/context.ts
1749
+ var createContext = (parent) => {
1750
+ const ctx = {
1751
+ delimiters: ["{{", "}}"],
1752
+ delimitersRE: /\{\{([^]+?)\}\}/g,
1753
+ ...parent,
1754
+ scope: parent ? parent.scope : reactive({}),
1755
+ dirs: parent ? parent.dirs : {},
1756
+ effects: [],
1757
+ blocks: [],
1758
+ cleanups: [],
1759
+ effect: (fn) => {
1760
+ if (inOnce) {
1761
+ queueJob(fn);
1762
+ return fn;
1763
+ }
1764
+ const e = effect$1(fn, { scheduler: () => queueJob(e) });
1765
+ ctx.effects.push(e);
1766
+ own(() => {
1767
+ stopEffect(e);
1768
+ remove(ctx.effects, e);
1769
+ });
1770
+ return e;
1771
+ }
1772
+ };
1773
+ return ctx;
1774
+ };
1775
+ /**
1776
+ * Framework-provided, so non-enumerable: `Object.assign`-ing one scope onto
1777
+ * another must copy the user's data and leave these alone. v-for does exactly
1778
+ * that on every update, which reset each row's $id and wiped its $refs.
1779
+ */
1780
+ var hide = (scope, key, value) => Object.defineProperty(scope, key, {
1781
+ value,
1782
+ writable: true,
1783
+ configurable: true
1784
+ });
1785
+ var createScopedContext = (ctx, data = {}) => {
1786
+ const parentScope = ctx.scope;
1787
+ const mergedScope = Object.create(parentScope);
1788
+ Object.defineProperties(mergedScope, Object.getOwnPropertyDescriptors(data));
1789
+ hide(mergedScope, "$refs", Object.create(parentScope.$refs));
1790
+ const reactiveProxy = reactive(new Proxy(mergedScope, { set(target, key, val, receiver) {
1791
+ if (receiver === reactiveProxy && !hasOwn(target, key)) return Reflect.set(parentScope, key, val);
1792
+ return Reflect.set(target, key, val, receiver);
1793
+ } }));
1794
+ const scopedCtx = {
1795
+ ...ctx,
1796
+ scope: reactiveProxy
1797
+ };
1798
+ hide(mergedScope, "$watch", createWatch(scopedCtx));
1799
+ hide(mergedScope, "$id", createId());
1800
+ bindContextMethods(reactiveProxy);
1801
+ return scopedCtx;
1802
+ };
1803
+ var bindContextMethods = (scope) => {
1804
+ for (const key of Object.keys(scope)) if (typeof scope[key] === "function") scope[key] = scope[key].bind(scope);
1805
+ };
1806
+ //#endregion
1807
+ //#region src/block.ts
1808
+ var Block = class {
1809
+ template;
1810
+ ctx;
1811
+ key;
1812
+ parentCtx;
1813
+ isFragment;
1814
+ start;
1815
+ end;
1816
+ owned = false;
1817
+ get el() {
1818
+ return this.start || this.template;
1819
+ }
1820
+ constructor(template, parentCtx, isRoot = false) {
1821
+ this.isFragment = template instanceof HTMLTemplateElement;
1822
+ if (isRoot) this.template = template;
1823
+ else if (this.isFragment) this.template = template.content.cloneNode(true);
1824
+ else this.template = template.cloneNode(true);
1825
+ if (isRoot) this.ctx = createContext(parentCtx);
1826
+ else {
1827
+ this.parentCtx = parentCtx;
1828
+ parentCtx.blocks.push(this);
1829
+ this.ctx = createContext(parentCtx);
1830
+ }
1831
+ walk(this.template, this.ctx);
1832
+ }
1833
+ insert(parent, anchor = null) {
1834
+ if (this.isFragment) {
1835
+ if (this.start) {
1836
+ let node = this.start;
1837
+ let next;
1838
+ while (node) {
1839
+ next = node.nextSibling;
1840
+ parent.insertBefore(node, anchor);
1841
+ if (node === this.end) break;
1842
+ node = next;
1843
+ }
1844
+ } else {
1845
+ this.start = new Text("");
1846
+ this.end = new Text("");
1847
+ parent.insertBefore(this.end, anchor);
1848
+ parent.insertBefore(this.start, this.end);
1849
+ parent.insertBefore(this.template, this.end);
1850
+ }
1851
+ } else if (!this.template.__teleported) parent.insertBefore(this.template, anchor);
1852
+ if (!this.owned) {
1853
+ this.owned = true;
1854
+ own(() => this.discard(), this.el);
1855
+ }
1856
+ }
1857
+ remove() {
1858
+ if (this.parentCtx) remove(this.parentCtx.blocks, this);
1859
+ const removeNow = () => {
1860
+ const parent = this.start ? this.start.parentNode : this.template.parentNode;
1861
+ if (parent) {
1862
+ if (this.start) {
1863
+ let node = this.start;
1864
+ let next;
1865
+ while (node) {
1866
+ next = node.nextSibling;
1867
+ parent.removeChild(node);
1868
+ if (node === this.end) break;
1869
+ node = next;
1870
+ }
1871
+ } else parent.removeChild(this.template);
1872
+ }
1873
+ this.teardown();
1874
+ };
1875
+ const leave = this.isFragment ? void 0 : this.template.__leave;
1876
+ if (leave) leave().then(removeNow);
1877
+ else removeNow();
1878
+ }
1879
+ /**
1880
+ * The bookkeeping half of `remove()`, for a block whose nodes are already
1881
+ * gone — `remove()`'s `removeChild` calls would throw on them.
1882
+ */
1883
+ discard() {
1884
+ if (this.parentCtx) remove(this.parentCtx.blocks, this);
1885
+ this.teardown();
1886
+ }
1887
+ teardown() {
1888
+ this.ctx.blocks.splice(0).forEach((child) => {
1889
+ child.teardown();
1890
+ });
1891
+ this.ctx.effects.splice(0).forEach(stopEffect);
1892
+ this.ctx.cleanups.splice(0).forEach((fn) => fn());
1893
+ }
1894
+ };
1895
+ //#endregion
1896
+ //#region src/store.ts
1897
+ /**
1898
+ * DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
1899
+ * blank instead of raising.
1900
+ *
1901
+ * The trap sits *under* `reactive`, not over it: `reactive` probes its target
1902
+ * for `__v_raw`, and a wrapper that forwards that probe is bypassed entirely.
1903
+ * `__v_`-prefixed keys are ignored for the same reason — they are not reads a
1904
+ * user wrote.
1905
+ *
1906
+ * Deferred to the end of the task, because reading a store before it is
1907
+ * registered is legitimate — the registry is reactive so the expression
1908
+ * re-runs. A microtask would warn on a store registered after an `await`. One
1909
+ * registered later still warns; a check cannot wait forever.
1910
+ */
1911
+ var registry = Object.create(null);
1912
+ var target = registry;
1913
+ target = new Proxy(registry, { get(obj, key, receiver) {
1914
+ if (typeof key === "string" && !key.startsWith("__") && !(key in obj)) setTimeout(() => {
1915
+ if (key in obj) return;
1916
+ warnOnce(`store-missing:${key}`, `$store.${key} is not registered, so it reads as undefined. Register it with store('${key}', { … }) before mounting, or check the spelling.`);
1917
+ });
1918
+ return Reflect.get(obj, key, receiver);
1919
+ } });
1920
+ var stores = reactive(target);
1921
+ /**
1922
+ * Register or retrieve a global store, shared across apps and exposed to every
1923
+ * expression as `$store.<name>`. Passing a value registers it and runs its
1924
+ * `init()` once, if present; omitting one retrieves.
1925
+ */
1926
+ var store = (name, value) => {
1927
+ if (value !== void 0) {
1928
+ stores[name] = value;
1929
+ if (typeof stores[name].init === "function") stores[name].init();
1930
+ registerStore(name, stores[name]);
1931
+ }
1932
+ return stores[name];
1933
+ };
1934
+ //#endregion
1935
+ //#region src/app.ts
1936
+ var mountedRoots = /* @__PURE__ */ new WeakSet();
1937
+ var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
1938
+ var createApp = (initialData) => {
1939
+ const ctx = createContext();
1940
+ if (typeof initialData === "function") {
1941
+ initialData = initialData();
1942
+ if (!initialData || typeof initialData !== "object") console.error(`createApp setup function must return an object.`);
1943
+ }
1944
+ if (initialData) {
1945
+ ctx.scope = reactive(initialData);
1946
+ bindContextMethods(ctx.scope);
1947
+ if (initialData.$delimiters) {
1948
+ const [open, close] = ctx.delimiters = initialData.$delimiters;
1949
+ ctx.delimitersRE = new RegExp(escapeRegex(open) + "([^]+?)" + escapeRegex(close), "g");
1950
+ }
1951
+ }
1952
+ ctx.scope.$s = toDisplayString;
1953
+ ctx.scope.$nextTick = nextTick;
1954
+ ctx.scope.$refs = Object.create(null);
1955
+ ctx.scope.$store = stores;
1956
+ ctx.scope.$watch = createWatch(ctx);
1957
+ ctx.scope.$id = createId();
1958
+ Object.defineProperty(ctx.scope, "$root", {
1959
+ value: ctx.scope,
1960
+ enumerable: false
1961
+ });
1962
+ const components = Object.create(null);
1963
+ let rootBlocks = [];
1964
+ const installedPlugins = /* @__PURE__ */ new Set();
1965
+ const pluginTeardowns = [];
1966
+ const ownErrorHandlers = [];
1967
+ const app = {
1968
+ get scope() {
1969
+ return ctx.scope;
1970
+ },
1971
+ directive(name, def) {
1972
+ if (def) {
1973
+ ctx.dirs[name] = def;
1974
+ return this;
1975
+ } else return ctx.dirs[name];
1976
+ },
1977
+ component(name, factory) {
1978
+ if (!factory) return components[name];
1979
+ if (name in components) warn(`component "${name}" is already registered and has been replaced. Registering twice is usually two modules claiming the same name.`);
1980
+ else if (name in ctx.scope) warn(`component "${name}" was not registered: the root scope already has a "${name}", and overwriting it would replace your data with the component. Rename one of them.`);
1981
+ if (!(name in components) && name in ctx.scope) return this;
1982
+ components[name] = factory;
1983
+ registerComponent(name);
1984
+ ctx.scope[name] = factory;
1985
+ return this;
1986
+ },
1987
+ onError(handler) {
1988
+ const off = addErrorHandler(handler);
1989
+ ownErrorHandlers.push(off);
1990
+ return () => {
1991
+ const i = ownErrorHandlers.indexOf(off);
1992
+ if (i > -1) ownErrorHandlers.splice(i, 1);
1993
+ off();
1994
+ };
1995
+ },
1996
+ use(plugin, options) {
1997
+ if (!installedPlugins.has(plugin)) {
1998
+ installedPlugins.add(plugin);
1999
+ const teardown = (typeof plugin === "function" ? plugin : plugin.install)(app, options);
2000
+ if (typeof teardown === "function") pluginTeardowns.push(teardown);
2001
+ }
2002
+ return app;
2003
+ },
2004
+ mount(el) {
2005
+ if (typeof el === "string") {
2006
+ el = document.querySelector(el);
2007
+ if (!el) {
2008
+ console.error(`selector ${el} has no matching element.`);
2009
+ return;
2010
+ }
2011
+ }
2012
+ el = el || document.documentElement;
2013
+ let roots;
2014
+ if (el.hasAttribute("v-scope")) roots = [el];
2015
+ else roots = [...el.querySelectorAll(`[v-scope]`)].filter((root) => !root.matches(`[v-scope] [v-scope]`));
2016
+ if (!roots.length) roots = [el];
2017
+ if (roots.length === 1 && roots[0] === document.documentElement) console.warn("Mounting on documentElement - this is non-optimal as LiteVue will be forced to crawl the entire page's DOM. Consider explicitly marking elements controlled by LiteVue with `v-scope`.");
2018
+ ctx.walk ??= walk;
2019
+ ctx.dispose ??= disposeSubtree;
2020
+ for (const el of roots) {
2021
+ if (mountedRoots.has(el)) warn("mount() was called again on an element that has already been mounted, so its directives were consumed by the first walk and nothing was bound this time. To re-activate a region, insert fresh markup and mount that instead.");
2022
+ mountedRoots.add(el);
2023
+ const name = el.getAttribute("v-name");
2024
+ const block = new Block(el, ctx, true);
2025
+ el.__ctx ??= block.ctx;
2026
+ if (!devtools.scopes.has(el)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
2027
+ rootBlocks.push(block);
2028
+ }
2029
+ return this;
2030
+ },
2031
+ /**
2032
+ * Tear down mounted regions: every root, or only those at or inside `el`.
2033
+ * Effects stop, cleanups run and scopes deregister; the rest of the app
2034
+ * keeps running. Without it, replacing a region's markup leaves its
2035
+ * effects writing to detached nodes.
2036
+ */
2037
+ unmount(el) {
2038
+ if (el == null) {
2039
+ rootBlocks.forEach((block) => block.teardown());
2040
+ rootBlocks = [];
2041
+ pluginTeardowns.splice(0).forEach((fn) => {
2042
+ try {
2043
+ fn();
2044
+ } catch (e) {
2045
+ handleError(e, {
2046
+ phase: "teardown",
2047
+ source: "plugin"
2048
+ });
2049
+ }
2050
+ });
2051
+ installedPlugins.clear();
2052
+ ownErrorHandlers.splice(0).forEach((off) => off());
2053
+ return;
2054
+ }
2055
+ const target = typeof el === "string" ? document.querySelector(el) : el;
2056
+ if (!target) {
2057
+ console.warn(`unmount: selector ${el} has no matching element.`);
2058
+ return;
2059
+ }
2060
+ const kept = [];
2061
+ for (const block of rootBlocks) {
2062
+ const root = block.template;
2063
+ if (target.contains(root)) block.teardown();
2064
+ else kept.push(block);
2065
+ }
2066
+ if (kept.length === rootBlocks.length) console.warn("unmount: no mounted region found at or inside the given element. Pass the same element that was mounted, or one containing it.");
2067
+ rootBlocks = kept;
2068
+ }
2069
+ };
2070
+ return app;
2071
+ };
2072
+ //#endregion
2073
+ //#region src/effect.ts
2074
+ /**
2075
+ * Runs `fn` now, then again when the reactive state it read changes. The
2076
+ * JS-side counterpart to `v-effect`, for work not tied to an element.
2077
+ *
2078
+ * Re-runs are scheduled, so a burst of mutations in one tick triggers one run
2079
+ * with the DOM already updated — unlike raw `effect`, which fires
2080
+ * synchronously per mutation.
2081
+ *
2082
+ * Returns a stop function. Nothing stops it automatically.
2083
+ */
2084
+ var watchEffect = (fn) => {
2085
+ let runner;
2086
+ runner = effect$1(fn, { scheduler: () => queueJob(runner) });
2087
+ return () => stopEffect(runner);
2088
+ };
2089
+ //#endregion
2090
+ //#region src/index.ts
2091
+ var s = document.currentScript;
2092
+ if (s && s.hasAttribute("init")) createApp().mount();
2093
+ //#endregion
2094
+ exports.computed = computed;
2095
+ exports.createApp = createApp;
2096
+ exports.devtools = devtools;
2097
+ exports.disableDevtools = disableDevtools;
2098
+ exports.nextTick = nextTick;
2099
+ exports.reactive = reactive;
2100
+ exports.store = store;
2101
+ exports.watchEffect = watchEffect;
2102
+ return exports;
2103
+ })({});