@reactive-vscode/vueuse 0.4.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/dist/index.cjs +1164 -1596
  2. package/dist/index.d.ts +549 -342
  3. package/dist/index.js +1214 -1646
  4. package/package.json +5 -5
package/dist/index.cjs CHANGED
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactivity = require("@reactive-vscode/reactivity");
4
+ function getCurrentInstance() {
5
+ return null;
6
+ }
7
+ function computedEager(fn, options) {
8
+ var _options$flush;
9
+ const result = reactivity.shallowRef();
10
+ reactivity.watchEffect(() => {
11
+ result.value = fn();
12
+ }, {
13
+ ...options,
14
+ flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync"
15
+ });
16
+ return reactivity.readonly(result);
17
+ }
18
+ const eagerComputed = computedEager;
4
19
  function computedWithControl(source, fn, options = {}) {
5
20
  let v = void 0;
6
21
  let track;
@@ -10,32 +25,36 @@ function computedWithControl(source, fn, options = {}) {
10
25
  dirty = true;
11
26
  trigger();
12
27
  };
13
- reactivity.watch(source, update, { flush: "sync", ...options });
14
- const get2 = typeof fn === "function" ? fn : fn.get;
15
- const set2 = typeof fn === "function" ? void 0 : fn.set;
28
+ reactivity.watch(source, update, {
29
+ flush: "sync",
30
+ ...options
31
+ });
32
+ const get$1 = typeof fn === "function" ? fn : fn.get;
33
+ const set$1 = typeof fn === "function" ? void 0 : fn.set;
16
34
  const result = reactivity.customRef((_track, _trigger) => {
17
35
  track = _track;
18
36
  trigger = _trigger;
19
37
  return {
20
38
  get() {
21
39
  if (dirty) {
22
- v = get2(v);
40
+ v = get$1(v);
23
41
  dirty = false;
24
42
  }
25
43
  track();
26
44
  return v;
27
45
  },
28
- set(v2) {
29
- set2 == null ? void 0 : set2(v2);
46
+ set(v$1) {
47
+ set$1 === null || set$1 === void 0 || set$1(v$1);
30
48
  }
31
49
  };
32
50
  });
33
51
  result.trigger = update;
34
52
  return result;
35
53
  }
36
- function tryOnScopeDispose(fn) {
54
+ const controlledComputed = computedWithControl;
55
+ function tryOnScopeDispose(fn, failSilently) {
37
56
  if (reactivity.getCurrentScope()) {
38
- reactivity.onScopeDispose(fn);
57
+ reactivity.onScopeDispose(fn, failSilently);
39
58
  return true;
40
59
  }
41
60
  return false;
@@ -53,9 +72,7 @@ function createEventHook() {
53
72
  fns.add(fn);
54
73
  const offFn = () => off(fn);
55
74
  tryOnScopeDispose(offFn);
56
- return {
57
- off: offFn
58
- };
75
+ return { off: offFn };
59
76
  };
60
77
  const trigger = (...args) => {
61
78
  return Promise.all(Array.from(fns).map((fn) => fn(...args)));
@@ -72,171 +89,57 @@ function createGlobalState(stateFactory) {
72
89
  let initialized = false;
73
90
  let state;
74
91
  const scope = reactivity.effectScope(true);
75
- return (...args) => {
92
+ return ((...args) => {
76
93
  if (!initialized) {
77
94
  state = scope.run(() => stateFactory(...args));
78
95
  initialized = true;
79
96
  }
80
97
  return state;
81
- };
98
+ });
82
99
  }
83
- // @__NO_SIDE_EFFECTS__
84
- function createRef(value, deep) {
85
- if (deep === true) {
86
- return reactivity.ref(value);
87
- } else {
88
- return reactivity.shallowRef(value);
89
- }
100
+ const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
101
+ const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => {
102
+ var _getCurrentInstance;
103
+ const key = args[0];
104
+ const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
105
+ const owner = instance !== null && instance !== void 0 ? instance : reactivity.getCurrentScope();
106
+ if (owner == null && !reactivity.hasInjectionContext()) throw new Error("injectLocal must be called in setup");
107
+ if (owner && localProvidedStateMap.has(owner) && key in localProvidedStateMap.get(owner)) return localProvidedStateMap.get(owner)[key];
108
+ return reactivity.inject(...args);
109
+ };
110
+ function provideLocal(key, value) {
111
+ var _getCurrentInstance;
112
+ const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
113
+ const owner = instance !== null && instance !== void 0 ? instance : reactivity.getCurrentScope();
114
+ if (owner == null) throw new Error("provideLocal must be called in setup");
115
+ if (!localProvidedStateMap.has(owner)) localProvidedStateMap.set(owner, /* @__PURE__ */ Object.create(null));
116
+ const localProvidedState = localProvidedStateMap.get(owner);
117
+ localProvidedState[key] = value;
118
+ return reactivity.provide(key, value);
90
119
  }
91
120
  // @__NO_SIDE_EFFECTS__
92
- function createSharedComposable(composable) {
93
- let subscribers = 0;
94
- let state;
95
- let scope;
96
- const dispose = () => {
97
- subscribers -= 1;
98
- if (scope && subscribers <= 0) {
99
- scope.stop();
100
- state = void 0;
101
- scope = void 0;
102
- }
103
- };
104
- return (...args) => {
105
- subscribers += 1;
106
- if (!scope) {
107
- scope = reactivity.effectScope(true);
108
- state = scope.run(() => composable(...args));
109
- }
110
- tryOnScopeDispose(dispose);
121
+ function createInjectionState(composable, options) {
122
+ const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
123
+ const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue;
124
+ const useProvidingState = (...args) => {
125
+ const state = composable(...args);
126
+ provideLocal(key, state);
111
127
  return state;
112
128
  };
113
- }
114
- function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
115
- for (const [key, value] of Object.entries(extend)) {
116
- if (key === "value")
117
- continue;
118
- if (reactivity.isRef(value) && unwrap) {
119
- Object.defineProperty(ref, key, {
120
- get() {
121
- return value.value;
122
- },
123
- set(v) {
124
- value.value = v;
125
- },
126
- enumerable
127
- });
128
- } else {
129
- Object.defineProperty(ref, key, { value, enumerable });
130
- }
131
- }
132
- return ref;
133
- }
134
- function get(obj, key) {
135
- if (key == null)
136
- return reactivity.unref(obj);
137
- return reactivity.unref(obj)[key];
138
- }
139
- function isDefined(v) {
140
- return reactivity.unref(v) != null;
141
- }
142
- // @__NO_SIDE_EFFECTS__
143
- function makeDestructurable(obj, arr) {
144
- if (typeof Symbol !== "undefined") {
145
- const clone = { ...obj };
146
- Object.defineProperty(clone, Symbol.iterator, {
147
- enumerable: false,
148
- value() {
149
- let index = 0;
150
- return {
151
- next: () => ({
152
- value: arr[index++],
153
- done: index > arr.length
154
- })
155
- };
156
- }
157
- });
158
- return clone;
159
- } else {
160
- return Object.assign([...arr], obj);
161
- }
129
+ const useInjectedState = () => /* @__PURE__ */ injectLocal(key, defaultValue);
130
+ return [useProvidingState, useInjectedState];
162
131
  }
163
132
  // @__NO_SIDE_EFFECTS__
164
- function reactify(fn, options) {
165
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? reactivity.unref : reactivity.toValue;
166
- return function(...args) {
167
- return reactivity.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
168
- };
169
- }
170
- // @__NO_SIDE_EFFECTS__
171
- function reactifyObject(obj, optionsOrKeys = {}) {
172
- let keys = [];
173
- let options;
174
- if (Array.isArray(optionsOrKeys)) {
175
- keys = optionsOrKeys;
176
- } else {
177
- options = optionsOrKeys;
178
- const { includeOwnProperties = true } = optionsOrKeys;
179
- keys.push(...Object.keys(obj));
180
- if (includeOwnProperties)
181
- keys.push(...Object.getOwnPropertyNames(obj));
182
- }
183
- return Object.fromEntries(
184
- keys.map((key) => {
185
- const value = obj[key];
186
- return [
187
- key,
188
- typeof value === "function" ? /* @__PURE__ */ reactify(value.bind(obj), options) : value
189
- ];
190
- })
191
- );
192
- }
193
- function toReactive(objectRef) {
194
- if (!reactivity.isRef(objectRef))
195
- return reactivity.reactive(objectRef);
196
- const proxy = new Proxy({}, {
197
- get(_, p, receiver) {
198
- return reactivity.unref(Reflect.get(objectRef.value, p, receiver));
199
- },
200
- set(_, p, value) {
201
- if (reactivity.isRef(objectRef.value[p]) && !reactivity.isRef(value))
202
- objectRef.value[p].value = value;
203
- else
204
- objectRef.value[p] = value;
205
- return true;
206
- },
207
- deleteProperty(_, p) {
208
- return Reflect.deleteProperty(objectRef.value, p);
209
- },
210
- has(_, p) {
211
- return Reflect.has(objectRef.value, p);
212
- },
213
- ownKeys() {
214
- return Object.keys(objectRef.value);
215
- },
216
- getOwnPropertyDescriptor() {
217
- return {
218
- enumerable: true,
219
- configurable: true
220
- };
221
- }
222
- });
223
- return reactivity.reactive(proxy);
224
- }
225
- function reactiveComputed(fn) {
226
- return toReactive(reactivity.computed(fn));
227
- }
228
- function reactiveOmit(obj, ...keys) {
229
- const flatKeys = keys.flat();
230
- const predicate = flatKeys[0];
231
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => !predicate(reactivity.toValue(v), k))) : Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
133
+ function createRef(value, deep) {
134
+ if (deep === true) return reactivity.ref(value);
135
+ else return reactivity.shallowRef(value);
232
136
  }
233
137
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
234
138
  const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
235
139
  const isDef = (val) => typeof val !== "undefined";
236
140
  const notNullish = (val) => val != null;
237
141
  const assert = (condition, ...infos) => {
238
- if (!condition)
239
- console.warn(...infos);
142
+ if (!condition) console.warn(...infos);
240
143
  };
241
144
  const toString = Object.prototype.toString;
242
145
  const isObject = (val) => toString.call(val) === "[object Object]";
@@ -252,91 +155,61 @@ const rand = (min, max) => {
252
155
  };
253
156
  const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
254
157
  function toRef(...args) {
255
- if (args.length !== 1)
256
- return reactivity.toRef(...args);
158
+ if (args.length !== 1) return reactivity.toRef(...args);
257
159
  const r = args[0];
258
- return typeof r === "function" ? reactivity.readonly(reactivity.customRef(() => ({ get: r, set: noop }))) : reactivity.ref(r);
259
- }
260
- const resolveRef = toRef;
261
- function reactivePick(obj, ...keys) {
262
- const flatKeys = keys.flat();
263
- const predicate = flatKeys[0];
264
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => predicate(reactivity.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
265
- }
266
- function refAutoReset(defaultValue, afterMs = 1e4) {
267
- return reactivity.customRef((track, trigger) => {
268
- let value = reactivity.toValue(defaultValue);
269
- let timer;
270
- const resetAfter = () => setTimeout(() => {
271
- value = reactivity.toValue(defaultValue);
272
- trigger();
273
- }, reactivity.toValue(afterMs));
274
- tryOnScopeDispose(() => {
275
- clearTimeout(timer);
276
- });
277
- return {
278
- get() {
279
- track();
280
- return value;
281
- },
282
- set(newValue) {
283
- value = newValue;
284
- trigger();
285
- clearTimeout(timer);
286
- timer = resetAfter();
287
- }
288
- };
289
- });
160
+ return typeof r === "function" ? reactivity.readonly(reactivity.customRef(() => ({
161
+ get: r,
162
+ set: noop
163
+ }))) : reactivity.ref(r);
290
164
  }
291
165
  function createFilterWrapper(filter, fn) {
292
166
  function wrapper(...args) {
293
167
  return new Promise((resolve, reject) => {
294
- Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
168
+ Promise.resolve(filter(() => fn.apply(this, args), {
169
+ fn,
170
+ thisArg: this,
171
+ args
172
+ })).then(resolve).catch(reject);
295
173
  });
296
174
  }
297
175
  return wrapper;
298
176
  }
299
- const bypassFilter = (invoke2) => {
300
- return invoke2();
177
+ const bypassFilter = (invoke$1) => {
178
+ return invoke$1();
301
179
  };
302
180
  function debounceFilter(ms, options = {}) {
303
181
  let timer;
304
182
  let maxTimer;
305
183
  let lastRejector = noop;
306
- const _clearTimeout = (timer2) => {
307
- clearTimeout(timer2);
184
+ const _clearTimeout = (timer$1) => {
185
+ clearTimeout(timer$1);
308
186
  lastRejector();
309
187
  lastRejector = noop;
310
188
  };
311
189
  let lastInvoker;
312
- const filter = (invoke2) => {
190
+ const filter = (invoke$1) => {
313
191
  const duration = reactivity.toValue(ms);
314
192
  const maxDuration = reactivity.toValue(options.maxWait);
315
- if (timer)
316
- _clearTimeout(timer);
193
+ if (timer) _clearTimeout(timer);
317
194
  if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
318
195
  if (maxTimer) {
319
196
  _clearTimeout(maxTimer);
320
197
  maxTimer = void 0;
321
198
  }
322
- return Promise.resolve(invoke2());
199
+ return Promise.resolve(invoke$1());
323
200
  }
324
201
  return new Promise((resolve, reject) => {
325
202
  lastRejector = options.rejectOnCancel ? reject : resolve;
326
- lastInvoker = invoke2;
327
- if (maxDuration && !maxTimer) {
328
- maxTimer = setTimeout(() => {
329
- if (timer)
330
- _clearTimeout(timer);
331
- maxTimer = void 0;
332
- resolve(lastInvoker());
333
- }, maxDuration);
334
- }
203
+ lastInvoker = invoke$1;
204
+ if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
205
+ if (timer) _clearTimeout(timer);
206
+ maxTimer = void 0;
207
+ resolve(lastInvoker());
208
+ }, maxDuration);
335
209
  timer = setTimeout(() => {
336
- if (maxTimer)
337
- _clearTimeout(maxTimer);
210
+ if (maxTimer) _clearTimeout(maxTimer);
338
211
  maxTimer = void 0;
339
- resolve(invoke2());
212
+ resolve(invoke$1());
340
213
  }, duration);
341
214
  });
342
215
  };
@@ -352,10 +225,8 @@ function throttleFilter(...args) {
352
225
  let trailing;
353
226
  let leading;
354
227
  let rejectOnCancel;
355
- if (!reactivity.isRef(args[0]) && typeof args[0] === "object")
356
- ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
357
- else
358
- [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
228
+ if (!reactivity.isRef(args[0]) && typeof args[0] === "object") ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
229
+ else [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
359
230
  const clear = () => {
360
231
  if (timer) {
361
232
  clearTimeout(timer);
@@ -367,39 +238,34 @@ function throttleFilter(...args) {
367
238
  const filter = (_invoke) => {
368
239
  const duration = reactivity.toValue(ms);
369
240
  const elapsed = Date.now() - lastExec;
370
- const invoke2 = () => {
241
+ const invoke$1 = () => {
371
242
  return lastValue = _invoke();
372
243
  };
373
244
  clear();
374
245
  if (duration <= 0) {
375
246
  lastExec = Date.now();
376
- return invoke2();
247
+ return invoke$1();
377
248
  }
378
- if (elapsed > duration && (leading || !isLeading)) {
249
+ if (elapsed > duration) {
379
250
  lastExec = Date.now();
380
- invoke2();
381
- } else if (trailing) {
382
- lastValue = new Promise((resolve, reject) => {
383
- lastRejector = rejectOnCancel ? reject : resolve;
384
- timer = setTimeout(() => {
385
- lastExec = Date.now();
386
- isLeading = true;
387
- resolve(invoke2());
388
- clear();
389
- }, Math.max(0, duration - elapsed));
390
- });
391
- }
392
- if (!leading && !timer)
393
- timer = setTimeout(() => isLeading = true, duration);
251
+ if (leading || !isLeading) invoke$1();
252
+ } else if (trailing) lastValue = new Promise((resolve, reject) => {
253
+ lastRejector = rejectOnCancel ? reject : resolve;
254
+ timer = setTimeout(() => {
255
+ lastExec = Date.now();
256
+ isLeading = true;
257
+ resolve(invoke$1());
258
+ clear();
259
+ }, Math.max(0, duration - elapsed));
260
+ });
261
+ if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration);
394
262
  isLeading = false;
395
263
  return lastValue;
396
264
  };
397
265
  return filter;
398
266
  }
399
267
  function pausableFilter(extendFilter = bypassFilter, options = {}) {
400
- const {
401
- initialState = "active"
402
- } = options;
268
+ const { initialState = "active" } = options;
403
269
  const isActive = toRef(initialState === "active");
404
270
  function pause() {
405
271
  isActive.value = false;
@@ -408,17 +274,19 @@ function pausableFilter(extendFilter = bypassFilter, options = {}) {
408
274
  isActive.value = true;
409
275
  }
410
276
  const eventFilter = (...args) => {
411
- if (isActive.value)
412
- extendFilter(...args);
277
+ if (isActive.value) extendFilter(...args);
278
+ };
279
+ return {
280
+ isActive: reactivity.readonly(isActive),
281
+ pause,
282
+ resume,
283
+ eventFilter
413
284
  };
414
- return { isActive: reactivity.readonly(isActive), pause, resume, eventFilter };
415
285
  }
416
286
  function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
417
287
  return new Promise((resolve, reject) => {
418
- if (throwOnTimeout)
419
- setTimeout(() => reject(reason), ms);
420
- else
421
- setTimeout(resolve, ms);
288
+ if (throwOnTimeout) setTimeout(() => reject(reason), ms);
289
+ else setTimeout(resolve, ms);
422
290
  });
423
291
  }
424
292
  function identity(arg) {
@@ -427,15 +295,13 @@ function identity(arg) {
427
295
  function createSingletonPromise(fn) {
428
296
  let _promise;
429
297
  function wrapper() {
430
- if (!_promise)
431
- _promise = fn();
298
+ if (!_promise) _promise = fn();
432
299
  return _promise;
433
300
  }
434
301
  wrapper.reset = async () => {
435
302
  const _prev = _promise;
436
303
  _promise = void 0;
437
- if (_prev)
438
- await _prev;
304
+ if (_prev) await _prev;
439
305
  };
440
306
  return wrapper;
441
307
  }
@@ -446,21 +312,21 @@ function containsProp(obj, ...props) {
446
312
  return props.some((k) => k in obj);
447
313
  }
448
314
  function increaseWithUnit(target, delta) {
449
- var _a;
450
- if (typeof target === "number")
451
- return target + delta;
452
- const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || "";
315
+ var _target$match;
316
+ if (typeof target === "number") return target + delta;
317
+ const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || "";
453
318
  const unit = target.slice(value.length);
454
319
  const result = Number.parseFloat(value) + delta;
455
- if (Number.isNaN(result))
456
- return target;
320
+ if (Number.isNaN(result)) return target;
457
321
  return result + unit;
458
322
  }
323
+ function pxValue(px) {
324
+ return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
325
+ }
459
326
  function objectPick(obj, keys, omitUndefined = false) {
460
327
  return keys.reduce((n, k) => {
461
328
  if (k in obj) {
462
- if (!omitUndefined || obj[k] !== void 0)
463
- n[k] = obj[k];
329
+ if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k];
464
330
  }
465
331
  return n;
466
332
  }, {});
@@ -478,10 +344,9 @@ function toArray(value) {
478
344
  }
479
345
  function cacheStringFunction(fn) {
480
346
  const cache = /* @__PURE__ */ Object.create(null);
481
- return (str) => {
482
- const hit = cache[str];
483
- return hit || (cache[str] = fn(str));
484
- };
347
+ return ((str) => {
348
+ return cache[str] || (cache[str] = fn(str));
349
+ });
485
350
  }
486
351
  const hyphenateRE = /\B([A-Z])/g;
487
352
  const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
@@ -490,14 +355,169 @@ const camelize = cacheStringFunction((str) => {
490
355
  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
491
356
  });
492
357
  function getLifeCycleTarget(target) {
493
- return target || null;
358
+ return target || getCurrentInstance();
359
+ }
360
+ // @__NO_SIDE_EFFECTS__
361
+ function createSharedComposable(composable) {
362
+ if (!isClient) return composable;
363
+ let subscribers = 0;
364
+ let state;
365
+ let scope;
366
+ const dispose = () => {
367
+ subscribers -= 1;
368
+ if (scope && subscribers <= 0) {
369
+ scope.stop();
370
+ state = void 0;
371
+ scope = void 0;
372
+ }
373
+ };
374
+ return ((...args) => {
375
+ subscribers += 1;
376
+ if (!scope) {
377
+ scope = reactivity.effectScope(true);
378
+ state = scope.run(() => composable(...args));
379
+ }
380
+ tryOnScopeDispose(dispose);
381
+ return state;
382
+ });
383
+ }
384
+ function extendRef(ref$1, extend, { enumerable = false, unwrap = true } = {}) {
385
+ for (const [key, value] of Object.entries(extend)) {
386
+ if (key === "value") continue;
387
+ if (reactivity.isRef(value) && unwrap) Object.defineProperty(ref$1, key, {
388
+ get() {
389
+ return value.value;
390
+ },
391
+ set(v) {
392
+ value.value = v;
393
+ },
394
+ enumerable
395
+ });
396
+ else Object.defineProperty(ref$1, key, {
397
+ value,
398
+ enumerable
399
+ });
400
+ }
401
+ return ref$1;
402
+ }
403
+ function get(obj, key) {
404
+ if (key == null) return reactivity.unref(obj);
405
+ return reactivity.unref(obj)[key];
406
+ }
407
+ function isDefined(v) {
408
+ return reactivity.unref(v) != null;
409
+ }
410
+ // @__NO_SIDE_EFFECTS__
411
+ function makeDestructurable(obj, arr) {
412
+ if (typeof Symbol !== "undefined") {
413
+ const clone = { ...obj };
414
+ Object.defineProperty(clone, Symbol.iterator, {
415
+ enumerable: false,
416
+ value() {
417
+ let index = 0;
418
+ return { next: () => ({
419
+ value: arr[index++],
420
+ done: index > arr.length
421
+ }) };
422
+ }
423
+ });
424
+ return clone;
425
+ } else return Object.assign([...arr], obj);
426
+ }
427
+ // @__NO_SIDE_EFFECTS__
428
+ function reactify(fn, options) {
429
+ const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? reactivity.unref : reactivity.toValue;
430
+ return function(...args) {
431
+ return reactivity.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
432
+ };
433
+ }
434
+ const createReactiveFn = reactify;
435
+ // @__NO_SIDE_EFFECTS__
436
+ function reactifyObject(obj, optionsOrKeys = {}) {
437
+ let keys = [];
438
+ let options;
439
+ if (Array.isArray(optionsOrKeys)) keys = optionsOrKeys;
440
+ else {
441
+ options = optionsOrKeys;
442
+ const { includeOwnProperties = true } = optionsOrKeys;
443
+ keys.push(...Object.keys(obj));
444
+ if (includeOwnProperties) keys.push(...Object.getOwnPropertyNames(obj));
445
+ }
446
+ return Object.fromEntries(keys.map((key) => {
447
+ const value = obj[key];
448
+ return [key, typeof value === "function" ? /* @__PURE__ */ reactify(value.bind(obj), options) : value];
449
+ }));
450
+ }
451
+ function toReactive(objectRef) {
452
+ if (!reactivity.isRef(objectRef)) return reactivity.reactive(objectRef);
453
+ return reactivity.reactive(new Proxy({}, {
454
+ get(_, p, receiver) {
455
+ return reactivity.unref(Reflect.get(objectRef.value, p, receiver));
456
+ },
457
+ set(_, p, value) {
458
+ if (reactivity.isRef(objectRef.value[p]) && !reactivity.isRef(value)) objectRef.value[p].value = value;
459
+ else objectRef.value[p] = value;
460
+ return true;
461
+ },
462
+ deleteProperty(_, p) {
463
+ return Reflect.deleteProperty(objectRef.value, p);
464
+ },
465
+ has(_, p) {
466
+ return Reflect.has(objectRef.value, p);
467
+ },
468
+ ownKeys() {
469
+ return Object.keys(objectRef.value);
470
+ },
471
+ getOwnPropertyDescriptor() {
472
+ return {
473
+ enumerable: true,
474
+ configurable: true
475
+ };
476
+ }
477
+ }));
478
+ }
479
+ function reactiveComputed(fn) {
480
+ return toReactive(reactivity.computed(fn));
494
481
  }
482
+ function reactiveOmit(obj, ...keys) {
483
+ const flatKeys = keys.flat();
484
+ const predicate = flatKeys[0];
485
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => !predicate(reactivity.toValue(v), k))) : Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
486
+ }
487
+ function reactivePick(obj, ...keys) {
488
+ const flatKeys = keys.flat();
489
+ const predicate = flatKeys[0];
490
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(reactivity.toRefs(obj)).filter(([k, v]) => predicate(reactivity.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
491
+ }
492
+ function refAutoReset(defaultValue, afterMs = 1e4) {
493
+ return reactivity.customRef((track, trigger) => {
494
+ let value = reactivity.toValue(defaultValue);
495
+ let timer;
496
+ const resetAfter = () => setTimeout(() => {
497
+ value = reactivity.toValue(defaultValue);
498
+ trigger();
499
+ }, reactivity.toValue(afterMs));
500
+ tryOnScopeDispose(() => {
501
+ clearTimeout(timer);
502
+ });
503
+ return {
504
+ get() {
505
+ track();
506
+ return value;
507
+ },
508
+ set(newValue) {
509
+ value = newValue;
510
+ trigger();
511
+ clearTimeout(timer);
512
+ timer = resetAfter();
513
+ }
514
+ };
515
+ });
516
+ }
517
+ const autoResetRef = refAutoReset;
495
518
  // @__NO_SIDE_EFFECTS__
496
519
  function useDebounceFn(fn, ms = 200, options = {}) {
497
- return createFilterWrapper(
498
- debounceFilter(ms, options),
499
- fn
500
- );
520
+ return createFilterWrapper(debounceFilter(ms, options), fn);
501
521
  }
502
522
  function refDebounced(value, ms = 200, options = {}) {
503
523
  const debounced = reactivity.ref(reactivity.toValue(value));
@@ -507,28 +527,49 @@ function refDebounced(value, ms = 200, options = {}) {
507
527
  reactivity.watch(value, () => updater());
508
528
  return reactivity.shallowReadonly(debounced);
509
529
  }
530
+ const debouncedRef = refDebounced;
531
+ const useDebounce = refDebounced;
510
532
  // @__NO_SIDE_EFFECTS__
511
533
  function refDefault(source, defaultValue) {
512
534
  return reactivity.computed({
513
535
  get() {
514
- var _a;
515
- return (_a = source.value) != null ? _a : defaultValue;
536
+ var _source$value;
537
+ return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue;
516
538
  },
517
539
  set(value) {
518
540
  source.value = value;
519
541
  }
520
542
  });
521
543
  }
544
+ function refManualReset(defaultValue) {
545
+ let value = reactivity.toValue(defaultValue);
546
+ let trigger;
547
+ const reset = () => {
548
+ value = reactivity.toValue(defaultValue);
549
+ trigger();
550
+ };
551
+ const refValue = reactivity.customRef((track, _trigger) => {
552
+ trigger = _trigger;
553
+ return {
554
+ get() {
555
+ track();
556
+ return value;
557
+ },
558
+ set(newValue) {
559
+ value = newValue;
560
+ trigger();
561
+ }
562
+ };
563
+ });
564
+ refValue.reset = reset;
565
+ return refValue;
566
+ }
522
567
  // @__NO_SIDE_EFFECTS__
523
568
  function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
524
- return createFilterWrapper(
525
- throttleFilter(ms, trailing, leading, rejectOnCancel),
526
- fn
527
- );
569
+ return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
528
570
  }
529
571
  function refThrottled(value, delay = 200, trailing = true, leading = true) {
530
- if (delay <= 0)
531
- return value;
572
+ if (delay <= 0) return value;
532
573
  const throttled = reactivity.ref(reactivity.toValue(value));
533
574
  const updater = /* @__PURE__ */ useThrottleFn(() => {
534
575
  throttled.value = value.value;
@@ -536,62 +577,56 @@ function refThrottled(value, delay = 200, trailing = true, leading = true) {
536
577
  reactivity.watch(value, () => updater());
537
578
  return throttled;
538
579
  }
580
+ const throttledRef = refThrottled;
581
+ const useThrottle = refThrottled;
539
582
  // @__NO_SIDE_EFFECTS__
540
583
  function refWithControl(initial, options = {}) {
541
584
  let source = initial;
542
585
  let track;
543
586
  let trigger;
544
- const ref = reactivity.customRef((_track, _trigger) => {
587
+ const ref$1 = reactivity.customRef((_track, _trigger) => {
545
588
  track = _track;
546
589
  trigger = _trigger;
547
590
  return {
548
591
  get() {
549
- return get2();
592
+ return get$1();
550
593
  },
551
594
  set(v) {
552
- set2(v);
595
+ set$1(v);
553
596
  }
554
597
  };
555
598
  });
556
- function get2(tracking = true) {
557
- if (tracking)
558
- track();
599
+ function get$1(tracking = true) {
600
+ if (tracking) track();
559
601
  return source;
560
602
  }
561
- function set2(value, triggering = true) {
562
- var _a, _b;
563
- if (value === source)
564
- return;
603
+ function set$1(value, triggering = true) {
604
+ var _options$onBeforeChan, _options$onChanged;
605
+ if (value === source) return;
565
606
  const old = source;
566
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
567
- return;
607
+ if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return;
568
608
  source = value;
569
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
570
- if (triggering)
571
- trigger();
572
- }
573
- const untrackedGet = () => get2(false);
574
- const silentSet = (v) => set2(v, false);
575
- const peek = () => get2(false);
576
- const lay = (v) => set2(v, false);
577
- return extendRef(
578
- ref,
579
- {
580
- get: get2,
581
- set: set2,
582
- untrackedGet,
583
- silentSet,
584
- peek,
585
- lay
586
- },
587
- { enumerable: true }
588
- );
609
+ (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old);
610
+ if (triggering) trigger();
611
+ }
612
+ const untrackedGet = () => get$1(false);
613
+ const silentSet = (v) => set$1(v, false);
614
+ const peek = () => get$1(false);
615
+ const lay = (v) => set$1(v, false);
616
+ return extendRef(ref$1, {
617
+ get: get$1,
618
+ set: set$1,
619
+ untrackedGet,
620
+ silentSet,
621
+ peek,
622
+ lay
623
+ }, { enumerable: true });
589
624
  }
590
625
  const controlledRef = refWithControl;
591
626
  function set(...args) {
592
627
  if (args.length === 2) {
593
- const [ref, value] = args;
594
- ref.value = value;
628
+ const [ref$1, value] = args;
629
+ ref$1.value = value;
595
630
  }
596
631
  if (args.length === 3) {
597
632
  const [target, key, value] = args;
@@ -599,191 +634,142 @@ function set(...args) {
599
634
  }
600
635
  }
601
636
  function watchWithFilter(source, cb, options = {}) {
602
- const {
603
- eventFilter = bypassFilter,
604
- ...watchOptions
605
- } = options;
606
- return reactivity.watch(
607
- source,
608
- createFilterWrapper(
609
- eventFilter,
610
- cb
611
- ),
612
- watchOptions
613
- );
637
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
638
+ return reactivity.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
614
639
  }
615
640
  function watchPausable(source, cb, options = {}) {
616
- const {
617
- eventFilter: filter,
618
- initialState = "active",
619
- ...watchOptions
620
- } = options;
641
+ const { eventFilter: filter, initialState = "active", ...watchOptions } = options;
621
642
  const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
622
- const stop = watchWithFilter(
623
- source,
624
- cb,
625
- {
643
+ return {
644
+ stop: watchWithFilter(source, cb, {
626
645
  ...watchOptions,
627
646
  eventFilter
628
- }
629
- );
630
- return { stop, pause, resume, isActive };
647
+ }),
648
+ pause,
649
+ resume,
650
+ isActive
651
+ };
631
652
  }
653
+ const pausableWatch = watchPausable;
632
654
  function syncRef(left, right, ...[options]) {
633
- const {
634
- flush = "sync",
635
- deep = false,
636
- immediate = true,
637
- direction = "both",
638
- transform = {}
639
- } = options || {};
655
+ const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {};
640
656
  const watchers = [];
641
657
  const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
642
658
  const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
643
- if (direction === "both" || direction === "ltr") {
644
- watchers.push(watchPausable(
645
- left,
646
- (newValue) => {
647
- watchers.forEach((w) => w.pause());
648
- right.value = transformLTR(newValue);
649
- watchers.forEach((w) => w.resume());
650
- },
651
- { flush, deep, immediate }
652
- ));
653
- }
654
- if (direction === "both" || direction === "rtl") {
655
- watchers.push(watchPausable(
656
- right,
657
- (newValue) => {
658
- watchers.forEach((w) => w.pause());
659
- left.value = transformRTL(newValue);
660
- watchers.forEach((w) => w.resume());
661
- },
662
- { flush, deep, immediate }
663
- ));
664
- }
659
+ if (direction === "both" || direction === "ltr") watchers.push(pausableWatch(left, (newValue) => {
660
+ watchers.forEach((w) => w.pause());
661
+ right.value = transformLTR(newValue);
662
+ watchers.forEach((w) => w.resume());
663
+ }, {
664
+ flush,
665
+ deep,
666
+ immediate
667
+ }));
668
+ if (direction === "both" || direction === "rtl") watchers.push(pausableWatch(right, (newValue) => {
669
+ watchers.forEach((w) => w.pause());
670
+ left.value = transformRTL(newValue);
671
+ watchers.forEach((w) => w.resume());
672
+ }, {
673
+ flush,
674
+ deep,
675
+ immediate
676
+ }));
665
677
  const stop = () => {
666
678
  watchers.forEach((w) => w.stop());
667
679
  };
668
680
  return stop;
669
681
  }
670
682
  function syncRefs(source, targets, options = {}) {
671
- const {
672
- flush = "sync",
673
- deep = false,
674
- immediate = true
675
- } = options;
683
+ const { flush = "sync", deep = false, immediate = true } = options;
676
684
  const targetsArray = toArray(targets);
677
- return reactivity.watch(
678
- source,
679
- (newValue) => targetsArray.forEach((target) => target.value = newValue),
680
- { flush, deep, immediate }
681
- );
685
+ return reactivity.watch(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), {
686
+ flush,
687
+ deep,
688
+ immediate
689
+ });
682
690
  }
683
691
  function toRefs(objectRef, options = {}) {
684
- if (!reactivity.isRef(objectRef))
685
- return reactivity.toRefs(objectRef);
692
+ if (!reactivity.isRef(objectRef)) return reactivity.toRefs(objectRef);
686
693
  const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
687
- for (const key in objectRef.value) {
688
- result[key] = reactivity.customRef(() => ({
689
- get() {
690
- return objectRef.value[key];
691
- },
692
- set(v) {
693
- var _a;
694
- const replaceRef = (_a = reactivity.toValue(options.replaceRef)) != null ? _a : true;
695
- if (replaceRef) {
696
- if (Array.isArray(objectRef.value)) {
697
- const copy = [...objectRef.value];
698
- copy[key] = v;
699
- objectRef.value = copy;
700
- } else {
701
- const newObject = { ...objectRef.value, [key]: v };
702
- Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
703
- objectRef.value = newObject;
704
- }
705
- } else {
706
- objectRef.value[key] = v;
707
- }
694
+ for (const key in objectRef.value) result[key] = reactivity.customRef(() => ({
695
+ get() {
696
+ return objectRef.value[key];
697
+ },
698
+ set(v) {
699
+ var _toValue;
700
+ if ((_toValue = reactivity.toValue(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true) if (Array.isArray(objectRef.value)) {
701
+ const copy = [...objectRef.value];
702
+ copy[key] = v;
703
+ objectRef.value = copy;
704
+ } else {
705
+ const newObject = {
706
+ ...objectRef.value,
707
+ [key]: v
708
+ };
709
+ Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
710
+ objectRef.value = newObject;
708
711
  }
709
- }));
710
- }
712
+ else objectRef.value[key] = v;
713
+ }
714
+ }));
711
715
  return result;
712
716
  }
713
- const toValue = reactivity.toValue;
714
- const resolveUnref = reactivity.toValue;
717
+ function tryOnBeforeMount(fn, sync = true, target) {
718
+ if (getLifeCycleTarget(target)) reactivity.onBeforeMount(fn, target);
719
+ else if (sync) fn();
720
+ else reactivity.nextTick(fn);
721
+ }
722
+ function tryOnBeforeUnmount(fn, target) {
723
+ if (getLifeCycleTarget(target)) reactivity.onBeforeUnmount(fn, target);
724
+ }
715
725
  function tryOnMounted(fn, sync = true, target) {
716
- const instance = getLifeCycleTarget(target);
717
- if (instance)
718
- ;
719
- else if (sync)
720
- fn();
721
- else
722
- reactivity.nextTick(fn);
726
+ if (getLifeCycleTarget(target)) ;
727
+ else if (sync) fn();
728
+ else reactivity.nextTick(fn);
729
+ }
730
+ function tryOnUnmounted(fn, target) {
731
+ if (getLifeCycleTarget(target)) reactivity.onUnmounted(fn, target);
723
732
  }
724
733
  function createUntil(r, isNot = false) {
725
734
  function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
726
735
  let stop = null;
727
- const watcher = new Promise((resolve) => {
728
- stop = reactivity.watch(
729
- r,
730
- (v) => {
731
- if (condition(v) !== isNot) {
732
- if (stop)
733
- stop();
734
- else
735
- reactivity.nextTick(() => stop == null ? void 0 : stop());
736
- resolve(v);
737
- }
738
- },
739
- {
740
- flush,
741
- deep,
742
- immediate: true
736
+ const promises = [new Promise((resolve) => {
737
+ stop = reactivity.watch(r, (v) => {
738
+ if (condition(v) !== isNot) {
739
+ if (stop) stop();
740
+ else reactivity.nextTick(() => stop === null || stop === void 0 ? void 0 : stop());
741
+ resolve(v);
743
742
  }
744
- );
745
- });
746
- const promises = [watcher];
747
- if (timeout != null) {
748
- promises.push(
749
- promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => stop == null ? void 0 : stop())
750
- );
751
- }
743
+ }, {
744
+ flush,
745
+ deep,
746
+ immediate: true
747
+ });
748
+ })];
749
+ if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop()));
752
750
  return Promise.race(promises);
753
751
  }
754
752
  function toBe(value, options) {
755
- if (!reactivity.isRef(value))
756
- return toMatch((v) => v === value, options);
757
- const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
753
+ if (!reactivity.isRef(value)) return toMatch((v) => v === value, options);
754
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {};
758
755
  let stop = null;
759
- const watcher = new Promise((resolve) => {
760
- stop = reactivity.watch(
761
- [r, value],
762
- ([v1, v2]) => {
763
- if (isNot !== (v1 === v2)) {
764
- if (stop)
765
- stop();
766
- else
767
- reactivity.nextTick(() => stop == null ? void 0 : stop());
768
- resolve(v1);
769
- }
770
- },
771
- {
772
- flush,
773
- deep,
774
- immediate: true
756
+ const promises = [new Promise((resolve) => {
757
+ stop = reactivity.watch([r, value], ([v1, v2]) => {
758
+ if (isNot !== (v1 === v2)) {
759
+ if (stop) stop();
760
+ else reactivity.nextTick(() => stop === null || stop === void 0 ? void 0 : stop());
761
+ resolve(v1);
775
762
  }
776
- );
777
- });
778
- const promises = [watcher];
779
- if (timeout != null) {
780
- promises.push(
781
- promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => {
782
- stop == null ? void 0 : stop();
783
- return reactivity.toValue(r);
784
- })
785
- );
786
- }
763
+ }, {
764
+ flush,
765
+ deep,
766
+ immediate: true
767
+ });
768
+ })];
769
+ if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => reactivity.toValue(r)).finally(() => {
770
+ stop === null || stop === void 0 || stop();
771
+ return reactivity.toValue(r);
772
+ }));
787
773
  return Promise.race(promises);
788
774
  }
789
775
  function toBeTruthy(options) {
@@ -814,33 +800,28 @@ function createUntil(r, isNot = false) {
814
800
  return count >= n;
815
801
  }, options);
816
802
  }
817
- if (Array.isArray(reactivity.toValue(r))) {
818
- const instance = {
819
- toMatch,
820
- toContains,
821
- changed,
822
- changedTimes,
823
- get not() {
824
- return createUntil(r, !isNot);
825
- }
826
- };
827
- return instance;
828
- } else {
829
- const instance = {
830
- toMatch,
831
- toBe,
832
- toBeTruthy,
833
- toBeNull,
834
- toBeNaN,
835
- toBeUndefined,
836
- changed,
837
- changedTimes,
838
- get not() {
839
- return createUntil(r, !isNot);
840
- }
841
- };
842
- return instance;
843
- }
803
+ if (Array.isArray(reactivity.toValue(r))) return {
804
+ toMatch,
805
+ toContains,
806
+ changed,
807
+ changedTimes,
808
+ get not() {
809
+ return createUntil(r, !isNot);
810
+ }
811
+ };
812
+ else return {
813
+ toMatch,
814
+ toBe,
815
+ toBeTruthy,
816
+ toBeNull,
817
+ toBeNaN,
818
+ toBeUndefined,
819
+ changed,
820
+ changedTimes,
821
+ get not() {
822
+ return createUntil(r, !isNot);
823
+ }
824
+ };
844
825
  }
845
826
  function until(r) {
846
827
  return createUntil(r);
@@ -850,13 +831,11 @@ function defaultComparator(value, othVal) {
850
831
  }
851
832
  // @__NO_SIDE_EFFECTS__
852
833
  function useArrayDifference(...args) {
853
- var _a, _b;
834
+ var _args$, _args$2;
854
835
  const list = args[0];
855
836
  const values = args[1];
856
- let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
857
- const {
858
- symmetric = false
859
- } = (_b = args[3]) != null ? _b : {};
837
+ let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator;
838
+ const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {};
860
839
  if (typeof compareFn === "string") {
861
840
  const key = compareFn;
862
841
  compareFn = (value, othVal) => value[key] === othVal[key];
@@ -865,9 +844,7 @@ function useArrayDifference(...args) {
865
844
  if (symmetric) {
866
845
  const diff2 = reactivity.computed(() => reactivity.toValue(values).filter((x) => reactivity.toValue(list).findIndex((y) => compareFn(x, y)) === -1));
867
846
  return reactivity.computed(() => symmetric ? [...reactivity.toValue(diff1), ...reactivity.toValue(diff2)] : reactivity.toValue(diff1));
868
- } else {
869
- return diff1;
870
- }
847
+ } else return diff1;
871
848
  }
872
849
  // @__NO_SIDE_EFFECTS__
873
850
  function useArrayEvery(list, fn) {
@@ -879,9 +856,7 @@ function useArrayFilter(list, fn) {
879
856
  }
880
857
  // @__NO_SIDE_EFFECTS__
881
858
  function useArrayFind(list, fn) {
882
- return reactivity.computed(() => reactivity.toValue(
883
- reactivity.toValue(list).find((element, index, array) => fn(reactivity.toValue(element), index, array))
884
- ));
859
+ return reactivity.computed(() => reactivity.toValue(reactivity.toValue(list).find((element, index, array) => fn(reactivity.toValue(element), index, array))));
885
860
  }
886
861
  // @__NO_SIDE_EFFECTS__
887
862
  function useArrayFindIndex(list, fn) {
@@ -889,43 +864,33 @@ function useArrayFindIndex(list, fn) {
889
864
  }
890
865
  function findLast(arr, cb) {
891
866
  let index = arr.length;
892
- while (index-- > 0) {
893
- if (cb(arr[index], index, arr))
894
- return arr[index];
895
- }
896
- return void 0;
867
+ while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index];
897
868
  }
898
869
  // @__NO_SIDE_EFFECTS__
899
870
  function useArrayFindLast(list, fn) {
900
- return reactivity.computed(() => reactivity.toValue(
901
- !Array.prototype.findLast ? findLast(reactivity.toValue(list), (element, index, array) => fn(reactivity.toValue(element), index, array)) : reactivity.toValue(list).findLast((element, index, array) => fn(reactivity.toValue(element), index, array))
902
- ));
871
+ return reactivity.computed(() => reactivity.toValue(!Array.prototype.findLast ? findLast(reactivity.toValue(list), (element, index, array) => fn(reactivity.toValue(element), index, array)) : reactivity.toValue(list).findLast((element, index, array) => fn(reactivity.toValue(element), index, array))));
903
872
  }
904
873
  function isArrayIncludesOptions(obj) {
905
874
  return isObject(obj) && containsProp(obj, "formIndex", "comparator");
906
875
  }
907
876
  // @__NO_SIDE_EFFECTS__
908
877
  function useArrayIncludes(...args) {
909
- var _a;
878
+ var _comparator;
910
879
  const list = args[0];
911
880
  const value = args[1];
912
881
  let comparator = args[2];
913
882
  let formIndex = 0;
914
883
  if (isArrayIncludesOptions(comparator)) {
915
- formIndex = (_a = comparator.fromIndex) != null ? _a : 0;
884
+ var _comparator$fromIndex;
885
+ formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0;
916
886
  comparator = comparator.comparator;
917
887
  }
918
888
  if (typeof comparator === "string") {
919
889
  const key = comparator;
920
- comparator = (element, value2) => element[key] === reactivity.toValue(value2);
890
+ comparator = (element, value$1) => element[key] === reactivity.toValue(value$1);
921
891
  }
922
- comparator = comparator != null ? comparator : (element, value2) => element === reactivity.toValue(value2);
923
- return reactivity.computed(() => reactivity.toValue(list).slice(formIndex).some((element, index, array) => comparator(
924
- reactivity.toValue(element),
925
- reactivity.toValue(value),
926
- index,
927
- reactivity.toValue(array)
928
- )));
892
+ comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === reactivity.toValue(value$1));
893
+ return reactivity.computed(() => reactivity.toValue(list).slice(formIndex).some((element, index, array) => comparator(reactivity.toValue(element), reactivity.toValue(value), index, reactivity.toValue(array))));
929
894
  }
930
895
  // @__NO_SIDE_EFFECTS__
931
896
  function useArrayJoin(list, separator) {
@@ -952,8 +917,7 @@ function uniq(array) {
952
917
  }
953
918
  function uniqueElementsBy(array, fn) {
954
919
  return array.reduce((acc, v) => {
955
- if (!acc.some((x) => fn(v, x, array)))
956
- acc.push(v);
920
+ if (!acc.some((x) => fn(v, x, array))) acc.push(v);
957
921
  return acc;
958
922
  }, []);
959
923
  }
@@ -967,35 +931,43 @@ function useArrayUnique(list, compareFn) {
967
931
  function useCounter(initialValue = 0, options = {}) {
968
932
  let _initialValue = reactivity.unref(initialValue);
969
933
  const count = reactivity.shallowRef(initialValue);
970
- const {
971
- max = Number.POSITIVE_INFINITY,
972
- min = Number.NEGATIVE_INFINITY
973
- } = options;
934
+ const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options;
974
935
  const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
975
936
  const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
976
- const get2 = () => count.value;
977
- const set2 = (val) => count.value = Math.max(min, Math.min(max, val));
937
+ const get$1 = () => count.value;
938
+ const set$1 = (val) => count.value = Math.max(min, Math.min(max, val));
978
939
  const reset = (val = _initialValue) => {
979
940
  _initialValue = val;
980
- return set2(val);
941
+ return set$1(val);
942
+ };
943
+ return {
944
+ count: reactivity.shallowReadonly(count),
945
+ inc,
946
+ dec,
947
+ get: get$1,
948
+ set: set$1,
949
+ reset
981
950
  };
982
- return { count: reactivity.shallowReadonly(count), inc, dec, get: get2, set: set2, reset };
983
951
  }
984
952
  const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
985
953
  const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
986
954
  function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
987
955
  let m = hours < 12 ? "AM" : "PM";
988
- if (hasPeriod)
989
- m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
956
+ if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
990
957
  return isLowercase ? m.toLowerCase() : m;
991
958
  }
992
959
  function formatOrdinal(num) {
993
- const suffixes = ["th", "st", "nd", "rd"];
960
+ const suffixes = [
961
+ "th",
962
+ "st",
963
+ "nd",
964
+ "rd"
965
+ ];
994
966
  const v = num % 100;
995
967
  return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
996
968
  }
997
969
  function formatDate(date, formatStr, options = {}) {
998
- var _a;
970
+ var _options$customMeridi;
999
971
  const years = date.getFullYear();
1000
972
  const month = date.getMonth();
1001
973
  const days = date.getDate();
@@ -1004,10 +976,10 @@ function formatDate(date, formatStr, options = {}) {
1004
976
  const seconds = date.getSeconds();
1005
977
  const milliseconds = date.getMilliseconds();
1006
978
  const day = date.getDay();
1007
- const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
979
+ const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem;
1008
980
  const stripTimeZone = (dateString) => {
1009
- var _a2;
1010
- return (_a2 = dateString.split(" ")[1]) != null ? _a2 : "";
981
+ var _dateString$split$;
982
+ return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : "";
1011
983
  };
1012
984
  const matches = {
1013
985
  Yo: () => formatOrdinal(years),
@@ -1048,17 +1020,14 @@ function formatDate(date, formatStr, options = {}) {
1048
1020
  zzzz: () => stripTimeZone(date.toLocaleDateString(reactivity.toValue(options.locales), { timeZoneName: "longOffset" }))
1049
1021
  };
1050
1022
  return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1051
- var _a2, _b;
1052
- return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match;
1023
+ var _ref, _matches$match;
1024
+ return (_ref = $1 !== null && $1 !== void 0 ? $1 : (_matches$match = matches[match]) === null || _matches$match === void 0 ? void 0 : _matches$match.call(matches)) !== null && _ref !== void 0 ? _ref : match;
1053
1025
  });
1054
1026
  }
1055
1027
  function normalizeDate(date) {
1056
- if (date === null)
1057
- return new Date(Number.NaN);
1058
- if (date === void 0)
1059
- return /* @__PURE__ */ new Date();
1060
- if (date instanceof Date)
1061
- return new Date(date);
1028
+ if (date === null) return /* @__PURE__ */ new Date(NaN);
1029
+ if (date === void 0) return /* @__PURE__ */ new Date();
1030
+ if (date instanceof Date) return new Date(date);
1062
1031
  if (typeof date === "string" && !/Z$/i.test(date)) {
1063
1032
  const d = date.match(REGEX_PARSE);
1064
1033
  if (d) {
@@ -1074,10 +1043,7 @@ function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1074
1043
  return reactivity.computed(() => formatDate(normalizeDate(reactivity.toValue(date)), reactivity.toValue(formatStr), options));
1075
1044
  }
1076
1045
  function useIntervalFn(cb, interval = 1e3, options = {}) {
1077
- const {
1078
- immediate = true,
1079
- immediateCallback = false
1080
- } = options;
1046
+ const { immediate = true, immediateCallback = false } = options;
1081
1047
  let timer = null;
1082
1048
  const isActive = reactivity.shallowRef(false);
1083
1049
  function clean() {
@@ -1092,24 +1058,16 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1092
1058
  }
1093
1059
  function resume() {
1094
1060
  const intervalValue = reactivity.toValue(interval);
1095
- if (intervalValue <= 0)
1096
- return;
1061
+ if (intervalValue <= 0) return;
1097
1062
  isActive.value = true;
1098
- if (immediateCallback)
1099
- cb();
1063
+ if (immediateCallback) cb();
1100
1064
  clean();
1101
- if (isActive.value)
1102
- timer = setInterval(cb, intervalValue);
1103
- }
1104
- if (immediate && isClient)
1105
- resume();
1106
- if (reactivity.isRef(interval) || typeof interval === "function") {
1107
- const stopWatch = reactivity.watch(interval, () => {
1108
- if (isActive.value && isClient)
1109
- resume();
1110
- });
1111
- tryOnScopeDispose(stopWatch);
1065
+ if (isActive.value) timer = setInterval(cb, intervalValue);
1112
1066
  }
1067
+ if (immediate && isClient) resume();
1068
+ if (reactivity.isRef(interval) || typeof interval === "function") tryOnScopeDispose(reactivity.watch(interval, () => {
1069
+ if (isActive.value && isClient) resume();
1070
+ }));
1113
1071
  tryOnScopeDispose(pause);
1114
1072
  return {
1115
1073
  isActive: reactivity.shallowReadonly(isActive),
@@ -1118,49 +1076,31 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1118
1076
  };
1119
1077
  }
1120
1078
  function useInterval(interval = 1e3, options = {}) {
1121
- const {
1122
- controls: exposeControls = false,
1123
- immediate = true,
1124
- callback
1125
- } = options;
1079
+ const { controls: exposeControls = false, immediate = true, callback } = options;
1126
1080
  const counter = reactivity.shallowRef(0);
1127
1081
  const update = () => counter.value += 1;
1128
1082
  const reset = () => {
1129
1083
  counter.value = 0;
1130
1084
  };
1131
- const controls = useIntervalFn(
1132
- callback ? () => {
1133
- update();
1134
- callback(counter.value);
1135
- } : update,
1136
- interval,
1137
- { immediate }
1138
- );
1139
- if (exposeControls) {
1140
- return {
1141
- counter: reactivity.shallowReadonly(counter),
1142
- reset,
1143
- ...controls
1144
- };
1145
- } else {
1146
- return reactivity.shallowReadonly(counter);
1147
- }
1085
+ const controls = useIntervalFn(callback ? () => {
1086
+ update();
1087
+ callback(counter.value);
1088
+ } : update, interval, { immediate });
1089
+ if (exposeControls) return {
1090
+ counter: reactivity.shallowReadonly(counter),
1091
+ reset,
1092
+ ...controls
1093
+ };
1094
+ else return reactivity.shallowReadonly(counter);
1148
1095
  }
1149
1096
  function useLastChanged(source, options = {}) {
1150
- var _a;
1151
- const ms = reactivity.shallowRef((_a = options.initialValue) != null ? _a : null);
1152
- reactivity.watch(
1153
- source,
1154
- () => ms.value = timestamp(),
1155
- options
1156
- );
1097
+ var _options$initialValue;
1098
+ const ms = reactivity.shallowRef((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null);
1099
+ reactivity.watch(source, () => ms.value = timestamp(), options);
1157
1100
  return reactivity.shallowReadonly(ms);
1158
1101
  }
1159
1102
  function useTimeoutFn(cb, interval, options = {}) {
1160
- const {
1161
- immediate = true,
1162
- immediateCallback = false
1163
- } = options;
1103
+ const { immediate = true, immediateCallback = false } = options;
1164
1104
  const isPending = reactivity.shallowRef(false);
1165
1105
  let timer;
1166
1106
  function clear() {
@@ -1174,8 +1114,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1174
1114
  clear();
1175
1115
  }
1176
1116
  function start(...args) {
1177
- if (immediateCallback)
1178
- cb();
1117
+ if (immediateCallback) cb();
1179
1118
  clear();
1180
1119
  isPending.value = true;
1181
1120
  timer = setTimeout(() => {
@@ -1186,8 +1125,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1186
1125
  }
1187
1126
  if (immediate) {
1188
1127
  isPending.value = true;
1189
- if (isClient)
1190
- start();
1128
+ if (isClient) start();
1191
1129
  }
1192
1130
  tryOnScopeDispose(stop);
1193
1131
  return {
@@ -1197,40 +1135,23 @@ function useTimeoutFn(cb, interval, options = {}) {
1197
1135
  };
1198
1136
  }
1199
1137
  function useTimeout(interval = 1e3, options = {}) {
1200
- const {
1201
- controls: exposeControls = false,
1202
- callback
1203
- } = options;
1204
- const controls = useTimeoutFn(
1205
- callback != null ? callback : noop,
1206
- interval,
1207
- options
1208
- );
1138
+ const { controls: exposeControls = false, callback } = options;
1139
+ const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options);
1209
1140
  const ready = reactivity.computed(() => !controls.isPending.value);
1210
- if (exposeControls) {
1211
- return {
1212
- ready,
1213
- ...controls
1214
- };
1215
- } else {
1216
- return ready;
1217
- }
1141
+ if (exposeControls) return {
1142
+ ready,
1143
+ ...controls
1144
+ };
1145
+ else return ready;
1218
1146
  }
1219
1147
  // @__NO_SIDE_EFFECTS__
1220
1148
  function useToNumber(value, options = {}) {
1221
- const {
1222
- method = "parseFloat",
1223
- radix,
1224
- nanToZero
1225
- } = options;
1149
+ const { method = "parseFloat", radix, nanToZero } = options;
1226
1150
  return reactivity.computed(() => {
1227
1151
  let resolved = reactivity.toValue(value);
1228
- if (typeof method === "function")
1229
- resolved = method(resolved);
1230
- else if (typeof resolved === "string")
1231
- resolved = Number[method](resolved, radix);
1232
- if (nanToZero && Number.isNaN(resolved))
1233
- resolved = 0;
1152
+ if (typeof method === "function") resolved = method(resolved);
1153
+ else if (typeof resolved === "string") resolved = Number[method](resolved, radix);
1154
+ if (nanToZero && Number.isNaN(resolved)) resolved = 0;
1234
1155
  return resolved;
1235
1156
  });
1236
1157
  }
@@ -1240,10 +1161,7 @@ function useToString(value) {
1240
1161
  }
1241
1162
  // @__NO_SIDE_EFFECTS__
1242
1163
  function useToggle(initialValue = false, options = {}) {
1243
- const {
1244
- truthyValue = true,
1245
- falsyValue = false
1246
- } = options;
1164
+ const { truthyValue = true, falsyValue = false } = options;
1247
1165
  const valueIsRef = reactivity.isRef(initialValue);
1248
1166
  const _value = reactivity.shallowRef(initialValue);
1249
1167
  function toggle(value) {
@@ -1256,85 +1174,60 @@ function useToggle(initialValue = false, options = {}) {
1256
1174
  return _value.value;
1257
1175
  }
1258
1176
  }
1259
- if (valueIsRef)
1260
- return toggle;
1261
- else
1262
- return [_value, toggle];
1177
+ if (valueIsRef) return toggle;
1178
+ else return [_value, toggle];
1263
1179
  }
1264
1180
  function watchArray(source, cb, options) {
1265
- let oldList = (options == null ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : reactivity.toValue(source)];
1181
+ let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : reactivity.toValue(source)];
1266
1182
  return reactivity.watch(source, (newList, _, onCleanup) => {
1267
1183
  const oldListRemains = Array.from({ length: oldList.length });
1268
1184
  const added = [];
1269
1185
  for (const obj of newList) {
1270
1186
  let found = false;
1271
- for (let i = 0; i < oldList.length; i++) {
1272
- if (!oldListRemains[i] && obj === oldList[i]) {
1273
- oldListRemains[i] = true;
1274
- found = true;
1275
- break;
1276
- }
1187
+ for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) {
1188
+ oldListRemains[i] = true;
1189
+ found = true;
1190
+ break;
1277
1191
  }
1278
- if (!found)
1279
- added.push(obj);
1192
+ if (!found) added.push(obj);
1280
1193
  }
1281
- const removed = oldList.filter((_2, i) => !oldListRemains[i]);
1194
+ const removed = oldList.filter((_$1, i) => !oldListRemains[i]);
1282
1195
  cb(newList, oldList, added, removed, onCleanup);
1283
1196
  oldList = [...newList];
1284
1197
  }, options);
1285
1198
  }
1286
1199
  function watchAtMost(source, cb, options) {
1287
- const {
1288
- count,
1289
- ...watchOptions
1290
- } = options;
1200
+ const { count, ...watchOptions } = options;
1291
1201
  const current = reactivity.shallowRef(0);
1292
- const stop = watchWithFilter(
1293
- source,
1294
- (...args) => {
1295
- current.value += 1;
1296
- if (current.value >= reactivity.toValue(count))
1297
- reactivity.nextTick(() => stop());
1298
- cb(...args);
1299
- },
1300
- watchOptions
1301
- );
1302
- return { count: current, stop };
1202
+ const { stop, resume, pause } = watchWithFilter(source, (...args) => {
1203
+ current.value += 1;
1204
+ if (current.value >= reactivity.toValue(count)) reactivity.nextTick(() => stop());
1205
+ cb(...args);
1206
+ }, watchOptions);
1207
+ return {
1208
+ count: current,
1209
+ stop,
1210
+ resume,
1211
+ pause
1212
+ };
1303
1213
  }
1304
1214
  function watchDebounced(source, cb, options = {}) {
1305
- const {
1306
- debounce = 0,
1307
- maxWait = void 0,
1308
- ...watchOptions
1309
- } = options;
1310
- return watchWithFilter(
1311
- source,
1312
- cb,
1313
- {
1314
- ...watchOptions,
1315
- eventFilter: debounceFilter(debounce, { maxWait })
1316
- }
1317
- );
1215
+ const { debounce = 0, maxWait = void 0, ...watchOptions } = options;
1216
+ return watchWithFilter(source, cb, {
1217
+ ...watchOptions,
1218
+ eventFilter: debounceFilter(debounce, { maxWait })
1219
+ });
1318
1220
  }
1221
+ const debouncedWatch = watchDebounced;
1319
1222
  function watchDeep(source, cb, options) {
1320
- return reactivity.watch(
1321
- source,
1322
- cb,
1323
- {
1324
- ...options,
1325
- deep: true
1326
- }
1327
- );
1223
+ return reactivity.watch(source, cb, {
1224
+ ...options,
1225
+ deep: true
1226
+ });
1328
1227
  }
1329
1228
  function watchIgnorable(source, cb, options = {}) {
1330
- const {
1331
- eventFilter = bypassFilter,
1332
- ...watchOptions
1333
- } = options;
1334
- const filteredCb = createFilterWrapper(
1335
- eventFilter,
1336
- cb
1337
- );
1229
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
1230
+ const filteredCb = createFilterWrapper(eventFilter, cb);
1338
1231
  let ignoreUpdates;
1339
1232
  let ignorePrevAsyncUpdates;
1340
1233
  let stop;
@@ -1347,14 +1240,9 @@ function watchIgnorable(source, cb, options = {}) {
1347
1240
  updater();
1348
1241
  ignore = false;
1349
1242
  };
1350
- stop = reactivity.watch(
1351
- source,
1352
- (...args) => {
1353
- if (!ignore)
1354
- filteredCb(...args);
1355
- },
1356
- watchOptions
1357
- );
1243
+ stop = reactivity.watch(source, (...args) => {
1244
+ if (!ignore) filteredCb(...args);
1245
+ }, watchOptions);
1358
1246
  } else {
1359
1247
  const disposables = [];
1360
1248
  let ignoreCounter = 0;
@@ -1362,81 +1250,59 @@ function watchIgnorable(source, cb, options = {}) {
1362
1250
  ignorePrevAsyncUpdates = () => {
1363
1251
  ignoreCounter = syncCounter;
1364
1252
  };
1365
- disposables.push(
1366
- reactivity.watch(
1367
- source,
1368
- () => {
1369
- syncCounter++;
1370
- },
1371
- { ...watchOptions, flush: "sync" }
1372
- )
1373
- );
1253
+ disposables.push(reactivity.watch(source, () => {
1254
+ syncCounter++;
1255
+ }, {
1256
+ ...watchOptions,
1257
+ flush: "sync"
1258
+ }));
1374
1259
  ignoreUpdates = (updater) => {
1375
1260
  const syncCounterPrev = syncCounter;
1376
1261
  updater();
1377
1262
  ignoreCounter += syncCounter - syncCounterPrev;
1378
1263
  };
1379
- disposables.push(
1380
- reactivity.watch(
1381
- source,
1382
- (...args) => {
1383
- const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
1384
- ignoreCounter = 0;
1385
- syncCounter = 0;
1386
- if (ignore)
1387
- return;
1388
- filteredCb(...args);
1389
- },
1390
- watchOptions
1391
- )
1392
- );
1264
+ disposables.push(reactivity.watch(source, (...args) => {
1265
+ const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
1266
+ ignoreCounter = 0;
1267
+ syncCounter = 0;
1268
+ if (ignore) return;
1269
+ filteredCb(...args);
1270
+ }, watchOptions));
1393
1271
  stop = () => {
1394
1272
  disposables.forEach((fn) => fn());
1395
1273
  };
1396
1274
  }
1397
- return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
1275
+ return {
1276
+ stop,
1277
+ ignoreUpdates,
1278
+ ignorePrevAsyncUpdates
1279
+ };
1398
1280
  }
1281
+ const ignorableWatch = watchIgnorable;
1399
1282
  function watchImmediate(source, cb, options) {
1400
- return reactivity.watch(
1401
- source,
1402
- cb,
1403
- {
1404
- ...options,
1405
- immediate: true
1406
- }
1407
- );
1283
+ return reactivity.watch(source, cb, {
1284
+ ...options,
1285
+ immediate: true
1286
+ });
1408
1287
  }
1409
1288
  function watchOnce(source, cb, options) {
1410
- return reactivity.watch(
1411
- source,
1412
- cb,
1413
- {
1414
- ...options,
1415
- once: true
1416
- }
1417
- );
1289
+ return reactivity.watch(source, cb, {
1290
+ ...options,
1291
+ once: true
1292
+ });
1418
1293
  }
1419
1294
  function watchThrottled(source, cb, options = {}) {
1420
- const {
1421
- throttle = 0,
1422
- trailing = true,
1423
- leading = true,
1424
- ...watchOptions
1425
- } = options;
1426
- return watchWithFilter(
1427
- source,
1428
- cb,
1429
- {
1430
- ...watchOptions,
1431
- eventFilter: throttleFilter(throttle, trailing, leading)
1432
- }
1433
- );
1295
+ const { throttle = 0, trailing = true, leading = true, ...watchOptions } = options;
1296
+ return watchWithFilter(source, cb, {
1297
+ ...watchOptions,
1298
+ eventFilter: throttleFilter(throttle, trailing, leading)
1299
+ });
1434
1300
  }
1301
+ const throttledWatch = watchThrottled;
1435
1302
  function watchTriggerable(source, cb, options = {}) {
1436
1303
  let cleanupFn;
1437
1304
  function onEffect() {
1438
- if (!cleanupFn)
1439
- return;
1305
+ if (!cleanupFn) return;
1440
1306
  const fn = cleanupFn;
1441
1307
  cleanupFn = void 0;
1442
1308
  fn();
@@ -1451,11 +1317,11 @@ function watchTriggerable(source, cb, options = {}) {
1451
1317
  const res = watchIgnorable(source, _cb, options);
1452
1318
  const { ignoreUpdates } = res;
1453
1319
  const trigger = () => {
1454
- let res2;
1320
+ let res$1;
1455
1321
  ignoreUpdates(() => {
1456
- res2 = _cb(getWatchSources(source), getOldValue(source));
1322
+ res$1 = _cb(getWatchSources(source), getOldValue(source));
1457
1323
  });
1458
- return res2;
1324
+ return res$1;
1459
1325
  };
1460
1326
  return {
1461
1327
  ...res,
@@ -1463,91 +1329,64 @@ function watchTriggerable(source, cb, options = {}) {
1463
1329
  };
1464
1330
  }
1465
1331
  function getWatchSources(sources) {
1466
- if (reactivity.isReactive(sources))
1467
- return sources;
1468
- if (Array.isArray(sources))
1469
- return sources.map((item) => reactivity.toValue(item));
1332
+ if (reactivity.isReactive(sources)) return sources;
1333
+ if (Array.isArray(sources)) return sources.map((item) => reactivity.toValue(item));
1470
1334
  return reactivity.toValue(sources);
1471
1335
  }
1472
1336
  function getOldValue(source) {
1473
1337
  return Array.isArray(source) ? source.map(() => void 0) : void 0;
1474
1338
  }
1475
1339
  function whenever(source, cb, options) {
1476
- const stop = reactivity.watch(
1477
- source,
1478
- (v, ov, onInvalidate) => {
1479
- if (v) {
1480
- if (options == null ? void 0 : options.once)
1481
- reactivity.nextTick(() => stop());
1482
- cb(v, ov, onInvalidate);
1483
- }
1484
- },
1485
- {
1486
- ...options,
1487
- once: false
1340
+ const stop = reactivity.watch(source, (v, ov, onInvalidate) => {
1341
+ if (v) {
1342
+ if (options === null || options === void 0 ? void 0 : options.once) reactivity.nextTick(() => stop());
1343
+ cb(v, ov, onInvalidate);
1488
1344
  }
1489
- );
1345
+ }, {
1346
+ ...options,
1347
+ once: false
1348
+ });
1490
1349
  return stop;
1491
1350
  }
1492
1351
  function computedAsync(evaluationCallback, initialState, optionsOrRef) {
1493
- var _a;
1352
+ var _globalThis$reportErr;
1494
1353
  let options;
1495
- if (reactivity.isRef(optionsOrRef)) {
1496
- options = {
1497
- evaluating: optionsOrRef
1498
- };
1499
- } else {
1500
- options = optionsOrRef || {};
1501
- }
1502
- const {
1503
- lazy = false,
1504
- flush = "pre",
1505
- evaluating = void 0,
1506
- shallow = true,
1507
- onError = (_a = globalThis.reportError) != null ? _a : noop
1508
- } = options;
1354
+ if (reactivity.isRef(optionsOrRef)) options = { evaluating: optionsOrRef };
1355
+ else options = optionsOrRef || {};
1356
+ const { lazy = false, flush = "sync", evaluating = void 0, shallow = true, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : noop } = options;
1509
1357
  const started = reactivity.shallowRef(!lazy);
1510
1358
  const current = shallow ? reactivity.shallowRef(initialState) : reactivity.ref(initialState);
1511
1359
  let counter = 0;
1512
1360
  reactivity.watchEffect(async (onInvalidate) => {
1513
- if (!started.value)
1514
- return;
1361
+ if (!started.value) return;
1515
1362
  counter++;
1516
1363
  const counterAtBeginning = counter;
1517
1364
  let hasFinished = false;
1518
- if (evaluating) {
1519
- Promise.resolve().then(() => {
1520
- evaluating.value = true;
1521
- });
1522
- }
1365
+ if (evaluating) Promise.resolve().then(() => {
1366
+ evaluating.value = true;
1367
+ });
1523
1368
  try {
1524
1369
  const result = await evaluationCallback((cancelCallback) => {
1525
1370
  onInvalidate(() => {
1526
- if (evaluating)
1527
- evaluating.value = false;
1528
- if (!hasFinished)
1529
- cancelCallback();
1371
+ if (evaluating) evaluating.value = false;
1372
+ if (!hasFinished) cancelCallback();
1530
1373
  });
1531
1374
  });
1532
- if (counterAtBeginning === counter)
1533
- current.value = result;
1375
+ if (counterAtBeginning === counter) current.value = result;
1534
1376
  } catch (e) {
1535
1377
  onError(e);
1536
1378
  } finally {
1537
- if (evaluating && counterAtBeginning === counter)
1538
- evaluating.value = false;
1379
+ if (evaluating && counterAtBeginning === counter) evaluating.value = false;
1539
1380
  hasFinished = true;
1540
1381
  }
1541
1382
  }, { flush });
1542
- if (lazy) {
1543
- return reactivity.computed(() => {
1544
- started.value = true;
1545
- return current.value;
1546
- });
1547
- } else {
1548
- return current;
1549
- }
1383
+ if (lazy) return reactivity.computed(() => {
1384
+ started.value = true;
1385
+ return current.value;
1386
+ });
1387
+ else return current;
1550
1388
  }
1389
+ const asyncComputed = computedAsync;
1551
1390
  // @__NO_SIDE_EFFECTS__
1552
1391
  function createUnrefFn(fn) {
1553
1392
  return function(...args) {
@@ -1556,16 +1395,11 @@ function createUnrefFn(fn) {
1556
1395
  }
1557
1396
  const defaultWindow = isClient ? window : void 0;
1558
1397
  function unrefElement(elRef) {
1559
- var _a;
1398
+ var _$el;
1560
1399
  const plain = reactivity.toValue(elRef);
1561
- return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
1400
+ return (_$el = plain === null || plain === void 0 ? void 0 : plain.$el) !== null && _$el !== void 0 ? _$el : plain;
1562
1401
  }
1563
1402
  function useEventListener(...args) {
1564
- const cleanups = [];
1565
- const cleanup = () => {
1566
- cleanups.forEach((fn) => fn());
1567
- cleanups.length = 0;
1568
- };
1569
1403
  const register = (el, event, listener, options) => {
1570
1404
  el.addEventListener(event, listener, options);
1571
1405
  return () => el.removeEventListener(event, listener, options);
@@ -1574,38 +1408,22 @@ function useEventListener(...args) {
1574
1408
  const test = toArray(reactivity.toValue(args[0])).filter((e) => e != null);
1575
1409
  return test.every((e) => typeof e !== "string") ? test : void 0;
1576
1410
  });
1577
- const stopWatch = watchImmediate(
1578
- () => {
1579
- var _a, _b;
1580
- return [
1581
- (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
1582
- toArray(reactivity.toValue(firstParamTargets.value ? args[1] : args[0])),
1583
- toArray(reactivity.unref(firstParamTargets.value ? args[2] : args[1])),
1584
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
1585
- reactivity.toValue(firstParamTargets.value ? args[3] : args[2])
1586
- ];
1587
- },
1588
- ([raw_targets, raw_events, raw_listeners, raw_options]) => {
1589
- cleanup();
1590
- if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
1591
- return;
1592
- const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
1593
- cleanups.push(
1594
- ...raw_targets.flatMap(
1595
- (el) => raw_events.flatMap(
1596
- (event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
1597
- )
1598
- )
1599
- );
1600
- },
1601
- { flush: "post" }
1602
- );
1603
- const stop = () => {
1604
- stopWatch();
1605
- cleanup();
1606
- };
1607
- tryOnScopeDispose(cleanup);
1608
- return stop;
1411
+ return watchImmediate(() => {
1412
+ var _firstParamTargets$va, _firstParamTargets$va2;
1413
+ return [
1414
+ (_firstParamTargets$va = (_firstParamTargets$va2 = firstParamTargets.value) === null || _firstParamTargets$va2 === void 0 ? void 0 : _firstParamTargets$va2.map((e) => unrefElement(e))) !== null && _firstParamTargets$va !== void 0 ? _firstParamTargets$va : [defaultWindow].filter((e) => e != null),
1415
+ toArray(reactivity.toValue(firstParamTargets.value ? args[1] : args[0])),
1416
+ toArray(reactivity.unref(firstParamTargets.value ? args[2] : args[1])),
1417
+ reactivity.toValue(firstParamTargets.value ? args[3] : args[2])
1418
+ ];
1419
+ }, ([raw_targets, raw_events, raw_listeners, raw_options], _, onCleanup) => {
1420
+ if (!(raw_targets === null || raw_targets === void 0 ? void 0 : raw_targets.length) || !(raw_events === null || raw_events === void 0 ? void 0 : raw_events.length) || !(raw_listeners === null || raw_listeners === void 0 ? void 0 : raw_listeners.length)) return;
1421
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
1422
+ const cleanups = raw_targets.flatMap((el) => raw_events.flatMap((event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))));
1423
+ onCleanup(() => {
1424
+ cleanups.forEach((fn) => fn());
1425
+ });
1426
+ }, { flush: "post" });
1609
1427
  }
1610
1428
  // @__NO_SIDE_EFFECTS__
1611
1429
  function useMounted() {
@@ -1621,53 +1439,48 @@ function useSupported(callback) {
1621
1439
  });
1622
1440
  }
1623
1441
  function useRafFn(fn, options = {}) {
1624
- const {
1625
- immediate = true,
1626
- fpsLimit = void 0,
1627
- window: window2 = defaultWindow,
1628
- once = false
1629
- } = options;
1442
+ const { immediate = true, fpsLimit = void 0, window: window$1 = defaultWindow, once = false } = options;
1630
1443
  const isActive = reactivity.shallowRef(false);
1631
1444
  const intervalLimit = reactivity.computed(() => {
1632
1445
  return fpsLimit ? 1e3 / reactivity.toValue(fpsLimit) : null;
1633
1446
  });
1634
1447
  let previousFrameTimestamp = 0;
1635
1448
  let rafId = null;
1636
- function loop(timestamp2) {
1637
- if (!isActive.value || !window2)
1638
- return;
1639
- if (!previousFrameTimestamp)
1640
- previousFrameTimestamp = timestamp2;
1641
- const delta = timestamp2 - previousFrameTimestamp;
1449
+ function loop(timestamp$1) {
1450
+ if (!isActive.value || !window$1) return;
1451
+ if (!previousFrameTimestamp) previousFrameTimestamp = timestamp$1;
1452
+ const delta = timestamp$1 - previousFrameTimestamp;
1642
1453
  if (intervalLimit.value && delta < intervalLimit.value) {
1643
- rafId = window2.requestAnimationFrame(loop);
1454
+ rafId = window$1.requestAnimationFrame(loop);
1644
1455
  return;
1645
1456
  }
1646
- previousFrameTimestamp = timestamp2;
1647
- fn({ delta, timestamp: timestamp2 });
1457
+ previousFrameTimestamp = timestamp$1;
1458
+ fn({
1459
+ delta,
1460
+ timestamp: timestamp$1
1461
+ });
1648
1462
  if (once) {
1649
1463
  isActive.value = false;
1650
1464
  rafId = null;
1651
1465
  return;
1652
1466
  }
1653
- rafId = window2.requestAnimationFrame(loop);
1467
+ rafId = window$1.requestAnimationFrame(loop);
1654
1468
  }
1655
1469
  function resume() {
1656
- if (!isActive.value && window2) {
1470
+ if (!isActive.value && window$1) {
1657
1471
  isActive.value = true;
1658
1472
  previousFrameTimestamp = 0;
1659
- rafId = window2.requestAnimationFrame(loop);
1473
+ rafId = window$1.requestAnimationFrame(loop);
1660
1474
  }
1661
1475
  }
1662
1476
  function pause() {
1663
1477
  isActive.value = false;
1664
- if (rafId != null && window2) {
1665
- window2.cancelAnimationFrame(rafId);
1478
+ if (rafId != null && window$1) {
1479
+ window$1.cancelAnimationFrame(rafId);
1666
1480
  rafId = null;
1667
1481
  }
1668
1482
  }
1669
- if (immediate)
1670
- resume();
1483
+ if (immediate) resume();
1671
1484
  tryOnScopeDispose(pause);
1672
1485
  return {
1673
1486
  isActive: reactivity.readonly(isActive),
@@ -1676,20 +1489,17 @@ function useRafFn(fn, options = {}) {
1676
1489
  };
1677
1490
  }
1678
1491
  function useAsyncQueue(tasks, options) {
1679
- const {
1680
- interrupt = true,
1681
- onError = noop,
1682
- onFinished = noop,
1683
- signal
1684
- } = options || {};
1492
+ const { interrupt = true, onError = noop, onFinished = noop, signal } = options || {};
1685
1493
  const promiseState = {
1686
1494
  aborted: "aborted",
1687
1495
  fulfilled: "fulfilled",
1688
1496
  pending: "pending",
1689
1497
  rejected: "rejected"
1690
1498
  };
1691
- const initialResult = Array.from(Array.from({ length: tasks.length }), () => ({ state: promiseState.pending, data: null }));
1692
- const result = reactivity.reactive(initialResult);
1499
+ const result = reactivity.reactive(Array.from(Array.from({ length: tasks.length }), () => ({
1500
+ state: promiseState.pending,
1501
+ data: null
1502
+ })));
1693
1503
  const activeIndex = reactivity.shallowRef(-1);
1694
1504
  if (!tasks || tasks.length === 0) {
1695
1505
  onFinished();
@@ -1705,31 +1515,30 @@ function useAsyncQueue(tasks, options) {
1705
1515
  }
1706
1516
  tasks.reduce((prev, curr) => {
1707
1517
  return prev.then((prevRes) => {
1708
- var _a;
1709
- if (signal == null ? void 0 : signal.aborted) {
1710
- updateResult(promiseState.aborted, new Error("aborted"));
1518
+ var _result$activeIndex$v;
1519
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
1520
+ updateResult(promiseState.aborted, /* @__PURE__ */ new Error("aborted"));
1711
1521
  return;
1712
1522
  }
1713
- if (((_a = result[activeIndex.value]) == null ? void 0 : _a.state) === promiseState.rejected && interrupt) {
1523
+ if (((_result$activeIndex$v = result[activeIndex.value]) === null || _result$activeIndex$v === void 0 ? void 0 : _result$activeIndex$v.state) === promiseState.rejected && interrupt) {
1714
1524
  onFinished();
1715
1525
  return;
1716
1526
  }
1717
1527
  const done = curr(prevRes).then((currentRes) => {
1718
1528
  updateResult(promiseState.fulfilled, currentRes);
1719
- if (activeIndex.value === tasks.length - 1)
1720
- onFinished();
1529
+ if (activeIndex.value === tasks.length - 1) onFinished();
1721
1530
  return currentRes;
1722
1531
  });
1723
- if (!signal)
1724
- return done;
1532
+ if (!signal) return done;
1725
1533
  return Promise.race([done, whenAborted(signal)]);
1726
1534
  }).catch((e) => {
1727
- if (signal == null ? void 0 : signal.aborted) {
1535
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
1728
1536
  updateResult(promiseState.aborted, e);
1729
1537
  return e;
1730
1538
  }
1731
1539
  updateResult(promiseState.rejected, e);
1732
1540
  onError();
1541
+ if (activeIndex.value === tasks.length - 1) onFinished();
1733
1542
  return e;
1734
1543
  });
1735
1544
  }, Promise.resolve());
@@ -1740,55 +1549,44 @@ function useAsyncQueue(tasks, options) {
1740
1549
  }
1741
1550
  function whenAborted(signal) {
1742
1551
  return new Promise((resolve, reject) => {
1743
- const error = new Error("aborted");
1744
- if (signal.aborted)
1745
- reject(error);
1746
- else
1747
- signal.addEventListener("abort", () => reject(error), { once: true });
1552
+ const error = /* @__PURE__ */ new Error("aborted");
1553
+ if (signal.aborted) reject(error);
1554
+ else signal.addEventListener("abort", () => reject(error), { once: true });
1748
1555
  });
1749
1556
  }
1750
1557
  function useAsyncState(promise, initialState, options) {
1751
- var _a;
1752
- const {
1753
- immediate = true,
1754
- delay = 0,
1755
- onError = (_a = globalThis.reportError) != null ? _a : noop,
1756
- onSuccess = noop,
1757
- resetOnExecute = true,
1758
- shallow = true,
1759
- throwError
1760
- } = options != null ? options : {};
1558
+ var _globalThis$reportErr;
1559
+ const { immediate = true, delay = 0, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : noop, onSuccess = noop, resetOnExecute = true, shallow = true, throwError } = options !== null && options !== void 0 ? options : {};
1761
1560
  const state = shallow ? reactivity.shallowRef(initialState) : reactivity.ref(initialState);
1762
1561
  const isReady = reactivity.shallowRef(false);
1763
1562
  const isLoading = reactivity.shallowRef(false);
1764
1563
  const error = reactivity.shallowRef(void 0);
1765
- async function execute(delay2 = 0, ...args) {
1766
- if (resetOnExecute)
1767
- state.value = reactivity.toValue(initialState);
1564
+ let executionsCount = 0;
1565
+ async function execute(delay$1 = 0, ...args) {
1566
+ const executionId = executionsCount += 1;
1567
+ if (resetOnExecute) state.value = reactivity.toValue(initialState);
1768
1568
  error.value = void 0;
1769
1569
  isReady.value = false;
1770
1570
  isLoading.value = true;
1771
- if (delay2 > 0)
1772
- await promiseTimeout(delay2);
1571
+ if (delay$1 > 0) await promiseTimeout(delay$1);
1773
1572
  const _promise = typeof promise === "function" ? promise(...args) : promise;
1774
1573
  try {
1775
1574
  const data = await _promise;
1776
- state.value = data;
1777
- isReady.value = true;
1575
+ if (executionId === executionsCount) {
1576
+ state.value = data;
1577
+ isReady.value = true;
1578
+ }
1778
1579
  onSuccess(data);
1779
1580
  } catch (e) {
1780
- error.value = e;
1581
+ if (executionId === executionsCount) error.value = e;
1781
1582
  onError(e);
1782
- if (throwError)
1783
- throw e;
1583
+ if (throwError) throw e;
1784
1584
  } finally {
1785
- isLoading.value = false;
1585
+ if (executionId === executionsCount) isLoading.value = false;
1786
1586
  }
1787
1587
  return state.value;
1788
1588
  }
1789
- if (immediate) {
1790
- execute(delay);
1791
- }
1589
+ if (immediate) execute(delay);
1792
1590
  const shell = {
1793
1591
  state,
1794
1592
  isReady,
@@ -1817,37 +1615,26 @@ const defaults = {
1817
1615
  null: () => ""
1818
1616
  };
1819
1617
  function getDefaultSerialization(target) {
1820
- if (!target)
1821
- return defaults.null;
1822
- if (target instanceof Map)
1823
- return defaults.map;
1824
- else if (target instanceof Set)
1825
- return defaults.set;
1826
- else if (Array.isArray(target))
1827
- return defaults.array;
1828
- else
1829
- return defaults.object;
1618
+ if (!target) return defaults.null;
1619
+ if (target instanceof Map) return defaults.map;
1620
+ else if (target instanceof Set) return defaults.set;
1621
+ else if (Array.isArray(target)) return defaults.array;
1622
+ else return defaults.object;
1830
1623
  }
1831
1624
  function useBase64(target, options) {
1832
1625
  const base64 = reactivity.shallowRef("");
1833
1626
  const promise = reactivity.shallowRef();
1834
1627
  function execute() {
1835
- if (!isClient)
1836
- return;
1628
+ if (!isClient) return;
1837
1629
  promise.value = new Promise((resolve, reject) => {
1838
1630
  try {
1839
1631
  const _target = reactivity.toValue(target);
1840
- if (_target == null) {
1841
- resolve("");
1842
- } else if (typeof _target === "string") {
1843
- resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
1844
- } else if (_target instanceof Blob) {
1845
- resolve(blobToBase64(_target));
1846
- } else if (_target instanceof ArrayBuffer) {
1847
- resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
1848
- } else if (_target instanceof HTMLCanvasElement) {
1849
- resolve(_target.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
1850
- } else if (_target instanceof HTMLImageElement) {
1632
+ if (_target == null) resolve("");
1633
+ else if (typeof _target === "string") resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
1634
+ else if (_target instanceof Blob) resolve(blobToBase64(_target));
1635
+ else if (_target instanceof ArrayBuffer) resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
1636
+ else if (_target instanceof HTMLCanvasElement) resolve(_target.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality));
1637
+ else if (_target instanceof HTMLImageElement) {
1851
1638
  const img = _target.cloneNode(false);
1852
1639
  img.crossOrigin = "Anonymous";
1853
1640
  imgLoaded(img).then(() => {
@@ -1856,28 +1643,23 @@ function useBase64(target, options) {
1856
1643
  canvas.width = img.width;
1857
1644
  canvas.height = img.height;
1858
1645
  ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
1859
- resolve(canvas.toDataURL(options == null ? void 0 : options.type, options == null ? void 0 : options.quality));
1646
+ resolve(canvas.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality));
1860
1647
  }).catch(reject);
1861
1648
  } else if (typeof _target === "object") {
1862
- const _serializeFn = (options == null ? void 0 : options.serializer) || getDefaultSerialization(_target);
1863
- const serialized = _serializeFn(_target);
1649
+ const serialized = ((options === null || options === void 0 ? void 0 : options.serializer) || getDefaultSerialization(_target))(_target);
1864
1650
  return resolve(blobToBase64(new Blob([serialized], { type: "application/json" })));
1865
- } else {
1866
- reject(new Error("target is unsupported types"));
1867
- }
1651
+ } else reject(/* @__PURE__ */ new Error("target is unsupported types"));
1868
1652
  } catch (error) {
1869
1653
  reject(error);
1870
1654
  }
1871
1655
  });
1872
1656
  promise.value.then((res) => {
1873
- base64.value = (options == null ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
1657
+ base64.value = (options === null || options === void 0 ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
1874
1658
  });
1875
1659
  return promise.value;
1876
1660
  }
1877
- if (reactivity.isRef(target) || typeof target === "function")
1878
- reactivity.watch(target, execute, { immediate: true });
1879
- else
1880
- execute();
1661
+ if (reactivity.isRef(target) || typeof target === "function") reactivity.watch(target, execute, { immediate: true });
1662
+ else execute();
1881
1663
  return {
1882
1664
  base64,
1883
1665
  promise,
@@ -1891,9 +1673,7 @@ function imgLoaded(img) {
1891
1673
  resolve();
1892
1674
  };
1893
1675
  img.onerror = reject;
1894
- } else {
1895
- resolve();
1896
- }
1676
+ } else resolve();
1897
1677
  });
1898
1678
  }
1899
1679
  function blobToBase64(blob) {
@@ -1907,42 +1687,33 @@ function blobToBase64(blob) {
1907
1687
  });
1908
1688
  }
1909
1689
  function useBroadcastChannel(options) {
1910
- const {
1911
- name,
1912
- window: window2 = defaultWindow
1913
- } = options;
1914
- const isSupported = /* @__PURE__ */ useSupported(() => window2 && "BroadcastChannel" in window2);
1690
+ const { name, window: window$1 = defaultWindow } = options;
1691
+ const isSupported = /* @__PURE__ */ useSupported(() => window$1 && "BroadcastChannel" in window$1);
1915
1692
  const isClosed = reactivity.shallowRef(false);
1916
1693
  const channel = reactivity.ref();
1917
1694
  const data = reactivity.ref();
1918
1695
  const error = reactivity.shallowRef(null);
1919
- const post = (data2) => {
1920
- if (channel.value)
1921
- channel.value.postMessage(data2);
1696
+ const post = (data$1) => {
1697
+ if (channel.value) channel.value.postMessage(data$1);
1922
1698
  };
1923
1699
  const close = () => {
1924
- if (channel.value)
1925
- channel.value.close();
1700
+ if (channel.value) channel.value.close();
1926
1701
  isClosed.value = true;
1927
1702
  };
1928
- if (isSupported.value) {
1929
- tryOnMounted(() => {
1930
- error.value = null;
1931
- channel.value = new BroadcastChannel(name);
1932
- const listenerOptions = {
1933
- passive: true
1934
- };
1935
- useEventListener(channel, "message", (e) => {
1936
- data.value = e.data;
1937
- }, listenerOptions);
1938
- useEventListener(channel, "messageerror", (e) => {
1939
- error.value = e;
1940
- }, listenerOptions);
1941
- useEventListener(channel, "close", () => {
1942
- isClosed.value = true;
1943
- }, listenerOptions);
1944
- });
1945
- }
1703
+ if (isSupported.value) tryOnMounted(() => {
1704
+ error.value = null;
1705
+ channel.value = new BroadcastChannel(name);
1706
+ const listenerOptions = { passive: true };
1707
+ useEventListener(channel, "message", (e) => {
1708
+ data.value = e.data;
1709
+ }, listenerOptions);
1710
+ useEventListener(channel, "messageerror", (e) => {
1711
+ error.value = e;
1712
+ }, listenerOptions);
1713
+ useEventListener(channel, "close", () => {
1714
+ isClosed.value = true;
1715
+ }, listenerOptions);
1716
+ });
1946
1717
  tryOnScopeDispose(() => {
1947
1718
  close();
1948
1719
  });
@@ -1960,8 +1731,7 @@ function useCached(refValue, comparator = (a, b) => a === b, options) {
1960
1731
  const { deepRefs = true, ...watchOptions } = options || {};
1961
1732
  const cachedValue = /* @__PURE__ */ createRef(refValue.value, deepRefs);
1962
1733
  reactivity.watch(() => refValue.value, (value) => {
1963
- if (!comparator(value, cachedValue.value))
1964
- cachedValue.value = value;
1734
+ if (!comparator(value, cachedValue.value)) cachedValue.value = value;
1965
1735
  }, watchOptions);
1966
1736
  return cachedValue;
1967
1737
  }
@@ -1972,13 +1742,7 @@ function useCloned(source, options = {}) {
1972
1742
  const cloned = reactivity.ref({});
1973
1743
  const isModified = reactivity.shallowRef(false);
1974
1744
  let _lastSync = false;
1975
- const {
1976
- manual,
1977
- clone = cloneFnJSON,
1978
- // watch options
1979
- deep = true,
1980
- immediate = true
1981
- } = options;
1745
+ const { manual, clone = cloneFnJSON, deep = true, immediate = true } = options;
1982
1746
  reactivity.watch(cloned, () => {
1983
1747
  if (_lastSync) {
1984
1748
  _lastSync = false;
@@ -1994,28 +1758,28 @@ function useCloned(source, options = {}) {
1994
1758
  isModified.value = false;
1995
1759
  cloned.value = clone(reactivity.toValue(source));
1996
1760
  }
1997
- if (!manual && (reactivity.isRef(source) || typeof source === "function")) {
1998
- reactivity.watch(source, sync, {
1999
- ...options,
2000
- deep,
2001
- immediate
2002
- });
2003
- } else {
2004
- sync();
2005
- }
2006
- return { cloned, isModified, sync };
1761
+ if (!manual && (reactivity.isRef(source) || typeof source === "function")) reactivity.watch(source, sync, {
1762
+ ...options,
1763
+ deep,
1764
+ immediate
1765
+ });
1766
+ else sync();
1767
+ return {
1768
+ cloned,
1769
+ isModified,
1770
+ sync
1771
+ };
2007
1772
  }
2008
1773
  function useCycleList(list, options) {
2009
1774
  const state = reactivity.shallowRef(getInitialValue());
2010
1775
  const listRef = toRef(list);
2011
1776
  const index = reactivity.computed({
2012
1777
  get() {
2013
- var _a;
1778
+ var _options$fallbackInde;
2014
1779
  const targetList = listRef.value;
2015
- let index2 = (options == null ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
2016
- if (index2 < 0)
2017
- index2 = (_a = options == null ? void 0 : options.fallbackIndex) != null ? _a : 0;
2018
- return index2;
1780
+ let index$1 = (options === null || options === void 0 ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
1781
+ if (index$1 < 0) index$1 = (_options$fallbackInde = options === null || options === void 0 ? void 0 : options.fallbackIndex) !== null && _options$fallbackInde !== void 0 ? _options$fallbackInde : 0;
1782
+ return index$1;
2019
1783
  },
2020
1784
  set(v) {
2021
1785
  set2(v);
@@ -2024,8 +1788,7 @@ function useCycleList(list, options) {
2024
1788
  function set2(i) {
2025
1789
  const targetList = listRef.value;
2026
1790
  const length = targetList.length;
2027
- const index2 = (i % length + length) % length;
2028
- const value = targetList[index2];
1791
+ const value = targetList[(i % length + length) % length];
2029
1792
  state.value = value;
2030
1793
  return value;
2031
1794
  }
@@ -2039,8 +1802,8 @@ function useCycleList(list, options) {
2039
1802
  return shift(-n);
2040
1803
  }
2041
1804
  function getInitialValue() {
2042
- var _a, _b;
2043
- return (_b = reactivity.toValue((_a = options == null ? void 0 : options.initialValue) != null ? _a : reactivity.toValue(list)[0])) != null ? _b : void 0;
1805
+ var _toValue, _options$initialValue;
1806
+ return (_toValue = reactivity.toValue((_options$initialValue = options === null || options === void 0 ? void 0 : options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : reactivity.toValue(list)[0])) !== null && _toValue !== void 0 ? _toValue : void 0;
2044
1807
  }
2045
1808
  reactivity.watch(listRef, () => set2(index.value));
2046
1809
  return {
@@ -2064,12 +1827,7 @@ function defaultParse(clone) {
2064
1827
  return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
2065
1828
  }
2066
1829
  function useManualRefHistory(source, options = {}) {
2067
- const {
2068
- clone = false,
2069
- dump = defaultDump(clone),
2070
- parse = defaultParse(clone),
2071
- setSource = fnSetSource
2072
- } = options;
1830
+ const { clone = false, dump = defaultDump(clone), parse = defaultParse(clone), setSource = fnSetSource } = options;
2073
1831
  function _createHistoryRecord() {
2074
1832
  return reactivity.markRaw({
2075
1833
  snapshot: dump(source.value),
@@ -2086,10 +1844,8 @@ function useManualRefHistory(source, options = {}) {
2086
1844
  const commit = () => {
2087
1845
  undoStack.value.unshift(last.value);
2088
1846
  last.value = _createHistoryRecord();
2089
- if (options.capacity && undoStack.value.length > options.capacity)
2090
- undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
2091
- if (redoStack.value.length)
2092
- redoStack.value.splice(0, redoStack.value.length);
1847
+ if (options.capacity && undoStack.value.length > options.capacity) undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
1848
+ if (redoStack.value.length) redoStack.value.splice(0, redoStack.value.length);
2093
1849
  };
2094
1850
  const clear = () => {
2095
1851
  undoStack.value.splice(0, undoStack.value.length);
@@ -2112,17 +1868,14 @@ function useManualRefHistory(source, options = {}) {
2112
1868
  const reset = () => {
2113
1869
  _setSource(last.value);
2114
1870
  };
2115
- const history = reactivity.computed(() => [last.value, ...undoStack.value]);
2116
- const canUndo = reactivity.computed(() => undoStack.value.length > 0);
2117
- const canRedo = reactivity.computed(() => redoStack.value.length > 0);
2118
1871
  return {
2119
1872
  source,
2120
1873
  undoStack,
2121
1874
  redoStack,
2122
1875
  last,
2123
- history,
2124
- canUndo,
2125
- canRedo,
1876
+ history: reactivity.computed(() => [last.value, ...undoStack.value]),
1877
+ canUndo: reactivity.computed(() => undoStack.value.length > 0),
1878
+ canRedo: reactivity.computed(() => redoStack.value.length > 0),
2126
1879
  clear,
2127
1880
  commit,
2128
1881
  reset,
@@ -2131,48 +1884,36 @@ function useManualRefHistory(source, options = {}) {
2131
1884
  };
2132
1885
  }
2133
1886
  function useRefHistory(source, options = {}) {
2134
- const {
2135
- deep = false,
2136
- flush = "pre",
2137
- eventFilter,
2138
- shouldCommit = () => true
2139
- } = options;
2140
- const {
2141
- eventFilter: composedFilter,
2142
- pause,
2143
- resume: resumeTracking,
2144
- isActive: isTracking
2145
- } = pausableFilter(eventFilter);
1887
+ const { deep = false, flush = "pre", eventFilter, shouldCommit = () => true } = options;
1888
+ const { eventFilter: composedFilter, pause, resume: resumeTracking, isActive: isTracking } = pausableFilter(eventFilter);
2146
1889
  let lastRawValue = source.value;
2147
- const {
2148
- ignoreUpdates,
2149
- ignorePrevAsyncUpdates,
2150
- stop
2151
- } = watchIgnorable(
2152
- source,
2153
- commit,
2154
- { deep, flush, eventFilter: composedFilter }
2155
- );
2156
- function setSource(source2, value) {
1890
+ const { ignoreUpdates, ignorePrevAsyncUpdates, stop } = watchIgnorable(source, commit, {
1891
+ deep,
1892
+ flush,
1893
+ eventFilter: composedFilter
1894
+ });
1895
+ function setSource(source$1, value) {
2157
1896
  ignorePrevAsyncUpdates();
2158
1897
  ignoreUpdates(() => {
2159
- source2.value = value;
1898
+ source$1.value = value;
2160
1899
  lastRawValue = value;
2161
1900
  });
2162
1901
  }
2163
- const manualHistory = useManualRefHistory(source, { ...options, clone: options.clone || deep, setSource });
1902
+ const manualHistory = useManualRefHistory(source, {
1903
+ ...options,
1904
+ clone: options.clone || deep,
1905
+ setSource
1906
+ });
2164
1907
  const { clear, commit: manualCommit } = manualHistory;
2165
1908
  function commit() {
2166
1909
  ignorePrevAsyncUpdates();
2167
- if (!shouldCommit(lastRawValue, source.value))
2168
- return;
1910
+ if (!shouldCommit(lastRawValue, source.value)) return;
2169
1911
  lastRawValue = source.value;
2170
1912
  manualCommit();
2171
1913
  }
2172
1914
  function resume(commitNow) {
2173
1915
  resumeTracking();
2174
- if (commitNow)
2175
- commit();
1916
+ if (commitNow) commit();
2176
1917
  }
2177
1918
  function batch(fn) {
2178
1919
  let canceled = false;
@@ -2180,8 +1921,7 @@ function useRefHistory(source, options = {}) {
2180
1921
  ignoreUpdates(() => {
2181
1922
  fn(cancel);
2182
1923
  });
2183
- if (!canceled)
2184
- commit();
1924
+ if (!canceled) commit();
2185
1925
  }
2186
1926
  function dispose() {
2187
1927
  stop();
@@ -2199,22 +1939,22 @@ function useRefHistory(source, options = {}) {
2199
1939
  }
2200
1940
  function useDebouncedRefHistory(source, options = {}) {
2201
1941
  const filter = options.debounce ? debounceFilter(options.debounce) : void 0;
2202
- const history = useRefHistory(source, { ...options, eventFilter: filter });
2203
- return {
2204
- ...history
2205
- };
1942
+ return { ...useRefHistory(source, {
1943
+ ...options,
1944
+ eventFilter: filter
1945
+ }) };
2206
1946
  }
2207
1947
  const events = /* @__PURE__ */ new Map();
2208
1948
  // @__NO_SIDE_EFFECTS__
2209
1949
  function useEventBus(key) {
2210
1950
  const scope = reactivity.getCurrentScope();
2211
1951
  function on(listener) {
2212
- var _a;
1952
+ var _scope$cleanups;
2213
1953
  const listeners = events.get(key) || /* @__PURE__ */ new Set();
2214
1954
  listeners.add(listener);
2215
1955
  events.set(key, listeners);
2216
1956
  const _off = () => off(listener);
2217
- (_a = scope == null ? void 0 : scope.cleanups) == null ? void 0 : _a.push(_off);
1957
+ scope === null || scope === void 0 || (_scope$cleanups = scope.cleanups) === null || _scope$cleanups === void 0 || _scope$cleanups.push(_off);
2218
1958
  return _off;
2219
1959
  }
2220
1960
  function once(listener) {
@@ -2226,20 +1966,24 @@ function useEventBus(key) {
2226
1966
  }
2227
1967
  function off(listener) {
2228
1968
  const listeners = events.get(key);
2229
- if (!listeners)
2230
- return;
1969
+ if (!listeners) return;
2231
1970
  listeners.delete(listener);
2232
- if (!listeners.size)
2233
- reset();
1971
+ if (!listeners.size) reset();
2234
1972
  }
2235
1973
  function reset() {
2236
1974
  events.delete(key);
2237
1975
  }
2238
1976
  function emit(event, payload) {
2239
- var _a;
2240
- (_a = events.get(key)) == null ? void 0 : _a.forEach((v) => v(event, payload));
1977
+ var _events$get;
1978
+ (_events$get = events.get(key)) === null || _events$get === void 0 || _events$get.forEach((v) => v(event, payload));
2241
1979
  }
2242
- return { on, once, off, emit, reset };
1980
+ return {
1981
+ on,
1982
+ once,
1983
+ off,
1984
+ emit,
1985
+ reset
1986
+ };
2243
1987
  }
2244
1988
  const payloadMapping = {
2245
1989
  json: "application/json",
@@ -2253,33 +1997,29 @@ function isAbsoluteURL(url) {
2253
1997
  return reAbsolute.test(url);
2254
1998
  }
2255
1999
  function headersToObject(headers) {
2256
- if (typeof Headers !== "undefined" && headers instanceof Headers)
2257
- return Object.fromEntries(headers.entries());
2000
+ if (typeof Headers !== "undefined" && headers instanceof Headers) return Object.fromEntries(headers.entries());
2258
2001
  return headers;
2259
2002
  }
2260
2003
  function combineCallbacks(combination, ...callbacks) {
2261
- if (combination === "overwrite") {
2262
- return async (ctx) => {
2263
- let callback;
2264
- for (let i = callbacks.length - 1; i >= 0; i--) {
2265
- if (callbacks[i] != null) {
2266
- callback = callbacks[i];
2267
- break;
2268
- }
2269
- }
2270
- if (callback)
2271
- return { ...ctx, ...await callback(ctx) };
2272
- return ctx;
2004
+ if (combination === "overwrite") return async (ctx) => {
2005
+ let callback;
2006
+ for (let i = callbacks.length - 1; i >= 0; i--) if (callbacks[i] != null) {
2007
+ callback = callbacks[i];
2008
+ break;
2009
+ }
2010
+ if (callback) return {
2011
+ ...ctx,
2012
+ ...await callback(ctx)
2273
2013
  };
2274
- } else {
2275
- return async (ctx) => {
2276
- for (const callback of callbacks) {
2277
- if (callback)
2278
- ctx = { ...ctx, ...await callback(ctx) };
2279
- }
2280
- return ctx;
2014
+ return ctx;
2015
+ };
2016
+ else return async (ctx) => {
2017
+ for (const callback of callbacks) if (callback) ctx = {
2018
+ ...ctx,
2019
+ ...await callback(ctx)
2281
2020
  };
2282
- }
2021
+ return ctx;
2022
+ };
2283
2023
  }
2284
2024
  function createFetch(config = {}) {
2285
2025
  const _combination = config.combination || "chain";
@@ -2293,41 +2033,34 @@ function createFetch(config = {}) {
2293
2033
  });
2294
2034
  let options = _options;
2295
2035
  let fetchOptions = _fetchOptions;
2296
- if (args.length > 0) {
2297
- if (isFetchOptions(args[0])) {
2298
- options = {
2299
- ...options,
2300
- ...args[0],
2301
- beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
2302
- afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
2303
- onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
2304
- };
2305
- } else {
2306
- fetchOptions = {
2307
- ...fetchOptions,
2308
- ...args[0],
2309
- headers: {
2310
- ...headersToObject(fetchOptions.headers) || {},
2311
- ...headersToObject(args[0].headers) || {}
2312
- }
2313
- };
2036
+ if (args.length > 0) if (isFetchOptions(args[0])) options = {
2037
+ ...options,
2038
+ ...args[0],
2039
+ beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
2040
+ afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
2041
+ onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
2042
+ };
2043
+ else fetchOptions = {
2044
+ ...fetchOptions,
2045
+ ...args[0],
2046
+ headers: {
2047
+ ...headersToObject(fetchOptions.headers) || {},
2048
+ ...headersToObject(args[0].headers) || {}
2314
2049
  }
2315
- }
2316
- if (args.length > 1 && isFetchOptions(args[1])) {
2317
- options = {
2318
- ...options,
2319
- ...args[1],
2320
- beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
2321
- afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
2322
- onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
2323
- };
2324
- }
2050
+ };
2051
+ if (args.length > 1 && isFetchOptions(args[1])) options = {
2052
+ ...options,
2053
+ ...args[1],
2054
+ beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
2055
+ afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
2056
+ onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
2057
+ };
2325
2058
  return useFetch(computedUrl, fetchOptions, options);
2326
2059
  }
2327
2060
  return useFactoryFetch;
2328
2061
  }
2329
2062
  function useFetch(url, ...args) {
2330
- var _a, _b;
2063
+ var _defaultWindow$fetch, _globalThis;
2331
2064
  const supportsAbort = typeof AbortController === "function";
2332
2065
  let fetchOptions = {};
2333
2066
  let options = {
@@ -2341,21 +2074,18 @@ function useFetch(url, ...args) {
2341
2074
  type: "text",
2342
2075
  payload: void 0
2343
2076
  };
2344
- if (args.length > 0) {
2345
- if (isFetchOptions(args[0]))
2346
- options = { ...options, ...args[0] };
2347
- else
2348
- fetchOptions = args[0];
2349
- }
2077
+ if (args.length > 0) if (isFetchOptions(args[0])) options = {
2078
+ ...options,
2079
+ ...args[0]
2080
+ };
2081
+ else fetchOptions = args[0];
2350
2082
  if (args.length > 1) {
2351
- if (isFetchOptions(args[1]))
2352
- options = { ...options, ...args[1] };
2353
- }
2354
- const {
2355
- fetch = (_b = (_a = defaultWindow) == null ? void 0 : _a.fetch) != null ? _b : globalThis == null ? void 0 : globalThis.fetch,
2356
- initialData,
2357
- timeout
2358
- } = options;
2083
+ if (isFetchOptions(args[1])) options = {
2084
+ ...options,
2085
+ ...args[1]
2086
+ };
2087
+ }
2088
+ const { fetch = (_defaultWindow$fetch = defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.fetch) !== null && _defaultWindow$fetch !== void 0 ? _defaultWindow$fetch : (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.fetch, initialData, timeout } = options;
2359
2089
  const responseEvent = /* @__PURE__ */ createEventHook();
2360
2090
  const errorEvent = /* @__PURE__ */ createEventHook();
2361
2091
  const finallyEvent = /* @__PURE__ */ createEventHook();
@@ -2371,7 +2101,7 @@ function useFetch(url, ...args) {
2371
2101
  let timer;
2372
2102
  const abort = (reason) => {
2373
2103
  if (supportsAbort) {
2374
- controller == null ? void 0 : controller.abort(reason);
2104
+ controller === null || controller === void 0 || controller.abort(reason);
2375
2105
  controller = new AbortController();
2376
2106
  controller.signal.onabort = () => aborted.value = true;
2377
2107
  fetchOptions = {
@@ -2384,11 +2114,10 @@ function useFetch(url, ...args) {
2384
2114
  isFetching.value = isLoading;
2385
2115
  isFinished.value = !isLoading;
2386
2116
  };
2387
- if (timeout)
2388
- timer = useTimeoutFn(abort, timeout, { immediate: false });
2117
+ if (timeout) timer = useTimeoutFn(abort, timeout, { immediate: false });
2389
2118
  let executeCounter = 0;
2390
2119
  const execute = async (throwOnFailed = false) => {
2391
- var _a2, _b2;
2120
+ var _context$options;
2392
2121
  abort();
2393
2122
  loading(true);
2394
2123
  error.value = null;
@@ -2402,12 +2131,11 @@ function useFetch(url, ...args) {
2402
2131
  };
2403
2132
  const payload = reactivity.toValue(config.payload);
2404
2133
  if (payload) {
2134
+ var _payloadMapping$confi;
2405
2135
  const headers = headersToObject(defaultFetchOptions.headers);
2406
2136
  const proto = Object.getPrototypeOf(payload);
2407
- if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData))
2408
- config.payloadType = "json";
2409
- if (config.payloadType)
2410
- headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
2137
+ if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData)) config.payloadType = "json";
2138
+ if (config.payloadType) headers["Content-Type"] = (_payloadMapping$confi = payloadMapping[config.payloadType]) !== null && _payloadMapping$confi !== void 0 ? _payloadMapping$confi : config.payloadType;
2411
2139
  defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
2412
2140
  }
2413
2141
  let isCanceled = false;
@@ -2421,26 +2149,21 @@ function useFetch(url, ...args) {
2421
2149
  isCanceled = true;
2422
2150
  }
2423
2151
  };
2424
- if (options.beforeFetch)
2425
- Object.assign(context, await options.beforeFetch(context));
2152
+ if (options.beforeFetch) Object.assign(context, await options.beforeFetch(context));
2426
2153
  if (isCanceled || !fetch) {
2427
2154
  loading(false);
2428
2155
  return Promise.resolve(null);
2429
2156
  }
2430
2157
  let responseData = null;
2431
- if (timer)
2432
- timer.start();
2433
- return fetch(
2434
- context.url,
2435
- {
2436
- ...defaultFetchOptions,
2437
- ...context.options,
2438
- headers: {
2439
- ...headersToObject(defaultFetchOptions.headers),
2440
- ...headersToObject((_b2 = context.options) == null ? void 0 : _b2.headers)
2441
- }
2158
+ if (timer) timer.start();
2159
+ return fetch(context.url, {
2160
+ ...defaultFetchOptions,
2161
+ ...context.options,
2162
+ headers: {
2163
+ ...headersToObject(defaultFetchOptions.headers),
2164
+ ...headersToObject((_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options.headers)
2442
2165
  }
2443
- ).then(async (fetchResponse) => {
2166
+ }).then(async (fetchResponse) => {
2444
2167
  response.value = fetchResponse;
2445
2168
  statusCode.value = fetchResponse.status;
2446
2169
  responseData = await fetchResponse.clone()[config.type]();
@@ -2448,52 +2171,37 @@ function useFetch(url, ...args) {
2448
2171
  data.value = initialData || null;
2449
2172
  throw new Error(fetchResponse.statusText);
2450
2173
  }
2451
- if (options.afterFetch) {
2452
- ({ data: responseData } = await options.afterFetch({
2453
- data: responseData,
2454
- response: fetchResponse,
2455
- context,
2456
- execute
2457
- }));
2458
- }
2174
+ if (options.afterFetch) ({ data: responseData } = await options.afterFetch({
2175
+ data: responseData,
2176
+ response: fetchResponse,
2177
+ context,
2178
+ execute
2179
+ }));
2459
2180
  data.value = responseData;
2460
2181
  responseEvent.trigger(fetchResponse);
2461
2182
  return fetchResponse;
2462
2183
  }).catch(async (fetchError) => {
2463
2184
  let errorData = fetchError.message || fetchError.name;
2464
- if (options.onFetchError) {
2465
- ({ error: errorData, data: responseData } = await options.onFetchError({
2466
- data: responseData,
2467
- error: fetchError,
2468
- response: response.value,
2469
- context,
2470
- execute
2471
- }));
2472
- }
2185
+ if (options.onFetchError) ({ error: errorData, data: responseData } = await options.onFetchError({
2186
+ data: responseData,
2187
+ error: fetchError,
2188
+ response: response.value,
2189
+ context,
2190
+ execute
2191
+ }));
2473
2192
  error.value = errorData;
2474
- if (options.updateDataOnError)
2475
- data.value = responseData;
2193
+ if (options.updateDataOnError) data.value = responseData;
2476
2194
  errorEvent.trigger(fetchError);
2477
- if (throwOnFailed)
2478
- throw fetchError;
2195
+ if (throwOnFailed) throw fetchError;
2479
2196
  return null;
2480
2197
  }).finally(() => {
2481
- if (currentExecuteCounter === executeCounter)
2482
- loading(false);
2483
- if (timer)
2484
- timer.stop();
2198
+ if (currentExecuteCounter === executeCounter) loading(false);
2199
+ if (timer) timer.stop();
2485
2200
  finallyEvent.trigger(null);
2486
2201
  });
2487
2202
  };
2488
2203
  const refetch = toRef(options.refetch);
2489
- reactivity.watch(
2490
- [
2491
- refetch,
2492
- toRef(url)
2493
- ],
2494
- ([refetch2]) => refetch2 && execute(),
2495
- { deep: true }
2496
- );
2204
+ reactivity.watch([refetch, toRef(url)], ([refetch$1]) => refetch$1 && execute(), { deep: true });
2497
2205
  const shell = {
2498
2206
  isFinished: reactivity.readonly(isFinished),
2499
2207
  isFetching: reactivity.readonly(isFetching),
@@ -2508,7 +2216,6 @@ function useFetch(url, ...args) {
2508
2216
  onFetchResponse: responseEvent.on,
2509
2217
  onFetchError: errorEvent.on,
2510
2218
  onFetchFinally: finallyEvent.on,
2511
- // method
2512
2219
  get: setMethod("GET"),
2513
2220
  put: setMethod("PUT"),
2514
2221
  post: setMethod("POST"),
@@ -2516,7 +2223,6 @@ function useFetch(url, ...args) {
2516
2223
  patch: setMethod("PATCH"),
2517
2224
  head: setMethod("HEAD"),
2518
2225
  options: setMethod("OPTIONS"),
2519
- // type
2520
2226
  json: setType("json"),
2521
2227
  text: setType("text"),
2522
2228
  blob: setType("blob"),
@@ -2529,16 +2235,7 @@ function useFetch(url, ...args) {
2529
2235
  config.method = method;
2530
2236
  config.payload = payload;
2531
2237
  config.payloadType = payloadType;
2532
- if (reactivity.isRef(config.payload)) {
2533
- reactivity.watch(
2534
- [
2535
- refetch,
2536
- toRef(config.payload)
2537
- ],
2538
- ([refetch2]) => refetch2 && execute(),
2539
- { deep: true }
2540
- );
2541
- }
2238
+ if (reactivity.isRef(config.payload)) reactivity.watch([refetch, toRef(config.payload)], ([refetch$1]) => refetch$1 && execute(), { deep: true });
2542
2239
  return {
2543
2240
  ...shell,
2544
2241
  then(onFulfilled, onRejected) {
@@ -2546,7 +2243,6 @@ function useFetch(url, ...args) {
2546
2243
  }
2547
2244
  };
2548
2245
  }
2549
- return void 0;
2550
2246
  };
2551
2247
  }
2552
2248
  function waitUntilFinished() {
@@ -2565,11 +2261,9 @@ function useFetch(url, ...args) {
2565
2261
  }
2566
2262
  };
2567
2263
  }
2568
- return void 0;
2569
2264
  };
2570
2265
  }
2571
- if (options.immediate)
2572
- Promise.resolve().then(() => execute());
2266
+ if (options.immediate) Promise.resolve().then(() => execute());
2573
2267
  return {
2574
2268
  ...shell,
2575
2269
  then(onFulfilled, onRejected) {
@@ -2578,138 +2272,113 @@ function useFetch(url, ...args) {
2578
2272
  };
2579
2273
  }
2580
2274
  function joinPaths(start, end) {
2581
- if (!start.endsWith("/") && !end.startsWith("/")) {
2582
- return `${start}/${end}`;
2583
- }
2584
- if (start.endsWith("/") && end.startsWith("/")) {
2585
- return `${start.slice(0, -1)}${end}`;
2586
- }
2275
+ if (!start.endsWith("/") && !end.startsWith("/")) return `${start}/${end}`;
2276
+ if (start.endsWith("/") && end.startsWith("/")) return `${start.slice(0, -1)}${end}`;
2587
2277
  return `${start}${end}`;
2588
2278
  }
2589
- const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
2279
+ const defaultEvents$1 = [
2280
+ "mousemove",
2281
+ "mousedown",
2282
+ "resize",
2283
+ "keydown",
2284
+ "touchstart",
2285
+ "wheel"
2286
+ ];
2590
2287
  const oneMinute = 6e4;
2591
2288
  function useIdle(timeout = oneMinute, options = {}) {
2592
- const {
2593
- initialState = false,
2594
- listenForVisibilityChange = true,
2595
- events: events2 = defaultEvents$1,
2596
- window: window2 = defaultWindow,
2597
- eventFilter = throttleFilter(50)
2598
- } = options;
2289
+ const { initialState = false, listenForVisibilityChange = true, events: events$1 = defaultEvents$1, window: window$1 = defaultWindow, eventFilter = throttleFilter(50) } = options;
2599
2290
  const idle = reactivity.shallowRef(initialState);
2600
2291
  const lastActive = reactivity.shallowRef(timestamp());
2292
+ const isPending = reactivity.shallowRef(false);
2601
2293
  let timer;
2602
2294
  const reset = () => {
2603
2295
  idle.value = false;
2604
2296
  clearTimeout(timer);
2605
2297
  timer = setTimeout(() => idle.value = true, timeout);
2606
2298
  };
2607
- const onEvent = createFilterWrapper(
2608
- eventFilter,
2609
- () => {
2610
- lastActive.value = timestamp();
2611
- reset();
2612
- }
2613
- );
2614
- if (window2) {
2615
- const document2 = window2.document;
2299
+ const onEvent = createFilterWrapper(eventFilter, () => {
2300
+ lastActive.value = timestamp();
2301
+ reset();
2302
+ });
2303
+ if (window$1) {
2304
+ const document$1 = window$1.document;
2616
2305
  const listenerOptions = { passive: true };
2617
- for (const event of events2)
2618
- useEventListener(window2, event, onEvent, listenerOptions);
2619
- if (listenForVisibilityChange) {
2620
- useEventListener(document2, "visibilitychange", () => {
2621
- if (!document2.hidden)
2622
- onEvent();
2623
- }, listenerOptions);
2624
- }
2625
- if (!initialState)
2626
- reset();
2306
+ for (const event of events$1) useEventListener(window$1, event, () => {
2307
+ if (!isPending.value) return;
2308
+ onEvent();
2309
+ }, listenerOptions);
2310
+ if (listenForVisibilityChange) useEventListener(document$1, "visibilitychange", () => {
2311
+ if (document$1.hidden || !isPending.value) return;
2312
+ onEvent();
2313
+ }, listenerOptions);
2314
+ start();
2315
+ }
2316
+ function start() {
2317
+ if (isPending.value) return;
2318
+ isPending.value = true;
2319
+ if (!initialState) reset();
2320
+ }
2321
+ function stop() {
2322
+ idle.value = initialState;
2323
+ clearTimeout(timer);
2324
+ isPending.value = false;
2627
2325
  }
2628
2326
  return {
2629
2327
  idle,
2630
2328
  lastActive,
2631
- reset
2329
+ reset,
2330
+ stop,
2331
+ start,
2332
+ isPending: reactivity.shallowReadonly(isPending)
2632
2333
  };
2633
2334
  }
2634
2335
  // @__NO_SIDE_EFFECTS__
2635
2336
  function useNow(options = {}) {
2636
- const {
2637
- controls: exposeControls = false,
2638
- interval = "requestAnimationFrame",
2639
- immediate = true
2640
- } = options;
2337
+ const { controls: exposeControls = false, interval = "requestAnimationFrame", immediate = true } = options;
2641
2338
  const now2 = reactivity.ref(/* @__PURE__ */ new Date());
2642
2339
  const update = () => now2.value = /* @__PURE__ */ new Date();
2643
2340
  const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate }) : useIntervalFn(update, interval, { immediate });
2644
- if (exposeControls) {
2645
- return {
2646
- now: now2,
2647
- ...controls
2648
- };
2649
- } else {
2650
- return now2;
2651
- }
2341
+ if (exposeControls) return {
2342
+ now: now2,
2343
+ ...controls
2344
+ };
2345
+ else return now2;
2652
2346
  }
2653
2347
  function useObjectUrl(object) {
2654
2348
  const url = reactivity.shallowRef();
2655
2349
  const release = () => {
2656
- if (url.value)
2657
- URL.revokeObjectURL(url.value);
2350
+ if (url.value) URL.revokeObjectURL(url.value);
2658
2351
  url.value = void 0;
2659
2352
  };
2660
- reactivity.watch(
2661
- () => reactivity.toValue(object),
2662
- (newObject) => {
2663
- release();
2664
- if (newObject)
2665
- url.value = URL.createObjectURL(newObject);
2666
- },
2667
- { immediate: true }
2668
- );
2353
+ reactivity.watch(() => reactivity.toValue(object), (newObject) => {
2354
+ release();
2355
+ if (newObject) url.value = URL.createObjectURL(newObject);
2356
+ }, { immediate: true });
2669
2357
  tryOnScopeDispose(release);
2670
2358
  return reactivity.readonly(url);
2671
2359
  }
2672
2360
  // @__NO_SIDE_EFFECTS__
2673
2361
  function useClamp(value, min, max) {
2674
- if (typeof value === "function" || reactivity.isReadonly(value))
2675
- return reactivity.computed(() => clamp(reactivity.toValue(value), reactivity.toValue(min), reactivity.toValue(max)));
2362
+ if (typeof value === "function" || reactivity.isReadonly(value)) return reactivity.computed(() => clamp(reactivity.toValue(value), reactivity.toValue(min), reactivity.toValue(max)));
2676
2363
  const _value = reactivity.ref(value);
2677
2364
  return reactivity.computed({
2678
2365
  get() {
2679
2366
  return _value.value = clamp(_value.value, reactivity.toValue(min), reactivity.toValue(max));
2680
2367
  },
2681
- set(value2) {
2682
- _value.value = clamp(value2, reactivity.toValue(min), reactivity.toValue(max));
2368
+ set(value$1) {
2369
+ _value.value = clamp(value$1, reactivity.toValue(min), reactivity.toValue(max));
2683
2370
  }
2684
2371
  });
2685
2372
  }
2686
2373
  function useOffsetPagination(options) {
2687
- const {
2688
- total = Number.POSITIVE_INFINITY,
2689
- pageSize = 10,
2690
- page = 1,
2691
- onPageChange = noop,
2692
- onPageSizeChange = noop,
2693
- onPageCountChange = noop
2694
- } = options;
2374
+ const { total = Number.POSITIVE_INFINITY, pageSize = 10, page = 1, onPageChange = noop, onPageSizeChange = noop, onPageCountChange = noop } = options;
2695
2375
  const currentPageSize = /* @__PURE__ */ useClamp(pageSize, 1, Number.POSITIVE_INFINITY);
2696
- const pageCount = reactivity.computed(() => Math.max(
2697
- 1,
2698
- Math.ceil(reactivity.toValue(total) / reactivity.toValue(currentPageSize))
2699
- ));
2376
+ const pageCount = reactivity.computed(() => Math.max(1, Math.ceil(reactivity.toValue(total) / reactivity.toValue(currentPageSize))));
2700
2377
  const currentPage = /* @__PURE__ */ useClamp(page, 1, pageCount);
2701
2378
  const isFirstPage = reactivity.computed(() => currentPage.value === 1);
2702
2379
  const isLastPage = reactivity.computed(() => currentPage.value === pageCount.value);
2703
- if (reactivity.isRef(page)) {
2704
- syncRef(page, currentPage, {
2705
- direction: reactivity.isReadonly(page) ? "ltr" : "both"
2706
- });
2707
- }
2708
- if (reactivity.isRef(pageSize)) {
2709
- syncRef(pageSize, currentPageSize, {
2710
- direction: reactivity.isReadonly(pageSize) ? "ltr" : "both"
2711
- });
2712
- }
2380
+ if (reactivity.isRef(page)) syncRef(page, currentPage, { direction: reactivity.isReadonly(page) ? "ltr" : "both" });
2381
+ if (reactivity.isRef(pageSize)) syncRef(pageSize, currentPageSize, { direction: reactivity.isReadonly(pageSize) ? "ltr" : "both" });
2713
2382
  function prev() {
2714
2383
  currentPage.value--;
2715
2384
  }
@@ -2738,45 +2407,36 @@ function useOffsetPagination(options) {
2738
2407
  }
2739
2408
  function usePrevious(value, initialValue) {
2740
2409
  const previous = reactivity.shallowRef(initialValue);
2741
- reactivity.watch(
2742
- toRef(value),
2743
- (_, oldValue) => {
2744
- previous.value = oldValue;
2745
- },
2746
- { flush: "sync" }
2747
- );
2410
+ reactivity.watch(toRef(value), (_, oldValue) => {
2411
+ previous.value = oldValue;
2412
+ }, { flush: "sync" });
2748
2413
  return reactivity.readonly(previous);
2749
2414
  }
2750
2415
  const defaultSortFn = (source, compareFn) => source.sort(compareFn);
2751
2416
  const defaultCompare = (a, b) => a - b;
2752
2417
  function useSorted(...args) {
2753
- var _a, _b, _c, _d;
2754
2418
  const [source] = args;
2755
2419
  let compareFn = defaultCompare;
2756
2420
  let options = {};
2757
- if (args.length === 2) {
2758
- if (typeof args[1] === "object") {
2759
- options = args[1];
2760
- compareFn = (_a = options.compareFn) != null ? _a : defaultCompare;
2761
- } else {
2762
- compareFn = (_b = args[1]) != null ? _b : defaultCompare;
2763
- }
2764
- } else if (args.length > 2) {
2765
- compareFn = (_c = args[1]) != null ? _c : defaultCompare;
2766
- options = (_d = args[2]) != null ? _d : {};
2767
- }
2768
- const {
2769
- dirty = false,
2770
- sortFn = defaultSortFn
2771
- } = options;
2772
- if (!dirty)
2773
- return reactivity.computed(() => sortFn([...reactivity.toValue(source)], compareFn));
2421
+ if (args.length === 2) if (typeof args[1] === "object") {
2422
+ var _options$compareFn;
2423
+ options = args[1];
2424
+ compareFn = (_options$compareFn = options.compareFn) !== null && _options$compareFn !== void 0 ? _options$compareFn : defaultCompare;
2425
+ } else {
2426
+ var _args$;
2427
+ compareFn = (_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : defaultCompare;
2428
+ }
2429
+ else if (args.length > 2) {
2430
+ var _args$2, _args$3;
2431
+ compareFn = (_args$2 = args[1]) !== null && _args$2 !== void 0 ? _args$2 : defaultCompare;
2432
+ options = (_args$3 = args[2]) !== null && _args$3 !== void 0 ? _args$3 : {};
2433
+ }
2434
+ const { dirty = false, sortFn = defaultSortFn } = options;
2435
+ if (!dirty) return reactivity.computed(() => sortFn([...reactivity.toValue(source)], compareFn));
2774
2436
  reactivity.watchEffect(() => {
2775
2437
  const result = sortFn(reactivity.toValue(source), compareFn);
2776
- if (reactivity.isRef(source))
2777
- source.value = result;
2778
- else
2779
- source.splice(0, source.length, ...result);
2438
+ if (reactivity.isRef(source)) source.value = result;
2439
+ else source.splice(0, source.length, ...result);
2780
2440
  });
2781
2441
  return source;
2782
2442
  }
@@ -2784,39 +2444,33 @@ function useSorted(...args) {
2784
2444
  function useStepper(steps, initialStep) {
2785
2445
  const stepsRef = reactivity.ref(steps);
2786
2446
  const stepNames = reactivity.computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
2787
- const index = reactivity.ref(stepNames.value.indexOf(initialStep != null ? initialStep : stepNames.value[0]));
2447
+ const index = reactivity.ref(stepNames.value.indexOf(initialStep !== null && initialStep !== void 0 ? initialStep : stepNames.value[0]));
2788
2448
  const current = reactivity.computed(() => at(index.value));
2789
2449
  const isFirst = reactivity.computed(() => index.value === 0);
2790
2450
  const isLast = reactivity.computed(() => index.value === stepNames.value.length - 1);
2791
2451
  const next = reactivity.computed(() => stepNames.value[index.value + 1]);
2792
2452
  const previous = reactivity.computed(() => stepNames.value[index.value - 1]);
2793
- function at(index2) {
2794
- if (Array.isArray(stepsRef.value))
2795
- return stepsRef.value[index2];
2796
- return stepsRef.value[stepNames.value[index2]];
2453
+ function at(index$1) {
2454
+ if (Array.isArray(stepsRef.value)) return stepsRef.value[index$1];
2455
+ return stepsRef.value[stepNames.value[index$1]];
2797
2456
  }
2798
2457
  function get2(step) {
2799
- if (!stepNames.value.includes(step))
2800
- return;
2458
+ if (!stepNames.value.includes(step)) return;
2801
2459
  return at(stepNames.value.indexOf(step));
2802
2460
  }
2803
2461
  function goTo(step) {
2804
- if (stepNames.value.includes(step))
2805
- index.value = stepNames.value.indexOf(step);
2462
+ if (stepNames.value.includes(step)) index.value = stepNames.value.indexOf(step);
2806
2463
  }
2807
2464
  function goToNext() {
2808
- if (isLast.value)
2809
- return;
2465
+ if (isLast.value) return;
2810
2466
  index.value++;
2811
2467
  }
2812
2468
  function goToPrevious() {
2813
- if (isFirst.value)
2814
- return;
2469
+ if (isFirst.value) return;
2815
2470
  index.value--;
2816
2471
  }
2817
2472
  function goBackTo(step) {
2818
- if (isAfter(step))
2819
- goTo(step);
2473
+ if (isAfter(step)) goTo(step);
2820
2474
  }
2821
2475
  function isNext(step) {
2822
2476
  return stepNames.value.indexOf(step) === index.value + 1;
@@ -2858,19 +2512,47 @@ function useStepper(steps, initialStep) {
2858
2512
  function useThrottledRefHistory(source, options = {}) {
2859
2513
  const { throttle = 200, trailing = true } = options;
2860
2514
  const filter = throttleFilter(throttle, trailing);
2861
- const history = useRefHistory(source, { ...options, eventFilter: filter });
2862
- return {
2863
- ...history
2864
- };
2515
+ return { ...useRefHistory(source, {
2516
+ ...options,
2517
+ eventFilter: filter
2518
+ }) };
2865
2519
  }
2866
2520
  const DEFAULT_UNITS = [
2867
- { max: 6e4, value: 1e3, name: "second" },
2868
- { max: 276e4, value: 6e4, name: "minute" },
2869
- { max: 72e6, value: 36e5, name: "hour" },
2870
- { max: 5184e5, value: 864e5, name: "day" },
2871
- { max: 24192e5, value: 6048e5, name: "week" },
2872
- { max: 28512e6, value: 2592e6, name: "month" },
2873
- { max: Number.POSITIVE_INFINITY, value: 31536e6, name: "year" }
2521
+ {
2522
+ max: 6e4,
2523
+ value: 1e3,
2524
+ name: "second"
2525
+ },
2526
+ {
2527
+ max: 276e4,
2528
+ value: 6e4,
2529
+ name: "minute"
2530
+ },
2531
+ {
2532
+ max: 72e6,
2533
+ value: 36e5,
2534
+ name: "hour"
2535
+ },
2536
+ {
2537
+ max: 5184e5,
2538
+ value: 864e5,
2539
+ name: "day"
2540
+ },
2541
+ {
2542
+ max: 24192e5,
2543
+ value: 6048e5,
2544
+ name: "week"
2545
+ },
2546
+ {
2547
+ max: 28512e6,
2548
+ value: 2592e6,
2549
+ name: "month"
2550
+ },
2551
+ {
2552
+ max: Number.POSITIVE_INFINITY,
2553
+ value: 31536e6,
2554
+ name: "year"
2555
+ }
2874
2556
  ];
2875
2557
  const DEFAULT_MESSAGES = {
2876
2558
  justNow: "just now",
@@ -2890,93 +2572,70 @@ function DEFAULT_FORMATTER(date) {
2890
2572
  }
2891
2573
  // @__NO_SIDE_EFFECTS__
2892
2574
  function useTimeAgo(time, options = {}) {
2893
- const {
2894
- controls: exposeControls = false,
2895
- updateInterval = 3e4
2896
- } = options;
2897
- const { now: now2, ...controls } = /* @__PURE__ */ useNow({ interval: updateInterval, controls: true });
2575
+ const { controls: exposeControls = false, updateInterval = 3e4 } = options;
2576
+ const { now: now2, ...controls } = /* @__PURE__ */ useNow({
2577
+ interval: updateInterval,
2578
+ controls: true
2579
+ });
2898
2580
  const timeAgo = reactivity.computed(() => formatTimeAgo(new Date(reactivity.toValue(time)), options, reactivity.toValue(now2)));
2899
- if (exposeControls) {
2900
- return {
2901
- timeAgo,
2902
- ...controls
2903
- };
2904
- } else {
2905
- return timeAgo;
2906
- }
2581
+ if (exposeControls) return {
2582
+ timeAgo,
2583
+ ...controls
2584
+ };
2585
+ else return timeAgo;
2907
2586
  }
2908
2587
  function formatTimeAgo(from, options = {}, now2 = Date.now()) {
2909
- var _a;
2910
- const {
2911
- max,
2912
- messages = DEFAULT_MESSAGES,
2913
- fullDateFormatter = DEFAULT_FORMATTER,
2914
- units = DEFAULT_UNITS,
2915
- showSecond = false,
2916
- rounding = "round"
2917
- } = options;
2588
+ const { max, messages = DEFAULT_MESSAGES, fullDateFormatter = DEFAULT_FORMATTER, units = DEFAULT_UNITS, showSecond = false, rounding = "round" } = options;
2918
2589
  const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
2919
2590
  const diff = +now2 - +from;
2920
2591
  const absDiff = Math.abs(diff);
2921
- function getValue(diff2, unit) {
2922
- return roundFn(Math.abs(diff2) / unit.value);
2592
+ function getValue$1(diff$1, unit) {
2593
+ return roundFn(Math.abs(diff$1) / unit.value);
2923
2594
  }
2924
- function format(diff2, unit) {
2925
- const val = getValue(diff2, unit);
2926
- const past = diff2 > 0;
2595
+ function format(diff$1, unit) {
2596
+ const val = getValue$1(diff$1, unit);
2597
+ const past = diff$1 > 0;
2927
2598
  const str = applyFormat(unit.name, val, past);
2928
2599
  return applyFormat(past ? "past" : "future", str, past);
2929
2600
  }
2930
2601
  function applyFormat(name, val, isPast) {
2931
2602
  const formatter = messages[name];
2932
- if (typeof formatter === "function")
2933
- return formatter(val, isPast);
2603
+ if (typeof formatter === "function") return formatter(val, isPast);
2934
2604
  return formatter.replace("{0}", val.toString());
2935
2605
  }
2936
- if (absDiff < 6e4 && !showSecond)
2937
- return messages.justNow;
2938
- if (typeof max === "number" && absDiff > max)
2939
- return fullDateFormatter(new Date(from));
2606
+ if (absDiff < 6e4 && !showSecond) return messages.justNow;
2607
+ if (typeof max === "number" && absDiff > max) return fullDateFormatter(new Date(from));
2940
2608
  if (typeof max === "string") {
2941
- const unitMax = (_a = units.find((i) => i.name === max)) == null ? void 0 : _a.max;
2942
- if (unitMax && absDiff > unitMax)
2943
- return fullDateFormatter(new Date(from));
2609
+ var _units$find;
2610
+ const unitMax = (_units$find = units.find((i) => i.name === max)) === null || _units$find === void 0 ? void 0 : _units$find.max;
2611
+ if (unitMax && absDiff > unitMax) return fullDateFormatter(new Date(from));
2944
2612
  }
2945
2613
  for (const [idx, unit] of units.entries()) {
2946
- const val = getValue(diff, unit);
2947
- if (val <= 0 && units[idx - 1])
2948
- return format(diff, units[idx - 1]);
2949
- if (absDiff < unit.max)
2950
- return format(diff, unit);
2614
+ if (getValue$1(diff, unit) <= 0 && units[idx - 1]) return format(diff, units[idx - 1]);
2615
+ if (absDiff < unit.max) return format(diff, unit);
2951
2616
  }
2952
2617
  return messages.invalid;
2953
2618
  }
2954
2619
  function useTimeoutPoll(fn, interval, options = {}) {
2955
- const {
2956
- immediate = true,
2957
- immediateCallback = false
2958
- } = options;
2620
+ const { immediate = true, immediateCallback = false } = options;
2959
2621
  const { start } = useTimeoutFn(loop, interval, { immediate });
2960
2622
  const isActive = reactivity.shallowRef(false);
2961
2623
  async function loop() {
2962
- if (!isActive.value)
2963
- return;
2624
+ if (!isActive.value) return;
2964
2625
  await fn();
2965
2626
  start();
2966
2627
  }
2967
2628
  function resume() {
2968
2629
  if (!isActive.value) {
2969
2630
  isActive.value = true;
2970
- if (immediateCallback)
2971
- fn();
2631
+ if (immediateCallback) fn();
2972
2632
  start();
2973
2633
  }
2974
2634
  }
2975
2635
  function pause() {
2976
2636
  isActive.value = false;
2977
2637
  }
2978
- if (immediate && isClient)
2979
- resume();
2638
+ if (immediate && isClient) resume();
2980
2639
  tryOnScopeDispose(pause);
2981
2640
  return {
2982
2641
  isActive,
@@ -2985,13 +2644,7 @@ function useTimeoutPoll(fn, interval, options = {}) {
2985
2644
  };
2986
2645
  }
2987
2646
  function useTimestamp(options = {}) {
2988
- const {
2989
- controls: exposeControls = false,
2990
- offset = 0,
2991
- immediate = true,
2992
- interval = "requestAnimationFrame",
2993
- callback
2994
- } = options;
2647
+ const { controls: exposeControls = false, offset = 0, immediate = true, interval = "requestAnimationFrame", callback } = options;
2995
2648
  const ts = reactivity.shallowRef(timestamp() + offset);
2996
2649
  const update = () => ts.value = timestamp() + offset;
2997
2650
  const cb = callback ? () => {
@@ -2999,50 +2652,32 @@ function useTimestamp(options = {}) {
2999
2652
  callback(ts.value);
3000
2653
  } : update;
3001
2654
  const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
3002
- if (exposeControls) {
3003
- return {
3004
- timestamp: ts,
3005
- ...controls
3006
- };
3007
- } else {
3008
- return ts;
3009
- }
2655
+ if (exposeControls) return {
2656
+ timestamp: ts,
2657
+ ...controls
2658
+ };
2659
+ else return ts;
3010
2660
  }
3011
2661
  function useUrlSearchParams(mode = "history", options = {}) {
3012
- const {
3013
- initialValue = {},
3014
- removeNullishValues = true,
3015
- removeFalsyValues = false,
3016
- write: enableWrite = true,
3017
- writeMode = "replace",
3018
- window: window2 = defaultWindow,
3019
- stringify = (params) => params.toString()
3020
- } = options;
3021
- if (!window2)
3022
- return reactivity.reactive(initialValue);
2662
+ const { initialValue = {}, removeNullishValues = true, removeFalsyValues = false, write: enableWrite = true, writeMode = "replace", window: window$1 = defaultWindow, stringify = (params) => params.toString() } = options;
2663
+ if (!window$1) return reactivity.reactive(initialValue);
3023
2664
  const state = reactivity.reactive({});
3024
2665
  function getRawParams() {
3025
- if (mode === "history") {
3026
- return window2.location.search || "";
3027
- } else if (mode === "hash") {
3028
- const hash = window2.location.hash || "";
2666
+ if (mode === "history") return window$1.location.search || "";
2667
+ else if (mode === "hash") {
2668
+ const hash = window$1.location.hash || "";
3029
2669
  const index = hash.indexOf("?");
3030
2670
  return index > 0 ? hash.slice(index) : "";
3031
- } else {
3032
- return (window2.location.hash || "").replace(/^#/, "");
3033
- }
2671
+ } else return (window$1.location.hash || "").replace(/^#/, "");
3034
2672
  }
3035
2673
  function constructQuery(params) {
3036
2674
  const stringified = stringify(params);
3037
- if (mode === "history")
3038
- return `${stringified ? `?${stringified}` : ""}${window2.location.hash || ""}`;
3039
- if (mode === "hash-params")
3040
- return `${window2.location.search || ""}${stringified ? `#${stringified}` : ""}`;
3041
- const hash = window2.location.hash || "#";
2675
+ if (mode === "history") return `${stringified ? `?${stringified}` : ""}${window$1.location.hash || ""}`;
2676
+ if (mode === "hash-params") return `${window$1.location.search || ""}${stringified ? `#${stringified}` : ""}`;
2677
+ const hash = window$1.location.hash || "#";
3042
2678
  const index = hash.indexOf("?");
3043
- if (index > 0)
3044
- return `${window2.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
3045
- return `${window2.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
2679
+ if (index > 0) return `${window$1.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
2680
+ return `${window$1.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
3046
2681
  }
3047
2682
  function read() {
3048
2683
  return new URLSearchParams(getRawParams());
@@ -3056,79 +2691,43 @@ function useUrlSearchParams(mode = "history", options = {}) {
3056
2691
  }
3057
2692
  Array.from(unusedKeys).forEach((key) => delete state[key]);
3058
2693
  }
3059
- const { pause, resume } = watchPausable(
3060
- state,
3061
- () => {
3062
- const params = new URLSearchParams("");
3063
- Object.keys(state).forEach((key) => {
3064
- const mapEntry = state[key];
3065
- if (Array.isArray(mapEntry))
3066
- mapEntry.forEach((value) => params.append(key, value));
3067
- else if (removeNullishValues && mapEntry == null)
3068
- params.delete(key);
3069
- else if (removeFalsyValues && !mapEntry)
3070
- params.delete(key);
3071
- else
3072
- params.set(key, mapEntry);
3073
- });
3074
- write(params, false);
3075
- },
3076
- { deep: true }
3077
- );
2694
+ const { pause, resume } = pausableWatch(state, () => {
2695
+ const params = new URLSearchParams("");
2696
+ Object.keys(state).forEach((key) => {
2697
+ const mapEntry = state[key];
2698
+ if (Array.isArray(mapEntry)) mapEntry.forEach((value) => params.append(key, value));
2699
+ else if (removeNullishValues && mapEntry == null) params.delete(key);
2700
+ else if (removeFalsyValues && !mapEntry) params.delete(key);
2701
+ else params.set(key, mapEntry);
2702
+ });
2703
+ write(params, false);
2704
+ }, { deep: true });
3078
2705
  function write(params, shouldUpdate, shouldWriteHistory = true) {
3079
2706
  pause();
3080
- if (shouldUpdate)
3081
- updateState(params);
3082
- if (writeMode === "replace") {
3083
- window2.history.replaceState(
3084
- window2.history.state,
3085
- window2.document.title,
3086
- window2.location.pathname + constructQuery(params)
3087
- );
3088
- } else {
3089
- if (shouldWriteHistory) {
3090
- window2.history.pushState(
3091
- window2.history.state,
3092
- window2.document.title,
3093
- window2.location.pathname + constructQuery(params)
3094
- );
3095
- }
3096
- }
2707
+ if (shouldUpdate) updateState(params);
2708
+ if (writeMode === "replace") window$1.history.replaceState(window$1.history.state, window$1.document.title, window$1.location.pathname + constructQuery(params));
2709
+ else if (shouldWriteHistory) window$1.history.pushState(window$1.history.state, window$1.document.title, window$1.location.pathname + constructQuery(params));
3097
2710
  reactivity.nextTick(() => resume());
3098
2711
  }
3099
2712
  function onChanged() {
3100
- if (!enableWrite)
3101
- return;
2713
+ if (!enableWrite) return;
3102
2714
  write(read(), true, false);
3103
2715
  }
3104
2716
  const listenerOptions = { passive: true };
3105
- useEventListener(window2, "popstate", onChanged, listenerOptions);
3106
- if (mode !== "history")
3107
- useEventListener(window2, "hashchange", onChanged, listenerOptions);
2717
+ useEventListener(window$1, "popstate", onChanged, listenerOptions);
2718
+ if (mode !== "history") useEventListener(window$1, "hashchange", onChanged, listenerOptions);
3108
2719
  const initial = read();
3109
- if (initial.keys().next().value)
3110
- updateState(initial);
3111
- else
3112
- Object.assign(state, initialValue);
2720
+ if (initial.keys().next().value) updateState(initial);
2721
+ else Object.assign(state, initialValue);
3113
2722
  return state;
3114
2723
  }
3115
2724
  const DEFAULT_PING_MESSAGE = "ping";
3116
2725
  function resolveNestedOptions(options) {
3117
- if (options === true)
3118
- return {};
2726
+ if (options === true) return {};
3119
2727
  return options;
3120
2728
  }
3121
2729
  function useWebSocket(url, options = {}) {
3122
- const {
3123
- onConnected,
3124
- onDisconnected,
3125
- onError,
3126
- onMessage,
3127
- immediate = true,
3128
- autoConnect = true,
3129
- autoClose = true,
3130
- protocols = []
3131
- } = options;
2730
+ const { onConnected, onDisconnected, onError, onMessage, immediate = true, autoConnect = true, autoClose = true, protocols = [] } = options;
3132
2731
  const data = reactivity.ref(null);
3133
2732
  const status = reactivity.shallowRef("CLOSED");
3134
2733
  const wsRef = reactivity.ref();
@@ -3142,8 +2741,7 @@ function useWebSocket(url, options = {}) {
3142
2741
  let pongTimeoutWait;
3143
2742
  const _sendBuffer = () => {
3144
2743
  if (bufferedData.length && wsRef.value && status.value === "OPEN") {
3145
- for (const buffer of bufferedData)
3146
- wsRef.value.send(buffer);
2744
+ for (const buffer of bufferedData) wsRef.value.send(buffer);
3147
2745
  bufferedData = [];
3148
2746
  }
3149
2747
  };
@@ -3159,113 +2757,87 @@ function useWebSocket(url, options = {}) {
3159
2757
  };
3160
2758
  const close = (code = 1e3, reason) => {
3161
2759
  resetRetry();
3162
- if (!isClient && !isWorker || !wsRef.value)
3163
- return;
2760
+ if (!isClient && !isWorker || !wsRef.value) return;
3164
2761
  explicitlyClosed = true;
3165
2762
  resetHeartbeat();
3166
- heartbeatPause == null ? void 0 : heartbeatPause();
2763
+ heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause();
3167
2764
  wsRef.value.close(code, reason);
3168
2765
  wsRef.value = void 0;
3169
2766
  };
3170
- const send = (data2, useBuffer = true) => {
2767
+ const send = (data$1, useBuffer = true) => {
3171
2768
  if (!wsRef.value || status.value !== "OPEN") {
3172
- if (useBuffer)
3173
- bufferedData.push(data2);
2769
+ if (useBuffer) bufferedData.push(data$1);
3174
2770
  return false;
3175
2771
  }
3176
2772
  _sendBuffer();
3177
- wsRef.value.send(data2);
2773
+ wsRef.value.send(data$1);
3178
2774
  return true;
3179
2775
  };
3180
2776
  const _init = () => {
3181
- if (explicitlyClosed || typeof urlRef.value === "undefined")
3182
- return;
2777
+ if (explicitlyClosed || typeof urlRef.value === "undefined") return;
3183
2778
  const ws = new WebSocket(urlRef.value, protocols);
3184
2779
  wsRef.value = ws;
3185
2780
  status.value = "CONNECTING";
3186
2781
  ws.onopen = () => {
3187
2782
  status.value = "OPEN";
3188
2783
  retried = 0;
3189
- onConnected == null ? void 0 : onConnected(ws);
3190
- heartbeatResume == null ? void 0 : heartbeatResume();
2784
+ onConnected === null || onConnected === void 0 || onConnected(ws);
2785
+ heartbeatResume === null || heartbeatResume === void 0 || heartbeatResume();
3191
2786
  _sendBuffer();
3192
2787
  };
3193
2788
  ws.onclose = (ev) => {
3194
2789
  status.value = "CLOSED";
3195
2790
  resetHeartbeat();
3196
- heartbeatPause == null ? void 0 : heartbeatPause();
3197
- onDisconnected == null ? void 0 : onDisconnected(ws, ev);
2791
+ heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause();
2792
+ onDisconnected === null || onDisconnected === void 0 || onDisconnected(ws, ev);
3198
2793
  if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) {
3199
- const {
3200
- retries = -1,
3201
- delay = 1e3,
3202
- onFailed
3203
- } = resolveNestedOptions(options.autoReconnect);
3204
- const checkRetires = typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries);
3205
- if (checkRetires(retried)) {
2794
+ const { retries = -1, delay = 1e3, onFailed } = resolveNestedOptions(options.autoReconnect);
2795
+ if ((typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries))(retried)) {
3206
2796
  retried += 1;
3207
- retryTimeout = setTimeout(_init, delay);
3208
- } else {
3209
- onFailed == null ? void 0 : onFailed();
3210
- }
2797
+ const delayTime = typeof delay === "function" ? delay(retried) : delay;
2798
+ retryTimeout = setTimeout(_init, delayTime);
2799
+ } else onFailed === null || onFailed === void 0 || onFailed();
3211
2800
  }
3212
2801
  };
3213
2802
  ws.onerror = (e) => {
3214
- onError == null ? void 0 : onError(ws, e);
2803
+ onError === null || onError === void 0 || onError(ws, e);
3215
2804
  };
3216
2805
  ws.onmessage = (e) => {
3217
2806
  if (options.heartbeat) {
3218
2807
  resetHeartbeat();
3219
- const {
3220
- message = DEFAULT_PING_MESSAGE,
3221
- responseMessage = message
3222
- } = resolveNestedOptions(options.heartbeat);
3223
- if (e.data === reactivity.toValue(responseMessage))
3224
- return;
2808
+ const { message = DEFAULT_PING_MESSAGE, responseMessage = message } = resolveNestedOptions(options.heartbeat);
2809
+ if (e.data === reactivity.toValue(responseMessage)) return;
3225
2810
  }
3226
2811
  data.value = e.data;
3227
- onMessage == null ? void 0 : onMessage(ws, e);
2812
+ onMessage === null || onMessage === void 0 || onMessage(ws, e);
3228
2813
  };
3229
2814
  };
3230
2815
  if (options.heartbeat) {
3231
- const {
3232
- message = DEFAULT_PING_MESSAGE,
3233
- interval = 1e3,
3234
- pongTimeout = 1e3
3235
- } = resolveNestedOptions(options.heartbeat);
3236
- const { pause, resume } = useIntervalFn(
3237
- () => {
3238
- send(reactivity.toValue(message), false);
3239
- if (pongTimeoutWait != null)
3240
- return;
3241
- pongTimeoutWait = setTimeout(() => {
3242
- close();
3243
- explicitlyClosed = false;
3244
- }, pongTimeout);
3245
- },
3246
- interval,
3247
- { immediate: false }
3248
- );
2816
+ const { message = DEFAULT_PING_MESSAGE, interval = 1e3, pongTimeout = 1e3 } = resolveNestedOptions(options.heartbeat);
2817
+ const { pause, resume } = useIntervalFn(() => {
2818
+ send(reactivity.toValue(message), false);
2819
+ if (pongTimeoutWait != null) return;
2820
+ pongTimeoutWait = setTimeout(() => {
2821
+ close();
2822
+ explicitlyClosed = false;
2823
+ }, pongTimeout);
2824
+ }, interval, { immediate: false });
3249
2825
  heartbeatPause = pause;
3250
2826
  heartbeatResume = resume;
3251
2827
  }
3252
2828
  if (autoClose) {
3253
- if (isClient)
3254
- useEventListener("beforeunload", () => close(), { passive: true });
2829
+ if (isClient) useEventListener("beforeunload", () => close(), { passive: true });
3255
2830
  tryOnScopeDispose(close);
3256
2831
  }
3257
2832
  const open = () => {
3258
- if (!isClient && !isWorker)
3259
- return;
2833
+ if (!isClient && !isWorker) return;
3260
2834
  close();
3261
2835
  explicitlyClosed = false;
3262
2836
  retried = 0;
3263
2837
  _init();
3264
2838
  };
3265
- if (immediate)
3266
- open();
3267
- if (autoConnect)
3268
- reactivity.watch(urlRef, open);
2839
+ if (immediate) open();
2840
+ if (autoConnect) reactivity.watch(urlRef, open);
3269
2841
  return {
3270
2842
  data,
3271
2843
  status,
@@ -3276,21 +2848,17 @@ function useWebSocket(url, options = {}) {
3276
2848
  };
3277
2849
  }
3278
2850
  function depsParser(deps, localDeps) {
3279
- if (deps.length === 0 && localDeps.length === 0)
3280
- return "";
2851
+ if (deps.length === 0 && localDeps.length === 0) return "";
3281
2852
  const depsString = deps.map((dep) => `'${dep}'`).toString();
3282
2853
  const depsFunctionString = localDeps.filter((dep) => typeof dep === "function").map((fn) => {
3283
2854
  const str = fn.toString();
3284
- if (str.trim().startsWith("function")) {
3285
- return str;
3286
- } else {
3287
- const name = fn.name;
3288
- return `const ${name} = ${str}`;
3289
- }
2855
+ if (str.trim().startsWith("function")) return str;
2856
+ else return `const ${fn.name} = ${str}`;
3290
2857
  }).join(";");
3291
2858
  const importString = `importScripts(${depsString});`;
3292
2859
  return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`;
3293
2860
  }
2861
+ var depsParser_default = depsParser;
3294
2862
  function jobRunner(userFunc) {
3295
2863
  return (e) => {
3296
2864
  const userFuncArgs = e.data[0];
@@ -3301,37 +2869,33 @@ function jobRunner(userFunc) {
3301
2869
  });
3302
2870
  };
3303
2871
  }
2872
+ var jobRunner_default = jobRunner;
3304
2873
  function createWorkerBlobUrl(fn, deps, localDeps) {
3305
- const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`;
2874
+ const blobCode = `${depsParser_default(deps, localDeps)}; onmessage=(${jobRunner_default})(${fn})`;
3306
2875
  const blob = new Blob([blobCode], { type: "text/javascript" });
3307
- const url = URL.createObjectURL(blob);
3308
- return url;
2876
+ return URL.createObjectURL(blob);
3309
2877
  }
2878
+ var createWorkerBlobUrl_default = createWorkerBlobUrl;
3310
2879
  function useWebWorkerFn(fn, options = {}) {
3311
- const {
3312
- dependencies = [],
3313
- localDependencies = [],
3314
- timeout,
3315
- window: window2 = defaultWindow
3316
- } = options;
2880
+ const { dependencies = [], localDependencies = [], timeout, window: window$1 = defaultWindow } = options;
3317
2881
  const worker = reactivity.ref();
3318
2882
  const workerStatus = reactivity.shallowRef("PENDING");
3319
2883
  const promise = reactivity.ref({});
3320
2884
  const timeoutId = reactivity.shallowRef();
3321
2885
  const workerTerminate = (status = "PENDING") => {
3322
- if (worker.value && worker.value._url && window2) {
2886
+ if (worker.value && worker.value._url && window$1) {
3323
2887
  worker.value.terminate();
3324
2888
  URL.revokeObjectURL(worker.value._url);
3325
2889
  promise.value = {};
3326
2890
  worker.value = void 0;
3327
- window2.clearTimeout(timeoutId.value);
2891
+ window$1.clearTimeout(timeoutId.value);
3328
2892
  workerStatus.value = status;
3329
2893
  }
3330
2894
  };
3331
2895
  workerTerminate();
3332
2896
  tryOnScopeDispose(workerTerminate);
3333
2897
  const generateWorker = () => {
3334
- const blobUrl = createWorkerBlobUrl(fn, dependencies, localDependencies);
2898
+ const blobUrl = createWorkerBlobUrl_default(fn, dependencies, localDependencies);
3335
2899
  const newWorker = new Worker(blobUrl);
3336
2900
  newWorker._url = blobUrl;
3337
2901
  newWorker.onmessage = (e) => {
@@ -3357,28 +2921,21 @@ function useWebWorkerFn(fn, options = {}) {
3357
2921
  reject(e);
3358
2922
  workerTerminate("ERROR");
3359
2923
  };
3360
- if (timeout) {
3361
- timeoutId.value = setTimeout(
3362
- () => workerTerminate("TIMEOUT_EXPIRED"),
3363
- timeout
3364
- );
3365
- }
2924
+ if (timeout) timeoutId.value = setTimeout(() => workerTerminate("TIMEOUT_EXPIRED"), timeout);
3366
2925
  return newWorker;
3367
2926
  };
3368
2927
  const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
3369
- var _a;
2928
+ var _worker$value;
3370
2929
  promise.value = {
3371
2930
  resolve,
3372
2931
  reject
3373
2932
  };
3374
- (_a = worker.value) == null ? void 0 : _a.postMessage([[...fnArgs]]);
2933
+ (_worker$value = worker.value) === null || _worker$value === void 0 || _worker$value.postMessage([[...fnArgs]]);
3375
2934
  workerStatus.value = "RUNNING";
3376
2935
  });
3377
2936
  const workerFn = (...fnArgs) => {
3378
2937
  if (workerStatus.value === "RUNNING") {
3379
- console.error(
3380
- "[useWebWorkerFn] You can only run one instance of the worker at a time."
3381
- );
2938
+ console.error("[useWebWorkerFn] You can only run one instance of the worker at a time.");
3382
2939
  return Promise.reject();
3383
2940
  }
3384
2941
  worker.value = generateWorker();
@@ -3391,28 +2948,32 @@ function useWebWorkerFn(fn, options = {}) {
3391
2948
  };
3392
2949
  }
3393
2950
  exports.assert = assert;
3394
- exports.asyncComputed = computedAsync;
3395
- exports.autoResetRef = refAutoReset;
2951
+ exports.asyncComputed = asyncComputed;
2952
+ exports.autoResetRef = autoResetRef;
3396
2953
  exports.bypassFilter = bypassFilter;
3397
2954
  exports.camelize = camelize;
3398
2955
  exports.clamp = clamp;
3399
2956
  exports.cloneFnJSON = cloneFnJSON;
3400
2957
  exports.computedAsync = computedAsync;
2958
+ exports.computedEager = computedEager;
3401
2959
  exports.computedWithControl = computedWithControl;
3402
2960
  exports.containsProp = containsProp;
3403
- exports.controlledComputed = computedWithControl;
2961
+ exports.controlledComputed = controlledComputed;
3404
2962
  exports.controlledRef = controlledRef;
3405
2963
  exports.createEventHook = createEventHook;
3406
2964
  exports.createFetch = createFetch;
3407
2965
  exports.createFilterWrapper = createFilterWrapper;
3408
2966
  exports.createGlobalState = createGlobalState;
3409
- exports.createReactiveFn = reactify;
2967
+ exports.createInjectionState = createInjectionState;
2968
+ exports.createReactiveFn = createReactiveFn;
2969
+ exports.createRef = createRef;
3410
2970
  exports.createSharedComposable = createSharedComposable;
3411
2971
  exports.createSingletonPromise = createSingletonPromise;
3412
2972
  exports.createUnrefFn = createUnrefFn;
3413
2973
  exports.debounceFilter = debounceFilter;
3414
- exports.debouncedRef = refDebounced;
3415
- exports.debouncedWatch = watchDebounced;
2974
+ exports.debouncedRef = debouncedRef;
2975
+ exports.debouncedWatch = debouncedWatch;
2976
+ exports.eagerComputed = eagerComputed;
3416
2977
  exports.extendRef = extendRef;
3417
2978
  exports.formatDate = formatDate;
3418
2979
  exports.formatTimeAgo = formatTimeAgo;
@@ -3421,8 +2982,9 @@ exports.getLifeCycleTarget = getLifeCycleTarget;
3421
2982
  exports.hasOwn = hasOwn;
3422
2983
  exports.hyphenate = hyphenate;
3423
2984
  exports.identity = identity;
3424
- exports.ignorableWatch = watchIgnorable;
2985
+ exports.ignorableWatch = ignorableWatch;
3425
2986
  exports.increaseWithUnit = increaseWithUnit;
2987
+ exports.injectLocal = injectLocal;
3426
2988
  exports.invoke = invoke;
3427
2989
  exports.isDef = isDef;
3428
2990
  exports.isDefined = isDefined;
@@ -3436,8 +2998,10 @@ exports.objectEntries = objectEntries;
3436
2998
  exports.objectOmit = objectOmit;
3437
2999
  exports.objectPick = objectPick;
3438
3000
  exports.pausableFilter = pausableFilter;
3439
- exports.pausableWatch = watchPausable;
3001
+ exports.pausableWatch = pausableWatch;
3440
3002
  exports.promiseTimeout = promiseTimeout;
3003
+ exports.provideLocal = provideLocal;
3004
+ exports.pxValue = pxValue;
3441
3005
  exports.rand = rand;
3442
3006
  exports.reactify = reactify;
3443
3007
  exports.reactifyObject = reactifyObject;
@@ -3447,21 +3011,25 @@ exports.reactivePick = reactivePick;
3447
3011
  exports.refAutoReset = refAutoReset;
3448
3012
  exports.refDebounced = refDebounced;
3449
3013
  exports.refDefault = refDefault;
3014
+ exports.refManualReset = refManualReset;
3450
3015
  exports.refThrottled = refThrottled;
3451
3016
  exports.refWithControl = refWithControl;
3452
- exports.resolveRef = resolveRef;
3453
- exports.resolveUnref = resolveUnref;
3454
3017
  exports.set = set;
3455
3018
  exports.syncRef = syncRef;
3456
3019
  exports.syncRefs = syncRefs;
3457
3020
  exports.throttleFilter = throttleFilter;
3458
- exports.throttledRef = refThrottled;
3459
- exports.throttledWatch = watchThrottled;
3021
+ exports.throttledRef = throttledRef;
3022
+ exports.throttledWatch = throttledWatch;
3023
+ exports.timestamp = timestamp;
3024
+ exports.toArray = toArray;
3460
3025
  exports.toReactive = toReactive;
3461
3026
  exports.toRef = toRef;
3462
3027
  exports.toRefs = toRefs;
3463
- exports.toValue = toValue;
3028
+ exports.tryOnBeforeMount = tryOnBeforeMount;
3029
+ exports.tryOnBeforeUnmount = tryOnBeforeUnmount;
3030
+ exports.tryOnMounted = tryOnMounted;
3464
3031
  exports.tryOnScopeDispose = tryOnScopeDispose;
3032
+ exports.tryOnUnmounted = tryOnUnmounted;
3465
3033
  exports.until = until;
3466
3034
  exports.useArrayDifference = useArrayDifference;
3467
3035
  exports.useArrayEvery = useArrayEvery;
@@ -3484,7 +3052,7 @@ exports.useCloned = useCloned;
3484
3052
  exports.useCounter = useCounter;
3485
3053
  exports.useCycleList = useCycleList;
3486
3054
  exports.useDateFormat = useDateFormat;
3487
- exports.useDebounce = refDebounced;
3055
+ exports.useDebounce = useDebounce;
3488
3056
  exports.useDebounceFn = useDebounceFn;
3489
3057
  exports.useDebouncedRefHistory = useDebouncedRefHistory;
3490
3058
  exports.useEventBus = useEventBus;
@@ -3501,7 +3069,7 @@ exports.usePrevious = usePrevious;
3501
3069
  exports.useRefHistory = useRefHistory;
3502
3070
  exports.useSorted = useSorted;
3503
3071
  exports.useStepper = useStepper;
3504
- exports.useThrottle = refThrottled;
3072
+ exports.useThrottle = useThrottle;
3505
3073
  exports.useThrottleFn = useThrottleFn;
3506
3074
  exports.useThrottledRefHistory = useThrottledRefHistory;
3507
3075
  exports.useTimeAgo = useTimeAgo;