@gct-paas/core-web 0.1.4-dev.0 → 0.1.4-dev.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.
@@ -1,9 +1,9 @@
1
- import { noop, makeDestructurable, camelize, toValue, isClient, isObject, tryOnScopeDispose, isIOS, tryOnMounted, notNullish, objectOmit, promiseTimeout, until, increaseWithUnit, objectEntries, createSingletonPromise, useTimeoutFn, pausableWatch as watchPausable, toRef, createEventHook, computedWithControl, timestamp, pausableFilter, ignorableWatch as watchIgnorable, debounceFilter, bypassFilter, createFilterWrapper, toRefs, useIntervalFn, containsProp, hasOwn, throttleFilter, useDebounceFn, useThrottleFn, clamp, syncRef, objectPick, tryOnUnmounted, watchWithFilter, tryOnBeforeUnmount, identity, isDef, isWorker } from '../../../../@vueuse_shared@10.11.1_vue@3.5.13_typescript@5.8.3_/node_modules/@vueuse/shared/index.mjs';
2
- export { assert, autoResetRef, computedEager, controlledRef, createGlobalState, createInjectionState, createReactiveFn, createSharedComposable, debouncedRef, debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hyphenate, injectLocal, invoke, isDefined, normalizeDate, now, provideLocal, rand, createReactiveFn as reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, autoResetRef as refAutoReset, debouncedRef as refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRefs, refThrottled as throttledRef, throttledWatch, toReactive, tryOnBeforeMount, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, debouncedRef as useDebounce, useInterval, useLastChanged, refThrottled as useThrottle, useTimeout, useToNumber, useToString, useToggle, watchArray, watchAtMost, debouncedWatch as watchDebounced, watchDeep, watchImmediate, watchOnce, throttledWatch as watchThrottled, watchTriggerable, whenever } from '../../../../@vueuse_shared@10.11.1_vue@3.5.13_typescript@5.8.3_/node_modules/@vueuse/shared/index.mjs';
3
- import { isVue3, isVue2, del, set } from '../../../../vue-demi@0.14.10_vue@3.5.13_typescript@5.8.3_/node_modules/vue-demi/lib/index.mjs';
4
- import { isRef, ref, shallowRef, watchEffect, computed, inject, version, defineComponent, shallowReactive, h, Fragment, TransitionGroup, watch, getCurrentInstance, customRef, onUpdated, onMounted, readonly, nextTick, reactive, markRaw, unref, getCurrentScope, isReadonly, onBeforeUpdate } from 'vue';
1
+ import { noop, makeDestructurable, camelize, isClient, toArray, watchImmediate, isObject, tryOnScopeDispose, isIOS, notNullish, tryOnMounted, objectOmit, promiseTimeout, until, injectLocal, provideLocal, pxValue, increaseWithUnit, objectEntries, createRef, createSingletonPromise, useTimeoutFn, pausableWatch as watchPausable, toRef, createEventHook, useIntervalFn, computedWithControl, timestamp, pausableFilter, ignorableWatch as watchIgnorable, debounceFilter, bypassFilter, createFilterWrapper, toRefs, watchOnce, containsProp, hasOwn, throttleFilter, useDebounceFn, useThrottleFn, tryOnUnmounted, clamp, syncRef, objectPick, watchWithFilter, identity, isDef, whenever, isWorker } from '../../../../@vueuse_shared@13.7.0_vue@3.5.18_typescript@5.9.2_/node_modules/@vueuse/shared/index.mjs';
2
+ export { assert, autoResetRef, computedEager, controlledRef, createGlobalState, createInjectionState, createReactiveFn, createSharedComposable, debouncedRef, debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hyphenate, invoke, isDefined, normalizeDate, now, rand, createReactiveFn as reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, autoResetRef as refAutoReset, debouncedRef as refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRefs, refThrottled as throttledRef, throttledWatch, toReactive, toValue, tryOnBeforeMount, tryOnBeforeUnmount, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, debouncedRef as useDebounce, useInterval, useLastChanged, refThrottled as useThrottle, useTimeout, useToNumber, useToString, useToggle, watchArray, watchAtMost, debouncedWatch as watchDebounced, watchDeep, throttledWatch as watchThrottled, watchTriggerable } from '../../../../@vueuse_shared@13.7.0_vue@3.5.18_typescript@5.9.2_/node_modules/@vueuse/shared/index.mjs';
3
+ import { isRef, shallowRef, ref, watchEffect, computed, inject, defineComponent, shallowReactive, h, Fragment, TransitionGroup, toValue, unref, getCurrentInstance, onMounted, watch, customRef, onUpdated, readonly, reactive, hasInjectionContext, toRaw, shallowReadonly, nextTick, markRaw, getCurrentScope, isReadonly, onBeforeUpdate } from 'vue';
5
4
 
6
5
  function computedAsync(evaluationCallback, initialState, optionsOrRef) {
6
+ var _a;
7
7
  let options;
8
8
  if (isRef(optionsOrRef)) {
9
9
  options = {
@@ -14,11 +14,12 @@ function computedAsync(evaluationCallback, initialState, optionsOrRef) {
14
14
  }
15
15
  const {
16
16
  lazy = false,
17
+ flush = "pre",
17
18
  evaluating = void 0,
18
19
  shallow = true,
19
- onError = noop
20
+ onError = (_a = globalThis.reportError) != null ? _a : noop
20
21
  } = options;
21
- const started = ref(!lazy);
22
+ const started = shallowRef(!lazy);
22
23
  const current = shallow ? shallowRef(initialState) : ref(initialState);
23
24
  let counter = 0;
24
25
  watchEffect(async (onInvalidate) => {
@@ -50,7 +51,7 @@ function computedAsync(evaluationCallback, initialState, optionsOrRef) {
50
51
  evaluating.value = false;
51
52
  hasFinished = true;
52
53
  }
53
- });
54
+ }, { flush });
54
55
  if (lazy) {
55
56
  return computed(() => {
56
57
  started.value = true;
@@ -68,40 +69,40 @@ function computedInject(key, options, defaultSource, treatDefaultAsFactory) {
68
69
  if (treatDefaultAsFactory)
69
70
  source = inject(key, defaultSource, treatDefaultAsFactory);
70
71
  if (typeof options === "function") {
71
- return computed((ctx) => options(source, ctx));
72
+ return computed((oldValue) => options(source, oldValue));
72
73
  } else {
73
74
  return computed({
74
- get: (ctx) => options.get(source, ctx),
75
+ get: (oldValue) => options.get(source, oldValue),
75
76
  set: options.set
76
77
  });
77
78
  }
78
79
  }
79
80
 
81
+ // @__NO_SIDE_EFFECTS__
80
82
  function createReusableTemplate(options = {}) {
81
- if (!isVue3 && !version.startsWith("2.7.")) {
82
- if (process.env.NODE_ENV !== "production")
83
- throw new Error("[VueUse] createReusableTemplate only works in Vue 2.7 or above.");
84
- return;
85
- }
86
83
  const {
87
84
  inheritAttrs = true
88
85
  } = options;
89
86
  const render = shallowRef();
90
- const define = /* #__PURE__ */ defineComponent({
87
+ const define = /*@__PURE__*/ defineComponent({
91
88
  setup(_, { slots }) {
92
89
  return () => {
93
90
  render.value = slots.default;
94
91
  };
95
92
  }
96
93
  });
97
- const reuse = /* #__PURE__ */ defineComponent({
94
+ const reuse = /*@__PURE__*/ defineComponent({
98
95
  inheritAttrs,
99
- setup(_, { attrs, slots }) {
96
+ props: options.props,
97
+ setup(props, { attrs, slots }) {
100
98
  return () => {
101
99
  var _a;
102
100
  if (!render.value && process.env.NODE_ENV !== "production")
103
101
  throw new Error("[VueUse] Failed to find the definition of reusable template");
104
- const vnode = (_a = render.value) == null ? void 0 : _a.call(render, { ...keysToCamelKebabCase(attrs), $slots: slots });
102
+ const vnode = (_a = render.value) == null ? void 0 : _a.call(render, {
103
+ ...options.props == null ? keysToCamelKebabCase(attrs) : props,
104
+ $slots: slots
105
+ });
105
106
  return inheritAttrs && (vnode == null ? void 0 : vnode.length) === 1 ? vnode[0] : vnode;
106
107
  };
107
108
  }
@@ -118,12 +119,8 @@ function keysToCamelKebabCase(obj) {
118
119
  return newObj;
119
120
  }
120
121
 
122
+ // @__NO_SIDE_EFFECTS__
121
123
  function createTemplatePromise(options = {}) {
122
- if (!isVue3) {
123
- if (process.env.NODE_ENV !== "production")
124
- throw new Error("[VueUse] createTemplatePromise only works in Vue 3 or above.");
125
- return;
126
- }
127
124
  let index = 0;
128
125
  const instances = ref([]);
129
126
  function create(...args) {
@@ -158,7 +155,7 @@ function createTemplatePromise(options = {}) {
158
155
  return instances.value[0].promise;
159
156
  return create(...args);
160
157
  }
161
- const component = /* #__PURE__ */ defineComponent((_, { slots }) => {
158
+ const component = /*@__PURE__*/ defineComponent((_, { slots }) => {
162
159
  const renderList = () => instances.value.map((props) => {
163
160
  var _a;
164
161
  return h(Fragment, { key: props.key }, (_a = slots.default) == null ? void 0 : _a.call(slots, props));
@@ -171,85 +168,87 @@ function createTemplatePromise(options = {}) {
171
168
  return component;
172
169
  }
173
170
 
171
+ // @__NO_SIDE_EFFECTS__
174
172
  function createUnrefFn(fn) {
175
173
  return function(...args) {
176
174
  return fn.apply(this, args.map((i) => toValue(i)));
177
175
  };
178
176
  }
179
177
 
178
+ const defaultWindow = isClient ? window : void 0;
179
+ const defaultDocument = isClient ? window.document : void 0;
180
+ const defaultNavigator = isClient ? window.navigator : void 0;
181
+ const defaultLocation = isClient ? window.location : void 0;
182
+
180
183
  function unrefElement(elRef) {
181
184
  var _a;
182
185
  const plain = toValue(elRef);
183
186
  return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
184
187
  }
185
188
 
186
- const defaultWindow = isClient ? window : void 0;
187
- const defaultDocument = isClient ? window.document : void 0;
188
- const defaultNavigator = isClient ? window.navigator : void 0;
189
- const defaultLocation = isClient ? window.location : void 0;
190
-
191
189
  function useEventListener(...args) {
192
- let target;
193
- let events;
194
- let listeners;
195
- let options;
196
- if (typeof args[0] === "string" || Array.isArray(args[0])) {
197
- [events, listeners, options] = args;
198
- target = defaultWindow;
199
- } else {
200
- [target, events, listeners, options] = args;
201
- }
202
- if (!target)
203
- return noop;
204
- if (!Array.isArray(events))
205
- events = [events];
206
- if (!Array.isArray(listeners))
207
- listeners = [listeners];
208
190
  const cleanups = [];
209
191
  const cleanup = () => {
210
192
  cleanups.forEach((fn) => fn());
211
193
  cleanups.length = 0;
212
194
  };
213
- const register = (el, event, listener, options2) => {
214
- el.addEventListener(event, listener, options2);
215
- return () => el.removeEventListener(event, listener, options2);
195
+ const register = (el, event, listener, options) => {
196
+ el.addEventListener(event, listener, options);
197
+ return () => el.removeEventListener(event, listener, options);
216
198
  };
217
- const stopWatch = watch(
218
- () => [unrefElement(target), toValue(options)],
219
- ([el, options2]) => {
199
+ const firstParamTargets = computed(() => {
200
+ const test = toArray(toValue(args[0])).filter((e) => e != null);
201
+ return test.every((e) => typeof e !== "string") ? test : void 0;
202
+ });
203
+ const stopWatch = watchImmediate(
204
+ () => {
205
+ var _a, _b;
206
+ return [
207
+ (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
208
+ toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
209
+ toArray(unref(firstParamTargets.value ? args[2] : args[1])),
210
+ // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
211
+ toValue(firstParamTargets.value ? args[3] : args[2])
212
+ ];
213
+ },
214
+ ([raw_targets, raw_events, raw_listeners, raw_options]) => {
220
215
  cleanup();
221
- if (!el)
216
+ 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))
222
217
  return;
223
- const optionsClone = isObject(options2) ? { ...options2 } : options2;
218
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
224
219
  cleanups.push(
225
- ...events.flatMap((event) => {
226
- return listeners.map((listener) => register(el, event, listener, optionsClone));
227
- })
220
+ ...raw_targets.flatMap(
221
+ (el) => raw_events.flatMap(
222
+ (event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
223
+ )
224
+ )
228
225
  );
229
226
  },
230
- { immediate: true, flush: "post" }
227
+ { flush: "post" }
231
228
  );
232
229
  const stop = () => {
233
230
  stopWatch();
234
231
  cleanup();
235
232
  };
236
- tryOnScopeDispose(stop);
233
+ tryOnScopeDispose(cleanup);
237
234
  return stop;
238
235
  }
239
236
 
240
237
  let _iOSWorkaround = false;
241
238
  function onClickOutside(target, handler, options = {}) {
242
- const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
243
- if (!window)
244
- return noop;
239
+ const { window = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
240
+ if (!window) {
241
+ return controls ? { stop: noop, cancel: noop, trigger: noop } : noop;
242
+ }
245
243
  if (isIOS && !_iOSWorkaround) {
246
244
  _iOSWorkaround = true;
247
- Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop));
248
- window.document.documentElement.addEventListener("click", noop);
245
+ const listenerOptions = { passive: true };
246
+ Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop, listenerOptions));
247
+ window.document.documentElement.addEventListener("click", noop, listenerOptions);
249
248
  }
250
249
  let shouldListen = true;
251
250
  const shouldIgnore = (event) => {
252
- return ignore.some((target2) => {
251
+ return toValue(ignore).some((target2) => {
253
252
  if (typeof target2 === "string") {
254
253
  return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
255
254
  } else {
@@ -258,11 +257,26 @@ function onClickOutside(target, handler, options = {}) {
258
257
  }
259
258
  });
260
259
  };
260
+ function hasMultipleRoots(target2) {
261
+ const vm = toValue(target2);
262
+ return vm && vm.$.subTree.shapeFlag === 16;
263
+ }
264
+ function checkMultipleRoots(target2, event) {
265
+ const vm = toValue(target2);
266
+ const children = vm.$.subTree && vm.$.subTree.children;
267
+ if (children == null || !Array.isArray(children))
268
+ return false;
269
+ return children.some((child) => child.el === event.target || event.composedPath().includes(child.el));
270
+ }
261
271
  const listener = (event) => {
262
272
  const el = unrefElement(target);
273
+ if (event.target == null)
274
+ return;
275
+ if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event))
276
+ return;
263
277
  if (!el || el === event.target || event.composedPath().includes(el))
264
278
  return;
265
- if (event.detail === 0)
279
+ if ("detail" in event && event.detail === 0)
266
280
  shouldListen = !shouldIgnore(event);
267
281
  if (!shouldListen) {
268
282
  shouldListen = true;
@@ -270,8 +284,17 @@ function onClickOutside(target, handler, options = {}) {
270
284
  }
271
285
  handler(event);
272
286
  };
287
+ let isProcessingClick = false;
273
288
  const cleanup = [
274
- useEventListener(window, "click", listener, { passive: true, capture }),
289
+ useEventListener(window, "click", (event) => {
290
+ if (!isProcessingClick) {
291
+ isProcessingClick = true;
292
+ setTimeout(() => {
293
+ isProcessingClick = false;
294
+ }, 0);
295
+ listener(event);
296
+ }
297
+ }, { passive: true, capture }),
275
298
  useEventListener(window, "pointerdown", (e) => {
276
299
  const el = unrefElement(target);
277
300
  shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
@@ -284,12 +307,128 @@ function onClickOutside(target, handler, options = {}) {
284
307
  handler(event);
285
308
  }
286
309
  }, 0);
287
- })
310
+ }, { passive: true })
288
311
  ].filter(Boolean);
289
312
  const stop = () => cleanup.forEach((fn) => fn());
313
+ if (controls) {
314
+ return {
315
+ stop,
316
+ cancel: () => {
317
+ shouldListen = false;
318
+ },
319
+ trigger: (event) => {
320
+ shouldListen = true;
321
+ listener(event);
322
+ shouldListen = false;
323
+ }
324
+ };
325
+ }
290
326
  return stop;
291
327
  }
292
328
 
329
+ // @__NO_SIDE_EFFECTS__
330
+ function useMounted() {
331
+ const isMounted = shallowRef(false);
332
+ const instance = getCurrentInstance();
333
+ if (instance) {
334
+ onMounted(() => {
335
+ isMounted.value = true;
336
+ }, instance);
337
+ }
338
+ return isMounted;
339
+ }
340
+
341
+ // @__NO_SIDE_EFFECTS__
342
+ function useSupported(callback) {
343
+ const isMounted = useMounted();
344
+ return computed(() => {
345
+ isMounted.value;
346
+ return Boolean(callback());
347
+ });
348
+ }
349
+
350
+ function useMutationObserver(target, callback, options = {}) {
351
+ const { window = defaultWindow, ...mutationOptions } = options;
352
+ let observer;
353
+ const isSupported = useSupported(() => window && "MutationObserver" in window);
354
+ const cleanup = () => {
355
+ if (observer) {
356
+ observer.disconnect();
357
+ observer = void 0;
358
+ }
359
+ };
360
+ const targets = computed(() => {
361
+ const value = toValue(target);
362
+ const items = toArray(value).map(unrefElement).filter(notNullish);
363
+ return new Set(items);
364
+ });
365
+ const stopWatch = watch(
366
+ targets,
367
+ (newTargets) => {
368
+ cleanup();
369
+ if (isSupported.value && newTargets.size) {
370
+ observer = new MutationObserver(callback);
371
+ newTargets.forEach((el) => observer.observe(el, mutationOptions));
372
+ }
373
+ },
374
+ { immediate: true, flush: "post" }
375
+ );
376
+ const takeRecords = () => {
377
+ return observer == null ? void 0 : observer.takeRecords();
378
+ };
379
+ const stop = () => {
380
+ stopWatch();
381
+ cleanup();
382
+ };
383
+ tryOnScopeDispose(stop);
384
+ return {
385
+ isSupported,
386
+ stop,
387
+ takeRecords
388
+ };
389
+ }
390
+
391
+ function onElementRemoval(target, callback, options = {}) {
392
+ const {
393
+ window = defaultWindow,
394
+ document = window == null ? void 0 : window.document,
395
+ flush = "sync"
396
+ } = options;
397
+ if (!window || !document)
398
+ return noop;
399
+ let stopFn;
400
+ const cleanupAndUpdate = (fn) => {
401
+ stopFn == null ? void 0 : stopFn();
402
+ stopFn = fn;
403
+ };
404
+ const stopWatch = watchEffect(() => {
405
+ const el = unrefElement(target);
406
+ if (el) {
407
+ const { stop } = useMutationObserver(
408
+ document,
409
+ (mutationsList) => {
410
+ const targetRemoved = mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el));
411
+ if (targetRemoved) {
412
+ callback(mutationsList);
413
+ }
414
+ },
415
+ {
416
+ window,
417
+ childList: true,
418
+ subtree: true
419
+ }
420
+ );
421
+ cleanupAndUpdate(stop);
422
+ }
423
+ }, { flush });
424
+ const stopHandle = () => {
425
+ stopWatch();
426
+ cleanupAndUpdate();
427
+ };
428
+ tryOnScopeDispose(stopHandle);
429
+ return stopHandle;
430
+ }
431
+
293
432
  function createKeyPredicate(keyFilter) {
294
433
  if (typeof keyFilter === "function")
295
434
  return keyFilter;
@@ -452,23 +591,24 @@ function isTypedCharValid({
452
591
  }) {
453
592
  if (metaKey || ctrlKey || altKey)
454
593
  return false;
455
- if (keyCode >= 48 && keyCode <= 57)
594
+ if (keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105)
456
595
  return true;
457
596
  if (keyCode >= 65 && keyCode <= 90)
458
597
  return true;
459
- if (keyCode >= 97 && keyCode <= 122)
460
- return true;
461
598
  return false;
462
599
  }
463
600
  function onStartTyping(callback, options = {}) {
464
601
  const { document: document2 = defaultDocument } = options;
465
602
  const keydown = (event) => {
466
- !isFocusedElementEditable() && isTypedCharValid(event) && callback(event);
603
+ if (!isFocusedElementEditable() && isTypedCharValid(event)) {
604
+ callback(event);
605
+ }
467
606
  };
468
607
  if (document2)
469
608
  useEventListener(document2, "keydown", keydown, { passive: true });
470
609
  }
471
610
 
611
+ // @__NO_SIDE_EFFECTS__
472
612
  function templateRef(key, initialValue = null) {
473
613
  const instance = getCurrentInstance();
474
614
  let _trigger = () => {
@@ -490,66 +630,7 @@ function templateRef(key, initialValue = null) {
490
630
  return element;
491
631
  }
492
632
 
493
- function useMounted() {
494
- const isMounted = ref(false);
495
- const instance = getCurrentInstance();
496
- if (instance) {
497
- onMounted(() => {
498
- isMounted.value = true;
499
- }, isVue2 ? void 0 : instance);
500
- }
501
- return isMounted;
502
- }
503
-
504
- function useSupported(callback) {
505
- const isMounted = useMounted();
506
- return computed(() => {
507
- isMounted.value;
508
- return Boolean(callback());
509
- });
510
- }
511
-
512
- function useMutationObserver(target, callback, options = {}) {
513
- const { window = defaultWindow, ...mutationOptions } = options;
514
- let observer;
515
- const isSupported = useSupported(() => window && "MutationObserver" in window);
516
- const cleanup = () => {
517
- if (observer) {
518
- observer.disconnect();
519
- observer = void 0;
520
- }
521
- };
522
- const targets = computed(() => {
523
- const value = toValue(target);
524
- const items = (Array.isArray(value) ? value : [value]).map(unrefElement).filter(notNullish);
525
- return new Set(items);
526
- });
527
- const stopWatch = watch(
528
- () => targets.value,
529
- (targets2) => {
530
- cleanup();
531
- if (isSupported.value && targets2.size) {
532
- observer = new MutationObserver(callback);
533
- targets2.forEach((el) => observer.observe(el, mutationOptions));
534
- }
535
- },
536
- { immediate: true, flush: "post" }
537
- );
538
- const takeRecords = () => {
539
- return observer == null ? void 0 : observer.takeRecords();
540
- };
541
- const stop = () => {
542
- cleanup();
543
- stopWatch();
544
- };
545
- tryOnScopeDispose(stop);
546
- return {
547
- isSupported,
548
- stop,
549
- takeRecords
550
- };
551
- }
552
-
633
+ // @__NO_SIDE_EFFECTS__
553
634
  function useActiveElement(options = {}) {
554
635
  var _a;
555
636
  const {
@@ -567,28 +648,34 @@ function useActiveElement(options = {}) {
567
648
  }
568
649
  return element;
569
650
  };
570
- const activeElement = ref();
651
+ const activeElement = shallowRef();
571
652
  const trigger = () => {
572
653
  activeElement.value = getDeepActiveElement();
573
654
  };
574
655
  if (window) {
575
- useEventListener(window, "blur", (event) => {
576
- if (event.relatedTarget !== null)
577
- return;
578
- trigger();
579
- }, true);
580
- useEventListener(window, "focus", trigger, true);
656
+ const listenerOptions = {
657
+ capture: true,
658
+ passive: true
659
+ };
660
+ useEventListener(
661
+ window,
662
+ "blur",
663
+ (event) => {
664
+ if (event.relatedTarget !== null)
665
+ return;
666
+ trigger();
667
+ },
668
+ listenerOptions
669
+ );
670
+ useEventListener(
671
+ window,
672
+ "focus",
673
+ trigger,
674
+ listenerOptions
675
+ );
581
676
  }
582
677
  if (triggerOnRemoval) {
583
- useMutationObserver(document, (mutations) => {
584
- mutations.filter((m) => m.removedNodes.length).map((n) => Array.from(n.removedNodes)).flat().forEach((node) => {
585
- if (node === activeElement.value)
586
- trigger();
587
- });
588
- }, {
589
- childList: true,
590
- subtree: true
591
- });
678
+ onElementRemoval(activeElement, trigger, { document });
592
679
  }
593
680
  trigger();
594
681
  return activeElement;
@@ -598,10 +685,13 @@ function useRafFn(fn, options = {}) {
598
685
  const {
599
686
  immediate = true,
600
687
  fpsLimit = void 0,
601
- window = defaultWindow
688
+ window = defaultWindow,
689
+ once = false
602
690
  } = options;
603
- const isActive = ref(false);
604
- const intervalLimit = fpsLimit ? 1e3 / fpsLimit : null;
691
+ const isActive = shallowRef(false);
692
+ const intervalLimit = computed(() => {
693
+ return fpsLimit ? 1e3 / toValue(fpsLimit) : null;
694
+ });
605
695
  let previousFrameTimestamp = 0;
606
696
  let rafId = null;
607
697
  function loop(timestamp) {
@@ -610,12 +700,17 @@ function useRafFn(fn, options = {}) {
610
700
  if (!previousFrameTimestamp)
611
701
  previousFrameTimestamp = timestamp;
612
702
  const delta = timestamp - previousFrameTimestamp;
613
- if (intervalLimit && delta < intervalLimit) {
703
+ if (intervalLimit.value && delta < intervalLimit.value) {
614
704
  rafId = window.requestAnimationFrame(loop);
615
705
  return;
616
706
  }
617
707
  previousFrameTimestamp = timestamp;
618
708
  fn({ delta, timestamp });
709
+ if (once) {
710
+ isActive.value = false;
711
+ rafId = null;
712
+ return;
713
+ }
619
714
  rafId = window.requestAnimationFrame(loop);
620
715
  }
621
716
  function resume() {
@@ -743,7 +838,8 @@ function useAnimate(target, keyframes, options) {
743
838
  };
744
839
  const reverse = () => {
745
840
  var _a;
746
- !animate.value && update();
841
+ if (!animate.value)
842
+ update();
747
843
  try {
748
844
  (_a = animate.value) == null ? void 0 : _a.reverse();
749
845
  syncResume();
@@ -771,21 +867,26 @@ function useAnimate(target, keyframes, options) {
771
867
  }
772
868
  };
773
869
  watch(() => unrefElement(target), (el) => {
774
- el && update();
870
+ if (el) {
871
+ update(true);
872
+ } else {
873
+ animate.value = void 0;
874
+ }
775
875
  });
776
876
  watch(() => keyframes, (value) => {
777
- !animate.value && update();
778
- if (!unrefElement(target) && animate.value) {
779
- animate.value.effect = new KeyframeEffect(
780
- unrefElement(target),
781
- toValue(value),
782
- animateOptions
783
- );
877
+ if (animate.value) {
878
+ update();
879
+ const targetEl = unrefElement(target);
880
+ if (targetEl) {
881
+ animate.value.effect = new KeyframeEffect(
882
+ targetEl,
883
+ toValue(value),
884
+ animateOptions
885
+ );
886
+ }
784
887
  }
785
888
  }, { deep: true });
786
- tryOnMounted(() => {
787
- nextTick(() => update(true));
788
- });
889
+ tryOnMounted(() => update(true), false);
789
890
  tryOnScopeDispose(cancel);
790
891
  function update(init) {
791
892
  const el = unrefElement(target);
@@ -803,12 +904,13 @@ function useAnimate(target, keyframes, options) {
803
904
  syncResume();
804
905
  onReady == null ? void 0 : onReady(animate.value);
805
906
  }
806
- useEventListener(animate, ["cancel", "finish", "remove"], syncPause);
907
+ const listenerOptions = { passive: true };
908
+ useEventListener(animate, ["cancel", "finish", "remove"], syncPause, listenerOptions);
807
909
  useEventListener(animate, "finish", () => {
808
910
  var _a;
809
911
  if (commitStyles)
810
912
  (_a = animate.value) == null ? void 0 : _a.commitStyles();
811
- });
913
+ }, listenerOptions);
812
914
  const { resume: resumeRef, pause: pauseRef } = useRafFn(() => {
813
915
  if (!animate.value)
814
916
  return;
@@ -863,7 +965,7 @@ function useAsyncQueue(tasks, options) {
863
965
  };
864
966
  const initialResult = Array.from(Array.from({ length: tasks.length }), () => ({ state: promiseState.pending, data: null }));
865
967
  const result = reactive(initialResult);
866
- const activeIndex = ref(-1);
968
+ const activeIndex = shallowRef(-1);
867
969
  if (!tasks || tasks.length === 0) {
868
970
  onFinished();
869
971
  return {
@@ -889,7 +991,8 @@ function useAsyncQueue(tasks, options) {
889
991
  }
890
992
  const done = curr(prevRes).then((currentRes) => {
891
993
  updateResult(promiseState.fulfilled, currentRes);
892
- activeIndex.value === tasks.length - 1 && onFinished();
994
+ if (activeIndex.value === tasks.length - 1)
995
+ onFinished();
893
996
  return currentRes;
894
997
  });
895
998
  if (!signal)
@@ -921,18 +1024,19 @@ function whenAborted(signal) {
921
1024
  }
922
1025
 
923
1026
  function useAsyncState(promise, initialState, options) {
1027
+ var _a;
924
1028
  const {
925
1029
  immediate = true,
926
1030
  delay = 0,
927
- onError = noop,
1031
+ onError = (_a = globalThis.reportError) != null ? _a : noop,
928
1032
  onSuccess = noop,
929
1033
  resetOnExecute = true,
930
1034
  shallow = true,
931
1035
  throwError
932
1036
  } = options != null ? options : {};
933
1037
  const state = shallow ? shallowRef(initialState) : ref(initialState);
934
- const isReady = ref(false);
935
- const isLoading = ref(false);
1038
+ const isReady = shallowRef(false);
1039
+ const isLoading = shallowRef(false);
936
1040
  const error = shallowRef(void 0);
937
1041
  async function execute(delay2 = 0, ...args) {
938
1042
  if (resetOnExecute)
@@ -958,14 +1062,16 @@ function useAsyncState(promise, initialState, options) {
958
1062
  }
959
1063
  return state.value;
960
1064
  }
961
- if (immediate)
1065
+ if (immediate) {
962
1066
  execute(delay);
1067
+ }
963
1068
  const shell = {
964
1069
  state,
965
1070
  isReady,
966
1071
  isLoading,
967
1072
  error,
968
- execute
1073
+ execute,
1074
+ executeImmediate: (...args) => execute(0, ...args)
969
1075
  };
970
1076
  function waitUntilIsLoaded() {
971
1077
  return new Promise((resolve, reject) => {
@@ -1001,8 +1107,8 @@ function getDefaultSerialization(target) {
1001
1107
  }
1002
1108
 
1003
1109
  function useBase64(target, options) {
1004
- const base64 = ref("");
1005
- const promise = ref();
1110
+ const base64 = shallowRef("");
1111
+ const promise = shallowRef();
1006
1112
  function execute() {
1007
1113
  if (!isClient)
1008
1114
  return;
@@ -1041,7 +1147,9 @@ function useBase64(target, options) {
1041
1147
  reject(error);
1042
1148
  }
1043
1149
  });
1044
- promise.value.then((res) => base64.value = res);
1150
+ promise.value.then((res) => {
1151
+ base64.value = (options == null ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
1152
+ });
1045
1153
  return promise.value;
1046
1154
  }
1047
1155
  if (isRef(target) || typeof target === "function")
@@ -1077,14 +1185,15 @@ function blobToBase64(blob) {
1077
1185
  });
1078
1186
  }
1079
1187
 
1188
+ // @__NO_SIDE_EFFECTS__
1080
1189
  function useBattery(options = {}) {
1081
1190
  const { navigator = defaultNavigator } = options;
1082
1191
  const events = ["chargingchange", "chargingtimechange", "dischargingtimechange", "levelchange"];
1083
1192
  const isSupported = useSupported(() => navigator && "getBattery" in navigator && typeof navigator.getBattery === "function");
1084
- const charging = ref(false);
1085
- const chargingTime = ref(0);
1086
- const dischargingTime = ref(0);
1087
- const level = ref(1);
1193
+ const charging = shallowRef(false);
1194
+ const chargingTime = shallowRef(0);
1195
+ const dischargingTime = shallowRef(0);
1196
+ const level = shallowRef(1);
1088
1197
  let battery;
1089
1198
  function updateBatteryInfo() {
1090
1199
  charging.value = this.charging;
@@ -1108,6 +1217,7 @@ function useBattery(options = {}) {
1108
1217
  };
1109
1218
  }
1110
1219
 
1220
+ // @__NO_SIDE_EFFECTS__
1111
1221
  function useBluetooth(options) {
1112
1222
  let {
1113
1223
  acceptAllDevices = false
@@ -1118,7 +1228,7 @@ function useBluetooth(options) {
1118
1228
  navigator = defaultNavigator
1119
1229
  } = options || {};
1120
1230
  const isSupported = useSupported(() => navigator && "bluetooth" in navigator);
1121
- const device = shallowRef(void 0);
1231
+ const device = shallowRef();
1122
1232
  const error = shallowRef(null);
1123
1233
  watch(device, () => {
1124
1234
  connectToBluetoothGATTServer();
@@ -1139,18 +1249,20 @@ function useBluetooth(options) {
1139
1249
  error.value = err;
1140
1250
  }
1141
1251
  }
1142
- const server = ref();
1143
- const isConnected = computed(() => {
1144
- var _a;
1145
- return ((_a = server.value) == null ? void 0 : _a.connected) || false;
1146
- });
1252
+ const server = shallowRef();
1253
+ const isConnected = shallowRef(false);
1254
+ function reset() {
1255
+ isConnected.value = false;
1256
+ device.value = void 0;
1257
+ server.value = void 0;
1258
+ }
1147
1259
  async function connectToBluetoothGATTServer() {
1148
1260
  error.value = null;
1149
1261
  if (device.value && device.value.gatt) {
1150
- device.value.addEventListener("gattserverdisconnected", () => {
1151
- });
1262
+ useEventListener(device, "gattserverdisconnected", reset, { passive: true });
1152
1263
  try {
1153
1264
  server.value = await device.value.gatt.connect();
1265
+ isConnected.value = server.value.connected;
1154
1266
  } catch (err) {
1155
1267
  error.value = err;
1156
1268
  }
@@ -1168,7 +1280,7 @@ function useBluetooth(options) {
1168
1280
  });
1169
1281
  return {
1170
1282
  isSupported,
1171
- isConnected,
1283
+ isConnected: readonly(isConnected),
1172
1284
  // Device:
1173
1285
  device,
1174
1286
  requestDevice,
@@ -1179,39 +1291,55 @@ function useBluetooth(options) {
1179
1291
  };
1180
1292
  }
1181
1293
 
1294
+ const ssrWidthSymbol = Symbol("vueuse-ssr-width");
1295
+ // @__NO_SIDE_EFFECTS__
1296
+ function useSSRWidth() {
1297
+ const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
1298
+ return typeof ssrWidth === "number" ? ssrWidth : void 0;
1299
+ }
1300
+ function provideSSRWidth(width, app) {
1301
+ if (app !== void 0) {
1302
+ app.provide(ssrWidthSymbol, width);
1303
+ } else {
1304
+ provideLocal(ssrWidthSymbol, width);
1305
+ }
1306
+ }
1307
+
1182
1308
  function useMediaQuery(query, options = {}) {
1183
- const { window = defaultWindow } = options;
1309
+ const { window = defaultWindow, ssrWidth = useSSRWidth() } = options;
1184
1310
  const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
1185
- let mediaQuery;
1186
- const matches = ref(false);
1311
+ const ssrSupport = shallowRef(typeof ssrWidth === "number");
1312
+ const mediaQuery = shallowRef();
1313
+ const matches = shallowRef(false);
1187
1314
  const handler = (event) => {
1188
1315
  matches.value = event.matches;
1189
1316
  };
1190
- const cleanup = () => {
1191
- if (!mediaQuery)
1317
+ watchEffect(() => {
1318
+ if (ssrSupport.value) {
1319
+ ssrSupport.value = !isSupported.value;
1320
+ const queryStrings = toValue(query).split(",");
1321
+ matches.value = queryStrings.some((queryString) => {
1322
+ const not = queryString.includes("not all");
1323
+ const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
1324
+ const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
1325
+ let res = Boolean(minWidth || maxWidth);
1326
+ if (minWidth && res) {
1327
+ res = ssrWidth >= pxValue(minWidth[1]);
1328
+ }
1329
+ if (maxWidth && res) {
1330
+ res = ssrWidth <= pxValue(maxWidth[1]);
1331
+ }
1332
+ return not ? !res : res;
1333
+ });
1192
1334
  return;
1193
- if ("removeEventListener" in mediaQuery)
1194
- mediaQuery.removeEventListener("change", handler);
1195
- else
1196
- mediaQuery.removeListener(handler);
1197
- };
1198
- const stopWatch = watchEffect(() => {
1335
+ }
1199
1336
  if (!isSupported.value)
1200
1337
  return;
1201
- cleanup();
1202
- mediaQuery = window.matchMedia(toValue(query));
1203
- if ("addEventListener" in mediaQuery)
1204
- mediaQuery.addEventListener("change", handler);
1205
- else
1206
- mediaQuery.addListener(handler);
1207
- matches.value = mediaQuery.matches;
1208
- });
1209
- tryOnScopeDispose(() => {
1210
- stopWatch();
1211
- cleanup();
1212
- mediaQuery = void 0;
1338
+ mediaQuery.value = window.matchMedia(toValue(query));
1339
+ matches.value = mediaQuery.value.matches;
1213
1340
  });
1214
- return matches;
1341
+ useEventListener(mediaQuery, "change", handler, { passive: true });
1342
+ return computed(() => matches.value);
1215
1343
  }
1216
1344
 
1217
1345
  const breakpointsTailwind = {
@@ -1287,7 +1415,15 @@ const breakpointsPrimeFlex = {
1287
1415
  lg: 992,
1288
1416
  xl: 1200
1289
1417
  };
1418
+ const breakpointsElement = {
1419
+ xs: 0,
1420
+ sm: 768,
1421
+ md: 992,
1422
+ lg: 1200,
1423
+ xl: 1920
1424
+ };
1290
1425
 
1426
+ // @__NO_SIDE_EFFECTS__
1291
1427
  function useBreakpoints(breakpoints, options = {}) {
1292
1428
  function getValue(k, delta) {
1293
1429
  let v = toValue(breakpoints[toValue(k)]);
@@ -1297,11 +1433,19 @@ function useBreakpoints(breakpoints, options = {}) {
1297
1433
  v = `${v}px`;
1298
1434
  return v;
1299
1435
  }
1300
- const { window = defaultWindow, strategy = "min-width" } = options;
1301
- function match(query) {
1436
+ const { window = defaultWindow, strategy = "min-width", ssrWidth = useSSRWidth() } = options;
1437
+ const ssrSupport = typeof ssrWidth === "number";
1438
+ const mounted = ssrSupport ? shallowRef(false) : { value: true };
1439
+ if (ssrSupport) {
1440
+ tryOnMounted(() => mounted.value = !!window);
1441
+ }
1442
+ function match(query, size) {
1443
+ if (!mounted.value && ssrSupport) {
1444
+ return query === "min" ? ssrWidth >= pxValue(size) : ssrWidth <= pxValue(size);
1445
+ }
1302
1446
  if (!window)
1303
1447
  return false;
1304
- return window.matchMedia(query).matches;
1448
+ return window.matchMedia(`(${query}-width: ${size})`).matches;
1305
1449
  }
1306
1450
  const greaterOrEqual = (k) => {
1307
1451
  return useMediaQuery(() => `(min-width: ${getValue(k)})`, options);
@@ -1318,7 +1462,7 @@ function useBreakpoints(breakpoints, options = {}) {
1318
1462
  return shortcuts;
1319
1463
  }, {});
1320
1464
  function current() {
1321
- const points = Object.keys(breakpoints).map((i) => [i, greaterOrEqual(i)]);
1465
+ const points = Object.keys(breakpoints).map((k) => [k, shortcutMethods[k], pxValue(getValue(k))]).sort((a, b) => a[2] - b[2]);
1322
1466
  return computed(() => points.filter(([, v]) => v.value).map(([k]) => k));
1323
1467
  }
1324
1468
  return Object.assign(shortcutMethods, {
@@ -1334,24 +1478,24 @@ function useBreakpoints(breakpoints, options = {}) {
1334
1478
  return useMediaQuery(() => `(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`, options);
1335
1479
  },
1336
1480
  isGreater(k) {
1337
- return match(`(min-width: ${getValue(k, 0.1)})`);
1481
+ return match("min", getValue(k, 0.1));
1338
1482
  },
1339
1483
  isGreaterOrEqual(k) {
1340
- return match(`(min-width: ${getValue(k)})`);
1484
+ return match("min", getValue(k));
1341
1485
  },
1342
1486
  isSmaller(k) {
1343
- return match(`(max-width: ${getValue(k, -0.1)})`);
1487
+ return match("max", getValue(k, -0.1));
1344
1488
  },
1345
1489
  isSmallerOrEqual(k) {
1346
- return match(`(max-width: ${getValue(k)})`);
1490
+ return match("max", getValue(k));
1347
1491
  },
1348
1492
  isInBetween(a, b) {
1349
- return match(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`);
1493
+ return match("min", getValue(a)) && match("max", getValue(b, -0.1));
1350
1494
  },
1351
1495
  current,
1352
1496
  active() {
1353
1497
  const bps = current();
1354
- return computed(() => bps.value.length === 0 ? "" : bps.value.at(-1));
1498
+ return computed(() => bps.value.length === 0 ? "" : bps.value.at(strategy === "min-width" ? -1 : 0));
1355
1499
  }
1356
1500
  });
1357
1501
  }
@@ -1362,7 +1506,7 @@ function useBroadcastChannel(options) {
1362
1506
  window = defaultWindow
1363
1507
  } = options;
1364
1508
  const isSupported = useSupported(() => window && "BroadcastChannel" in window);
1365
- const isClosed = ref(false);
1509
+ const isClosed = shallowRef(false);
1366
1510
  const channel = ref();
1367
1511
  const data = ref();
1368
1512
  const error = shallowRef(null);
@@ -1379,15 +1523,18 @@ function useBroadcastChannel(options) {
1379
1523
  tryOnMounted(() => {
1380
1524
  error.value = null;
1381
1525
  channel.value = new BroadcastChannel(name);
1382
- channel.value.addEventListener("message", (e) => {
1526
+ const listenerOptions = {
1527
+ passive: true
1528
+ };
1529
+ useEventListener(channel, "message", (e) => {
1383
1530
  data.value = e.data;
1384
- }, { passive: true });
1385
- channel.value.addEventListener("messageerror", (e) => {
1531
+ }, listenerOptions);
1532
+ useEventListener(channel, "messageerror", (e) => {
1386
1533
  error.value = e;
1387
- }, { passive: true });
1388
- channel.value.addEventListener("close", () => {
1534
+ }, listenerOptions);
1535
+ useEventListener(channel, "close", () => {
1389
1536
  isClosed.value = true;
1390
- });
1537
+ }, listenerOptions);
1391
1538
  });
1392
1539
  }
1393
1540
  tryOnScopeDispose(() => {
@@ -1414,13 +1561,14 @@ const WRITABLE_PROPERTIES = [
1414
1561
  "protocol",
1415
1562
  "search"
1416
1563
  ];
1564
+ // @__NO_SIDE_EFFECTS__
1417
1565
  function useBrowserLocation(options = {}) {
1418
1566
  const { window = defaultWindow } = options;
1419
1567
  const refs = Object.fromEntries(
1420
1568
  WRITABLE_PROPERTIES.map((key) => [key, ref()])
1421
1569
  );
1422
- for (const [key, ref2] of objectEntries(refs)) {
1423
- watch(ref2, (value) => {
1570
+ for (const [key, ref] of objectEntries(refs)) {
1571
+ watch(ref, (value) => {
1424
1572
  if (!(window == null ? void 0 : window.location) || window.location[key] === value)
1425
1573
  return;
1426
1574
  window.location[key] = value;
@@ -1442,14 +1590,16 @@ function useBrowserLocation(options = {}) {
1442
1590
  };
1443
1591
  const state = ref(buildState("load"));
1444
1592
  if (window) {
1445
- useEventListener(window, "popstate", () => state.value = buildState("popstate"), { passive: true });
1446
- useEventListener(window, "hashchange", () => state.value = buildState("hashchange"), { passive: true });
1593
+ const listenerOptions = { passive: true };
1594
+ useEventListener(window, "popstate", () => state.value = buildState("popstate"), listenerOptions);
1595
+ useEventListener(window, "hashchange", () => state.value = buildState("hashchange"), listenerOptions);
1447
1596
  }
1448
1597
  return state;
1449
1598
  }
1450
1599
 
1451
- function useCached(refValue, comparator = (a, b) => a === b, watchOptions) {
1452
- const cachedValue = ref(refValue.value);
1600
+ function useCached(refValue, comparator = (a, b) => a === b, options) {
1601
+ const { deepRefs = true, ...watchOptions } = options || {};
1602
+ const cachedValue = createRef(refValue.value, deepRefs);
1453
1603
  watch(() => refValue.value, (value) => {
1454
1604
  if (!comparator(value, cachedValue.value))
1455
1605
  cachedValue.value = value;
@@ -1457,32 +1607,35 @@ function useCached(refValue, comparator = (a, b) => a === b, watchOptions) {
1457
1607
  return cachedValue;
1458
1608
  }
1459
1609
 
1610
+ // @__NO_SIDE_EFFECTS__
1460
1611
  function usePermission(permissionDesc, options = {}) {
1461
1612
  const {
1462
1613
  controls = false,
1463
1614
  navigator = defaultNavigator
1464
1615
  } = options;
1465
1616
  const isSupported = useSupported(() => navigator && "permissions" in navigator);
1466
- let permissionStatus;
1617
+ const permissionStatus = shallowRef();
1467
1618
  const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
1468
- const state = ref();
1469
- const onChange = () => {
1470
- if (permissionStatus)
1471
- state.value = permissionStatus.state;
1619
+ const state = shallowRef();
1620
+ const update = () => {
1621
+ var _a, _b;
1622
+ state.value = (_b = (_a = permissionStatus.value) == null ? void 0 : _a.state) != null ? _b : "prompt";
1472
1623
  };
1624
+ useEventListener(permissionStatus, "change", update, { passive: true });
1473
1625
  const query = createSingletonPromise(async () => {
1474
1626
  if (!isSupported.value)
1475
1627
  return;
1476
- if (!permissionStatus) {
1628
+ if (!permissionStatus.value) {
1477
1629
  try {
1478
- permissionStatus = await navigator.permissions.query(desc);
1479
- useEventListener(permissionStatus, "change", onChange);
1480
- onChange();
1630
+ permissionStatus.value = await navigator.permissions.query(desc);
1481
1631
  } catch (e) {
1482
- state.value = "prompt";
1632
+ permissionStatus.value = void 0;
1633
+ } finally {
1634
+ update();
1483
1635
  }
1484
1636
  }
1485
- return permissionStatus;
1637
+ if (controls)
1638
+ return toRaw(permissionStatus.value);
1486
1639
  });
1487
1640
  query();
1488
1641
  if (controls) {
@@ -1508,25 +1661,35 @@ function useClipboard(options = {}) {
1508
1661
  const permissionRead = usePermission("clipboard-read");
1509
1662
  const permissionWrite = usePermission("clipboard-write");
1510
1663
  const isSupported = computed(() => isClipboardApiSupported.value || legacy);
1511
- const text = ref("");
1512
- const copied = ref(false);
1513
- const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
1514
- function updateText() {
1515
- if (isClipboardApiSupported.value && isAllowed(permissionRead.value)) {
1516
- navigator.clipboard.readText().then((value) => {
1517
- text.value = value;
1518
- });
1519
- } else {
1664
+ const text = shallowRef("");
1665
+ const copied = shallowRef(false);
1666
+ const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
1667
+ async function updateText() {
1668
+ let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value));
1669
+ if (!useLegacy) {
1670
+ try {
1671
+ text.value = await navigator.clipboard.readText();
1672
+ } catch (e) {
1673
+ useLegacy = true;
1674
+ }
1675
+ }
1676
+ if (useLegacy) {
1520
1677
  text.value = legacyRead();
1521
1678
  }
1522
1679
  }
1523
1680
  if (isSupported.value && read)
1524
- useEventListener(["copy", "cut"], updateText);
1681
+ useEventListener(["copy", "cut"], updateText, { passive: true });
1525
1682
  async function copy(value = toValue(source)) {
1526
1683
  if (isSupported.value && value != null) {
1527
- if (isClipboardApiSupported.value && isAllowed(permissionWrite.value))
1528
- await navigator.clipboard.writeText(value);
1529
- else
1684
+ let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value));
1685
+ if (!useLegacy) {
1686
+ try {
1687
+ await navigator.clipboard.writeText(value);
1688
+ } catch (e) {
1689
+ useLegacy = true;
1690
+ }
1691
+ }
1692
+ if (useLegacy)
1530
1693
  legacyCopy(value);
1531
1694
  text.value = value;
1532
1695
  copied.value = true;
@@ -1567,8 +1730,8 @@ function useClipboardItems(options = {}) {
1567
1730
  } = options;
1568
1731
  const isSupported = useSupported(() => navigator && "clipboard" in navigator);
1569
1732
  const content = ref([]);
1570
- const copied = ref(false);
1571
- const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
1733
+ const copied = shallowRef(false);
1734
+ const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
1572
1735
  function updateContent() {
1573
1736
  if (isSupported.value) {
1574
1737
  navigator.clipboard.read().then((items) => {
@@ -1576,8 +1739,9 @@ function useClipboardItems(options = {}) {
1576
1739
  });
1577
1740
  }
1578
1741
  }
1579
- if (isSupported.value && read)
1580
- useEventListener(["copy", "cut"], updateContent);
1742
+ if (isSupported.value && read) {
1743
+ useEventListener(["copy", "cut"], updateContent, { passive: true });
1744
+ }
1581
1745
  async function copy(value = toValue(source)) {
1582
1746
  if (isSupported.value && value != null) {
1583
1747
  await navigator.clipboard.write(value);
@@ -1588,9 +1752,10 @@ function useClipboardItems(options = {}) {
1588
1752
  }
1589
1753
  return {
1590
1754
  isSupported,
1591
- content,
1592
- copied,
1593
- copy
1755
+ content: shallowReadonly(content),
1756
+ copied: readonly(copied),
1757
+ copy,
1758
+ read: updateContent
1594
1759
  };
1595
1760
  }
1596
1761
 
@@ -1599,6 +1764,8 @@ function cloneFnJSON(source) {
1599
1764
  }
1600
1765
  function useCloned(source, options = {}) {
1601
1766
  const cloned = ref({});
1767
+ const isModified = shallowRef(false);
1768
+ let _lastSync = false;
1602
1769
  const {
1603
1770
  manual,
1604
1771
  clone = cloneFnJSON,
@@ -1606,7 +1773,19 @@ function useCloned(source, options = {}) {
1606
1773
  deep = true,
1607
1774
  immediate = true
1608
1775
  } = options;
1776
+ watch(cloned, () => {
1777
+ if (_lastSync) {
1778
+ _lastSync = false;
1779
+ return;
1780
+ }
1781
+ isModified.value = true;
1782
+ }, {
1783
+ deep: true,
1784
+ flush: "sync"
1785
+ });
1609
1786
  function sync() {
1787
+ _lastSync = true;
1788
+ isModified.value = false;
1610
1789
  cloned.value = clone(toValue(source));
1611
1790
  }
1612
1791
  if (!manual && (isRef(source) || typeof source === "function")) {
@@ -1618,7 +1797,7 @@ function useCloned(source, options = {}) {
1618
1797
  } else {
1619
1798
  sync();
1620
1799
  }
1621
- return { cloned, sync };
1800
+ return { cloned, isModified, sync };
1622
1801
  }
1623
1802
 
1624
1803
  const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -1636,6 +1815,11 @@ function setSSRHandler(key, fn) {
1636
1815
  handlers[key] = fn;
1637
1816
  }
1638
1817
 
1818
+ // @__NO_SIDE_EFFECTS__
1819
+ function usePreferredDark(options) {
1820
+ return useMediaQuery("(prefers-color-scheme: dark)", options);
1821
+ }
1822
+
1639
1823
  function guessSerializerType(rawInit) {
1640
1824
  return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
1641
1825
  }
@@ -1692,6 +1876,7 @@ function useStorage(key, defaults, storage, options = {}) {
1692
1876
  initOnMounted
1693
1877
  } = options;
1694
1878
  const data = (shallow ? shallowRef : ref)(typeof defaults === "function" ? defaults() : defaults);
1879
+ const keyComputed = computed(() => toValue(key));
1695
1880
  if (!storage) {
1696
1881
  try {
1697
1882
  storage = getSSRHandler("getDefaultStorage", () => {
@@ -1709,41 +1894,60 @@ function useStorage(key, defaults, storage, options = {}) {
1709
1894
  const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
1710
1895
  const { pause: pauseWatch, resume: resumeWatch } = watchPausable(
1711
1896
  data,
1712
- () => write(data.value),
1897
+ (newValue) => write(newValue),
1713
1898
  { flush, deep, eventFilter }
1714
1899
  );
1900
+ watch(keyComputed, () => update(), { flush });
1901
+ let firstMounted = false;
1902
+ const onStorageEvent = (ev) => {
1903
+ if (initOnMounted && !firstMounted) {
1904
+ return;
1905
+ }
1906
+ update(ev);
1907
+ };
1908
+ const onStorageCustomEvent = (ev) => {
1909
+ if (initOnMounted && !firstMounted) {
1910
+ return;
1911
+ }
1912
+ updateFromCustomEvent(ev);
1913
+ };
1715
1914
  if (window && listenToStorageChanges) {
1915
+ if (storage instanceof Storage)
1916
+ useEventListener(window, "storage", onStorageEvent, { passive: true });
1917
+ else
1918
+ useEventListener(window, customStorageEventName, onStorageCustomEvent);
1919
+ }
1920
+ if (initOnMounted) {
1716
1921
  tryOnMounted(() => {
1717
- useEventListener(window, "storage", update);
1718
- useEventListener(window, customStorageEventName, updateFromCustomEvent);
1719
- if (initOnMounted)
1720
- update();
1922
+ firstMounted = true;
1923
+ update();
1721
1924
  });
1722
- }
1723
- if (!initOnMounted)
1925
+ } else {
1724
1926
  update();
1927
+ }
1725
1928
  function dispatchWriteEvent(oldValue, newValue) {
1726
1929
  if (window) {
1727
- window.dispatchEvent(new CustomEvent(customStorageEventName, {
1728
- detail: {
1729
- key,
1730
- oldValue,
1731
- newValue,
1732
- storageArea: storage
1733
- }
1930
+ const payload = {
1931
+ key: keyComputed.value,
1932
+ oldValue,
1933
+ newValue,
1934
+ storageArea: storage
1935
+ };
1936
+ window.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, {
1937
+ detail: payload
1734
1938
  }));
1735
1939
  }
1736
1940
  }
1737
1941
  function write(v) {
1738
1942
  try {
1739
- const oldValue = storage.getItem(key);
1943
+ const oldValue = storage.getItem(keyComputed.value);
1740
1944
  if (v == null) {
1741
1945
  dispatchWriteEvent(oldValue, null);
1742
- storage.removeItem(key);
1946
+ storage.removeItem(keyComputed.value);
1743
1947
  } else {
1744
1948
  const serialized = serializer.write(v);
1745
1949
  if (oldValue !== serialized) {
1746
- storage.setItem(key, serialized);
1950
+ storage.setItem(keyComputed.value, serialized);
1747
1951
  dispatchWriteEvent(oldValue, serialized);
1748
1952
  }
1749
1953
  }
@@ -1752,10 +1956,10 @@ function useStorage(key, defaults, storage, options = {}) {
1752
1956
  }
1753
1957
  }
1754
1958
  function read(event) {
1755
- const rawValue = event ? event.newValue : storage.getItem(key);
1959
+ const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
1756
1960
  if (rawValue == null) {
1757
1961
  if (writeDefaults && rawInit != null)
1758
- storage.setItem(key, serializer.write(rawInit));
1962
+ storage.setItem(keyComputed.value, serializer.write(rawInit));
1759
1963
  return rawInit;
1760
1964
  } else if (!event && mergeDefaults) {
1761
1965
  const value = serializer.read(rawValue);
@@ -1777,12 +1981,15 @@ function useStorage(key, defaults, storage, options = {}) {
1777
1981
  data.value = rawInit;
1778
1982
  return;
1779
1983
  }
1780
- if (event && event.key !== key)
1984
+ if (event && event.key !== keyComputed.value) {
1781
1985
  return;
1986
+ }
1782
1987
  pauseWatch();
1783
1988
  try {
1784
- if ((event == null ? void 0 : event.newValue) !== serializer.write(data.value))
1989
+ const serializedData = serializer.write(data.value);
1990
+ if (event === void 0 || (event == null ? void 0 : event.newValue) !== serializedData) {
1785
1991
  data.value = read(event);
1992
+ }
1786
1993
  } catch (e) {
1787
1994
  onError(e);
1788
1995
  } finally {
@@ -1798,10 +2005,7 @@ function useStorage(key, defaults, storage, options = {}) {
1798
2005
  return data;
1799
2006
  }
1800
2007
 
1801
- function usePreferredDark(options) {
1802
- return useMediaQuery("(prefers-color-scheme: dark)", options);
1803
- }
1804
-
2008
+ const CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
1805
2009
  function useColorMode(options = {}) {
1806
2010
  const {
1807
2011
  selector = "html",
@@ -1831,23 +2035,36 @@ function useColorMode(options = {}) {
1831
2035
  const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : unrefElement(selector2);
1832
2036
  if (!el)
1833
2037
  return;
1834
- let style;
1835
- if (disableTransition) {
1836
- style = window.document.createElement("style");
1837
- const styleString = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
1838
- style.appendChild(document.createTextNode(styleString));
1839
- window.document.head.appendChild(style);
1840
- }
2038
+ const classesToAdd = /* @__PURE__ */ new Set();
2039
+ const classesToRemove = /* @__PURE__ */ new Set();
2040
+ let attributeToChange = null;
1841
2041
  if (attribute2 === "class") {
1842
2042
  const current = value.split(/\s/g);
1843
2043
  Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
1844
2044
  if (current.includes(v))
1845
- el.classList.add(v);
2045
+ classesToAdd.add(v);
1846
2046
  else
1847
- el.classList.remove(v);
2047
+ classesToRemove.add(v);
1848
2048
  });
1849
2049
  } else {
1850
- el.setAttribute(attribute2, value);
2050
+ attributeToChange = { key: attribute2, value };
2051
+ }
2052
+ if (classesToAdd.size === 0 && classesToRemove.size === 0 && attributeToChange === null)
2053
+ return;
2054
+ let style;
2055
+ if (disableTransition) {
2056
+ style = window.document.createElement("style");
2057
+ style.appendChild(document.createTextNode(CSS_DISABLE_TRANS));
2058
+ window.document.head.appendChild(style);
2059
+ }
2060
+ for (const c of classesToAdd) {
2061
+ el.classList.add(c);
2062
+ }
2063
+ for (const c of classesToRemove) {
2064
+ el.classList.remove(c);
2065
+ }
2066
+ if (attributeToChange) {
2067
+ el.setAttribute(attributeToChange.key, attributeToChange.value);
1851
2068
  }
1852
2069
  if (disableTransition) {
1853
2070
  window.getComputedStyle(style).opacity;
@@ -1875,14 +2092,11 @@ function useColorMode(options = {}) {
1875
2092
  store.value = v;
1876
2093
  }
1877
2094
  });
1878
- try {
1879
- return Object.assign(auto, { store, system, state });
1880
- } catch (e) {
1881
- return auto;
1882
- }
2095
+ return Object.assign(auto, { store, system, state });
1883
2096
  }
1884
2097
 
1885
- function useConfirmDialog(revealed = ref(false)) {
2098
+ // @__NO_SIDE_EFFECTS__
2099
+ function useConfirmDialog(revealed = shallowRef(false)) {
1886
2100
  const confirmHook = createEventHook();
1887
2101
  const cancelHook = createEventHook();
1888
2102
  const revealHook = createEventHook();
@@ -1915,9 +2129,52 @@ function useConfirmDialog(revealed = ref(false)) {
1915
2129
  };
1916
2130
  }
1917
2131
 
2132
+ function useCountdown(initialCountdown, options) {
2133
+ var _a, _b;
2134
+ const remaining = shallowRef(toValue(initialCountdown));
2135
+ const intervalController = useIntervalFn(() => {
2136
+ var _a2, _b2;
2137
+ const value = remaining.value - 1;
2138
+ remaining.value = value < 0 ? 0 : value;
2139
+ (_a2 = options == null ? void 0 : options.onTick) == null ? void 0 : _a2.call(options);
2140
+ if (remaining.value <= 0) {
2141
+ intervalController.pause();
2142
+ (_b2 = options == null ? void 0 : options.onComplete) == null ? void 0 : _b2.call(options);
2143
+ }
2144
+ }, (_a = options == null ? void 0 : options.interval) != null ? _a : 1e3, { immediate: (_b = options == null ? void 0 : options.immediate) != null ? _b : false });
2145
+ const reset = (countdown) => {
2146
+ var _a2;
2147
+ remaining.value = (_a2 = toValue(countdown)) != null ? _a2 : toValue(initialCountdown);
2148
+ };
2149
+ const stop = () => {
2150
+ intervalController.pause();
2151
+ reset();
2152
+ };
2153
+ const resume = () => {
2154
+ if (!intervalController.isActive.value) {
2155
+ if (remaining.value > 0) {
2156
+ intervalController.resume();
2157
+ }
2158
+ }
2159
+ };
2160
+ const start = (countdown) => {
2161
+ reset(countdown);
2162
+ intervalController.resume();
2163
+ };
2164
+ return {
2165
+ remaining,
2166
+ reset,
2167
+ stop,
2168
+ start,
2169
+ pause: intervalController.pause,
2170
+ resume,
2171
+ isActive: intervalController.isActive
2172
+ };
2173
+ }
2174
+
1918
2175
  function useCssVar(prop, target, options = {}) {
1919
- const { window = defaultWindow, initialValue = "", observe = false } = options;
1920
- const variable = ref(initialValue);
2176
+ const { window = defaultWindow, initialValue, observe = false } = options;
2177
+ const variable = shallowRef(initialValue);
1921
2178
  const elRef = computed(() => {
1922
2179
  var _a;
1923
2180
  return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
@@ -1926,9 +2183,9 @@ function useCssVar(prop, target, options = {}) {
1926
2183
  var _a;
1927
2184
  const key = toValue(prop);
1928
2185
  const el = toValue(elRef);
1929
- if (el && window) {
2186
+ if (el && window && key) {
1930
2187
  const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
1931
- variable.value = value || initialValue;
2188
+ variable.value = value || variable.value || initialValue;
1932
2189
  }
1933
2190
  }
1934
2191
  if (observe) {
@@ -1939,16 +2196,25 @@ function useCssVar(prop, target, options = {}) {
1939
2196
  }
1940
2197
  watch(
1941
2198
  [elRef, () => toValue(prop)],
1942
- updateCssVar,
2199
+ (_, old) => {
2200
+ if (old[0] && old[1])
2201
+ old[0].style.removeProperty(old[1]);
2202
+ updateCssVar();
2203
+ },
1943
2204
  { immediate: true }
1944
2205
  );
1945
2206
  watch(
1946
- variable,
1947
- (val) => {
1948
- var _a;
1949
- if ((_a = elRef.value) == null ? void 0 : _a.style)
1950
- elRef.value.style.setProperty(toValue(prop), val);
1951
- }
2207
+ [variable, elRef],
2208
+ ([val, el]) => {
2209
+ const raw_prop = toValue(prop);
2210
+ if ((el == null ? void 0 : el.style) && raw_prop) {
2211
+ if (val == null)
2212
+ el.style.removeProperty(raw_prop);
2213
+ else
2214
+ el.style.setProperty(raw_prop, val);
2215
+ }
2216
+ },
2217
+ { immediate: true }
1952
2218
  );
1953
2219
  return variable;
1954
2220
  }
@@ -2014,8 +2280,7 @@ function useCycleList(list, options) {
2014
2280
  function useDark(options = {}) {
2015
2281
  const {
2016
2282
  valueDark = "dark",
2017
- valueLight = "",
2018
- window = defaultWindow
2283
+ valueLight = ""
2019
2284
  } = options;
2020
2285
  const mode = useColorMode({
2021
2286
  ...options,
@@ -2031,14 +2296,7 @@ function useDark(options = {}) {
2031
2296
  light: valueLight
2032
2297
  }
2033
2298
  });
2034
- const system = computed(() => {
2035
- if (mode.system) {
2036
- return mode.system.value;
2037
- } else {
2038
- const preferredDark = usePreferredDark({ window });
2039
- return preferredDark.value ? "dark" : "light";
2040
- }
2041
- });
2299
+ const system = computed(() => mode.system.value);
2042
2300
  const isDark = computed({
2043
2301
  get() {
2044
2302
  return mode.value === "dark";
@@ -2138,7 +2396,8 @@ function useRefHistory(source, options = {}) {
2138
2396
  const {
2139
2397
  deep = false,
2140
2398
  flush = "pre",
2141
- eventFilter
2399
+ eventFilter,
2400
+ shouldCommit = () => true
2142
2401
  } = options;
2143
2402
  const {
2144
2403
  eventFilter: composedFilter,
@@ -2146,6 +2405,7 @@ function useRefHistory(source, options = {}) {
2146
2405
  resume: resumeTracking,
2147
2406
  isActive: isTracking
2148
2407
  } = pausableFilter(eventFilter);
2408
+ let lastRawValue = source.value;
2149
2409
  const {
2150
2410
  ignoreUpdates,
2151
2411
  ignorePrevAsyncUpdates,
@@ -2159,12 +2419,16 @@ function useRefHistory(source, options = {}) {
2159
2419
  ignorePrevAsyncUpdates();
2160
2420
  ignoreUpdates(() => {
2161
2421
  source2.value = value;
2422
+ lastRawValue = value;
2162
2423
  });
2163
2424
  }
2164
2425
  const manualHistory = useManualRefHistory(source, { ...options, clone: options.clone || deep, setSource });
2165
2426
  const { clear, commit: manualCommit } = manualHistory;
2166
2427
  function commit() {
2167
2428
  ignorePrevAsyncUpdates();
2429
+ if (!shouldCommit(lastRawValue, source.value))
2430
+ return;
2431
+ lastRawValue = source.value;
2168
2432
  manualCommit();
2169
2433
  }
2170
2434
  function resume(commitNow) {
@@ -2207,50 +2471,99 @@ function useDebouncedRefHistory(source, options = {}) {
2207
2471
  function useDeviceMotion(options = {}) {
2208
2472
  const {
2209
2473
  window = defaultWindow,
2474
+ requestPermissions = false,
2210
2475
  eventFilter = bypassFilter
2211
2476
  } = options;
2477
+ const isSupported = useSupported(() => typeof DeviceMotionEvent !== "undefined");
2478
+ const requirePermissions = useSupported(() => isSupported.value && "requestPermission" in DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission === "function");
2479
+ const permissionGranted = shallowRef(false);
2212
2480
  const acceleration = ref({ x: null, y: null, z: null });
2213
2481
  const rotationRate = ref({ alpha: null, beta: null, gamma: null });
2214
- const interval = ref(0);
2482
+ const interval = shallowRef(0);
2215
2483
  const accelerationIncludingGravity = ref({
2216
2484
  x: null,
2217
2485
  y: null,
2218
2486
  z: null
2219
2487
  });
2220
- if (window) {
2221
- const onDeviceMotion = createFilterWrapper(
2222
- eventFilter,
2223
- (event) => {
2224
- acceleration.value = event.acceleration;
2225
- accelerationIncludingGravity.value = event.accelerationIncludingGravity;
2226
- rotationRate.value = event.rotationRate;
2227
- interval.value = event.interval;
2488
+ function init() {
2489
+ if (window) {
2490
+ const onDeviceMotion = createFilterWrapper(
2491
+ eventFilter,
2492
+ (event) => {
2493
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2494
+ acceleration.value = {
2495
+ x: ((_a = event.acceleration) == null ? void 0 : _a.x) || null,
2496
+ y: ((_b = event.acceleration) == null ? void 0 : _b.y) || null,
2497
+ z: ((_c = event.acceleration) == null ? void 0 : _c.z) || null
2498
+ };
2499
+ accelerationIncludingGravity.value = {
2500
+ x: ((_d = event.accelerationIncludingGravity) == null ? void 0 : _d.x) || null,
2501
+ y: ((_e = event.accelerationIncludingGravity) == null ? void 0 : _e.y) || null,
2502
+ z: ((_f = event.accelerationIncludingGravity) == null ? void 0 : _f.z) || null
2503
+ };
2504
+ rotationRate.value = {
2505
+ alpha: ((_g = event.rotationRate) == null ? void 0 : _g.alpha) || null,
2506
+ beta: ((_h = event.rotationRate) == null ? void 0 : _h.beta) || null,
2507
+ gamma: ((_i = event.rotationRate) == null ? void 0 : _i.gamma) || null
2508
+ };
2509
+ interval.value = event.interval;
2510
+ }
2511
+ );
2512
+ useEventListener(window, "devicemotion", onDeviceMotion, { passive: true });
2513
+ }
2514
+ }
2515
+ const ensurePermissions = async () => {
2516
+ if (!requirePermissions.value)
2517
+ permissionGranted.value = true;
2518
+ if (permissionGranted.value)
2519
+ return;
2520
+ if (requirePermissions.value) {
2521
+ const requestPermission = DeviceMotionEvent.requestPermission;
2522
+ try {
2523
+ const response = await requestPermission();
2524
+ if (response === "granted") {
2525
+ permissionGranted.value = true;
2526
+ init();
2527
+ }
2528
+ } catch (error) {
2529
+ console.error(error);
2228
2530
  }
2229
- );
2230
- useEventListener(window, "devicemotion", onDeviceMotion);
2531
+ }
2532
+ };
2533
+ if (isSupported.value) {
2534
+ if (requestPermissions && requirePermissions.value) {
2535
+ ensurePermissions().then(() => init());
2536
+ } else {
2537
+ init();
2538
+ }
2231
2539
  }
2232
2540
  return {
2233
2541
  acceleration,
2234
2542
  accelerationIncludingGravity,
2235
2543
  rotationRate,
2236
- interval
2544
+ interval,
2545
+ isSupported,
2546
+ requirePermissions,
2547
+ ensurePermissions,
2548
+ permissionGranted
2237
2549
  };
2238
2550
  }
2239
2551
 
2552
+ // @__NO_SIDE_EFFECTS__
2240
2553
  function useDeviceOrientation(options = {}) {
2241
2554
  const { window = defaultWindow } = options;
2242
2555
  const isSupported = useSupported(() => window && "DeviceOrientationEvent" in window);
2243
- const isAbsolute = ref(false);
2244
- const alpha = ref(null);
2245
- const beta = ref(null);
2246
- const gamma = ref(null);
2556
+ const isAbsolute = shallowRef(false);
2557
+ const alpha = shallowRef(null);
2558
+ const beta = shallowRef(null);
2559
+ const gamma = shallowRef(null);
2247
2560
  if (window && isSupported.value) {
2248
2561
  useEventListener(window, "deviceorientation", (event) => {
2249
2562
  isAbsolute.value = event.absolute;
2250
2563
  alpha.value = event.alpha;
2251
2564
  beta.value = event.beta;
2252
2565
  gamma.value = event.gamma;
2253
- });
2566
+ }, { passive: true });
2254
2567
  }
2255
2568
  return {
2256
2569
  isSupported,
@@ -2261,25 +2574,21 @@ function useDeviceOrientation(options = {}) {
2261
2574
  };
2262
2575
  }
2263
2576
 
2577
+ // @__NO_SIDE_EFFECTS__
2264
2578
  function useDevicePixelRatio(options = {}) {
2265
2579
  const {
2266
2580
  window = defaultWindow
2267
2581
  } = options;
2268
- const pixelRatio = ref(1);
2582
+ const pixelRatio = shallowRef(1);
2583
+ const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options);
2584
+ let stop = noop;
2269
2585
  if (window) {
2270
- let observe2 = function() {
2271
- pixelRatio.value = window.devicePixelRatio;
2272
- cleanup2();
2273
- media = window.matchMedia(`(resolution: ${pixelRatio.value}dppx)`);
2274
- media.addEventListener("change", observe2, { once: true });
2275
- }, cleanup2 = function() {
2276
- media == null ? void 0 : media.removeEventListener("change", observe2);
2277
- };
2278
- let media;
2279
- observe2();
2280
- tryOnScopeDispose(cleanup2);
2586
+ stop = watchImmediate(query, () => pixelRatio.value = window.devicePixelRatio);
2281
2587
  }
2282
- return { pixelRatio };
2588
+ return {
2589
+ pixelRatio: readonly(pixelRatio),
2590
+ stop
2591
+ };
2283
2592
  }
2284
2593
 
2285
2594
  function useDevicesList(options = {}) {
@@ -2294,7 +2603,7 @@ function useDevicesList(options = {}) {
2294
2603
  const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput"));
2295
2604
  const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput"));
2296
2605
  const isSupported = useSupported(() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices);
2297
- const permissionGranted = ref(false);
2606
+ const permissionGranted = shallowRef(false);
2298
2607
  let stream;
2299
2608
  async function update() {
2300
2609
  if (!isSupported.value)
@@ -2307,16 +2616,28 @@ function useDevicesList(options = {}) {
2307
2616
  }
2308
2617
  }
2309
2618
  async function ensurePermissions() {
2619
+ const deviceName = constraints.video ? "camera" : "microphone";
2310
2620
  if (!isSupported.value)
2311
2621
  return false;
2312
2622
  if (permissionGranted.value)
2313
2623
  return true;
2314
- const { state, query } = usePermission("camera", { controls: true });
2624
+ const { state, query } = usePermission(deviceName, { controls: true });
2315
2625
  await query();
2316
2626
  if (state.value !== "granted") {
2317
- stream = await navigator.mediaDevices.getUserMedia(constraints);
2627
+ let granted = true;
2628
+ try {
2629
+ const allDevices = await navigator.mediaDevices.enumerateDevices();
2630
+ const hasCamera = allDevices.some((device) => device.kind === "videoinput");
2631
+ const hasMicrophone = allDevices.some((device) => device.kind === "audioinput" || device.kind === "audiooutput");
2632
+ constraints.video = hasCamera ? constraints.video : false;
2633
+ constraints.audio = hasMicrophone ? constraints.audio : false;
2634
+ stream = await navigator.mediaDevices.getUserMedia(constraints);
2635
+ } catch (e) {
2636
+ stream = null;
2637
+ granted = false;
2638
+ }
2318
2639
  update();
2319
- permissionGranted.value = true;
2640
+ permissionGranted.value = granted;
2320
2641
  } else {
2321
2642
  permissionGranted.value = true;
2322
2643
  }
@@ -2325,7 +2646,7 @@ function useDevicesList(options = {}) {
2325
2646
  if (isSupported.value) {
2326
2647
  if (requestPermissions)
2327
2648
  ensurePermissions();
2328
- useEventListener(navigator.mediaDevices, "devicechange", update);
2649
+ useEventListener(navigator.mediaDevices, "devicechange", update, { passive: true });
2329
2650
  update();
2330
2651
  }
2331
2652
  return {
@@ -2341,7 +2662,7 @@ function useDevicesList(options = {}) {
2341
2662
 
2342
2663
  function useDisplayMedia(options = {}) {
2343
2664
  var _a;
2344
- const enabled = ref((_a = options.enabled) != null ? _a : false);
2665
+ const enabled = shallowRef((_a = options.enabled) != null ? _a : false);
2345
2666
  const video = options.video;
2346
2667
  const audio = options.audio;
2347
2668
  const { navigator = defaultNavigator } = options;
@@ -2356,7 +2677,7 @@ function useDisplayMedia(options = {}) {
2356
2677
  if (!isSupported.value || stream.value)
2357
2678
  return;
2358
2679
  stream.value = await navigator.mediaDevices.getDisplayMedia(constraint);
2359
- (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => t.addEventListener("ended", stop));
2680
+ (_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => useEventListener(t, "ended", stop, { passive: true }));
2360
2681
  return stream.value;
2361
2682
  }
2362
2683
  async function _stop() {
@@ -2393,19 +2714,20 @@ function useDisplayMedia(options = {}) {
2393
2714
  };
2394
2715
  }
2395
2716
 
2717
+ // @__NO_SIDE_EFFECTS__
2396
2718
  function useDocumentVisibility(options = {}) {
2397
2719
  const { document = defaultDocument } = options;
2398
2720
  if (!document)
2399
- return ref("visible");
2400
- const visibility = ref(document.visibilityState);
2721
+ return shallowRef("visible");
2722
+ const visibility = shallowRef(document.visibilityState);
2401
2723
  useEventListener(document, "visibilitychange", () => {
2402
2724
  visibility.value = document.visibilityState;
2403
- });
2725
+ }, { passive: true });
2404
2726
  return visibility;
2405
2727
  }
2406
2728
 
2407
2729
  function useDraggable(target, options = {}) {
2408
- var _a, _b;
2730
+ var _a;
2409
2731
  const {
2410
2732
  pointerTypes,
2411
2733
  preventDefault,
@@ -2418,7 +2740,8 @@ function useDraggable(target, options = {}) {
2418
2740
  axis = "both",
2419
2741
  draggingElement = defaultWindow,
2420
2742
  containerElement,
2421
- handle: draggingHandle = target
2743
+ handle: draggingHandle = target,
2744
+ buttons = [0]
2422
2745
  } = options;
2423
2746
  const position = ref(
2424
2747
  (_a = toValue(initialValue)) != null ? _a : { x: 0, y: 0 }
@@ -2437,7 +2760,7 @@ function useDraggable(target, options = {}) {
2437
2760
  };
2438
2761
  const start = (e) => {
2439
2762
  var _a2;
2440
- if (e.button !== 0)
2763
+ if (!toValue(buttons).includes(e.button))
2441
2764
  return;
2442
2765
  if (toValue(options.disabled) || !filterEvent(e))
2443
2766
  return;
@@ -2490,7 +2813,13 @@ function useDraggable(target, options = {}) {
2490
2813
  handleEvent(e);
2491
2814
  };
2492
2815
  if (isClient) {
2493
- const config = { capture: (_b = options.capture) != null ? _b : true };
2816
+ const config = () => {
2817
+ var _a2;
2818
+ return {
2819
+ capture: (_a2 = options.capture) != null ? _a2 : true,
2820
+ passive: !toValue(preventDefault)
2821
+ };
2822
+ };
2494
2823
  useEventListener(draggingHandle, "pointerdown", start, config);
2495
2824
  useEventListener(draggingElement, "pointermove", move, config);
2496
2825
  useEventListener(draggingElement, "pointerup", end, config);
@@ -2506,55 +2835,86 @@ function useDraggable(target, options = {}) {
2506
2835
  }
2507
2836
 
2508
2837
  function useDropZone(target, options = {}) {
2509
- const isOverDropZone = ref(false);
2838
+ var _a, _b;
2839
+ const isOverDropZone = shallowRef(false);
2510
2840
  const files = shallowRef(null);
2511
2841
  let counter = 0;
2512
- let isDataTypeIncluded = true;
2842
+ let isValid = true;
2513
2843
  if (isClient) {
2514
2844
  const _options = typeof options === "function" ? { onDrop: options } : options;
2845
+ const multiple = (_a = _options.multiple) != null ? _a : true;
2846
+ const preventDefaultForUnhandled = (_b = _options.preventDefaultForUnhandled) != null ? _b : false;
2515
2847
  const getFiles = (event) => {
2516
- var _a, _b;
2517
- const list = Array.from((_b = (_a = event.dataTransfer) == null ? void 0 : _a.files) != null ? _b : []);
2518
- return files.value = list.length === 0 ? null : list;
2848
+ var _a2, _b2;
2849
+ const list = Array.from((_b2 = (_a2 = event.dataTransfer) == null ? void 0 : _a2.files) != null ? _b2 : []);
2850
+ return list.length === 0 ? null : multiple ? list : [list[0]];
2519
2851
  };
2520
- useEventListener(target, "dragenter", (event) => {
2521
- var _a, _b;
2522
- const types = Array.from(((_a = event == null ? void 0 : event.dataTransfer) == null ? void 0 : _a.items) || []).map((i) => i.kind === "file" ? i.type : null).filter(notNullish);
2523
- if (_options.dataTypes && event.dataTransfer) {
2524
- const dataTypes = unref(_options.dataTypes);
2525
- isDataTypeIncluded = typeof dataTypes === "function" ? dataTypes(types) : dataTypes ? dataTypes.some((item) => types.includes(item)) : true;
2526
- if (!isDataTypeIncluded)
2527
- return;
2852
+ const checkDataTypes = (types) => {
2853
+ const dataTypes = unref(_options.dataTypes);
2854
+ if (typeof dataTypes === "function")
2855
+ return dataTypes(types);
2856
+ if (!(dataTypes == null ? void 0 : dataTypes.length))
2857
+ return true;
2858
+ if (types.length === 0)
2859
+ return false;
2860
+ return types.every(
2861
+ (type) => dataTypes.some((allowedType) => type.includes(allowedType))
2862
+ );
2863
+ };
2864
+ const checkValidity = (items) => {
2865
+ const types = Array.from(items != null ? items : []).map((item) => item.type);
2866
+ const dataTypesValid = checkDataTypes(types);
2867
+ const multipleFilesValid = multiple || items.length <= 1;
2868
+ return dataTypesValid && multipleFilesValid;
2869
+ };
2870
+ const isSafari = () => /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in window);
2871
+ const handleDragEvent = (event, eventType) => {
2872
+ var _a2, _b2, _c, _d, _e, _f;
2873
+ const dataTransferItemList = (_a2 = event.dataTransfer) == null ? void 0 : _a2.items;
2874
+ isValid = (_b2 = dataTransferItemList && checkValidity(dataTransferItemList)) != null ? _b2 : false;
2875
+ if (preventDefaultForUnhandled) {
2876
+ event.preventDefault();
2528
2877
  }
2529
- event.preventDefault();
2530
- counter += 1;
2531
- isOverDropZone.value = true;
2532
- (_b = _options.onEnter) == null ? void 0 : _b.call(_options, getFiles(event), event);
2533
- });
2534
- useEventListener(target, "dragover", (event) => {
2535
- var _a;
2536
- if (!isDataTypeIncluded)
2537
- return;
2538
- event.preventDefault();
2539
- (_a = _options.onOver) == null ? void 0 : _a.call(_options, getFiles(event), event);
2540
- });
2541
- useEventListener(target, "dragleave", (event) => {
2542
- var _a;
2543
- if (!isDataTypeIncluded)
2878
+ if (!isSafari() && !isValid) {
2879
+ if (event.dataTransfer) {
2880
+ event.dataTransfer.dropEffect = "none";
2881
+ }
2544
2882
  return;
2883
+ }
2545
2884
  event.preventDefault();
2546
- counter -= 1;
2547
- if (counter === 0)
2548
- isOverDropZone.value = false;
2549
- (_a = _options.onLeave) == null ? void 0 : _a.call(_options, getFiles(event), event);
2550
- });
2551
- useEventListener(target, "drop", (event) => {
2552
- var _a;
2553
- event.preventDefault();
2554
- counter = 0;
2555
- isOverDropZone.value = false;
2556
- (_a = _options.onDrop) == null ? void 0 : _a.call(_options, getFiles(event), event);
2557
- });
2885
+ if (event.dataTransfer) {
2886
+ event.dataTransfer.dropEffect = "copy";
2887
+ }
2888
+ const currentFiles = getFiles(event);
2889
+ switch (eventType) {
2890
+ case "enter":
2891
+ counter += 1;
2892
+ isOverDropZone.value = true;
2893
+ (_c = _options.onEnter) == null ? void 0 : _c.call(_options, null, event);
2894
+ break;
2895
+ case "over":
2896
+ (_d = _options.onOver) == null ? void 0 : _d.call(_options, null, event);
2897
+ break;
2898
+ case "leave":
2899
+ counter -= 1;
2900
+ if (counter === 0)
2901
+ isOverDropZone.value = false;
2902
+ (_e = _options.onLeave) == null ? void 0 : _e.call(_options, null, event);
2903
+ break;
2904
+ case "drop":
2905
+ counter = 0;
2906
+ isOverDropZone.value = false;
2907
+ if (isValid) {
2908
+ files.value = currentFiles;
2909
+ (_f = _options.onDrop) == null ? void 0 : _f.call(_options, currentFiles, event);
2910
+ }
2911
+ break;
2912
+ }
2913
+ };
2914
+ useEventListener(target, "dragenter", (event) => handleDragEvent(event, "enter"));
2915
+ useEventListener(target, "dragover", (event) => handleDragEvent(event, "over"));
2916
+ useEventListener(target, "dragleave", (event) => handleDragEvent(event, "leave"));
2917
+ useEventListener(target, "drop", (event) => handleDragEvent(event, "drop"));
2558
2918
  }
2559
2919
  return {
2560
2920
  files,
@@ -2572,15 +2932,20 @@ function useResizeObserver(target, callback, options = {}) {
2572
2932
  observer = void 0;
2573
2933
  }
2574
2934
  };
2575
- const targets = computed(() => Array.isArray(target) ? target.map((el) => unrefElement(el)) : [unrefElement(target)]);
2935
+ const targets = computed(() => {
2936
+ const _targets = toValue(target);
2937
+ return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
2938
+ });
2576
2939
  const stopWatch = watch(
2577
2940
  targets,
2578
2941
  (els) => {
2579
2942
  cleanup();
2580
2943
  if (isSupported.value && window) {
2581
2944
  observer = new ResizeObserver(callback);
2582
- for (const _el of els)
2583
- _el && observer.observe(_el, observerOptions);
2945
+ for (const _el of els) {
2946
+ if (_el)
2947
+ observer.observe(_el, observerOptions);
2948
+ }
2584
2949
  }
2585
2950
  },
2586
2951
  { immediate: true, flush: "post" }
@@ -2601,17 +2966,18 @@ function useElementBounding(target, options = {}) {
2601
2966
  reset = true,
2602
2967
  windowResize = true,
2603
2968
  windowScroll = true,
2604
- immediate = true
2969
+ immediate = true,
2970
+ updateTiming = "sync"
2605
2971
  } = options;
2606
- const height = ref(0);
2607
- const bottom = ref(0);
2608
- const left = ref(0);
2609
- const right = ref(0);
2610
- const top = ref(0);
2611
- const width = ref(0);
2612
- const x = ref(0);
2613
- const y = ref(0);
2614
- function update() {
2972
+ const height = shallowRef(0);
2973
+ const bottom = shallowRef(0);
2974
+ const left = shallowRef(0);
2975
+ const right = shallowRef(0);
2976
+ const top = shallowRef(0);
2977
+ const width = shallowRef(0);
2978
+ const x = shallowRef(0);
2979
+ const y = shallowRef(0);
2980
+ function recalculate() {
2615
2981
  const el = unrefElement(target);
2616
2982
  if (!el) {
2617
2983
  if (reset) {
@@ -2636,6 +3002,12 @@ function useElementBounding(target, options = {}) {
2636
3002
  x.value = rect.x;
2637
3003
  y.value = rect.y;
2638
3004
  }
3005
+ function update() {
3006
+ if (updateTiming === "sync")
3007
+ recalculate();
3008
+ else if (updateTiming === "next-frame")
3009
+ requestAnimationFrame(() => recalculate());
3010
+ }
2639
3011
  useResizeObserver(target, update);
2640
3012
  watch(() => unrefElement(target), (ele) => !ele && update());
2641
3013
  useMutationObserver(target, update, {
@@ -2676,7 +3048,7 @@ function useElementByPoint(options) {
2676
3048
  return document && "elementsFromPoint" in document;
2677
3049
  return document && "elementFromPoint" in document;
2678
3050
  });
2679
- const element = ref(null);
3051
+ const element = shallowRef(null);
2680
3052
  const cb = () => {
2681
3053
  var _a, _b;
2682
3054
  element.value = toValue(multiple) ? (_a = document == null ? void 0 : document.elementsFromPoint(toValue(x), toValue(y))) != null ? _a : [] : (_b = document == null ? void 0 : document.elementFromPoint(toValue(x), toValue(y))) != null ? _b : null;
@@ -2693,9 +3065,10 @@ function useElementHover(el, options = {}) {
2693
3065
  const {
2694
3066
  delayEnter = 0,
2695
3067
  delayLeave = 0,
3068
+ triggerOnRemoval = false,
2696
3069
  window = defaultWindow
2697
3070
  } = options;
2698
- const isHovered = ref(false);
3071
+ const isHovered = shallowRef(false);
2699
3072
  let timer;
2700
3073
  const toggle = (entering) => {
2701
3074
  const delay = entering ? delayEnter : delayLeave;
@@ -2712,6 +3085,12 @@ function useElementHover(el, options = {}) {
2712
3085
  return isHovered;
2713
3086
  useEventListener(el, "mouseenter", () => toggle(true), { passive: true });
2714
3087
  useEventListener(el, "mouseleave", () => toggle(false), { passive: true });
3088
+ if (triggerOnRemoval) {
3089
+ onElementRemoval(
3090
+ computed(() => unrefElement(el)),
3091
+ () => toggle(false)
3092
+ );
3093
+ }
2715
3094
  return isHovered;
2716
3095
  }
2717
3096
 
@@ -2721,8 +3100,8 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
2721
3100
  var _a, _b;
2722
3101
  return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
2723
3102
  });
2724
- const width = ref(initialSize.width);
2725
- const height = ref(initialSize.height);
3103
+ const width = shallowRef(initialSize.width);
3104
+ const height = shallowRef(initialSize.height);
2726
3105
  const { stop: stop1 } = useResizeObserver(
2727
3106
  target,
2728
3107
  ([entry]) => {
@@ -2736,7 +3115,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
2736
3115
  }
2737
3116
  } else {
2738
3117
  if (boxSize) {
2739
- const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
3118
+ const formatBoxSize = toArray(boxSize);
2740
3119
  width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
2741
3120
  height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
2742
3121
  } else {
@@ -2776,17 +3155,17 @@ function useIntersectionObserver(target, callback, options = {}) {
2776
3155
  const {
2777
3156
  root,
2778
3157
  rootMargin = "0px",
2779
- threshold = 0.1,
3158
+ threshold = 0,
2780
3159
  window = defaultWindow,
2781
3160
  immediate = true
2782
3161
  } = options;
2783
3162
  const isSupported = useSupported(() => window && "IntersectionObserver" in window);
2784
3163
  const targets = computed(() => {
2785
3164
  const _target = toValue(target);
2786
- return (Array.isArray(_target) ? _target : [_target]).map(unrefElement).filter(notNullish);
3165
+ return toArray(_target).map(unrefElement).filter(notNullish);
2787
3166
  });
2788
3167
  let cleanup = noop;
2789
- const isActive = ref(immediate);
3168
+ const isActive = shallowRef(immediate);
2790
3169
  const stopWatch = isSupported.value ? watch(
2791
3170
  () => [targets.value, unrefElement(root), isActive.value],
2792
3171
  ([targets2, root2]) => {
@@ -2832,9 +3211,15 @@ function useIntersectionObserver(target, callback, options = {}) {
2832
3211
  }
2833
3212
 
2834
3213
  function useElementVisibility(element, options = {}) {
2835
- const { window = defaultWindow, scrollTarget, threshold = 0 } = options;
2836
- const elementIsVisible = ref(false);
2837
- useIntersectionObserver(
3214
+ const {
3215
+ window = defaultWindow,
3216
+ scrollTarget,
3217
+ threshold = 0,
3218
+ rootMargin,
3219
+ once = false
3220
+ } = options;
3221
+ const elementIsVisible = shallowRef(false);
3222
+ const { stop } = useIntersectionObserver(
2838
3223
  element,
2839
3224
  (intersectionObserverEntries) => {
2840
3225
  let isIntersecting = elementIsVisible.value;
@@ -2846,11 +3231,17 @@ function useElementVisibility(element, options = {}) {
2846
3231
  }
2847
3232
  }
2848
3233
  elementIsVisible.value = isIntersecting;
3234
+ if (once) {
3235
+ watchOnce(elementIsVisible, () => {
3236
+ stop();
3237
+ });
3238
+ }
2849
3239
  },
2850
3240
  {
2851
3241
  root: scrollTarget,
2852
3242
  window,
2853
- threshold
3243
+ threshold,
3244
+ rootMargin: toValue(rootMargin)
2854
3245
  }
2855
3246
  );
2856
3247
  return elementIsVisible;
@@ -2858,6 +3249,7 @@ function useElementVisibility(element, options = {}) {
2858
3249
 
2859
3250
  const events = /* @__PURE__ */ new Map();
2860
3251
 
3252
+ // @__NO_SIDE_EFFECTS__
2861
3253
  function useEventBus(key) {
2862
3254
  const scope = getCurrentScope();
2863
3255
  function on(listener) {
@@ -2900,9 +3292,9 @@ function resolveNestedOptions$1(options) {
2900
3292
  return options;
2901
3293
  }
2902
3294
  function useEventSource(url, events = [], options = {}) {
2903
- const event = ref(null);
2904
- const data = ref(null);
2905
- const status = ref("CONNECTING");
3295
+ const event = shallowRef(null);
3296
+ const data = shallowRef(null);
3297
+ const status = shallowRef("CONNECTING");
2906
3298
  const eventSource = ref(null);
2907
3299
  const error = shallowRef(null);
2908
3300
  const urlRef = toRef(url);
@@ -2911,7 +3303,9 @@ function useEventSource(url, events = [], options = {}) {
2911
3303
  let retried = 0;
2912
3304
  const {
2913
3305
  withCredentials = false,
2914
- immediate = true
3306
+ immediate = true,
3307
+ autoConnect = true,
3308
+ autoReconnect
2915
3309
  } = options;
2916
3310
  const close = () => {
2917
3311
  if (isClient && eventSource.value) {
@@ -2934,13 +3328,13 @@ function useEventSource(url, events = [], options = {}) {
2934
3328
  es.onerror = (e) => {
2935
3329
  status.value = "CLOSED";
2936
3330
  error.value = e;
2937
- if (es.readyState === 2 && !explicitlyClosed && options.autoReconnect) {
3331
+ if (es.readyState === 2 && !explicitlyClosed && autoReconnect) {
2938
3332
  es.close();
2939
3333
  const {
2940
3334
  retries = -1,
2941
3335
  delay = 1e3,
2942
3336
  onFailed
2943
- } = resolveNestedOptions$1(options.autoReconnect);
3337
+ } = resolveNestedOptions$1(autoReconnect);
2944
3338
  retried += 1;
2945
3339
  if (typeof retries === "number" && (retries < 0 || retried < retries))
2946
3340
  setTimeout(_init, delay);
@@ -2959,7 +3353,8 @@ function useEventSource(url, events = [], options = {}) {
2959
3353
  useEventListener(es, event_name, (e) => {
2960
3354
  event.value = event_name;
2961
3355
  data.value = e.data || null;
2962
- });
3356
+ lastEventId.value = e.lastEventId || null;
3357
+ }, { passive: true });
2963
3358
  }
2964
3359
  };
2965
3360
  const open = () => {
@@ -2971,7 +3366,9 @@ function useEventSource(url, events = [], options = {}) {
2971
3366
  _init();
2972
3367
  };
2973
3368
  if (immediate)
2974
- watch(urlRef, open, { immediate: true });
3369
+ open();
3370
+ if (autoConnect)
3371
+ watch(urlRef, open);
2975
3372
  tryOnScopeDispose(close);
2976
3373
  return {
2977
3374
  eventSource,
@@ -2985,10 +3382,11 @@ function useEventSource(url, events = [], options = {}) {
2985
3382
  };
2986
3383
  }
2987
3384
 
3385
+ // @__NO_SIDE_EFFECTS__
2988
3386
  function useEyeDropper(options = {}) {
2989
3387
  const { initialValue = "" } = options;
2990
3388
  const isSupported = useSupported(() => typeof window !== "undefined" && "EyeDropper" in window);
2991
- const sRGBHex = ref(initialValue);
3389
+ const sRGBHex = shallowRef(initialValue);
2992
3390
  async function open(openOptions) {
2993
3391
  if (!isSupported.value)
2994
3392
  return;
@@ -3051,7 +3449,13 @@ function headersToObject(headers) {
3051
3449
  function combineCallbacks(combination, ...callbacks) {
3052
3450
  if (combination === "overwrite") {
3053
3451
  return async (ctx) => {
3054
- const callback = callbacks[callbacks.length - 1];
3452
+ let callback;
3453
+ for (let i = callbacks.length - 1; i >= 0; i--) {
3454
+ if (callbacks[i] != null) {
3455
+ callback = callbacks[i];
3456
+ break;
3457
+ }
3458
+ }
3055
3459
  if (callback)
3056
3460
  return { ...ctx, ...await callback(ctx) };
3057
3461
  return ctx;
@@ -3112,7 +3516,7 @@ function createFetch(config = {}) {
3112
3516
  return useFactoryFetch;
3113
3517
  }
3114
3518
  function useFetch(url, ...args) {
3115
- var _a;
3519
+ var _a, _b;
3116
3520
  const supportsAbort = typeof AbortController === "function";
3117
3521
  let fetchOptions = {};
3118
3522
  let options = {
@@ -3137,26 +3541,26 @@ function useFetch(url, ...args) {
3137
3541
  options = { ...options, ...args[1] };
3138
3542
  }
3139
3543
  const {
3140
- fetch = (_a = defaultWindow) == null ? void 0 : _a.fetch,
3544
+ fetch = (_b = (_a = defaultWindow) == null ? void 0 : _a.fetch) != null ? _b : globalThis == null ? void 0 : globalThis.fetch,
3141
3545
  initialData,
3142
3546
  timeout
3143
3547
  } = options;
3144
3548
  const responseEvent = createEventHook();
3145
3549
  const errorEvent = createEventHook();
3146
3550
  const finallyEvent = createEventHook();
3147
- const isFinished = ref(false);
3148
- const isFetching = ref(false);
3149
- const aborted = ref(false);
3150
- const statusCode = ref(null);
3551
+ const isFinished = shallowRef(false);
3552
+ const isFetching = shallowRef(false);
3553
+ const aborted = shallowRef(false);
3554
+ const statusCode = shallowRef(null);
3151
3555
  const response = shallowRef(null);
3152
3556
  const error = shallowRef(null);
3153
3557
  const data = shallowRef(initialData || null);
3154
3558
  const canAbort = computed(() => supportsAbort && isFetching.value);
3155
3559
  let controller;
3156
3560
  let timer;
3157
- const abort = () => {
3561
+ const abort = (reason) => {
3158
3562
  if (supportsAbort) {
3159
- controller == null ? void 0 : controller.abort();
3563
+ controller == null ? void 0 : controller.abort(reason);
3160
3564
  controller = new AbortController();
3161
3565
  controller.signal.onabort = () => aborted.value = true;
3162
3566
  fetchOptions = {
@@ -3173,7 +3577,7 @@ function useFetch(url, ...args) {
3173
3577
  timer = useTimeoutFn(abort, timeout, { immediate: false });
3174
3578
  let executeCounter = 0;
3175
3579
  const execute = async (throwOnFailed = false) => {
3176
- var _a2, _b;
3580
+ var _a2, _b2;
3177
3581
  abort();
3178
3582
  loading(true);
3179
3583
  error.value = null;
@@ -3185,10 +3589,11 @@ function useFetch(url, ...args) {
3185
3589
  method: config.method,
3186
3590
  headers: {}
3187
3591
  };
3188
- if (config.payload) {
3592
+ const payload = toValue(config.payload);
3593
+ if (payload) {
3189
3594
  const headers = headersToObject(defaultFetchOptions.headers);
3190
- const payload = toValue(config.payload);
3191
- if (!config.payloadType && payload && Object.getPrototypeOf(payload) === Object.prototype && !(payload instanceof FormData))
3595
+ const proto = Object.getPrototypeOf(payload);
3596
+ if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData))
3192
3597
  config.payloadType = "json";
3193
3598
  if (config.payloadType)
3194
3599
  headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
@@ -3221,7 +3626,7 @@ function useFetch(url, ...args) {
3221
3626
  ...context.options,
3222
3627
  headers: {
3223
3628
  ...headersToObject(defaultFetchOptions.headers),
3224
- ...headersToObject((_b = context.options) == null ? void 0 : _b.headers)
3629
+ ...headersToObject((_b2 = context.options) == null ? void 0 : _b2.headers)
3225
3630
  }
3226
3631
  }
3227
3632
  ).then(async (fetchResponse) => {
@@ -3235,7 +3640,9 @@ function useFetch(url, ...args) {
3235
3640
  if (options.afterFetch) {
3236
3641
  ({ data: responseData } = await options.afterFetch({
3237
3642
  data: responseData,
3238
- response: fetchResponse
3643
+ response: fetchResponse,
3644
+ context,
3645
+ execute
3239
3646
  }));
3240
3647
  }
3241
3648
  data.value = responseData;
@@ -3247,7 +3654,9 @@ function useFetch(url, ...args) {
3247
3654
  ({ error: errorData, data: responseData } = await options.onFetchError({
3248
3655
  data: responseData,
3249
3656
  error: fetchError,
3250
- response: response.value
3657
+ response: response.value,
3658
+ context,
3659
+ execute
3251
3660
  }));
3252
3661
  }
3253
3662
  error.value = errorData;
@@ -3331,7 +3740,7 @@ function useFetch(url, ...args) {
3331
3740
  }
3332
3741
  function waitUntilFinished() {
3333
3742
  return new Promise((resolve, reject) => {
3334
- until(isFinished).toBe(true).then(() => resolve(shell)).catch((error2) => reject(error2));
3743
+ until(isFinished).toBe(true).then(() => resolve(shell)).catch(reject);
3335
3744
  });
3336
3745
  }
3337
3746
  function setType(type) {
@@ -3358,8 +3767,12 @@ function useFetch(url, ...args) {
3358
3767
  };
3359
3768
  }
3360
3769
  function joinPaths(start, end) {
3361
- if (!start.endsWith("/") && !end.startsWith("/"))
3770
+ if (!start.endsWith("/") && !end.startsWith("/")) {
3362
3771
  return `${start}/${end}`;
3772
+ }
3773
+ if (start.endsWith("/") && end.startsWith("/")) {
3774
+ return `${start.slice(0, -1)}${end}`;
3775
+ }
3363
3776
  return `${start}${end}`;
3364
3777
  }
3365
3778
 
@@ -3369,50 +3782,79 @@ const DEFAULT_OPTIONS = {
3369
3782
  reset: false,
3370
3783
  directory: false
3371
3784
  };
3785
+ function prepareInitialFiles(files) {
3786
+ if (!files)
3787
+ return null;
3788
+ if (files instanceof FileList)
3789
+ return files;
3790
+ const dt = new DataTransfer();
3791
+ for (const file of files) {
3792
+ dt.items.add(file);
3793
+ }
3794
+ return dt.files;
3795
+ }
3372
3796
  function useFileDialog(options = {}) {
3373
3797
  const {
3374
3798
  document = defaultDocument
3375
3799
  } = options;
3376
- const files = ref(null);
3377
- const { on: onChange, trigger } = createEventHook();
3378
- let input;
3379
- if (document) {
3380
- input = document.createElement("input");
3381
- input.type = "file";
3382
- input.onchange = (event) => {
3383
- const result = event.target;
3384
- files.value = result.files;
3385
- trigger(files.value);
3386
- };
3387
- }
3800
+ const files = ref(prepareInitialFiles(options.initialFiles));
3801
+ const { on: onChange, trigger: changeTrigger } = createEventHook();
3802
+ const { on: onCancel, trigger: cancelTrigger } = createEventHook();
3803
+ const inputRef = computed(() => {
3804
+ var _a;
3805
+ const input = (_a = unrefElement(options.input)) != null ? _a : document ? document.createElement("input") : void 0;
3806
+ if (input) {
3807
+ input.type = "file";
3808
+ input.onchange = (event) => {
3809
+ const result = event.target;
3810
+ files.value = result.files;
3811
+ changeTrigger(files.value);
3812
+ };
3813
+ input.oncancel = () => {
3814
+ cancelTrigger();
3815
+ };
3816
+ }
3817
+ return input;
3818
+ });
3388
3819
  const reset = () => {
3389
3820
  files.value = null;
3390
- if (input && input.value) {
3391
- input.value = "";
3392
- trigger(null);
3821
+ if (inputRef.value && inputRef.value.value) {
3822
+ inputRef.value.value = "";
3823
+ changeTrigger(null);
3393
3824
  }
3394
3825
  };
3826
+ const applyOptions = (options2) => {
3827
+ const el = inputRef.value;
3828
+ if (!el)
3829
+ return;
3830
+ el.multiple = toValue(options2.multiple);
3831
+ el.accept = toValue(options2.accept);
3832
+ el.webkitdirectory = toValue(options2.directory);
3833
+ if (hasOwn(options2, "capture"))
3834
+ el.capture = toValue(options2.capture);
3835
+ };
3395
3836
  const open = (localOptions) => {
3396
- if (!input)
3837
+ const el = inputRef.value;
3838
+ if (!el)
3397
3839
  return;
3398
- const _options = {
3840
+ const mergedOptions = {
3399
3841
  ...DEFAULT_OPTIONS,
3400
3842
  ...options,
3401
3843
  ...localOptions
3402
3844
  };
3403
- input.multiple = _options.multiple;
3404
- input.accept = _options.accept;
3405
- input.webkitdirectory = _options.directory;
3406
- if (hasOwn(_options, "capture"))
3407
- input.capture = _options.capture;
3408
- if (_options.reset)
3845
+ applyOptions(mergedOptions);
3846
+ if (toValue(mergedOptions.reset))
3409
3847
  reset();
3410
- input.click();
3848
+ el.click();
3411
3849
  };
3850
+ watchEffect(() => {
3851
+ applyOptions(options);
3852
+ });
3412
3853
  return {
3413
3854
  files: readonly(files),
3414
3855
  open,
3415
3856
  reset,
3857
+ onCancel,
3416
3858
  onChange
3417
3859
  };
3418
3860
  }
@@ -3424,9 +3866,9 @@ function useFileSystemAccess(options = {}) {
3424
3866
  } = options;
3425
3867
  const window = _window;
3426
3868
  const isSupported = useSupported(() => window && "showSaveFilePicker" in window && "showOpenFilePicker" in window);
3427
- const fileHandle = ref();
3428
- const data = ref();
3429
- const file = ref();
3869
+ const fileHandle = shallowRef();
3870
+ const data = shallowRef();
3871
+ const file = shallowRef();
3430
3872
  const fileName = computed(() => {
3431
3873
  var _a, _b;
3432
3874
  return (_b = (_a = file.value) == null ? void 0 : _a.name) != null ? _b : "";
@@ -3514,14 +3956,15 @@ function useFileSystemAccess(options = {}) {
3514
3956
 
3515
3957
  function useFocus(target, options = {}) {
3516
3958
  const { initialValue = false, focusVisible = false, preventScroll = false } = options;
3517
- const innerFocused = ref(false);
3959
+ const innerFocused = shallowRef(false);
3518
3960
  const targetElement = computed(() => unrefElement(target));
3961
+ const listenerOptions = { passive: true };
3519
3962
  useEventListener(targetElement, "focus", (event) => {
3520
3963
  var _a, _b;
3521
3964
  if (!focusVisible || ((_b = (_a = event.target).matches) == null ? void 0 : _b.call(_a, ":focus-visible")))
3522
3965
  innerFocused.value = true;
3523
- });
3524
- useEventListener(targetElement, "blur", () => innerFocused.value = false);
3966
+ }, listenerOptions);
3967
+ useEventListener(targetElement, "blur", () => innerFocused.value = false, listenerOptions);
3525
3968
  const focused = computed({
3526
3969
  get: () => innerFocused.value,
3527
3970
  set(value) {
@@ -3542,16 +3985,31 @@ function useFocus(target, options = {}) {
3542
3985
  return { focused };
3543
3986
  }
3544
3987
 
3988
+ const EVENT_FOCUS_IN = "focusin";
3989
+ const EVENT_FOCUS_OUT = "focusout";
3990
+ const PSEUDO_CLASS_FOCUS_WITHIN = ":focus-within";
3545
3991
  function useFocusWithin(target, options = {}) {
3546
- const activeElement = useActiveElement(options);
3992
+ const { window = defaultWindow } = options;
3547
3993
  const targetElement = computed(() => unrefElement(target));
3548
- const focused = computed(() => targetElement.value && activeElement.value ? targetElement.value.contains(activeElement.value) : false);
3994
+ const _focused = shallowRef(false);
3995
+ const focused = computed(() => _focused.value);
3996
+ const activeElement = useActiveElement(options);
3997
+ if (!window || !activeElement.value) {
3998
+ return { focused };
3999
+ }
4000
+ const listenerOptions = { passive: true };
4001
+ useEventListener(targetElement, EVENT_FOCUS_IN, () => _focused.value = true, listenerOptions);
4002
+ useEventListener(targetElement, EVENT_FOCUS_OUT, () => {
4003
+ var _a, _b, _c;
4004
+ return _focused.value = (_c = (_b = (_a = targetElement.value) == null ? void 0 : _a.matches) == null ? void 0 : _b.call(_a, PSEUDO_CLASS_FOCUS_WITHIN)) != null ? _c : false;
4005
+ }, listenerOptions);
3549
4006
  return { focused };
3550
4007
  }
3551
4008
 
4009
+ // @__NO_SIDE_EFFECTS__
3552
4010
  function useFps(options) {
3553
4011
  var _a;
3554
- const fps = ref(0);
4012
+ const fps = shallowRef(0);
3555
4013
  if (typeof performance === "undefined")
3556
4014
  return fps;
3557
4015
  const every = (_a = options == null ? void 0 : options.every) != null ? _a : 10;
@@ -3584,9 +4042,9 @@ function useFullscreen(target, options = {}) {
3584
4042
  } = options;
3585
4043
  const targetRef = computed(() => {
3586
4044
  var _a;
3587
- return (_a = unrefElement(target)) != null ? _a : document == null ? void 0 : document.querySelector("html");
4045
+ return (_a = unrefElement(target)) != null ? _a : document == null ? void 0 : document.documentElement;
3588
4046
  });
3589
- const isFullscreen = ref(false);
4047
+ const isFullscreen = shallowRef(false);
3590
4048
  const requestMethod = computed(() => {
3591
4049
  return [
3592
4050
  "requestFullscreen",
@@ -3675,8 +4133,10 @@ function useFullscreen(target, options = {}) {
3675
4133
  if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen())
3676
4134
  isFullscreen.value = isElementFullScreenValue;
3677
4135
  };
3678
- useEventListener(document, eventHandlers, handlerCallback, false);
3679
- useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, false);
4136
+ const listenerOptions = { capture: false, passive: true };
4137
+ useEventListener(document, eventHandlers, handlerCallback, listenerOptions);
4138
+ useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, listenerOptions);
4139
+ tryOnMounted(handlerCallback, false);
3680
4140
  if (autoExit)
3681
4141
  tryOnScopeDispose(exit);
3682
4142
  return {
@@ -3731,6 +4191,7 @@ function mapGamepadToXbox360Controller(gamepad) {
3731
4191
  return null;
3732
4192
  });
3733
4193
  }
4194
+ // @__NO_SIDE_EFFECTS__
3734
4195
  function useGamepad(options = {}) {
3735
4196
  const {
3736
4197
  navigator = defaultNavigator
@@ -3777,8 +4238,9 @@ function useGamepad(options = {}) {
3777
4238
  gamepads.value = gamepads.value.filter((x) => x.index !== gamepad.index);
3778
4239
  onDisconnectedHook.trigger(gamepad.index);
3779
4240
  };
3780
- useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad));
3781
- useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad));
4241
+ const listenerOptions = { passive: true };
4242
+ useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad), listenerOptions);
4243
+ useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad), listenerOptions);
3782
4244
  tryOnMounted(() => {
3783
4245
  const _gamepads = (navigator == null ? void 0 : navigator.getGamepads()) || [];
3784
4246
  for (const gamepad of _gamepads) {
@@ -3807,7 +4269,7 @@ function useGeolocation(options = {}) {
3807
4269
  immediate = true
3808
4270
  } = options;
3809
4271
  const isSupported = useSupported(() => navigator && "geolocation" in navigator);
3810
- const locatedAt = ref(null);
4272
+ const locatedAt = shallowRef(null);
3811
4273
  const error = shallowRef(null);
3812
4274
  const coords = ref({
3813
4275
  accuracy: 0,
@@ -3866,8 +4328,8 @@ function useIdle(timeout = oneMinute, options = {}) {
3866
4328
  window = defaultWindow,
3867
4329
  eventFilter = throttleFilter(50)
3868
4330
  } = options;
3869
- const idle = ref(initialState);
3870
- const lastActive = ref(timestamp());
4331
+ const idle = shallowRef(initialState);
4332
+ const lastActive = shallowRef(timestamp());
3871
4333
  let timer;
3872
4334
  const reset = () => {
3873
4335
  idle.value = false;
@@ -3883,15 +4345,17 @@ function useIdle(timeout = oneMinute, options = {}) {
3883
4345
  );
3884
4346
  if (window) {
3885
4347
  const document = window.document;
4348
+ const listenerOptions = { passive: true };
3886
4349
  for (const event of events)
3887
- useEventListener(window, event, onEvent, { passive: true });
4350
+ useEventListener(window, event, onEvent, listenerOptions);
3888
4351
  if (listenForVisibilityChange) {
3889
4352
  useEventListener(document, "visibilitychange", () => {
3890
4353
  if (!document.hidden)
3891
4354
  onEvent();
3892
- });
4355
+ }, listenerOptions);
3893
4356
  }
3894
- reset();
4357
+ if (!initialState)
4358
+ reset();
3895
4359
  }
3896
4360
  return {
3897
4361
  idle,
@@ -3903,20 +4367,32 @@ function useIdle(timeout = oneMinute, options = {}) {
3903
4367
  async function loadImage(options) {
3904
4368
  return new Promise((resolve, reject) => {
3905
4369
  const img = new Image();
3906
- const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy } = options;
4370
+ const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy, width, height, decoding, fetchPriority, ismap, usemap } = options;
3907
4371
  img.src = src;
3908
- if (srcset)
4372
+ if (srcset != null)
3909
4373
  img.srcset = srcset;
3910
- if (sizes)
4374
+ if (sizes != null)
3911
4375
  img.sizes = sizes;
3912
- if (clazz)
4376
+ if (clazz != null)
3913
4377
  img.className = clazz;
3914
- if (loading)
4378
+ if (loading != null)
3915
4379
  img.loading = loading;
3916
- if (crossorigin)
4380
+ if (crossorigin != null)
3917
4381
  img.crossOrigin = crossorigin;
3918
- if (referrerPolicy)
4382
+ if (referrerPolicy != null)
3919
4383
  img.referrerPolicy = referrerPolicy;
4384
+ if (width != null)
4385
+ img.width = width;
4386
+ if (height != null)
4387
+ img.height = height;
4388
+ if (decoding != null)
4389
+ img.decoding = decoding;
4390
+ if (fetchPriority != null)
4391
+ img.fetchPriority = fetchPriority;
4392
+ if (ismap != null)
4393
+ img.isMap = ismap;
4394
+ if (usemap != null)
4395
+ img.useMap = usemap;
3920
4396
  img.onload = () => resolve(img);
3921
4397
  img.onerror = reject;
3922
4398
  });
@@ -3938,6 +4414,14 @@ function useImage(options, asyncStateOptions = {}) {
3938
4414
  return state;
3939
4415
  }
3940
4416
 
4417
+ function resolveElement(el) {
4418
+ if (typeof Window !== "undefined" && el instanceof Window)
4419
+ return el.document.documentElement;
4420
+ if (typeof Document !== "undefined" && el instanceof Document)
4421
+ return el.documentElement;
4422
+ return el;
4423
+ }
4424
+
3941
4425
  const ARRIVED_STATE_THRESHOLD_PIXELS = 1;
3942
4426
  function useScroll(element, options = {}) {
3943
4427
  const {
@@ -3951,6 +4435,9 @@ function useScroll(element, options = {}) {
3951
4435
  top: 0,
3952
4436
  bottom: 0
3953
4437
  },
4438
+ observe: _observe = {
4439
+ mutation: false
4440
+ },
3954
4441
  eventListenerOptions = {
3955
4442
  capture: false,
3956
4443
  passive: true
@@ -3961,8 +4448,11 @@ function useScroll(element, options = {}) {
3961
4448
  console.error(e);
3962
4449
  }
3963
4450
  } = options;
3964
- const internalX = ref(0);
3965
- const internalY = ref(0);
4451
+ const observe = typeof _observe === "boolean" ? {
4452
+ mutation: _observe
4453
+ } : _observe;
4454
+ const internalX = shallowRef(0);
4455
+ const internalY = shallowRef(0);
3966
4456
  const x = computed({
3967
4457
  get() {
3968
4458
  return internalX.value;
@@ -3997,7 +4487,7 @@ function useScroll(element, options = {}) {
3997
4487
  if (y != null)
3998
4488
  internalY.value = scrollContainer.scrollTop;
3999
4489
  }
4000
- const isScrolling = ref(false);
4490
+ const isScrolling = shallowRef(false);
4001
4491
  const arrivedState = reactive({
4002
4492
  left: true,
4003
4493
  right: false,
@@ -4026,12 +4516,13 @@ function useScroll(element, options = {}) {
4026
4516
  if (!window)
4027
4517
  return;
4028
4518
  const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
4029
- const { display, flexDirection } = getComputedStyle(el);
4519
+ const { display, flexDirection, direction } = getComputedStyle(el);
4520
+ const directionMultipler = direction === "rtl" ? -1 : 1;
4030
4521
  const scrollLeft = el.scrollLeft;
4031
4522
  directions.left = scrollLeft < internalX.value;
4032
4523
  directions.right = scrollLeft > internalX.value;
4033
- const left = Math.abs(scrollLeft) <= (offset.left || 0);
4034
- const right = Math.abs(scrollLeft) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
4524
+ const left = Math.abs(scrollLeft * directionMultipler) <= (offset.left || 0);
4525
+ const right = Math.abs(scrollLeft * directionMultipler) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
4035
4526
  if (display === "flex" && flexDirection === "row-reverse") {
4036
4527
  arrivedState.left = right;
4037
4528
  arrivedState.right = left;
@@ -4082,6 +4573,22 @@ function useScroll(element, options = {}) {
4082
4573
  onError(e);
4083
4574
  }
4084
4575
  });
4576
+ if ((observe == null ? void 0 : observe.mutation) && element != null && element !== window && element !== document) {
4577
+ useMutationObserver(
4578
+ element,
4579
+ () => {
4580
+ const _element = toValue(element);
4581
+ if (!_element)
4582
+ return;
4583
+ setArrivedState(_element);
4584
+ },
4585
+ {
4586
+ attributes: true,
4587
+ childList: true,
4588
+ subtree: true
4589
+ }
4590
+ );
4591
+ }
4085
4592
  useEventListener(
4086
4593
  element,
4087
4594
  "scrollend",
@@ -4102,14 +4609,6 @@ function useScroll(element, options = {}) {
4102
4609
  };
4103
4610
  }
4104
4611
 
4105
- function resolveElement(el) {
4106
- if (typeof Window !== "undefined" && el instanceof Window)
4107
- return el.document.documentElement;
4108
- if (typeof Document !== "undefined" && el instanceof Document)
4109
- return el.documentElement;
4110
- return el;
4111
- }
4112
-
4113
4612
  function useInfiniteScroll(element, onLoadMore, options = {}) {
4114
4613
  var _a;
4115
4614
  const {
@@ -4151,30 +4650,35 @@ function useInfiniteScroll(element, onLoadMore, options = {}) {
4151
4650
  }
4152
4651
  }
4153
4652
  }
4154
- watch(
4653
+ const stop = watch(
4155
4654
  () => [state.arrivedState[direction], isElementVisible.value],
4156
4655
  checkAndLoad,
4157
4656
  { immediate: true }
4158
4657
  );
4658
+ tryOnUnmounted(stop);
4159
4659
  return {
4160
- isLoading
4660
+ isLoading,
4661
+ reset() {
4662
+ nextTick(() => checkAndLoad());
4663
+ }
4161
4664
  };
4162
4665
  }
4163
4666
 
4164
4667
  const defaultEvents = ["mousedown", "mouseup", "keydown", "keyup"];
4668
+ // @__NO_SIDE_EFFECTS__
4165
4669
  function useKeyModifier(modifier, options = {}) {
4166
4670
  const {
4167
4671
  events = defaultEvents,
4168
4672
  document = defaultDocument,
4169
4673
  initial = null
4170
4674
  } = options;
4171
- const state = ref(initial);
4675
+ const state = shallowRef(initial);
4172
4676
  if (document) {
4173
4677
  events.forEach((listenerEvent) => {
4174
4678
  useEventListener(document, listenerEvent, (evt) => {
4175
4679
  if (typeof evt.getModifierState === "function")
4176
4680
  state.value = evt.getModifierState(modifier);
4177
- });
4681
+ }, { passive: true });
4178
4682
  });
4179
4683
  }
4180
4684
  return state;
@@ -4213,6 +4717,7 @@ function useMagicKeys(options = {}) {
4213
4717
  };
4214
4718
  const refs = useReactive ? reactive(obj) : obj;
4215
4719
  const metaDeps = /* @__PURE__ */ new Set();
4720
+ const shiftDeps = /* @__PURE__ */ new Set();
4216
4721
  const usedKeys = /* @__PURE__ */ new Set();
4217
4722
  function setRefs(key, value) {
4218
4723
  if (key in refs) {
@@ -4242,6 +4747,19 @@ function useMagicKeys(options = {}) {
4242
4747
  usedKeys.add(key2);
4243
4748
  setRefs(key2, value);
4244
4749
  }
4750
+ if (key === "shift" && !value) {
4751
+ const shiftDepsArray = Array.from(shiftDeps);
4752
+ const shiftIndex = shiftDepsArray.indexOf("shift");
4753
+ shiftDepsArray.forEach((key2, index) => {
4754
+ if (index >= shiftIndex) {
4755
+ current.delete(key2);
4756
+ setRefs(key2, false);
4757
+ }
4758
+ });
4759
+ shiftDeps.clear();
4760
+ } else if (typeof e.getModifierState === "function" && e.getModifierState("Shift") && value) {
4761
+ [...current, ...values].forEach((key2) => shiftDeps.add(key2));
4762
+ }
4245
4763
  if (key === "meta" && !value) {
4246
4764
  metaDeps.forEach((key2) => {
4247
4765
  current.delete(key2);
@@ -4260,8 +4778,8 @@ function useMagicKeys(options = {}) {
4260
4778
  updateRefs(e, false);
4261
4779
  return onEventFired(e);
4262
4780
  }, { passive });
4263
- useEventListener("blur", reset, { passive: true });
4264
- useEventListener("focus", reset, { passive: true });
4781
+ useEventListener("blur", reset, { passive });
4782
+ useEventListener("focus", reset, { passive });
4265
4783
  const proxy = new Proxy(
4266
4784
  refs,
4267
4785
  {
@@ -4274,9 +4792,9 @@ function useMagicKeys(options = {}) {
4274
4792
  if (!(prop in refs)) {
4275
4793
  if (/[+_-]/.test(prop)) {
4276
4794
  const keys = prop.split(/[+_-]/g).map((i) => i.trim());
4277
- refs[prop] = computed(() => keys.every((key) => toValue(proxy[key])));
4795
+ refs[prop] = computed(() => keys.map((key) => toValue(proxy[key])).every(Boolean));
4278
4796
  } else {
4279
- refs[prop] = ref(false);
4797
+ refs[prop] = shallowRef(false);
4280
4798
  }
4281
4799
  }
4282
4800
  const r = Reflect.get(target2, prop, rec);
@@ -4313,22 +4831,24 @@ function useMediaControls(target, options = {}) {
4313
4831
  const {
4314
4832
  document = defaultDocument
4315
4833
  } = options;
4316
- const currentTime = ref(0);
4317
- const duration = ref(0);
4318
- const seeking = ref(false);
4319
- const volume = ref(1);
4320
- const waiting = ref(false);
4321
- const ended = ref(false);
4322
- const playing = ref(false);
4323
- const rate = ref(1);
4324
- const stalled = ref(false);
4834
+ const listenerOptions = { passive: true };
4835
+ const currentTime = shallowRef(0);
4836
+ const duration = shallowRef(0);
4837
+ const seeking = shallowRef(false);
4838
+ const volume = shallowRef(1);
4839
+ const waiting = shallowRef(false);
4840
+ const ended = shallowRef(false);
4841
+ const playing = shallowRef(false);
4842
+ const rate = shallowRef(1);
4843
+ const stalled = shallowRef(false);
4325
4844
  const buffered = ref([]);
4326
4845
  const tracks = ref([]);
4327
- const selectedTrack = ref(-1);
4328
- const isPictureInPicture = ref(false);
4329
- const muted = ref(false);
4846
+ const selectedTrack = shallowRef(-1);
4847
+ const isPictureInPicture = shallowRef(false);
4848
+ const muted = shallowRef(false);
4330
4849
  const supportsPictureInPicture = document && "pictureInPictureEnabled" in document;
4331
4850
  const sourceErrorEvent = createEventHook();
4851
+ const playbackErrorEvent = createEventHook();
4332
4852
  const disableTrack = (track) => {
4333
4853
  usingElRef(target, (el) => {
4334
4854
  if (track) {
@@ -4380,24 +4900,18 @@ function useMediaControls(target, options = {}) {
4380
4900
  else if (isObject(src))
4381
4901
  sources = [src];
4382
4902
  el.querySelectorAll("source").forEach((e) => {
4383
- e.removeEventListener("error", sourceErrorEvent.trigger);
4384
4903
  e.remove();
4385
4904
  });
4386
- sources.forEach(({ src: src2, type }) => {
4905
+ sources.forEach(({ src: src2, type, media }) => {
4387
4906
  const source = document.createElement("source");
4388
4907
  source.setAttribute("src", src2);
4389
4908
  source.setAttribute("type", type || "");
4390
- source.addEventListener("error", sourceErrorEvent.trigger);
4909
+ source.setAttribute("media", media || "");
4910
+ useEventListener(source, "error", sourceErrorEvent.trigger, listenerOptions);
4391
4911
  el.appendChild(source);
4392
4912
  });
4393
4913
  el.load();
4394
4914
  });
4395
- tryOnScopeDispose(() => {
4396
- const el = toValue(target);
4397
- if (!el)
4398
- return;
4399
- el.querySelectorAll("source").forEach((e) => e.removeEventListener("error", sourceErrorEvent.trigger));
4400
- });
4401
4915
  watch([target, volume], () => {
4402
4916
  const el = toValue(target);
4403
4917
  if (!el)
@@ -4446,46 +4960,133 @@ function useMediaControls(target, options = {}) {
4446
4960
  const el = toValue(target);
4447
4961
  if (!el)
4448
4962
  return;
4449
- isPlaying ? el.play() : el.pause();
4450
- });
4451
- useEventListener(target, "timeupdate", () => ignoreCurrentTimeUpdates(() => currentTime.value = toValue(target).currentTime));
4452
- useEventListener(target, "durationchange", () => duration.value = toValue(target).duration);
4453
- useEventListener(target, "progress", () => buffered.value = timeRangeToArray(toValue(target).buffered));
4454
- useEventListener(target, "seeking", () => seeking.value = true);
4455
- useEventListener(target, "seeked", () => seeking.value = false);
4456
- useEventListener(target, ["waiting", "loadstart"], () => {
4457
- waiting.value = true;
4458
- ignorePlayingUpdates(() => playing.value = false);
4459
- });
4460
- useEventListener(target, "loadeddata", () => waiting.value = false);
4461
- useEventListener(target, "playing", () => {
4462
- waiting.value = false;
4463
- ended.value = false;
4464
- ignorePlayingUpdates(() => playing.value = true);
4465
- });
4466
- useEventListener(target, "ratechange", () => rate.value = toValue(target).playbackRate);
4467
- useEventListener(target, "stalled", () => stalled.value = true);
4468
- useEventListener(target, "ended", () => ended.value = true);
4469
- useEventListener(target, "pause", () => ignorePlayingUpdates(() => playing.value = false));
4470
- useEventListener(target, "play", () => ignorePlayingUpdates(() => playing.value = true));
4471
- useEventListener(target, "enterpictureinpicture", () => isPictureInPicture.value = true);
4472
- useEventListener(target, "leavepictureinpicture", () => isPictureInPicture.value = false);
4473
- useEventListener(target, "volumechange", () => {
4474
- const el = toValue(target);
4475
- if (!el)
4476
- return;
4477
- volume.value = el.volume;
4478
- muted.value = el.muted;
4963
+ if (isPlaying) {
4964
+ el.play().catch((e) => {
4965
+ playbackErrorEvent.trigger(e);
4966
+ throw e;
4967
+ });
4968
+ } else {
4969
+ el.pause();
4970
+ }
4479
4971
  });
4972
+ useEventListener(
4973
+ target,
4974
+ "timeupdate",
4975
+ () => ignoreCurrentTimeUpdates(() => currentTime.value = toValue(target).currentTime),
4976
+ listenerOptions
4977
+ );
4978
+ useEventListener(
4979
+ target,
4980
+ "durationchange",
4981
+ () => duration.value = toValue(target).duration,
4982
+ listenerOptions
4983
+ );
4984
+ useEventListener(
4985
+ target,
4986
+ "progress",
4987
+ () => buffered.value = timeRangeToArray(toValue(target).buffered),
4988
+ listenerOptions
4989
+ );
4990
+ useEventListener(
4991
+ target,
4992
+ "seeking",
4993
+ () => seeking.value = true,
4994
+ listenerOptions
4995
+ );
4996
+ useEventListener(
4997
+ target,
4998
+ "seeked",
4999
+ () => seeking.value = false,
5000
+ listenerOptions
5001
+ );
5002
+ useEventListener(
5003
+ target,
5004
+ ["waiting", "loadstart"],
5005
+ () => {
5006
+ waiting.value = true;
5007
+ ignorePlayingUpdates(() => playing.value = false);
5008
+ },
5009
+ listenerOptions
5010
+ );
5011
+ useEventListener(
5012
+ target,
5013
+ "loadeddata",
5014
+ () => waiting.value = false,
5015
+ listenerOptions
5016
+ );
5017
+ useEventListener(
5018
+ target,
5019
+ "playing",
5020
+ () => {
5021
+ waiting.value = false;
5022
+ ended.value = false;
5023
+ ignorePlayingUpdates(() => playing.value = true);
5024
+ },
5025
+ listenerOptions
5026
+ );
5027
+ useEventListener(
5028
+ target,
5029
+ "ratechange",
5030
+ () => rate.value = toValue(target).playbackRate,
5031
+ listenerOptions
5032
+ );
5033
+ useEventListener(
5034
+ target,
5035
+ "stalled",
5036
+ () => stalled.value = true,
5037
+ listenerOptions
5038
+ );
5039
+ useEventListener(
5040
+ target,
5041
+ "ended",
5042
+ () => ended.value = true,
5043
+ listenerOptions
5044
+ );
5045
+ useEventListener(
5046
+ target,
5047
+ "pause",
5048
+ () => ignorePlayingUpdates(() => playing.value = false),
5049
+ listenerOptions
5050
+ );
5051
+ useEventListener(
5052
+ target,
5053
+ "play",
5054
+ () => ignorePlayingUpdates(() => playing.value = true),
5055
+ listenerOptions
5056
+ );
5057
+ useEventListener(
5058
+ target,
5059
+ "enterpictureinpicture",
5060
+ () => isPictureInPicture.value = true,
5061
+ listenerOptions
5062
+ );
5063
+ useEventListener(
5064
+ target,
5065
+ "leavepictureinpicture",
5066
+ () => isPictureInPicture.value = false,
5067
+ listenerOptions
5068
+ );
5069
+ useEventListener(
5070
+ target,
5071
+ "volumechange",
5072
+ () => {
5073
+ const el = toValue(target);
5074
+ if (!el)
5075
+ return;
5076
+ volume.value = el.volume;
5077
+ muted.value = el.muted;
5078
+ },
5079
+ listenerOptions
5080
+ );
4480
5081
  const listeners = [];
4481
5082
  const stop = watch([target], () => {
4482
5083
  const el = toValue(target);
4483
5084
  if (!el)
4484
5085
  return;
4485
5086
  stop();
4486
- listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks));
4487
- listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks));
4488
- listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks));
5087
+ listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
5088
+ listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
5089
+ listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
4489
5090
  });
4490
5091
  tryOnScopeDispose(() => listeners.forEach((listener) => listener()));
4491
5092
  return {
@@ -4511,30 +5112,16 @@ function useMediaControls(target, options = {}) {
4511
5112
  togglePictureInPicture,
4512
5113
  isPictureInPicture,
4513
5114
  // Events
4514
- onSourceError: sourceErrorEvent.on
5115
+ onSourceError: sourceErrorEvent.on,
5116
+ onPlaybackError: playbackErrorEvent.on
4515
5117
  };
4516
5118
  }
4517
5119
 
4518
- function getMapVue2Compat() {
4519
- const data = shallowReactive({});
4520
- return {
4521
- get: (key) => data[key],
4522
- set: (key, value) => set(data, key, value),
4523
- has: (key) => hasOwn(data, key),
4524
- delete: (key) => del(data, key),
4525
- clear: () => {
4526
- Object.keys(data).forEach((key) => {
4527
- del(data, key);
4528
- });
4529
- }
4530
- };
4531
- }
5120
+ // @__NO_SIDE_EFFECTS__
4532
5121
  function useMemoize(resolver, options) {
4533
5122
  const initCache = () => {
4534
5123
  if (options == null ? void 0 : options.cache)
4535
5124
  return shallowReactive(options.cache);
4536
- if (isVue2)
4537
- return getMapVue2Compat();
4538
5125
  return shallowReactive(/* @__PURE__ */ new Map());
4539
5126
  };
4540
5127
  const cache = initCache();
@@ -4564,6 +5151,7 @@ function useMemoize(resolver, options) {
4564
5151
  return memoized;
4565
5152
  }
4566
5153
 
5154
+ // @__NO_SIDE_EFFECTS__
4567
5155
  function useMemory(options = {}) {
4568
5156
  const memory = ref();
4569
5157
  const isSupported = useSupported(() => typeof performance !== "undefined" && "memory" in performance);
@@ -4580,7 +5168,7 @@ const UseMouseBuiltinExtractors = {
4580
5168
  page: (event) => [event.pageX, event.pageY],
4581
5169
  client: (event) => [event.clientX, event.clientY],
4582
5170
  screen: (event) => [event.screenX, event.screenY],
4583
- movement: (event) => event instanceof Touch ? null : [event.movementX, event.movementY]
5171
+ movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
4584
5172
  };
4585
5173
  function useMouse(options = {}) {
4586
5174
  const {
@@ -4594,9 +5182,11 @@ function useMouse(options = {}) {
4594
5182
  eventFilter
4595
5183
  } = options;
4596
5184
  let _prevMouseEvent = null;
4597
- const x = ref(initialValue.x);
4598
- const y = ref(initialValue.y);
4599
- const sourceType = ref(null);
5185
+ let _prevScrollX = 0;
5186
+ let _prevScrollY = 0;
5187
+ const x = shallowRef(initialValue.x);
5188
+ const y = shallowRef(initialValue.y);
5189
+ const sourceType = shallowRef(null);
4600
5190
  const extractor = typeof type === "function" ? type : UseMouseBuiltinExtractors[type];
4601
5191
  const mouseHandler = (event) => {
4602
5192
  const result = extractor(event);
@@ -4605,6 +5195,10 @@ function useMouse(options = {}) {
4605
5195
  [x.value, y.value] = result;
4606
5196
  sourceType.value = "mouse";
4607
5197
  }
5198
+ if (window) {
5199
+ _prevScrollX = window.scrollX;
5200
+ _prevScrollY = window.scrollY;
5201
+ }
4608
5202
  };
4609
5203
  const touchHandler = (event) => {
4610
5204
  if (event.touches.length > 0) {
@@ -4620,8 +5214,8 @@ function useMouse(options = {}) {
4620
5214
  return;
4621
5215
  const pos = extractor(_prevMouseEvent);
4622
5216
  if (_prevMouseEvent instanceof MouseEvent && pos) {
4623
- x.value = pos[0] + window.scrollX;
4624
- y.value = pos[1] + window.scrollY;
5217
+ x.value = pos[0] + window.scrollX - _prevScrollX;
5218
+ y.value = pos[1] + window.scrollY - _prevScrollY;
4625
5219
  }
4626
5220
  };
4627
5221
  const reset = () => {
@@ -4640,7 +5234,7 @@ function useMouse(options = {}) {
4640
5234
  useEventListener(target, "touchend", reset, listenerOptions);
4641
5235
  }
4642
5236
  if (scroll && type === "page")
4643
- useEventListener(window, "scroll", scrollHandlerWrapper, { passive: true });
5237
+ useEventListener(window, "scroll", scrollHandlerWrapper, listenerOptions);
4644
5238
  }
4645
5239
  return {
4646
5240
  x,
@@ -4651,51 +5245,87 @@ function useMouse(options = {}) {
4651
5245
 
4652
5246
  function useMouseInElement(target, options = {}) {
4653
5247
  const {
5248
+ windowResize = true,
5249
+ windowScroll = true,
4654
5250
  handleOutside = true,
4655
5251
  window = defaultWindow
4656
5252
  } = options;
4657
5253
  const type = options.type || "page";
4658
5254
  const { x, y, sourceType } = useMouse(options);
4659
- const targetRef = ref(target != null ? target : window == null ? void 0 : window.document.body);
4660
- const elementX = ref(0);
4661
- const elementY = ref(0);
4662
- const elementPositionX = ref(0);
4663
- const elementPositionY = ref(0);
4664
- const elementHeight = ref(0);
4665
- const elementWidth = ref(0);
4666
- const isOutside = ref(true);
4667
- let stop = () => {
4668
- };
5255
+ const targetRef = shallowRef(target != null ? target : window == null ? void 0 : window.document.body);
5256
+ const elementX = shallowRef(0);
5257
+ const elementY = shallowRef(0);
5258
+ const elementPositionX = shallowRef(0);
5259
+ const elementPositionY = shallowRef(0);
5260
+ const elementHeight = shallowRef(0);
5261
+ const elementWidth = shallowRef(0);
5262
+ const isOutside = shallowRef(true);
5263
+ function update() {
5264
+ if (!window)
5265
+ return;
5266
+ const el = unrefElement(targetRef);
5267
+ if (!el || !(el instanceof Element))
5268
+ return;
5269
+ const {
5270
+ left,
5271
+ top,
5272
+ width,
5273
+ height
5274
+ } = el.getBoundingClientRect();
5275
+ elementPositionX.value = left + (type === "page" ? window.pageXOffset : 0);
5276
+ elementPositionY.value = top + (type === "page" ? window.pageYOffset : 0);
5277
+ elementHeight.value = height;
5278
+ elementWidth.value = width;
5279
+ const elX = x.value - elementPositionX.value;
5280
+ const elY = y.value - elementPositionY.value;
5281
+ isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
5282
+ if (handleOutside || !isOutside.value) {
5283
+ elementX.value = elX;
5284
+ elementY.value = elY;
5285
+ }
5286
+ }
5287
+ const stopFnList = [];
5288
+ function stop() {
5289
+ stopFnList.forEach((fn) => fn());
5290
+ stopFnList.length = 0;
5291
+ }
5292
+ tryOnMounted(() => {
5293
+ update();
5294
+ });
4669
5295
  if (window) {
4670
- stop = watch(
5296
+ const {
5297
+ stop: stopResizeObserver
5298
+ } = useResizeObserver(targetRef, update);
5299
+ const {
5300
+ stop: stopMutationObserver
5301
+ } = useMutationObserver(targetRef, update, {
5302
+ attributeFilter: ["style", "class"]
5303
+ });
5304
+ const stopWatch = watch(
4671
5305
  [targetRef, x, y],
4672
- () => {
4673
- const el = unrefElement(targetRef);
4674
- if (!el)
4675
- return;
4676
- const {
4677
- left,
4678
- top,
4679
- width,
4680
- height
4681
- } = el.getBoundingClientRect();
4682
- elementPositionX.value = left + (type === "page" ? window.pageXOffset : 0);
4683
- elementPositionY.value = top + (type === "page" ? window.pageYOffset : 0);
4684
- elementHeight.value = height;
4685
- elementWidth.value = width;
4686
- const elX = x.value - elementPositionX.value;
4687
- const elY = y.value - elementPositionY.value;
4688
- isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
4689
- if (handleOutside || !isOutside.value) {
4690
- elementX.value = elX;
4691
- elementY.value = elY;
4692
- }
4693
- },
4694
- { immediate: true }
5306
+ update
4695
5307
  );
4696
- useEventListener(document, "mouseleave", () => {
4697
- isOutside.value = true;
4698
- });
5308
+ stopFnList.push(
5309
+ stopResizeObserver,
5310
+ stopMutationObserver,
5311
+ stopWatch
5312
+ );
5313
+ useEventListener(
5314
+ document,
5315
+ "mouseleave",
5316
+ () => isOutside.value = true,
5317
+ { passive: true }
5318
+ );
5319
+ if (windowScroll) {
5320
+ stopFnList.push(
5321
+ useEventListener("scroll", update, { capture: true, passive: true })
5322
+ );
5323
+ }
5324
+ if (windowResize) {
5325
+ stopFnList.push(
5326
+ useEventListener("resize", update, { passive: true })
5327
+ );
5328
+ }
4699
5329
  }
4700
5330
  return {
4701
5331
  x,
@@ -4720,35 +5350,40 @@ function useMousePressed(options = {}) {
4720
5350
  initialValue = false,
4721
5351
  window = defaultWindow
4722
5352
  } = options;
4723
- const pressed = ref(initialValue);
4724
- const sourceType = ref(null);
5353
+ const pressed = shallowRef(initialValue);
5354
+ const sourceType = shallowRef(null);
4725
5355
  if (!window) {
4726
5356
  return {
4727
5357
  pressed,
4728
5358
  sourceType
4729
5359
  };
4730
5360
  }
4731
- const onPressed = (srcType) => () => {
5361
+ const onPressed = (srcType) => (event) => {
5362
+ var _a;
4732
5363
  pressed.value = true;
4733
5364
  sourceType.value = srcType;
5365
+ (_a = options.onPressed) == null ? void 0 : _a.call(options, event);
4734
5366
  };
4735
- const onReleased = () => {
5367
+ const onReleased = (event) => {
5368
+ var _a;
4736
5369
  pressed.value = false;
4737
5370
  sourceType.value = null;
5371
+ (_a = options.onReleased) == null ? void 0 : _a.call(options, event);
4738
5372
  };
4739
5373
  const target = computed(() => unrefElement(options.target) || window);
4740
- useEventListener(target, "mousedown", onPressed("mouse"), { passive: true, capture });
4741
- useEventListener(window, "mouseleave", onReleased, { passive: true, capture });
4742
- useEventListener(window, "mouseup", onReleased, { passive: true, capture });
5374
+ const listenerOptions = { passive: true, capture };
5375
+ useEventListener(target, "mousedown", onPressed("mouse"), listenerOptions);
5376
+ useEventListener(window, "mouseleave", onReleased, listenerOptions);
5377
+ useEventListener(window, "mouseup", onReleased, listenerOptions);
4743
5378
  if (drag) {
4744
- useEventListener(target, "dragstart", onPressed("mouse"), { passive: true, capture });
4745
- useEventListener(window, "drop", onReleased, { passive: true, capture });
4746
- useEventListener(window, "dragend", onReleased, { passive: true, capture });
5379
+ useEventListener(target, "dragstart", onPressed("mouse"), listenerOptions);
5380
+ useEventListener(window, "drop", onReleased, listenerOptions);
5381
+ useEventListener(window, "dragend", onReleased, listenerOptions);
4747
5382
  }
4748
5383
  if (touch) {
4749
- useEventListener(target, "touchstart", onPressed("touch"), { passive: true, capture });
4750
- useEventListener(window, "touchend", onReleased, { passive: true, capture });
4751
- useEventListener(window, "touchcancel", onReleased, { passive: true, capture });
5384
+ useEventListener(target, "touchstart", onPressed("touch"), listenerOptions);
5385
+ useEventListener(window, "touchend", onReleased, listenerOptions);
5386
+ useEventListener(window, "touchcancel", onReleased, listenerOptions);
4752
5387
  }
4753
5388
  return {
4754
5389
  pressed,
@@ -4756,34 +5391,36 @@ function useMousePressed(options = {}) {
4756
5391
  };
4757
5392
  }
4758
5393
 
5394
+ // @__NO_SIDE_EFFECTS__
4759
5395
  function useNavigatorLanguage(options = {}) {
4760
5396
  const { window = defaultWindow } = options;
4761
5397
  const navigator = window == null ? void 0 : window.navigator;
4762
5398
  const isSupported = useSupported(() => navigator && "language" in navigator);
4763
- const language = ref(navigator == null ? void 0 : navigator.language);
5399
+ const language = shallowRef(navigator == null ? void 0 : navigator.language);
4764
5400
  useEventListener(window, "languagechange", () => {
4765
5401
  if (navigator)
4766
5402
  language.value = navigator.language;
4767
- });
5403
+ }, { passive: true });
4768
5404
  return {
4769
5405
  isSupported,
4770
5406
  language
4771
5407
  };
4772
5408
  }
4773
5409
 
5410
+ // @__NO_SIDE_EFFECTS__
4774
5411
  function useNetwork(options = {}) {
4775
5412
  const { window = defaultWindow } = options;
4776
5413
  const navigator = window == null ? void 0 : window.navigator;
4777
5414
  const isSupported = useSupported(() => navigator && "connection" in navigator);
4778
- const isOnline = ref(true);
4779
- const saveData = ref(false);
4780
- const offlineAt = ref(void 0);
4781
- const onlineAt = ref(void 0);
4782
- const downlink = ref(void 0);
4783
- const downlinkMax = ref(void 0);
4784
- const rtt = ref(void 0);
4785
- const effectiveType = ref(void 0);
4786
- const type = ref("unknown");
5415
+ const isOnline = shallowRef(true);
5416
+ const saveData = shallowRef(false);
5417
+ const offlineAt = shallowRef(void 0);
5418
+ const onlineAt = shallowRef(void 0);
5419
+ const downlink = shallowRef(void 0);
5420
+ const downlinkMax = shallowRef(void 0);
5421
+ const rtt = shallowRef(void 0);
5422
+ const effectiveType = shallowRef(void 0);
5423
+ const type = shallowRef("unknown");
4787
5424
  const connection = isSupported.value && navigator.connection;
4788
5425
  function updateNetworkInformation() {
4789
5426
  if (!navigator)
@@ -4800,41 +5437,44 @@ function useNetwork(options = {}) {
4800
5437
  type.value = connection.type;
4801
5438
  }
4802
5439
  }
5440
+ const listenerOptions = { passive: true };
4803
5441
  if (window) {
4804
5442
  useEventListener(window, "offline", () => {
4805
5443
  isOnline.value = false;
4806
5444
  offlineAt.value = Date.now();
4807
- });
5445
+ }, listenerOptions);
4808
5446
  useEventListener(window, "online", () => {
4809
5447
  isOnline.value = true;
4810
5448
  onlineAt.value = Date.now();
4811
- });
5449
+ }, listenerOptions);
4812
5450
  }
4813
5451
  if (connection)
4814
- useEventListener(connection, "change", updateNetworkInformation, false);
5452
+ useEventListener(connection, "change", updateNetworkInformation, listenerOptions);
4815
5453
  updateNetworkInformation();
4816
5454
  return {
4817
5455
  isSupported,
4818
- isOnline,
4819
- saveData,
4820
- offlineAt,
4821
- onlineAt,
4822
- downlink,
4823
- downlinkMax,
4824
- effectiveType,
4825
- rtt,
4826
- type
5456
+ isOnline: readonly(isOnline),
5457
+ saveData: readonly(saveData),
5458
+ offlineAt: readonly(offlineAt),
5459
+ onlineAt: readonly(onlineAt),
5460
+ downlink: readonly(downlink),
5461
+ downlinkMax: readonly(downlinkMax),
5462
+ effectiveType: readonly(effectiveType),
5463
+ rtt: readonly(rtt),
5464
+ type: readonly(type)
4827
5465
  };
4828
5466
  }
4829
5467
 
5468
+ // @__NO_SIDE_EFFECTS__
4830
5469
  function useNow(options = {}) {
4831
5470
  const {
4832
5471
  controls: exposeControls = false,
4833
- interval = "requestAnimationFrame"
5472
+ interval = "requestAnimationFrame",
5473
+ immediate = true
4834
5474
  } = options;
4835
5475
  const now = ref(/* @__PURE__ */ new Date());
4836
5476
  const update = () => now.value = /* @__PURE__ */ new Date();
4837
- const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate: true }) : useIntervalFn(update, interval, { immediate: true });
5477
+ const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate }) : useIntervalFn(update, interval, { immediate });
4838
5478
  if (exposeControls) {
4839
5479
  return {
4840
5480
  now,
@@ -4846,7 +5486,7 @@ function useNow(options = {}) {
4846
5486
  }
4847
5487
 
4848
5488
  function useObjectUrl(object) {
4849
- const url = ref();
5489
+ const url = shallowRef();
4850
5490
  const release = () => {
4851
5491
  if (url.value)
4852
5492
  URL.revokeObjectURL(url.value);
@@ -4865,6 +5505,7 @@ function useObjectUrl(object) {
4865
5505
  return readonly(url);
4866
5506
  }
4867
5507
 
5508
+ // @__NO_SIDE_EFFECTS__
4868
5509
  function useClamp(value, min, max) {
4869
5510
  if (typeof value === "function" || isReadonly(value))
4870
5511
  return computed(() => clamp(toValue(value), toValue(min), toValue(max)));
@@ -4933,14 +5574,16 @@ function useOffsetPagination(options) {
4933
5574
  return returnValue;
4934
5575
  }
4935
5576
 
5577
+ // @__NO_SIDE_EFFECTS__
4936
5578
  function useOnline(options = {}) {
4937
5579
  const { isOnline } = useNetwork(options);
4938
5580
  return isOnline;
4939
5581
  }
4940
5582
 
5583
+ // @__NO_SIDE_EFFECTS__
4941
5584
  function usePageLeave(options = {}) {
4942
5585
  const { window = defaultWindow } = options;
4943
- const isLeft = ref(false);
5586
+ const isLeft = shallowRef(false);
4944
5587
  const handler = (event) => {
4945
5588
  if (!window)
4946
5589
  return;
@@ -4949,13 +5592,15 @@ function usePageLeave(options = {}) {
4949
5592
  isLeft.value = !from;
4950
5593
  };
4951
5594
  if (window) {
4952
- useEventListener(window, "mouseout", handler, { passive: true });
4953
- useEventListener(window.document, "mouseleave", handler, { passive: true });
4954
- useEventListener(window.document, "mouseenter", handler, { passive: true });
5595
+ const listenerOptions = { passive: true };
5596
+ useEventListener(window, "mouseout", handler, listenerOptions);
5597
+ useEventListener(window.document, "mouseleave", handler, listenerOptions);
5598
+ useEventListener(window.document, "mouseenter", handler, listenerOptions);
4955
5599
  }
4956
5600
  return isLeft;
4957
5601
  }
4958
5602
 
5603
+ // @__NO_SIDE_EFFECTS__
4959
5604
  function useScreenOrientation(options = {}) {
4960
5605
  const {
4961
5606
  window = defaultWindow
@@ -4963,12 +5608,12 @@ function useScreenOrientation(options = {}) {
4963
5608
  const isSupported = useSupported(() => window && "screen" in window && "orientation" in window.screen);
4964
5609
  const screenOrientation = isSupported.value ? window.screen.orientation : {};
4965
5610
  const orientation = ref(screenOrientation.type);
4966
- const angle = ref(screenOrientation.angle || 0);
5611
+ const angle = shallowRef(screenOrientation.angle || 0);
4967
5612
  if (isSupported.value) {
4968
5613
  useEventListener(window, "orientationchange", () => {
4969
5614
  orientation.value = screenOrientation.type;
4970
5615
  angle.value = screenOrientation.angle;
4971
- });
5616
+ }, { passive: true });
4972
5617
  }
4973
5618
  const lockOrientation = (type) => {
4974
5619
  if (isSupported.value && typeof screenOrientation.lock === "function")
@@ -5120,7 +5765,7 @@ function usePointer(options = {}) {
5120
5765
  const {
5121
5766
  target = defaultWindow
5122
5767
  } = options;
5123
- const isInside = ref(false);
5768
+ const isInside = shallowRef(false);
5124
5769
  const state = ref(options.initialValue || {});
5125
5770
  Object.assign(state.value, defaultState, state.value);
5126
5771
  const handler = (event) => {
@@ -5140,13 +5785,15 @@ function usePointer(options = {}) {
5140
5785
  };
5141
5786
  }
5142
5787
 
5788
+ // @__NO_SIDE_EFFECTS__
5143
5789
  function usePointerLock(target, options = {}) {
5144
5790
  const { document = defaultDocument } = options;
5145
5791
  const isSupported = useSupported(() => document && "pointerLockElement" in document);
5146
- const element = ref();
5147
- const triggerElement = ref();
5792
+ const element = shallowRef();
5793
+ const triggerElement = shallowRef();
5148
5794
  let targetElement;
5149
5795
  if (isSupported.value) {
5796
+ const listenerOptions = { passive: true };
5150
5797
  useEventListener(document, "pointerlockchange", () => {
5151
5798
  var _a;
5152
5799
  const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
@@ -5155,7 +5802,7 @@ function usePointerLock(target, options = {}) {
5155
5802
  if (!element.value)
5156
5803
  targetElement = triggerElement.value = null;
5157
5804
  }
5158
- });
5805
+ }, listenerOptions);
5159
5806
  useEventListener(document, "pointerlockerror", () => {
5160
5807
  var _a;
5161
5808
  const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
@@ -5163,7 +5810,7 @@ function usePointerLock(target, options = {}) {
5163
5810
  const action = document.pointerLockElement ? "release" : "acquire";
5164
5811
  throw new Error(`Failed to ${action} pointer lock.`);
5165
5812
  }
5166
- });
5813
+ }, listenerOptions);
5167
5814
  }
5168
5815
  async function lock(e) {
5169
5816
  var _a;
@@ -5215,8 +5862,8 @@ function usePointerSwipe(target, options = {}) {
5215
5862
  const distanceY = computed(() => posStart.y - posEnd.y);
5216
5863
  const { max, abs } = Math;
5217
5864
  const isThresholdExceeded = computed(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold);
5218
- const isSwiping = ref(false);
5219
- const isPointerDown = ref(false);
5865
+ const isSwiping = shallowRef(false);
5866
+ const isPointerDown = shallowRef(false);
5220
5867
  const direction = computed(() => {
5221
5868
  if (!isThresholdExceeded.value)
5222
5869
  return "none";
@@ -5232,6 +5879,7 @@ function usePointerSwipe(target, options = {}) {
5232
5879
  const isPrimaryButton = e.buttons === 1;
5233
5880
  return (_c = (_b = (_a = options.pointerTypes) == null ? void 0 : _a.includes(e.pointerType)) != null ? _b : isReleasingButton || isPrimaryButton) != null ? _c : true;
5234
5881
  };
5882
+ const listenerOptions = { passive: true };
5235
5883
  const stops = [
5236
5884
  useEventListener(target, "pointerdown", (e) => {
5237
5885
  if (!eventIsAllowed(e))
@@ -5243,7 +5891,7 @@ function usePointerSwipe(target, options = {}) {
5243
5891
  updatePosStart(x, y);
5244
5892
  updatePosEnd(x, y);
5245
5893
  onSwipeStart == null ? void 0 : onSwipeStart(e);
5246
- }),
5894
+ }, listenerOptions),
5247
5895
  useEventListener(target, "pointermove", (e) => {
5248
5896
  if (!eventIsAllowed(e))
5249
5897
  return;
@@ -5255,7 +5903,7 @@ function usePointerSwipe(target, options = {}) {
5255
5903
  isSwiping.value = true;
5256
5904
  if (isSwiping.value)
5257
5905
  onSwipe == null ? void 0 : onSwipe(e);
5258
- }),
5906
+ }, listenerOptions),
5259
5907
  useEventListener(target, "pointerup", (e) => {
5260
5908
  if (!eventIsAllowed(e))
5261
5909
  return;
@@ -5263,11 +5911,11 @@ function usePointerSwipe(target, options = {}) {
5263
5911
  onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
5264
5912
  isPointerDown.value = false;
5265
5913
  isSwiping.value = false;
5266
- })
5914
+ }, listenerOptions)
5267
5915
  ];
5268
5916
  tryOnMounted(() => {
5269
5917
  var _a, _b, _c, _d, _e, _f, _g, _h;
5270
- (_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "none");
5918
+ (_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "pan-y");
5271
5919
  if (disableTextSelect) {
5272
5920
  (_d = (_c = targetRef.value) == null ? void 0 : _c.style) == null ? void 0 : _d.setProperty("-webkit-user-select", "none");
5273
5921
  (_f = (_e = targetRef.value) == null ? void 0 : _e.style) == null ? void 0 : _f.setProperty("-ms-user-select", "none");
@@ -5286,6 +5934,7 @@ function usePointerSwipe(target, options = {}) {
5286
5934
  };
5287
5935
  }
5288
5936
 
5937
+ // @__NO_SIDE_EFFECTS__
5289
5938
  function usePreferredColorScheme(options) {
5290
5939
  const isLight = useMediaQuery("(prefers-color-scheme: light)", options);
5291
5940
  const isDark = useMediaQuery("(prefers-color-scheme: dark)", options);
@@ -5298,6 +5947,7 @@ function usePreferredColorScheme(options) {
5298
5947
  });
5299
5948
  }
5300
5949
 
5950
+ // @__NO_SIDE_EFFECTS__
5301
5951
  function usePreferredContrast(options) {
5302
5952
  const isMore = useMediaQuery("(prefers-contrast: more)", options);
5303
5953
  const isLess = useMediaQuery("(prefers-contrast: less)", options);
@@ -5313,6 +5963,7 @@ function usePreferredContrast(options) {
5313
5963
  });
5314
5964
  }
5315
5965
 
5966
+ // @__NO_SIDE_EFFECTS__
5316
5967
  function usePreferredLanguages(options = {}) {
5317
5968
  const { window = defaultWindow } = options;
5318
5969
  if (!window)
@@ -5321,10 +5972,11 @@ function usePreferredLanguages(options = {}) {
5321
5972
  const value = ref(navigator.languages);
5322
5973
  useEventListener(window, "languagechange", () => {
5323
5974
  value.value = navigator.languages;
5324
- });
5975
+ }, { passive: true });
5325
5976
  return value;
5326
5977
  }
5327
5978
 
5979
+ // @__NO_SIDE_EFFECTS__
5328
5980
  function usePreferredReducedMotion(options) {
5329
5981
  const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
5330
5982
  return computed(() => {
@@ -5334,6 +5986,16 @@ function usePreferredReducedMotion(options) {
5334
5986
  });
5335
5987
  }
5336
5988
 
5989
+ // @__NO_SIDE_EFFECTS__
5990
+ function usePreferredReducedTransparency(options) {
5991
+ const isReduced = useMediaQuery("(prefers-reduced-transparency: reduce)", options);
5992
+ return computed(() => {
5993
+ if (isReduced.value)
5994
+ return "reduce";
5995
+ return "no-preference";
5996
+ });
5997
+ }
5998
+
5337
5999
  function usePrevious(value, initialValue) {
5338
6000
  const previous = shallowRef(initialValue);
5339
6001
  watch(
@@ -5351,10 +6013,10 @@ const rightVarName = "--vueuse-safe-area-right";
5351
6013
  const bottomVarName = "--vueuse-safe-area-bottom";
5352
6014
  const leftVarName = "--vueuse-safe-area-left";
5353
6015
  function useScreenSafeArea() {
5354
- const top = ref("");
5355
- const right = ref("");
5356
- const bottom = ref("");
5357
- const left = ref("");
6016
+ const top = shallowRef("");
6017
+ const right = shallowRef("");
6018
+ const bottom = shallowRef("");
6019
+ const left = shallowRef("");
5358
6020
  if (isClient) {
5359
6021
  const topCssVar = useCssVar(topVarName);
5360
6022
  const rightCssVar = useCssVar(rightVarName);
@@ -5364,8 +6026,8 @@ function useScreenSafeArea() {
5364
6026
  rightCssVar.value = "env(safe-area-inset-right, 0px)";
5365
6027
  bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
5366
6028
  leftCssVar.value = "env(safe-area-inset-left, 0px)";
5367
- update();
5368
- useEventListener("resize", useDebounceFn(update));
6029
+ tryOnMounted(update);
6030
+ useEventListener("resize", useDebounceFn(update), { passive: true });
5369
6031
  }
5370
6032
  function update() {
5371
6033
  top.value = getValue(topVarName);
@@ -5396,9 +6058,10 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
5396
6058
  noModule,
5397
6059
  defer,
5398
6060
  document = defaultDocument,
5399
- attrs = {}
6061
+ attrs = {},
6062
+ nonce = void 0
5400
6063
  } = options;
5401
- const scriptTag = ref(null);
6064
+ const scriptTag = shallowRef(null);
5402
6065
  let _promise = null;
5403
6066
  const loadScript = (waitForScriptLoad) => new Promise((resolve, reject) => {
5404
6067
  const resolveWithElement = (el2) => {
@@ -5425,18 +6088,24 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
5425
6088
  el.noModule = noModule;
5426
6089
  if (referrerPolicy)
5427
6090
  el.referrerPolicy = referrerPolicy;
6091
+ if (nonce) {
6092
+ el.nonce = nonce;
6093
+ }
5428
6094
  Object.entries(attrs).forEach(([name, value]) => el == null ? void 0 : el.setAttribute(name, value));
5429
6095
  shouldAppend = true;
5430
6096
  } else if (el.hasAttribute("data-loaded")) {
5431
6097
  resolveWithElement(el);
5432
6098
  }
5433
- el.addEventListener("error", (event) => reject(event));
5434
- el.addEventListener("abort", (event) => reject(event));
5435
- el.addEventListener("load", () => {
6099
+ const listenerOptions = {
6100
+ passive: true
6101
+ };
6102
+ useEventListener(el, "error", (event) => reject(event), listenerOptions);
6103
+ useEventListener(el, "abort", (event) => reject(event), listenerOptions);
6104
+ useEventListener(el, "load", () => {
5436
6105
  el.setAttribute("data-loaded", "true");
5437
6106
  onLoaded(el);
5438
6107
  resolveWithElement(el);
5439
- });
6108
+ }, listenerOptions);
5440
6109
  if (shouldAppend)
5441
6110
  el = document.head.appendChild(el);
5442
6111
  if (!waitForScriptLoad)
@@ -5488,7 +6157,7 @@ function preventDefault(rawEvent) {
5488
6157
  }
5489
6158
  const elInitialOverflow = /* @__PURE__ */ new WeakMap();
5490
6159
  function useScrollLock(element, initialState = false) {
5491
- const isLocked = ref(initialState);
6160
+ const isLocked = shallowRef(initialState);
5492
6161
  let stopTouchMoveListener = null;
5493
6162
  let initialOverflow = "";
5494
6163
  watch(toRef(element), (el) => {
@@ -5528,7 +6197,8 @@ function useScrollLock(element, initialState = false) {
5528
6197
  const el = resolveElement(toValue(element));
5529
6198
  if (!el || !isLocked.value)
5530
6199
  return;
5531
- isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
6200
+ if (isIOS)
6201
+ stopTouchMoveListener == null ? void 0 : stopTouchMoveListener();
5532
6202
  el.style.overflow = initialOverflow;
5533
6203
  elInitialOverflow.delete(el);
5534
6204
  isLocked.value = false;
@@ -5551,6 +6221,7 @@ function useSessionStorage(key, initialValue, options = {}) {
5551
6221
  return useStorage(key, initialValue, window == null ? void 0 : window.sessionStorage, options);
5552
6222
  }
5553
6223
 
6224
+ // @__NO_SIDE_EFFECTS__
5554
6225
  function useShare(shareOptions = {}, options = {}) {
5555
6226
  const { navigator = defaultNavigator } = options;
5556
6227
  const _navigator = navigator;
@@ -5612,31 +6283,38 @@ function useSpeechRecognition(options = {}) {
5612
6283
  const {
5613
6284
  interimResults = true,
5614
6285
  continuous = true,
6286
+ maxAlternatives = 1,
5615
6287
  window = defaultWindow
5616
6288
  } = options;
5617
6289
  const lang = toRef(options.lang || "en-US");
5618
- const isListening = ref(false);
5619
- const isFinal = ref(false);
5620
- const result = ref("");
6290
+ const isListening = shallowRef(false);
6291
+ const isFinal = shallowRef(false);
6292
+ const result = shallowRef("");
5621
6293
  const error = shallowRef(void 0);
5622
- const toggle = (value = !isListening.value) => {
5623
- isListening.value = value;
5624
- };
6294
+ let recognition;
5625
6295
  const start = () => {
5626
6296
  isListening.value = true;
5627
6297
  };
5628
6298
  const stop = () => {
5629
6299
  isListening.value = false;
5630
6300
  };
6301
+ const toggle = (value = !isListening.value) => {
6302
+ if (value) {
6303
+ start();
6304
+ } else {
6305
+ stop();
6306
+ }
6307
+ };
5631
6308
  const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
5632
6309
  const isSupported = useSupported(() => SpeechRecognition);
5633
- let recognition;
5634
6310
  if (isSupported.value) {
5635
6311
  recognition = new SpeechRecognition();
5636
6312
  recognition.continuous = continuous;
5637
6313
  recognition.interimResults = interimResults;
5638
6314
  recognition.lang = toValue(lang);
6315
+ recognition.maxAlternatives = maxAlternatives;
5639
6316
  recognition.onstart = () => {
6317
+ isListening.value = true;
5640
6318
  isFinal.value = false;
5641
6319
  };
5642
6320
  watch(lang, (lang2) => {
@@ -5657,15 +6335,17 @@ function useSpeechRecognition(options = {}) {
5657
6335
  isListening.value = false;
5658
6336
  recognition.lang = toValue(lang);
5659
6337
  };
5660
- watch(isListening, () => {
5661
- if (isListening.value)
6338
+ watch(isListening, (newValue, oldValue) => {
6339
+ if (newValue === oldValue)
6340
+ return;
6341
+ if (newValue)
5662
6342
  recognition.start();
5663
6343
  else
5664
6344
  recognition.stop();
5665
6345
  });
5666
6346
  }
5667
6347
  tryOnScopeDispose(() => {
5668
- isListening.value = false;
6348
+ stop();
5669
6349
  });
5670
6350
  return {
5671
6351
  isSupported,
@@ -5685,12 +6365,13 @@ function useSpeechSynthesis(text, options = {}) {
5685
6365
  pitch = 1,
5686
6366
  rate = 1,
5687
6367
  volume = 1,
5688
- window = defaultWindow
6368
+ window = defaultWindow,
6369
+ onBoundary
5689
6370
  } = options;
5690
6371
  const synth = window && window.speechSynthesis;
5691
6372
  const isSupported = useSupported(() => synth);
5692
- const isPlaying = ref(false);
5693
- const status = ref("init");
6373
+ const isPlaying = shallowRef(false);
6374
+ const status = shallowRef("init");
5694
6375
  const spokenText = toRef(text || "");
5695
6376
  const lang = toRef(options.lang || "en-US");
5696
6377
  const error = shallowRef(void 0);
@@ -5702,7 +6383,7 @@ function useSpeechSynthesis(text, options = {}) {
5702
6383
  utterance2.voice = toValue(options.voice) || null;
5703
6384
  utterance2.pitch = toValue(pitch);
5704
6385
  utterance2.rate = toValue(rate);
5705
- utterance2.volume = volume;
6386
+ utterance2.volume = toValue(volume);
5706
6387
  utterance2.onstart = () => {
5707
6388
  isPlaying.value = true;
5708
6389
  status.value = "play";
@@ -5722,6 +6403,9 @@ function useSpeechSynthesis(text, options = {}) {
5722
6403
  utterance2.onerror = (event) => {
5723
6404
  error.value = event;
5724
6405
  };
6406
+ utterance2.onboundary = (event) => {
6407
+ onBoundary == null ? void 0 : onBoundary(event);
6408
+ };
5725
6409
  };
5726
6410
  const utterance = computed(() => {
5727
6411
  isPlaying.value = false;
@@ -5732,7 +6416,8 @@ function useSpeechSynthesis(text, options = {}) {
5732
6416
  });
5733
6417
  const speak = () => {
5734
6418
  synth.cancel();
5735
- utterance && synth.speak(utterance.value);
6419
+ if (utterance)
6420
+ synth.speak(utterance.value);
5736
6421
  };
5737
6422
  const stop = () => {
5738
6423
  synth.cancel();
@@ -5771,6 +6456,7 @@ function useSpeechSynthesis(text, options = {}) {
5771
6456
  };
5772
6457
  }
5773
6458
 
6459
+ // @__NO_SIDE_EFFECTS__
5774
6460
  function useStepper(steps, initialStep) {
5775
6461
  const stepsRef = ref(steps);
5776
6462
  const stepNames = computed(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
@@ -5859,11 +6545,12 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
5859
6545
  eventFilter,
5860
6546
  onError = (e) => {
5861
6547
  console.error(e);
5862
- }
6548
+ },
6549
+ onReady
5863
6550
  } = options;
5864
6551
  const rawInit = toValue(initialValue);
5865
6552
  const type = guessSerializerType(rawInit);
5866
- const data = (shallow ? shallowRef : ref)(initialValue);
6553
+ const data = (shallow ? shallowRef : ref)(toValue(initialValue));
5867
6554
  const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
5868
6555
  if (!storage) {
5869
6556
  try {
@@ -5898,9 +6585,14 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
5898
6585
  onError(e);
5899
6586
  }
5900
6587
  }
5901
- read();
6588
+ const promise = new Promise((resolve) => {
6589
+ read().then(() => {
6590
+ onReady == null ? void 0 : onReady(data.value);
6591
+ resolve(data);
6592
+ });
6593
+ });
5902
6594
  if (window && listenToStorageChanges)
5903
- useEventListener(window, "storage", (e) => Promise.resolve().then(() => read(e)));
6595
+ useEventListener(window, "storage", (e) => Promise.resolve().then(() => read(e)), { passive: true });
5904
6596
  if (storage) {
5905
6597
  watchWithFilter(
5906
6598
  data,
@@ -5921,19 +6613,23 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
5921
6613
  }
5922
6614
  );
5923
6615
  }
6616
+ Object.assign(data, {
6617
+ then: promise.then.bind(promise),
6618
+ catch: promise.catch.bind(promise)
6619
+ });
5924
6620
  return data;
5925
6621
  }
5926
6622
 
5927
6623
  let _id = 0;
5928
6624
  function useStyleTag(css, options = {}) {
5929
- const isLoaded = ref(false);
6625
+ const isLoaded = shallowRef(false);
5930
6626
  const {
5931
6627
  document = defaultDocument,
5932
6628
  immediate = true,
5933
6629
  manual = false,
5934
6630
  id = `vueuse_styletag_${++_id}`
5935
6631
  } = options;
5936
- const cssRef = ref(css);
6632
+ const cssRef = shallowRef(css);
5937
6633
  let stop = () => {
5938
6634
  };
5939
6635
  const load = () => {
@@ -5942,6 +6638,8 @@ function useStyleTag(css, options = {}) {
5942
6638
  const el = document.getElementById(id) || document.createElement("style");
5943
6639
  if (!el.isConnected) {
5944
6640
  el.id = id;
6641
+ if (options.nonce)
6642
+ el.nonce = options.nonce;
5945
6643
  if (options.media)
5946
6644
  el.media = options.media;
5947
6645
  document.head.appendChild(el);
@@ -5983,8 +6681,7 @@ function useSwipe(target, options = {}) {
5983
6681
  onSwipe,
5984
6682
  onSwipeEnd,
5985
6683
  onSwipeStart,
5986
- passive = true,
5987
- window = defaultWindow
6684
+ passive = true
5988
6685
  } = options;
5989
6686
  const coordsStart = reactive({ x: 0, y: 0 });
5990
6687
  const coordsEnd = reactive({ x: 0, y: 0 });
@@ -5992,7 +6689,7 @@ function useSwipe(target, options = {}) {
5992
6689
  const diffY = computed(() => coordsStart.y - coordsEnd.y);
5993
6690
  const { max, abs } = Math;
5994
6691
  const isThresholdExceeded = computed(() => max(abs(diffX.value), abs(diffY.value)) >= threshold);
5995
- const isSwiping = ref(false);
6692
+ const isSwiping = shallowRef(false);
5996
6693
  const direction = computed(() => {
5997
6694
  if (!isThresholdExceeded.value)
5998
6695
  return "none";
@@ -6011,12 +6708,7 @@ function useSwipe(target, options = {}) {
6011
6708
  coordsEnd.x = x;
6012
6709
  coordsEnd.y = y;
6013
6710
  };
6014
- let listenerOptions;
6015
- const isPassiveEventSupported = checkPassiveEventSupport(window == null ? void 0 : window.document);
6016
- if (!passive)
6017
- listenerOptions = isPassiveEventSupported ? { passive: false, capture: true } : { capture: true };
6018
- else
6019
- listenerOptions = isPassiveEventSupported ? { passive: true } : { capture: false };
6711
+ const listenerOptions = { passive, capture: !passive };
6020
6712
  const onTouchEnd = (e) => {
6021
6713
  if (isSwiping.value)
6022
6714
  onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
@@ -6026,8 +6718,6 @@ function useSwipe(target, options = {}) {
6026
6718
  useEventListener(target, "touchstart", (e) => {
6027
6719
  if (e.touches.length !== 1)
6028
6720
  return;
6029
- if (listenerOptions.capture && !listenerOptions.passive)
6030
- e.preventDefault();
6031
6721
  const [x, y] = getTouchEventCoords(e);
6032
6722
  updateCoordsStart(x, y);
6033
6723
  updateCoordsEnd(x, y);
@@ -6038,6 +6728,8 @@ function useSwipe(target, options = {}) {
6038
6728
  return;
6039
6729
  const [x, y] = getTouchEventCoords(e);
6040
6730
  updateCoordsEnd(x, y);
6731
+ if (listenerOptions.capture && !listenerOptions.passive && Math.abs(diffX.value) > Math.abs(diffY.value))
6732
+ e.preventDefault();
6041
6733
  if (!isSwiping.value && isThresholdExceeded.value)
6042
6734
  isSwiping.value = true;
6043
6735
  if (isSwiping.value)
@@ -6047,31 +6739,19 @@ function useSwipe(target, options = {}) {
6047
6739
  ];
6048
6740
  const stop = () => stops.forEach((s) => s());
6049
6741
  return {
6050
- isPassiveEventSupported,
6051
6742
  isSwiping,
6052
6743
  direction,
6053
6744
  coordsStart,
6054
6745
  coordsEnd,
6055
6746
  lengthX: diffX,
6056
6747
  lengthY: diffY,
6057
- stop
6058
- };
6059
- }
6060
- function checkPassiveEventSupport(document) {
6061
- if (!document)
6062
- return false;
6063
- let supportsPassive = false;
6064
- const optionsBlock = {
6065
- get passive() {
6066
- supportsPassive = true;
6067
- return false;
6068
- }
6748
+ stop,
6749
+ // TODO: Remove in the next major version
6750
+ isPassiveEventSupported: true
6069
6751
  };
6070
- document.addEventListener("x", noop, optionsBlock);
6071
- document.removeEventListener("x", noop);
6072
- return supportsPassive;
6073
6752
  }
6074
6753
 
6754
+ // @__NO_SIDE_EFFECTS__
6075
6755
  function useTemplateRefsList() {
6076
6756
  const refs = ref([]);
6077
6757
  refs.value.set = (el) => {
@@ -6084,6 +6764,7 @@ function useTemplateRefsList() {
6084
6764
  return refs;
6085
6765
  }
6086
6766
 
6767
+ // @__NO_SIDE_EFFECTS__
6087
6768
  function useTextDirection(options = {}) {
6088
6769
  const {
6089
6770
  document = defaultDocument,
@@ -6126,6 +6807,7 @@ function getRangesFromSelection(selection) {
6126
6807
  const rangeCount = (_a = selection.rangeCount) != null ? _a : 0;
6127
6808
  return Array.from({ length: rangeCount }, (_, i) => selection.getRangeAt(i));
6128
6809
  }
6810
+ // @__NO_SIDE_EFFECTS__
6129
6811
  function useTextSelection(options = {}) {
6130
6812
  const {
6131
6813
  window = defaultWindow
@@ -6143,7 +6825,7 @@ function useTextSelection(options = {}) {
6143
6825
  selection.value = window.getSelection();
6144
6826
  }
6145
6827
  if (window)
6146
- useEventListener(window.document, "selectionchange", onSelectionChange);
6828
+ useEventListener(window.document, "selectionchange", onSelectionChange, { passive: true });
6147
6829
  return {
6148
6830
  text,
6149
6831
  rects,
@@ -6152,12 +6834,21 @@ function useTextSelection(options = {}) {
6152
6834
  };
6153
6835
  }
6154
6836
 
6155
- function useTextareaAutosize(options) {
6156
- var _a;
6157
- const textarea = ref(options == null ? void 0 : options.element);
6158
- const input = ref(options == null ? void 0 : options.input);
6159
- const styleProp = (_a = options == null ? void 0 : options.styleProp) != null ? _a : "height";
6160
- const textareaScrollHeight = ref(1);
6837
+ function tryRequestAnimationFrame(window = defaultWindow, fn) {
6838
+ if (window && typeof window.requestAnimationFrame === "function") {
6839
+ window.requestAnimationFrame(fn);
6840
+ } else {
6841
+ fn();
6842
+ }
6843
+ }
6844
+ function useTextareaAutosize(options = {}) {
6845
+ var _a, _b;
6846
+ const { window = defaultWindow } = options;
6847
+ const textarea = toRef(options == null ? void 0 : options.element);
6848
+ const input = toRef((_a = options == null ? void 0 : options.input) != null ? _a : "");
6849
+ const styleProp = (_b = options == null ? void 0 : options.styleProp) != null ? _b : "height";
6850
+ const textareaScrollHeight = shallowRef(1);
6851
+ const textareaOldWidth = shallowRef(0);
6161
6852
  function triggerResize() {
6162
6853
  var _a2;
6163
6854
  if (!textarea.value)
@@ -6165,8 +6856,9 @@ function useTextareaAutosize(options) {
6165
6856
  let height = "";
6166
6857
  textarea.value.style[styleProp] = "1px";
6167
6858
  textareaScrollHeight.value = (_a2 = textarea.value) == null ? void 0 : _a2.scrollHeight;
6168
- if (options == null ? void 0 : options.styleTarget)
6169
- toValue(options.styleTarget).style[styleProp] = `${textareaScrollHeight.value}px`;
6859
+ const _styleTarget = toValue(options == null ? void 0 : options.styleTarget);
6860
+ if (_styleTarget)
6861
+ _styleTarget.style[styleProp] = `${textareaScrollHeight.value}px`;
6170
6862
  else
6171
6863
  height = `${textareaScrollHeight.value}px`;
6172
6864
  textarea.value.style[styleProp] = height;
@@ -6176,7 +6868,14 @@ function useTextareaAutosize(options) {
6176
6868
  var _a2;
6177
6869
  return (_a2 = options == null ? void 0 : options.onResize) == null ? void 0 : _a2.call(options);
6178
6870
  });
6179
- useResizeObserver(textarea, () => triggerResize());
6871
+ useResizeObserver(textarea, ([{ contentRect }]) => {
6872
+ if (textareaOldWidth.value === contentRect.width)
6873
+ return;
6874
+ tryRequestAnimationFrame(window, () => {
6875
+ textareaOldWidth.value = contentRect.width;
6876
+ triggerResize();
6877
+ });
6878
+ });
6180
6879
  if (options == null ? void 0 : options.watch)
6181
6880
  watch(options.watch, triggerResize, { immediate: true, deep: true });
6182
6881
  return {
@@ -6220,6 +6919,7 @@ const DEFAULT_MESSAGES = {
6220
6919
  function DEFAULT_FORMATTER(date) {
6221
6920
  return date.toISOString().slice(0, 10);
6222
6921
  }
6922
+ // @__NO_SIDE_EFFECTS__
6223
6923
  function useTimeAgo(time, options = {}) {
6224
6924
  const {
6225
6925
  controls: exposeControls = false,
@@ -6283,9 +6983,82 @@ function formatTimeAgo(from, options = {}, now = Date.now()) {
6283
6983
  return messages.invalid;
6284
6984
  }
6285
6985
 
6286
- function useTimeoutPoll(fn, interval, timeoutPollOptions) {
6287
- const { start } = useTimeoutFn(loop, interval, { immediate: false });
6288
- const isActive = ref(false);
6986
+ const UNITS = [
6987
+ { name: "year", ms: 31536e6 },
6988
+ { name: "month", ms: 2592e6 },
6989
+ { name: "week", ms: 6048e5 },
6990
+ { name: "day", ms: 864e5 },
6991
+ { name: "hour", ms: 36e5 },
6992
+ { name: "minute", ms: 6e4 },
6993
+ { name: "second", ms: 1e3 }
6994
+ ];
6995
+ function useTimeAgoIntl(time, options = {}) {
6996
+ const {
6997
+ controls: exposeControls = false,
6998
+ updateInterval = 3e4
6999
+ } = options;
7000
+ const { now, ...controls } = useNow({ interval: updateInterval, controls: true });
7001
+ const result = computed(
7002
+ () => getTimeAgoIntlResult(new Date(toValue(time)), options, toValue(now))
7003
+ );
7004
+ const parts = computed(() => result.value.parts);
7005
+ const timeAgoIntl = computed(
7006
+ () => formatTimeAgoIntlParts(parts.value, {
7007
+ ...options,
7008
+ locale: result.value.resolvedLocale
7009
+ })
7010
+ );
7011
+ return exposeControls ? { timeAgoIntl, parts, ...controls } : timeAgoIntl;
7012
+ }
7013
+ function formatTimeAgoIntl(from, options = {}, now = Date.now()) {
7014
+ const { parts, resolvedLocale } = getTimeAgoIntlResult(from, options, now);
7015
+ return formatTimeAgoIntlParts(parts, {
7016
+ ...options,
7017
+ locale: resolvedLocale
7018
+ });
7019
+ }
7020
+ function getTimeAgoIntlResult(from, options = {}, now = Date.now()) {
7021
+ const {
7022
+ locale,
7023
+ relativeTimeFormatOptions = { numeric: "auto" }
7024
+ } = options;
7025
+ const rtf = new Intl.RelativeTimeFormat(locale, relativeTimeFormatOptions);
7026
+ const { locale: resolvedLocale } = rtf.resolvedOptions();
7027
+ const diff = +from - +now;
7028
+ const absDiff = Math.abs(diff);
7029
+ for (const { name, ms } of UNITS) {
7030
+ if (absDiff >= ms) {
7031
+ return {
7032
+ resolvedLocale,
7033
+ parts: rtf.formatToParts(Math.round(diff / ms), name)
7034
+ };
7035
+ }
7036
+ }
7037
+ return {
7038
+ resolvedLocale,
7039
+ parts: rtf.formatToParts(0, "second")
7040
+ };
7041
+ }
7042
+ function formatTimeAgoIntlParts(parts, options = {}) {
7043
+ const {
7044
+ insertSpace = true,
7045
+ joinParts,
7046
+ locale
7047
+ } = options;
7048
+ if (typeof joinParts === "function")
7049
+ return joinParts(parts, locale);
7050
+ if (!insertSpace)
7051
+ return parts.map((part) => part.value).join("");
7052
+ return parts.map((part) => part.value.trim()).join(" ");
7053
+ }
7054
+
7055
+ function useTimeoutPoll(fn, interval, options = {}) {
7056
+ const {
7057
+ immediate = true,
7058
+ immediateCallback = false
7059
+ } = options;
7060
+ const { start } = useTimeoutFn(loop, interval, { immediate });
7061
+ const isActive = shallowRef(false);
6289
7062
  async function loop() {
6290
7063
  if (!isActive.value)
6291
7064
  return;
@@ -6295,13 +7068,15 @@ function useTimeoutPoll(fn, interval, timeoutPollOptions) {
6295
7068
  function resume() {
6296
7069
  if (!isActive.value) {
6297
7070
  isActive.value = true;
6298
- loop();
7071
+ if (immediateCallback)
7072
+ fn();
7073
+ start();
6299
7074
  }
6300
7075
  }
6301
7076
  function pause() {
6302
7077
  isActive.value = false;
6303
7078
  }
6304
- if (timeoutPollOptions == null ? void 0 : timeoutPollOptions.immediate)
7079
+ if (immediate && isClient)
6305
7080
  resume();
6306
7081
  tryOnScopeDispose(pause);
6307
7082
  return {
@@ -6319,7 +7094,7 @@ function useTimestamp(options = {}) {
6319
7094
  interval = "requestAnimationFrame",
6320
7095
  callback
6321
7096
  } = options;
6322
- const ts = ref(timestamp() + offset);
7097
+ const ts = shallowRef(timestamp() + offset);
6323
7098
  const update = () => ts.value = timestamp() + offset;
6324
7099
  const cb = callback ? () => {
6325
7100
  update();
@@ -6344,7 +7119,7 @@ function useTitle(newTitle = null, options = {}) {
6344
7119
  } = options;
6345
7120
  const originalTitle = (_a = document == null ? void 0 : document.title) != null ? _a : "";
6346
7121
  const title = toRef((_b = newTitle != null ? newTitle : document == null ? void 0 : document.title) != null ? _b : null);
6347
- const isReadonly = newTitle && typeof newTitle === "function";
7122
+ const isReadonly = !!(newTitle && typeof newTitle === "function");
6348
7123
  function format(t) {
6349
7124
  if (!("titleTemplate" in options))
6350
7125
  return t;
@@ -6353,9 +7128,9 @@ function useTitle(newTitle = null, options = {}) {
6353
7128
  }
6354
7129
  watch(
6355
7130
  title,
6356
- (t, o) => {
6357
- if (t !== o && document)
6358
- document.title = format(typeof t === "string" ? t : "");
7131
+ (newValue, oldValue) => {
7132
+ if (newValue !== oldValue && document)
7133
+ document.title = format(newValue != null ? newValue : "");
6359
7134
  },
6360
7135
  { immediate: true }
6361
7136
  );
@@ -6369,7 +7144,7 @@ function useTitle(newTitle = null, options = {}) {
6369
7144
  { childList: true }
6370
7145
  );
6371
7146
  }
6372
- tryOnBeforeUnmount(() => {
7147
+ tryOnScopeDispose(() => {
6373
7148
  if (restoreOnUnmount) {
6374
7149
  const restoredTitle = restoreOnUnmount(originalTitle, title.value || "");
6375
7150
  if (restoredTitle != null && document)
@@ -6433,6 +7208,9 @@ function toVec(t) {
6433
7208
  }
6434
7209
  function executeTransition(source, from, to, options = {}) {
6435
7210
  var _a, _b;
7211
+ const {
7212
+ window = defaultWindow
7213
+ } = options;
6436
7214
  const fromVal = toValue(from);
6437
7215
  const toVal = toValue(to);
6438
7216
  const v1 = toVec(fromVal);
@@ -6461,7 +7239,7 @@ function executeTransition(source, from, to, options = {}) {
6461
7239
  else if (typeof source.value === "number")
6462
7240
  source.value = arr[0];
6463
7241
  if (now < endAt) {
6464
- requestAnimationFrame(tick);
7242
+ window == null ? void 0 : window.requestAnimationFrame(tick);
6465
7243
  } else {
6466
7244
  source.value = toVal;
6467
7245
  resolve();
@@ -6515,7 +7293,9 @@ function useUrlSearchParams(mode = "history", options = {}) {
6515
7293
  removeNullishValues = true,
6516
7294
  removeFalsyValues = false,
6517
7295
  write: enableWrite = true,
6518
- window = defaultWindow
7296
+ writeMode = "replace",
7297
+ window = defaultWindow,
7298
+ stringify = (params) => params.toString()
6519
7299
  } = options;
6520
7300
  if (!window)
6521
7301
  return reactive(initialValue);
@@ -6532,7 +7312,7 @@ function useUrlSearchParams(mode = "history", options = {}) {
6532
7312
  }
6533
7313
  }
6534
7314
  function constructQuery(params) {
6535
- const stringified = params.toString();
7315
+ const stringified = stringify(params);
6536
7316
  if (mode === "history")
6537
7317
  return `${stringified ? `?${stringified}` : ""}${window.location.hash || ""}`;
6538
7318
  if (mode === "hash-params")
@@ -6540,8 +7320,8 @@ function useUrlSearchParams(mode = "history", options = {}) {
6540
7320
  const hash = window.location.hash || "#";
6541
7321
  const index = hash.indexOf("?");
6542
7322
  if (index > 0)
6543
- return `${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
6544
- return `${hash}${stringified ? `?${stringified}` : ""}`;
7323
+ return `${window.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
7324
+ return `${window.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
6545
7325
  }
6546
7326
  function read() {
6547
7327
  return new URLSearchParams(getRawParams());
@@ -6570,7 +7350,7 @@ function useUrlSearchParams(mode = "history", options = {}) {
6570
7350
  else
6571
7351
  params.set(key, mapEntry);
6572
7352
  });
6573
- write(params);
7353
+ write(params, false);
6574
7354
  },
6575
7355
  { deep: true }
6576
7356
  );
@@ -6578,11 +7358,19 @@ function useUrlSearchParams(mode = "history", options = {}) {
6578
7358
  pause();
6579
7359
  if (shouldUpdate)
6580
7360
  updateState(params);
6581
- window.history.replaceState(
6582
- window.history.state,
6583
- window.document.title,
6584
- window.location.pathname + constructQuery(params)
6585
- );
7361
+ if (writeMode === "replace") {
7362
+ window.history.replaceState(
7363
+ window.history.state,
7364
+ window.document.title,
7365
+ window.location.pathname + constructQuery(params)
7366
+ );
7367
+ } else {
7368
+ window.history.pushState(
7369
+ window.history.state,
7370
+ window.document.title,
7371
+ window.location.pathname + constructQuery(params)
7372
+ );
7373
+ }
6586
7374
  resume();
6587
7375
  }
6588
7376
  function onChanged() {
@@ -6590,9 +7378,10 @@ function useUrlSearchParams(mode = "history", options = {}) {
6590
7378
  return;
6591
7379
  write(read(), true);
6592
7380
  }
6593
- useEventListener(window, "popstate", onChanged, false);
7381
+ const listenerOptions = { passive: true };
7382
+ useEventListener(window, "popstate", onChanged, listenerOptions);
6594
7383
  if (mode !== "history")
6595
- useEventListener(window, "hashchange", onChanged, false);
7384
+ useEventListener(window, "hashchange", onChanged, listenerOptions);
6596
7385
  const initial = read();
6597
7386
  if (initial.keys().next().value)
6598
7387
  updateState(initial);
@@ -6603,8 +7392,8 @@ function useUrlSearchParams(mode = "history", options = {}) {
6603
7392
 
6604
7393
  function useUserMedia(options = {}) {
6605
7394
  var _a, _b;
6606
- const enabled = ref((_a = options.enabled) != null ? _a : false);
6607
- const autoSwitch = ref((_b = options.autoSwitch) != null ? _b : true);
7395
+ const enabled = shallowRef((_a = options.enabled) != null ? _a : false);
7396
+ const autoSwitch = shallowRef((_b = options.autoSwitch) != null ? _b : true);
6608
7397
  const constraints = ref(options.constraints);
6609
7398
  const { navigator = defaultNavigator } = options;
6610
7399
  const isSupported = useSupported(() => {
@@ -6686,8 +7475,9 @@ function useUserMedia(options = {}) {
6686
7475
  };
6687
7476
  }
6688
7477
 
7478
+ // @__NO_SIDE_EFFECTS__
6689
7479
  function useVModel(props, key, emit, options = {}) {
6690
- var _a, _b, _c, _d, _e;
7480
+ var _a, _b, _c;
6691
7481
  const {
6692
7482
  clone = false,
6693
7483
  passive = false,
@@ -6700,14 +7490,7 @@ function useVModel(props, key, emit, options = {}) {
6700
7490
  const _emit = emit || (vm == null ? void 0 : vm.emit) || ((_a = vm == null ? void 0 : vm.$emit) == null ? void 0 : _a.bind(vm)) || ((_c = (_b = vm == null ? void 0 : vm.proxy) == null ? void 0 : _b.$emit) == null ? void 0 : _c.bind(vm == null ? void 0 : vm.proxy));
6701
7491
  let event = eventName;
6702
7492
  if (!key) {
6703
- if (isVue2) {
6704
- const modelOptions = (_e = (_d = vm == null ? void 0 : vm.proxy) == null ? void 0 : _d.$options) == null ? void 0 : _e.model;
6705
- key = (modelOptions == null ? void 0 : modelOptions.value) || "value";
6706
- if (!eventName)
6707
- event = (modelOptions == null ? void 0 : modelOptions.event) || "input";
6708
- } else {
6709
- key = "modelValue";
6710
- }
7493
+ key = "modelValue";
6711
7494
  }
6712
7495
  event = event || `update:${key.toString()}`;
6713
7496
  const cloneFn = (val) => !clone ? val : typeof clone === "function" ? clone(val) : cloneFnJSON(val);
@@ -6755,6 +7538,7 @@ function useVModel(props, key, emit, options = {}) {
6755
7538
  }
6756
7539
  }
6757
7540
 
7541
+ // @__NO_SIDE_EFFECTS__
6758
7542
  function useVModels(props, emit, options = {}) {
6759
7543
  const ret = {};
6760
7544
  for (const key in props) {
@@ -6768,6 +7552,7 @@ function useVModels(props, emit, options = {}) {
6768
7552
  return ret;
6769
7553
  }
6770
7554
 
7555
+ // @__NO_SIDE_EFFECTS__
6771
7556
  function useVibrate(options) {
6772
7557
  const {
6773
7558
  pattern = [],
@@ -6821,7 +7606,7 @@ function useVirtualList(list, options) {
6821
7606
  };
6822
7607
  }
6823
7608
  function useVirtualListResources(list) {
6824
- const containerRef = ref(null);
7609
+ const containerRef = shallowRef(null);
6825
7610
  const size = useElementSize(containerRef);
6826
7611
  const currentList = ref([]);
6827
7612
  const source = shallowRef(list);
@@ -6892,7 +7677,7 @@ function createGetDistance(itemSize, source) {
6892
7677
  };
6893
7678
  }
6894
7679
  function useWatchForSizes(size, list, containerRef, calculateRange) {
6895
- watch([size.width, size.height, list, containerRef], () => {
7680
+ watch([size.width, size.height, () => toValue(list), containerRef], () => {
6896
7681
  calculateRange();
6897
7682
  });
6898
7683
  }
@@ -6979,40 +7764,53 @@ function useVerticalVirtualList(options, list) {
6979
7764
  };
6980
7765
  }
6981
7766
 
7767
+ // @__NO_SIDE_EFFECTS__
6982
7768
  function useWakeLock(options = {}) {
6983
7769
  const {
6984
7770
  navigator = defaultNavigator,
6985
7771
  document = defaultDocument
6986
7772
  } = options;
6987
- let wakeLock;
7773
+ const requestedType = shallowRef(false);
7774
+ const sentinel = shallowRef(null);
7775
+ const documentVisibility = useDocumentVisibility({ document });
6988
7776
  const isSupported = useSupported(() => navigator && "wakeLock" in navigator);
6989
- const isActive = ref(false);
6990
- async function onVisibilityChange() {
6991
- if (!isSupported.value || !wakeLock)
6992
- return;
6993
- if (document && document.visibilityState === "visible")
6994
- wakeLock = await navigator.wakeLock.request("screen");
6995
- isActive.value = !wakeLock.released;
7777
+ const isActive = computed(() => !!sentinel.value && documentVisibility.value === "visible");
7778
+ if (isSupported.value) {
7779
+ useEventListener(sentinel, "release", () => {
7780
+ var _a, _b;
7781
+ requestedType.value = (_b = (_a = sentinel.value) == null ? void 0 : _a.type) != null ? _b : false;
7782
+ }, { passive: true });
7783
+ whenever(
7784
+ () => documentVisibility.value === "visible" && (document == null ? void 0 : document.visibilityState) === "visible" && requestedType.value,
7785
+ (type) => {
7786
+ requestedType.value = false;
7787
+ forceRequest(type);
7788
+ }
7789
+ );
7790
+ }
7791
+ async function forceRequest(type) {
7792
+ var _a;
7793
+ await ((_a = sentinel.value) == null ? void 0 : _a.release());
7794
+ sentinel.value = isSupported.value ? await navigator.wakeLock.request(type) : null;
6996
7795
  }
6997
- if (document)
6998
- useEventListener(document, "visibilitychange", onVisibilityChange, { passive: true });
6999
7796
  async function request(type) {
7000
- if (!isSupported.value)
7001
- return;
7002
- wakeLock = await navigator.wakeLock.request(type);
7003
- isActive.value = !wakeLock.released;
7797
+ if (documentVisibility.value === "visible")
7798
+ await forceRequest(type);
7799
+ else
7800
+ requestedType.value = type;
7004
7801
  }
7005
7802
  async function release() {
7006
- if (!isSupported.value || !wakeLock)
7007
- return;
7008
- await wakeLock.release();
7009
- isActive.value = !wakeLock.released;
7010
- wakeLock = null;
7803
+ requestedType.value = false;
7804
+ const s = sentinel.value;
7805
+ sentinel.value = null;
7806
+ await (s == null ? void 0 : s.release());
7011
7807
  }
7012
7808
  return {
7809
+ sentinel,
7013
7810
  isSupported,
7014
7811
  isActive,
7015
7812
  request,
7813
+ forceRequest,
7016
7814
  release
7017
7815
  };
7018
7816
  }
@@ -7026,14 +7824,20 @@ function useWebNotification(options = {}) {
7026
7824
  const isSupported = useSupported(() => {
7027
7825
  if (!window || !("Notification" in window))
7028
7826
  return false;
7827
+ if (Notification.permission === "granted")
7828
+ return true;
7029
7829
  try {
7030
- new Notification("");
7830
+ const notification2 = new Notification("");
7831
+ notification2.onshow = () => {
7832
+ notification2.close();
7833
+ };
7031
7834
  } catch (e) {
7032
- return false;
7835
+ if (e.name === "TypeError")
7836
+ return false;
7033
7837
  }
7034
7838
  return true;
7035
7839
  });
7036
- const permissionGranted = ref(isSupported.value && "permission" in Notification && Notification.permission === "granted");
7840
+ const permissionGranted = shallowRef(isSupported.value && "permission" in Notification && Notification.permission === "granted");
7037
7841
  const notification = ref(null);
7038
7842
  const ensurePermissions = async () => {
7039
7843
  if (!isSupported.value)
@@ -7104,11 +7908,12 @@ function useWebSocket(url, options = {}) {
7104
7908
  onError,
7105
7909
  onMessage,
7106
7910
  immediate = true,
7911
+ autoConnect = true,
7107
7912
  autoClose = true,
7108
7913
  protocols = []
7109
7914
  } = options;
7110
7915
  const data = ref(null);
7111
- const status = ref("CLOSED");
7916
+ const status = shallowRef("CLOSED");
7112
7917
  const wsRef = ref();
7113
7918
  const urlRef = toRef(url);
7114
7919
  let heartbeatPause;
@@ -7116,6 +7921,7 @@ function useWebSocket(url, options = {}) {
7116
7921
  let explicitlyClosed = false;
7117
7922
  let retried = 0;
7118
7923
  let bufferedData = [];
7924
+ let retryTimeout;
7119
7925
  let pongTimeoutWait;
7120
7926
  const _sendBuffer = () => {
7121
7927
  if (bufferedData.length && wsRef.value && status.value === "OPEN") {
@@ -7124,12 +7930,19 @@ function useWebSocket(url, options = {}) {
7124
7930
  bufferedData = [];
7125
7931
  }
7126
7932
  };
7933
+ const resetRetry = () => {
7934
+ if (retryTimeout != null) {
7935
+ clearTimeout(retryTimeout);
7936
+ retryTimeout = void 0;
7937
+ }
7938
+ };
7127
7939
  const resetHeartbeat = () => {
7128
7940
  clearTimeout(pongTimeoutWait);
7129
7941
  pongTimeoutWait = void 0;
7130
7942
  };
7131
7943
  const close = (code = 1e3, reason) => {
7132
- if (!isClient || !wsRef.value)
7944
+ resetRetry();
7945
+ if (!isClient && !isWorker || !wsRef.value)
7133
7946
  return;
7134
7947
  explicitlyClosed = true;
7135
7948
  resetHeartbeat();
@@ -7155,26 +7968,29 @@ function useWebSocket(url, options = {}) {
7155
7968
  status.value = "CONNECTING";
7156
7969
  ws.onopen = () => {
7157
7970
  status.value = "OPEN";
7971
+ retried = 0;
7158
7972
  onConnected == null ? void 0 : onConnected(ws);
7159
7973
  heartbeatResume == null ? void 0 : heartbeatResume();
7160
7974
  _sendBuffer();
7161
7975
  };
7162
7976
  ws.onclose = (ev) => {
7163
7977
  status.value = "CLOSED";
7978
+ resetHeartbeat();
7979
+ heartbeatPause == null ? void 0 : heartbeatPause();
7164
7980
  onDisconnected == null ? void 0 : onDisconnected(ws, ev);
7165
- if (!explicitlyClosed && options.autoReconnect) {
7981
+ if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) {
7166
7982
  const {
7167
7983
  retries = -1,
7168
7984
  delay = 1e3,
7169
7985
  onFailed
7170
7986
  } = resolveNestedOptions(options.autoReconnect);
7171
- retried += 1;
7172
- if (typeof retries === "number" && (retries < 0 || retried < retries))
7173
- setTimeout(_init, delay);
7174
- else if (typeof retries === "function" && retries())
7175
- setTimeout(_init, delay);
7176
- else
7987
+ const checkRetires = typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries);
7988
+ if (checkRetires(retried)) {
7989
+ retried += 1;
7990
+ retryTimeout = setTimeout(_init, delay);
7991
+ } else {
7177
7992
  onFailed == null ? void 0 : onFailed();
7993
+ }
7178
7994
  }
7179
7995
  };
7180
7996
  ws.onerror = (e) => {
@@ -7184,9 +8000,10 @@ function useWebSocket(url, options = {}) {
7184
8000
  if (options.heartbeat) {
7185
8001
  resetHeartbeat();
7186
8002
  const {
7187
- message = DEFAULT_PING_MESSAGE
8003
+ message = DEFAULT_PING_MESSAGE,
8004
+ responseMessage = message
7188
8005
  } = resolveNestedOptions(options.heartbeat);
7189
- if (e.data === message)
8006
+ if (e.data === toValue(responseMessage))
7190
8007
  return;
7191
8008
  }
7192
8009
  data.value = e.data;
@@ -7201,7 +8018,7 @@ function useWebSocket(url, options = {}) {
7201
8018
  } = resolveNestedOptions(options.heartbeat);
7202
8019
  const { pause, resume } = useIntervalFn(
7203
8020
  () => {
7204
- send(message, false);
8021
+ send(toValue(message), false);
7205
8022
  if (pongTimeoutWait != null)
7206
8023
  return;
7207
8024
  pongTimeoutWait = setTimeout(() => {
@@ -7217,7 +8034,7 @@ function useWebSocket(url, options = {}) {
7217
8034
  }
7218
8035
  if (autoClose) {
7219
8036
  if (isClient)
7220
- useEventListener("beforeunload", () => close());
8037
+ useEventListener("beforeunload", () => close(), { passive: true });
7221
8038
  tryOnScopeDispose(close);
7222
8039
  }
7223
8040
  const open = () => {
@@ -7230,7 +8047,8 @@ function useWebSocket(url, options = {}) {
7230
8047
  };
7231
8048
  if (immediate)
7232
8049
  open();
7233
- watch(urlRef, open);
8050
+ if (autoConnect)
8051
+ watch(urlRef, open);
7234
8052
  return {
7235
8053
  data,
7236
8054
  status,
@@ -7280,17 +8098,6 @@ function useWebWorker(arg0, workerOptions, options) {
7280
8098
  };
7281
8099
  }
7282
8100
 
7283
- function jobRunner(userFunc) {
7284
- return (e) => {
7285
- const userFuncArgs = e.data[0];
7286
- return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => {
7287
- postMessage(["SUCCESS", result]);
7288
- }).catch((error) => {
7289
- postMessage(["ERROR", error]);
7290
- });
7291
- };
7292
- }
7293
-
7294
8101
  function depsParser(deps, localDeps) {
7295
8102
  if (deps.length === 0 && localDeps.length === 0)
7296
8103
  return "";
@@ -7308,6 +8115,17 @@ function depsParser(deps, localDeps) {
7308
8115
  return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`;
7309
8116
  }
7310
8117
 
8118
+ function jobRunner(userFunc) {
8119
+ return (e) => {
8120
+ const userFuncArgs = e.data[0];
8121
+ return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => {
8122
+ postMessage(["SUCCESS", result]);
8123
+ }).catch((error) => {
8124
+ postMessage(["ERROR", error]);
8125
+ });
8126
+ };
8127
+ }
8128
+
7311
8129
  function createWorkerBlobUrl(fn, deps, localDeps) {
7312
8130
  const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`;
7313
8131
  const blob = new Blob([blobCode], { type: "text/javascript" });
@@ -7323,9 +8141,9 @@ function useWebWorkerFn(fn, options = {}) {
7323
8141
  window = defaultWindow
7324
8142
  } = options;
7325
8143
  const worker = ref();
7326
- const workerStatus = ref("PENDING");
8144
+ const workerStatus = shallowRef("PENDING");
7327
8145
  const promise = ref({});
7328
- const timeoutId = ref();
8146
+ const timeoutId = shallowRef();
7329
8147
  const workerTerminate = (status = "PENDING") => {
7330
8148
  if (worker.value && worker.value._url && window) {
7331
8149
  worker.value.terminate();
@@ -7374,11 +8192,12 @@ function useWebWorkerFn(fn, options = {}) {
7374
8192
  return newWorker;
7375
8193
  };
7376
8194
  const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
8195
+ var _a;
7377
8196
  promise.value = {
7378
8197
  resolve,
7379
8198
  reject
7380
8199
  };
7381
- worker.value && worker.value.postMessage([[...fnArgs]]);
8200
+ (_a = worker.value) == null ? void 0 : _a.postMessage([[...fnArgs]]);
7382
8201
  workerStatus.value = "RUNNING";
7383
8202
  });
7384
8203
  const workerFn = (...fnArgs) => {
@@ -7398,74 +8217,49 @@ function useWebWorkerFn(fn, options = {}) {
7398
8217
  };
7399
8218
  }
7400
8219
 
8220
+ // @__NO_SIDE_EFFECTS__
7401
8221
  function useWindowFocus(options = {}) {
7402
8222
  const { window = defaultWindow } = options;
7403
8223
  if (!window)
7404
- return ref(false);
7405
- const focused = ref(window.document.hasFocus());
8224
+ return shallowRef(false);
8225
+ const focused = shallowRef(window.document.hasFocus());
8226
+ const listenerOptions = { passive: true };
7406
8227
  useEventListener(window, "blur", () => {
7407
8228
  focused.value = false;
7408
- });
8229
+ }, listenerOptions);
7409
8230
  useEventListener(window, "focus", () => {
7410
8231
  focused.value = true;
7411
- });
8232
+ }, listenerOptions);
7412
8233
  return focused;
7413
8234
  }
7414
8235
 
7415
8236
  function useWindowScroll(options = {}) {
7416
- const { window = defaultWindow, behavior = "auto" } = options;
7417
- if (!window) {
7418
- return {
7419
- x: ref(0),
7420
- y: ref(0)
7421
- };
7422
- }
7423
- const internalX = ref(window.scrollX);
7424
- const internalY = ref(window.scrollY);
7425
- const x = computed({
7426
- get() {
7427
- return internalX.value;
7428
- },
7429
- set(x2) {
7430
- scrollTo({ left: x2, behavior });
7431
- }
7432
- });
7433
- const y = computed({
7434
- get() {
7435
- return internalY.value;
7436
- },
7437
- set(y2) {
7438
- scrollTo({ top: y2, behavior });
7439
- }
7440
- });
7441
- useEventListener(
7442
- window,
7443
- "scroll",
7444
- () => {
7445
- internalX.value = window.scrollX;
7446
- internalY.value = window.scrollY;
7447
- },
7448
- {
7449
- capture: false,
7450
- passive: true
7451
- }
7452
- );
7453
- return { x, y };
8237
+ const { window = defaultWindow, ...rest } = options;
8238
+ return useScroll(window, rest);
7454
8239
  }
7455
8240
 
8241
+ // @__NO_SIDE_EFFECTS__
7456
8242
  function useWindowSize(options = {}) {
7457
8243
  const {
7458
8244
  window = defaultWindow,
7459
8245
  initialWidth = Number.POSITIVE_INFINITY,
7460
8246
  initialHeight = Number.POSITIVE_INFINITY,
7461
8247
  listenOrientation = true,
7462
- includeScrollbar = true
8248
+ includeScrollbar = true,
8249
+ type = "inner"
7463
8250
  } = options;
7464
- const width = ref(initialWidth);
7465
- const height = ref(initialHeight);
8251
+ const width = shallowRef(initialWidth);
8252
+ const height = shallowRef(initialHeight);
7466
8253
  const update = () => {
7467
8254
  if (window) {
7468
- if (includeScrollbar) {
8255
+ if (type === "outer") {
8256
+ width.value = window.outerWidth;
8257
+ height.value = window.outerHeight;
8258
+ } else if (type === "visual" && window.visualViewport) {
8259
+ const { width: visualViewportWidth, height: visualViewportHeight, scale } = window.visualViewport;
8260
+ width.value = Math.round(visualViewportWidth * scale);
8261
+ height.value = Math.round(visualViewportHeight * scale);
8262
+ } else if (includeScrollbar) {
7469
8263
  width.value = window.innerWidth;
7470
8264
  height.value = window.innerHeight;
7471
8265
  } else {
@@ -7476,7 +8270,11 @@ function useWindowSize(options = {}) {
7476
8270
  };
7477
8271
  update();
7478
8272
  tryOnMounted(update);
7479
- useEventListener("resize", update, { passive: true });
8273
+ const listenerOptions = { passive: true };
8274
+ useEventListener("resize", update, listenerOptions);
8275
+ if (window && type === "visual" && window.visualViewport) {
8276
+ useEventListener(window.visualViewport, "resize", update, listenerOptions);
8277
+ }
7480
8278
  if (listenOrientation) {
7481
8279
  const matches = useMediaQuery("(orientation: portrait)");
7482
8280
  watch(matches, () => update());
@@ -7484,4 +8282,4 @@ function useWindowSize(options = {}) {
7484
8282
  return { width, height };
7485
8283
  }
7486
8284
 
7487
- export { DefaultMagicKeysAliasMap, StorageSerializers, TransitionPresets, computedAsync as asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsPrimeFlex, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, breakpointsVuetifyV2, breakpointsVuetifyV3, bypassFilter, camelize, clamp, cloneFnJSON, computedAsync, computedInject, computedWithControl, containsProp, computedWithControl as controlledComputed, createEventHook, createFetch, createFilterWrapper, createReusableTemplate, createSingletonPromise, createTemplatePromise, createUnrefFn, customStorageEventName, debounceFilter, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, getSSRHandler, hasOwn, identity, watchIgnorable as ignorableWatch, increaseWithUnit, isClient, isDef, isIOS, isObject, isWorker, makeDestructurable, mapGamepadToXbox360Controller, noop, notNullish, objectEntries, objectOmit, objectPick, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, pausableFilter, watchPausable as pausableWatch, promiseTimeout, setSSRHandler, syncRef, templateRef, throttleFilter, timestamp, toRef, toRefs, toValue, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, unrefElement, until, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useClipboardItems, useCloned, useColorMode, useConfirmDialog, useCssVar, useCurrentElement, useCycleList, useDark, useDebounceFn, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useIntervalFn, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottleFn, useThrottledRefHistory, useTimeAgo, useTimeoutFn, useTimeoutPoll, useTimestamp, useTitle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, watchIgnorable, watchPausable, watchWithFilter };
8285
+ export { DefaultMagicKeysAliasMap, StorageSerializers, TransitionPresets, computedAsync as asyncComputed, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsElement, breakpointsMasterCss, breakpointsPrimeFlex, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, breakpointsVuetifyV2, breakpointsVuetifyV3, bypassFilter, camelize, clamp, cloneFnJSON, computedAsync, computedInject, computedWithControl, containsProp, computedWithControl as controlledComputed, createEventHook, createFetch, createFilterWrapper, createRef, createReusableTemplate, createSingletonPromise, createTemplatePromise, createUnrefFn, customStorageEventName, debounceFilter, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, executeTransition, formatTimeAgo, formatTimeAgoIntl, formatTimeAgoIntlParts, getSSRHandler, hasOwn, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, isClient, isDef, isIOS, isObject, isWorker, makeDestructurable, mapGamepadToXbox360Controller, noop, notNullish, objectEntries, objectOmit, objectPick, onClickOutside, onElementRemoval, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, provideSSRWidth, pxValue, setSSRHandler, syncRef, templateRef, throttleFilter, timestamp, toArray, toRef, toRefs, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, unrefElement, until, useActiveElement, useAnimate, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useClipboardItems, useCloned, useColorMode, useConfirmDialog, useCountdown, useCssVar, useCurrentElement, useCycleList, useDark, useDebounceFn, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useIntervalFn, useKeyModifier, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePreferredReducedTransparency, usePrevious, useRafFn, useRefHistory, useResizeObserver, useSSRWidth, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, useThrottleFn, useThrottledRefHistory, useTimeAgo, useTimeAgoIntl, useTimeoutFn, useTimeoutPoll, useTimestamp, useTitle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchWithFilter, whenever };