@vueuse/shared 14.0.0-alpha.2 → 14.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2086 +1,2092 @@
1
1
  (function(exports, vue) {
2
2
 
3
3
  //#region rolldown:runtime
4
- var __create = Object.create;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
24
 
25
25
  //#endregion
26
26
  vue = __toESM(vue);
27
27
 
28
28
  //#region computedEager/index.ts
29
29
  /**
30
- * Note: If you are using Vue 3.4+, you can straight use computed instead.
31
- * Because in Vue 3.4+, if computed new value does not change,
32
- * computed, effect, watch, watchEffect, render dependencies will not be triggered.
33
- * refer: https://github.com/vuejs/core/pull/5912
34
- *
35
- * @param fn effect function
36
- * @param options WatchOptionsBase
37
- * @returns readonly shallowRef
38
- */
39
- function computedEager(fn, options) {
40
- var _options$flush;
41
- const result = (0, vue.shallowRef)();
42
- (0, vue.watchEffect)(() => {
43
- result.value = fn();
44
- }, {
45
- ...options,
46
- flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync"
47
- });
48
- return (0, vue.readonly)(result);
49
- }
50
- /** @deprecated use `computedEager` instead */
51
- const eagerComputed = computedEager;
30
+ *
31
+ * @deprecated This function will be removed in future version.
32
+ *
33
+ * Note: If you are using Vue 3.4+, you can straight use computed instead.
34
+ * Because in Vue 3.4+, if computed new value does not change,
35
+ * computed, effect, watch, watchEffect, render dependencies will not be triggered.
36
+ * refer: https://github.com/vuejs/core/pull/5912
37
+ *
38
+ * @param fn effect function
39
+ * @param options WatchOptionsBase
40
+ * @returns readonly shallowRef
41
+ */
42
+ function computedEager(fn, options) {
43
+ var _options$flush;
44
+ const result = (0, vue.shallowRef)();
45
+ (0, vue.watchEffect)(() => {
46
+ result.value = fn();
47
+ }, {
48
+ ...options,
49
+ flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync"
50
+ });
51
+ return (0, vue.readonly)(result);
52
+ }
53
+ /** @deprecated use `computedEager` instead */
54
+ const eagerComputed = computedEager;
52
55
 
53
56
  //#endregion
54
57
  //#region computedWithControl/index.ts
55
58
  /**
56
- * Explicitly define the deps of computed.
57
- *
58
- * @param source
59
- * @param fn
60
- */
61
- function computedWithControl(source, fn, options = {}) {
62
- let v = void 0;
63
- let track;
64
- let trigger;
65
- let dirty = true;
66
- const update = () => {
67
- dirty = true;
68
- trigger();
69
- };
70
- (0, vue.watch)(source, update, {
71
- flush: "sync",
72
- ...options
73
- });
74
- const get$1 = typeof fn === "function" ? fn : fn.get;
75
- const set$1 = typeof fn === "function" ? void 0 : fn.set;
76
- const result = (0, vue.customRef)((_track, _trigger) => {
77
- track = _track;
78
- trigger = _trigger;
79
- return {
80
- get() {
81
- if (dirty) {
82
- v = get$1(v);
83
- dirty = false;
84
- }
85
- track();
86
- return v;
87
- },
88
- set(v$1) {
89
- set$1 === null || set$1 === void 0 || set$1(v$1);
90
- }
59
+ * Explicitly define the deps of computed.
60
+ *
61
+ * @param source
62
+ * @param fn
63
+ */
64
+ function computedWithControl(source, fn, options = {}) {
65
+ let v = void 0;
66
+ let track;
67
+ let trigger;
68
+ let dirty = true;
69
+ const update = () => {
70
+ dirty = true;
71
+ trigger();
91
72
  };
92
- });
93
- result.trigger = update;
94
- return result;
95
- }
96
- /** @deprecated use `computedWithControl` instead */
97
- const controlledComputed = computedWithControl;
73
+ (0, vue.watch)(source, update, {
74
+ flush: "sync",
75
+ ...options
76
+ });
77
+ const get$1 = typeof fn === "function" ? fn : fn.get;
78
+ const set$1 = typeof fn === "function" ? void 0 : fn.set;
79
+ const result = (0, vue.customRef)((_track, _trigger) => {
80
+ track = _track;
81
+ trigger = _trigger;
82
+ return {
83
+ get() {
84
+ if (dirty) {
85
+ v = get$1(v);
86
+ dirty = false;
87
+ }
88
+ track();
89
+ return v;
90
+ },
91
+ set(v$1) {
92
+ set$1 === null || set$1 === void 0 || set$1(v$1);
93
+ }
94
+ };
95
+ });
96
+ result.trigger = update;
97
+ return result;
98
+ }
99
+ /** @deprecated use `computedWithControl` instead */
100
+ const controlledComputed = computedWithControl;
98
101
 
99
102
  //#endregion
100
103
  //#region tryOnScopeDispose/index.ts
101
104
  /**
102
- * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
103
- *
104
- * @param fn
105
- */
106
- function tryOnScopeDispose(fn) {
107
- if ((0, vue.getCurrentScope)()) {
108
- (0, vue.onScopeDispose)(fn);
109
- return true;
105
+ * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
106
+ *
107
+ * @param fn
108
+ */
109
+ function tryOnScopeDispose(fn) {
110
+ if ((0, vue.getCurrentScope)()) {
111
+ (0, vue.onScopeDispose)(fn);
112
+ return true;
113
+ }
114
+ return false;
110
115
  }
111
- return false;
112
- }
113
116
 
114
117
  //#endregion
115
118
  //#region createEventHook/index.ts
116
119
  /**
117
- * Utility for creating event hooks
118
- *
119
- * @see https://vueuse.org/createEventHook
120
- *
121
- * @__NO_SIDE_EFFECTS__
122
- */
123
- function createEventHook() {
124
- const fns = /* @__PURE__ */ new Set();
125
- const off = (fn) => {
126
- fns.delete(fn);
127
- };
128
- const clear = () => {
129
- fns.clear();
130
- };
131
- const on = (fn) => {
132
- fns.add(fn);
133
- const offFn = () => off(fn);
134
- tryOnScopeDispose(offFn);
135
- return { off: offFn };
136
- };
137
- const trigger = (...args) => {
138
- return Promise.all(Array.from(fns).map((fn) => fn(...args)));
139
- };
140
- return {
141
- on,
142
- off,
143
- trigger,
144
- clear
145
- };
146
- }
120
+ * Utility for creating event hooks
121
+ *
122
+ * @see https://vueuse.org/createEventHook
123
+ *
124
+ * @__NO_SIDE_EFFECTS__
125
+ */
126
+ function createEventHook() {
127
+ const fns = /* @__PURE__ */ new Set();
128
+ const off = (fn) => {
129
+ fns.delete(fn);
130
+ };
131
+ const clear = () => {
132
+ fns.clear();
133
+ };
134
+ const on = (fn) => {
135
+ fns.add(fn);
136
+ const offFn = () => off(fn);
137
+ tryOnScopeDispose(offFn);
138
+ return { off: offFn };
139
+ };
140
+ const trigger = (...args) => {
141
+ return Promise.all(Array.from(fns).map((fn) => fn(...args)));
142
+ };
143
+ return {
144
+ on,
145
+ off,
146
+ trigger,
147
+ clear
148
+ };
149
+ }
147
150
 
148
151
  //#endregion
149
152
  //#region createGlobalState/index.ts
150
153
  /**
151
- * Keep states in the global scope to be reusable across Vue instances.
152
- *
153
- * @see https://vueuse.org/createGlobalState
154
- * @param stateFactory A factory function to create the state
155
- *
156
- * @__NO_SIDE_EFFECTS__
157
- */
158
- function createGlobalState(stateFactory) {
159
- let initialized = false;
160
- let state;
161
- const scope = (0, vue.effectScope)(true);
162
- return ((...args) => {
163
- if (!initialized) {
164
- state = scope.run(() => stateFactory(...args));
165
- initialized = true;
166
- }
167
- return state;
168
- });
169
- }
154
+ * Keep states in the global scope to be reusable across Vue instances.
155
+ *
156
+ * @see https://vueuse.org/createGlobalState
157
+ * @param stateFactory A factory function to create the state
158
+ *
159
+ * @__NO_SIDE_EFFECTS__
160
+ */
161
+ function createGlobalState(stateFactory) {
162
+ let initialized = false;
163
+ let state;
164
+ const scope = (0, vue.effectScope)(true);
165
+ return ((...args) => {
166
+ if (!initialized) {
167
+ state = scope.run(() => stateFactory(...args));
168
+ initialized = true;
169
+ }
170
+ return state;
171
+ });
172
+ }
170
173
 
171
174
  //#endregion
172
175
  //#region provideLocal/map.ts
173
- const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
176
+ const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
174
177
 
175
178
  //#endregion
176
179
  //#region injectLocal/index.ts
177
180
  /**
178
- * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
179
- *
180
- * @example
181
- * ```ts
182
- * injectLocal('MyInjectionKey', 1)
183
- * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
184
- * ```
185
- *
186
- * @__NO_SIDE_EFFECTS__
187
- */
188
- const injectLocal = (...args) => {
189
- var _getCurrentInstance;
190
- const key = args[0];
191
- const instance = (_getCurrentInstance = (0, vue.getCurrentInstance)()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
192
- if (instance == null && !(0, vue.hasInjectionContext)()) throw new Error("injectLocal must be called in setup");
193
- if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance)) return localProvidedStateMap.get(instance)[key];
194
- return (0, vue.inject)(...args);
195
- };
181
+ * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * injectLocal('MyInjectionKey', 1)
186
+ * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
187
+ * ```
188
+ *
189
+ * @__NO_SIDE_EFFECTS__
190
+ */
191
+ const injectLocal = (...args) => {
192
+ var _getCurrentInstance;
193
+ const key = args[0];
194
+ const instance = (_getCurrentInstance = (0, vue.getCurrentInstance)()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
195
+ if (instance == null && !(0, vue.hasInjectionContext)()) throw new Error("injectLocal must be called in setup");
196
+ if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance)) return localProvidedStateMap.get(instance)[key];
197
+ return (0, vue.inject)(...args);
198
+ };
196
199
 
197
200
  //#endregion
198
201
  //#region provideLocal/index.ts
199
202
  /**
200
- * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.
201
- *
202
- * @example
203
- * ```ts
204
- * provideLocal('MyInjectionKey', 1)
205
- * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
206
- * ```
207
- */
208
- function provideLocal(key, value) {
209
- var _getCurrentInstance;
210
- const instance = (_getCurrentInstance = (0, vue.getCurrentInstance)()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
211
- if (instance == null) throw new Error("provideLocal must be called in setup");
212
- if (!localProvidedStateMap.has(instance)) localProvidedStateMap.set(instance, Object.create(null));
213
- const localProvidedState = localProvidedStateMap.get(instance);
214
- localProvidedState[key] = value;
215
- return (0, vue.provide)(key, value);
216
- }
203
+ * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * provideLocal('MyInjectionKey', 1)
208
+ * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
209
+ * ```
210
+ */
211
+ function provideLocal(key, value) {
212
+ var _getCurrentInstance;
213
+ const instance = (_getCurrentInstance = (0, vue.getCurrentInstance)()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
214
+ if (instance == null) throw new Error("provideLocal must be called in setup");
215
+ if (!localProvidedStateMap.has(instance)) localProvidedStateMap.set(instance, Object.create(null));
216
+ const localProvidedState = localProvidedStateMap.get(instance);
217
+ localProvidedState[key] = value;
218
+ return (0, vue.provide)(key, value);
219
+ }
217
220
 
218
221
  //#endregion
219
222
  //#region createInjectionState/index.ts
220
223
  /**
221
- * Create global state that can be injected into components.
222
- *
223
- * @see https://vueuse.org/createInjectionState
224
- *
225
- * @__NO_SIDE_EFFECTS__
226
- */
227
- function createInjectionState(composable, options) {
228
- const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
229
- const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue;
230
- const useProvidingState = (...args) => {
231
- const state = composable(...args);
232
- provideLocal(key, state);
233
- return state;
234
- };
235
- const useInjectedState = () => injectLocal(key, defaultValue);
236
- return [useProvidingState, useInjectedState];
237
- }
224
+ * Create global state that can be injected into components.
225
+ *
226
+ * @see https://vueuse.org/createInjectionState
227
+ *
228
+ * @__NO_SIDE_EFFECTS__
229
+ */
230
+ function createInjectionState(composable, options) {
231
+ const key = (options === null || options === void 0 ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
232
+ const defaultValue = options === null || options === void 0 ? void 0 : options.defaultValue;
233
+ const useProvidingState = (...args) => {
234
+ const state = composable(...args);
235
+ provideLocal(key, state);
236
+ return state;
237
+ };
238
+ const useInjectedState = () => injectLocal(key, defaultValue);
239
+ return [useProvidingState, useInjectedState];
240
+ }
238
241
 
239
242
  //#endregion
240
243
  //#region createRef/index.ts
241
244
  /**
242
- * Returns a `deepRef` or `shallowRef` depending on the `deep` param.
243
- *
244
- * @example createRef(1) // ShallowRef<number>
245
- * @example createRef(1, false) // ShallowRef<number>
246
- * @example createRef(1, true) // Ref<number>
247
- * @example createRef("string") // ShallowRef<string>
248
- * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B">
249
- *
250
- * @param value
251
- * @param deep
252
- * @returns the `deepRef` or `shallowRef`
253
- *
254
- * @__NO_SIDE_EFFECTS__
255
- */
256
- function createRef(value, deep) {
257
- if (deep === true) return (0, vue.ref)(value);
258
- else return (0, vue.shallowRef)(value);
259
- }
245
+ * Returns a `deepRef` or `shallowRef` depending on the `deep` param.
246
+ *
247
+ * @example createRef(1) // ShallowRef<number>
248
+ * @example createRef(1, false) // ShallowRef<number>
249
+ * @example createRef(1, true) // Ref<number>
250
+ * @example createRef("string") // ShallowRef<string>
251
+ * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B">
252
+ *
253
+ * @param value
254
+ * @param deep
255
+ * @returns the `deepRef` or `shallowRef`
256
+ *
257
+ * @__NO_SIDE_EFFECTS__
258
+ */
259
+ function createRef(value, deep) {
260
+ if (deep === true) return (0, vue.ref)(value);
261
+ else return (0, vue.shallowRef)(value);
262
+ }
260
263
 
261
264
  //#endregion
262
- //#region createSharedComposable/index.ts
265
+ //#region utils/is.ts
266
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
267
+ const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
268
+ const isDef = (val) => typeof val !== "undefined";
269
+ const notNullish = (val) => val != null;
270
+ const assert = (condition, ...infos) => {
271
+ if (!condition) console.warn(...infos);
272
+ };
273
+ const toString = Object.prototype.toString;
274
+ const isObject = (val) => toString.call(val) === "[object Object]";
275
+ const now = () => Date.now();
276
+ const timestamp = () => +Date.now();
277
+ const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
278
+ const noop = () => {};
279
+ const rand = (min, max) => {
280
+ min = Math.ceil(min);
281
+ max = Math.floor(max);
282
+ return Math.floor(Math.random() * (max - min + 1)) + min;
283
+ };
284
+ const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
285
+ const isIOS = /* @__PURE__ */ getIsIOS();
286
+ function getIsIOS() {
287
+ var _window, _window2, _window3;
288
+ return isClient && ((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent));
289
+ }
290
+
291
+ //#endregion
292
+ //#region toRef/index.ts
293
+ function toRef(...args) {
294
+ if (args.length !== 1) return (0, vue.toRef)(...args);
295
+ const r = args[0];
296
+ return typeof r === "function" ? (0, vue.readonly)((0, vue.customRef)(() => ({
297
+ get: r,
298
+ set: noop
299
+ }))) : (0, vue.ref)(r);
300
+ }
301
+
302
+ //#endregion
303
+ //#region utils/filters.ts
263
304
  /**
264
- * Make a composable function usable with multiple Vue instances.
265
- *
266
- * @see https://vueuse.org/createSharedComposable
267
- *
268
- * @__NO_SIDE_EFFECTS__
269
- */
270
- function createSharedComposable(composable) {
271
- let subscribers = 0;
272
- let state;
273
- let scope;
274
- const dispose = () => {
275
- subscribers -= 1;
276
- if (scope && subscribers <= 0) {
277
- scope.stop();
278
- state = void 0;
279
- scope = void 0;
305
+ * @internal
306
+ */
307
+ function createFilterWrapper(filter, fn) {
308
+ function wrapper(...args) {
309
+ return new Promise((resolve, reject) => {
310
+ Promise.resolve(filter(() => fn.apply(this, args), {
311
+ fn,
312
+ thisArg: this,
313
+ args
314
+ })).then(resolve).catch(reject);
315
+ });
280
316
  }
317
+ return wrapper;
318
+ }
319
+ const bypassFilter = (invoke$1) => {
320
+ return invoke$1();
281
321
  };
282
- return ((...args) => {
283
- subscribers += 1;
284
- if (!scope) {
285
- scope = (0, vue.effectScope)(true);
286
- state = scope.run(() => composable(...args));
322
+ /**
323
+ * Create an EventFilter that debounce the events
324
+ */
325
+ function debounceFilter(ms, options = {}) {
326
+ let timer;
327
+ let maxTimer;
328
+ let lastRejector = noop;
329
+ const _clearTimeout = (timer$1) => {
330
+ clearTimeout(timer$1);
331
+ lastRejector();
332
+ lastRejector = noop;
333
+ };
334
+ let lastInvoker;
335
+ const filter = (invoke$1) => {
336
+ const duration = (0, vue.toValue)(ms);
337
+ const maxDuration = (0, vue.toValue)(options.maxWait);
338
+ if (timer) _clearTimeout(timer);
339
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
340
+ if (maxTimer) {
341
+ _clearTimeout(maxTimer);
342
+ maxTimer = void 0;
343
+ }
344
+ return Promise.resolve(invoke$1());
345
+ }
346
+ return new Promise((resolve, reject) => {
347
+ lastRejector = options.rejectOnCancel ? reject : resolve;
348
+ lastInvoker = invoke$1;
349
+ if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
350
+ if (timer) _clearTimeout(timer);
351
+ maxTimer = void 0;
352
+ resolve(lastInvoker());
353
+ }, maxDuration);
354
+ timer = setTimeout(() => {
355
+ if (maxTimer) _clearTimeout(maxTimer);
356
+ maxTimer = void 0;
357
+ resolve(invoke$1());
358
+ }, duration);
359
+ });
360
+ };
361
+ return filter;
362
+ }
363
+ function throttleFilter(...args) {
364
+ let lastExec = 0;
365
+ let timer;
366
+ let isLeading = true;
367
+ let lastRejector = noop;
368
+ let lastValue;
369
+ let ms;
370
+ let trailing;
371
+ let leading;
372
+ let rejectOnCancel;
373
+ if (!(0, vue.isRef)(args[0]) && typeof args[0] === "object") ({delay: ms, trailing = true, leading = true, rejectOnCancel = false} = args[0]);
374
+ else [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
375
+ const clear = () => {
376
+ if (timer) {
377
+ clearTimeout(timer);
378
+ timer = void 0;
379
+ lastRejector();
380
+ lastRejector = noop;
381
+ }
382
+ };
383
+ const filter = (_invoke) => {
384
+ const duration = (0, vue.toValue)(ms);
385
+ const elapsed = Date.now() - lastExec;
386
+ const invoke$1 = () => {
387
+ return lastValue = _invoke();
388
+ };
389
+ clear();
390
+ if (duration <= 0) {
391
+ lastExec = Date.now();
392
+ return invoke$1();
393
+ }
394
+ if (elapsed > duration) {
395
+ lastExec = Date.now();
396
+ if (leading || !isLeading) invoke$1();
397
+ } else if (trailing) lastValue = new Promise((resolve, reject) => {
398
+ lastRejector = rejectOnCancel ? reject : resolve;
399
+ timer = setTimeout(() => {
400
+ lastExec = Date.now();
401
+ isLeading = true;
402
+ resolve(invoke$1());
403
+ clear();
404
+ }, Math.max(0, duration - elapsed));
405
+ });
406
+ if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration);
407
+ isLeading = false;
408
+ return lastValue;
409
+ };
410
+ return filter;
411
+ }
412
+ /**
413
+ * EventFilter that gives extra controls to pause and resume the filter
414
+ *
415
+ * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
416
+ * @param options Options to configure the filter
417
+ */
418
+ function pausableFilter(extendFilter = bypassFilter, options = {}) {
419
+ const { initialState = "active" } = options;
420
+ const isActive = toRef(initialState === "active");
421
+ function pause() {
422
+ isActive.value = false;
287
423
  }
288
- tryOnScopeDispose(dispose);
289
- return state;
290
- });
291
- }
424
+ function resume() {
425
+ isActive.value = true;
426
+ }
427
+ const eventFilter = (...args) => {
428
+ if (isActive.value) extendFilter(...args);
429
+ };
430
+ return {
431
+ isActive: (0, vue.readonly)(isActive),
432
+ pause,
433
+ resume,
434
+ eventFilter
435
+ };
436
+ }
292
437
 
293
438
  //#endregion
294
- //#region extendRef/index.ts
295
- function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
296
- for (const [key, value] of Object.entries(extend)) {
297
- if (key === "value") continue;
298
- if ((0, vue.isRef)(value) && unwrap) Object.defineProperty(ref, key, {
299
- get() {
300
- return value.value;
301
- },
302
- set(v) {
303
- value.value = v;
304
- },
305
- enumerable
439
+ //#region utils/general.ts
440
+ function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
441
+ return new Promise((resolve, reject) => {
442
+ if (throwOnTimeout) setTimeout(() => reject(reason), ms);
443
+ else setTimeout(resolve, ms);
306
444
  });
307
- else Object.defineProperty(ref, key, {
308
- value,
309
- enumerable
445
+ }
446
+ function identity(arg) {
447
+ return arg;
448
+ }
449
+ /**
450
+ * Create singleton promise function
451
+ *
452
+ * @example
453
+ * ```
454
+ * const promise = createSingletonPromise(async () => { ... })
455
+ *
456
+ * await promise()
457
+ * await promise() // all of them will be bind to a single promise instance
458
+ * await promise() // and be resolved together
459
+ * ```
460
+ */
461
+ function createSingletonPromise(fn) {
462
+ let _promise;
463
+ function wrapper() {
464
+ if (!_promise) _promise = fn();
465
+ return _promise;
466
+ }
467
+ wrapper.reset = async () => {
468
+ const _prev = _promise;
469
+ _promise = void 0;
470
+ if (_prev) await _prev;
471
+ };
472
+ return wrapper;
473
+ }
474
+ function invoke(fn) {
475
+ return fn();
476
+ }
477
+ function containsProp(obj, ...props) {
478
+ return props.some((k) => k in obj);
479
+ }
480
+ function increaseWithUnit(target, delta) {
481
+ var _target$match;
482
+ if (typeof target === "number") return target + delta;
483
+ const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || "";
484
+ const unit = target.slice(value.length);
485
+ const result = Number.parseFloat(value) + delta;
486
+ if (Number.isNaN(result)) return target;
487
+ return result + unit;
488
+ }
489
+ /**
490
+ * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client
491
+ */
492
+ function pxValue(px) {
493
+ return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
494
+ }
495
+ /**
496
+ * Create a new subset object by giving keys
497
+ */
498
+ function objectPick(obj, keys, omitUndefined = false) {
499
+ return keys.reduce((n, k) => {
500
+ if (k in obj) {
501
+ if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k];
502
+ }
503
+ return n;
504
+ }, {});
505
+ }
506
+ /**
507
+ * Create a new subset object by omit giving keys
508
+ */
509
+ function objectOmit(obj, keys, omitUndefined = false) {
510
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
511
+ return (!omitUndefined || value !== void 0) && !keys.includes(key);
512
+ }));
513
+ }
514
+ function objectEntries(obj) {
515
+ return Object.entries(obj);
516
+ }
517
+ function toArray(value) {
518
+ return Array.isArray(value) ? value : [value];
519
+ }
520
+
521
+ //#endregion
522
+ //#region utils/port.ts
523
+ function cacheStringFunction(fn) {
524
+ const cache = Object.create(null);
525
+ return ((str) => {
526
+ return cache[str] || (cache[str] = fn(str));
310
527
  });
311
528
  }
312
- return ref;
313
- }
529
+ const hyphenateRE = /\B([A-Z])/g;
530
+ const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
531
+ const camelizeRE = /-(\w)/g;
532
+ const camelize = cacheStringFunction((str) => {
533
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
534
+ });
535
+
536
+ //#endregion
537
+ //#region utils/vue.ts
538
+ function getLifeCycleTarget(target) {
539
+ return target || (0, vue.getCurrentInstance)();
540
+ }
541
+
542
+ //#endregion
543
+ //#region createSharedComposable/index.ts
544
+ /**
545
+ * Make a composable function usable with multiple Vue instances.
546
+ *
547
+ * @see https://vueuse.org/createSharedComposable
548
+ *
549
+ * @__NO_SIDE_EFFECTS__
550
+ */
551
+ function createSharedComposable(composable) {
552
+ if (!isClient) return composable;
553
+ let subscribers = 0;
554
+ let state;
555
+ let scope;
556
+ const dispose = () => {
557
+ subscribers -= 1;
558
+ if (scope && subscribers <= 0) {
559
+ scope.stop();
560
+ state = void 0;
561
+ scope = void 0;
562
+ }
563
+ };
564
+ return ((...args) => {
565
+ subscribers += 1;
566
+ if (!scope) {
567
+ scope = (0, vue.effectScope)(true);
568
+ state = scope.run(() => composable(...args));
569
+ }
570
+ tryOnScopeDispose(dispose);
571
+ return state;
572
+ });
573
+ }
574
+
575
+ //#endregion
576
+ //#region extendRef/index.ts
577
+ function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
578
+ for (const [key, value] of Object.entries(extend)) {
579
+ if (key === "value") continue;
580
+ if ((0, vue.isRef)(value) && unwrap) Object.defineProperty(ref, key, {
581
+ get() {
582
+ return value.value;
583
+ },
584
+ set(v) {
585
+ value.value = v;
586
+ },
587
+ enumerable
588
+ });
589
+ else Object.defineProperty(ref, key, {
590
+ value,
591
+ enumerable
592
+ });
593
+ }
594
+ return ref;
595
+ }
314
596
 
315
597
  //#endregion
316
598
  //#region get/index.ts
317
- function get(obj, key) {
318
- if (key == null) return (0, vue.unref)(obj);
319
- return (0, vue.unref)(obj)[key];
320
- }
599
+ function get(obj, key) {
600
+ if (key == null) return (0, vue.unref)(obj);
601
+ return (0, vue.unref)(obj)[key];
602
+ }
321
603
 
322
604
  //#endregion
323
605
  //#region isDefined/index.ts
324
- function isDefined(v) {
325
- return (0, vue.unref)(v) != null;
326
- }
606
+ function isDefined(v) {
607
+ return (0, vue.unref)(v) != null;
608
+ }
327
609
 
328
610
  //#endregion
329
611
  //#region makeDestructurable/index.ts
330
- /* @__NO_SIDE_EFFECTS__ */
331
- function makeDestructurable(obj, arr) {
332
- if (typeof Symbol !== "undefined") {
333
- const clone = { ...obj };
334
- Object.defineProperty(clone, Symbol.iterator, {
335
- enumerable: false,
336
- value() {
337
- let index = 0;
338
- return { next: () => ({
339
- value: arr[index++],
340
- done: index > arr.length
341
- }) };
342
- }
343
- });
344
- return clone;
345
- } else return Object.assign([...arr], obj);
346
- }
612
+ /* @__NO_SIDE_EFFECTS__ */
613
+ function makeDestructurable(obj, arr) {
614
+ if (typeof Symbol !== "undefined") {
615
+ const clone = { ...obj };
616
+ Object.defineProperty(clone, Symbol.iterator, {
617
+ enumerable: false,
618
+ value() {
619
+ let index = 0;
620
+ return { next: () => ({
621
+ value: arr[index++],
622
+ done: index > arr.length
623
+ }) };
624
+ }
625
+ });
626
+ return clone;
627
+ } else return Object.assign([...arr], obj);
628
+ }
347
629
 
348
630
  //#endregion
349
631
  //#region reactify/index.ts
350
632
  /**
351
- * Converts plain function into a reactive function.
352
- * The converted function accepts refs as it's arguments
353
- * and returns a ComputedRef, with proper typing.
354
- *
355
- * @param fn - Source function
356
- * @param options - Options
357
- *
358
- * @__NO_SIDE_EFFECTS__
359
- */
360
- function reactify(fn, options) {
361
- const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? vue.unref : vue.toValue;
362
- return function(...args) {
363
- return (0, vue.computed)(() => fn.apply(this, args.map((i) => unrefFn(i))));
364
- };
365
- }
366
- /** @deprecated use `reactify` instead */
367
- const createReactiveFn = reactify;
633
+ * Converts plain function into a reactive function.
634
+ * The converted function accepts refs as it's arguments
635
+ * and returns a ComputedRef, with proper typing.
636
+ *
637
+ * @param fn - Source function
638
+ * @param options - Options
639
+ *
640
+ * @__NO_SIDE_EFFECTS__
641
+ */
642
+ function reactify(fn, options) {
643
+ const unrefFn = (options === null || options === void 0 ? void 0 : options.computedGetter) === false ? vue.unref : vue.toValue;
644
+ return function(...args) {
645
+ return (0, vue.computed)(() => fn.apply(this, args.map((i) => unrefFn(i))));
646
+ };
647
+ }
648
+ /** @deprecated use `reactify` instead */
649
+ const createReactiveFn = reactify;
368
650
 
369
651
  //#endregion
370
652
  //#region reactifyObject/index.ts
371
653
  /**
372
- * Apply `reactify` to an object
373
- *
374
- * @__NO_SIDE_EFFECTS__
375
- */
376
- function reactifyObject(obj, optionsOrKeys = {}) {
377
- let keys = [];
378
- let options;
379
- if (Array.isArray(optionsOrKeys)) keys = optionsOrKeys;
380
- else {
381
- options = optionsOrKeys;
382
- const { includeOwnProperties = true } = optionsOrKeys;
383
- keys.push(...Object.keys(obj));
384
- if (includeOwnProperties) keys.push(...Object.getOwnPropertyNames(obj));
385
- }
386
- return Object.fromEntries(keys.map((key) => {
387
- const value = obj[key];
388
- return [key, typeof value === "function" ? reactify(value.bind(obj), options) : value];
389
- }));
390
- }
654
+ * Apply `reactify` to an object
655
+ *
656
+ * @__NO_SIDE_EFFECTS__
657
+ */
658
+ function reactifyObject(obj, optionsOrKeys = {}) {
659
+ let keys = [];
660
+ let options;
661
+ if (Array.isArray(optionsOrKeys)) keys = optionsOrKeys;
662
+ else {
663
+ options = optionsOrKeys;
664
+ const { includeOwnProperties = true } = optionsOrKeys;
665
+ keys.push(...Object.keys(obj));
666
+ if (includeOwnProperties) keys.push(...Object.getOwnPropertyNames(obj));
667
+ }
668
+ return Object.fromEntries(keys.map((key) => {
669
+ const value = obj[key];
670
+ return [key, typeof value === "function" ? reactify(value.bind(obj), options) : value];
671
+ }));
672
+ }
391
673
 
392
674
  //#endregion
393
675
  //#region toReactive/index.ts
394
676
  /**
395
- * Converts ref to reactive.
396
- *
397
- * @see https://vueuse.org/toReactive
398
- * @param objectRef A ref of object
399
- */
400
- function toReactive(objectRef) {
401
- if (!(0, vue.isRef)(objectRef)) return (0, vue.reactive)(objectRef);
402
- const proxy = new Proxy({}, {
403
- get(_, p, receiver) {
404
- return (0, vue.unref)(Reflect.get(objectRef.value, p, receiver));
405
- },
406
- set(_, p, value) {
407
- if ((0, vue.isRef)(objectRef.value[p]) && !(0, vue.isRef)(value)) objectRef.value[p].value = value;
408
- else objectRef.value[p] = value;
409
- return true;
410
- },
411
- deleteProperty(_, p) {
412
- return Reflect.deleteProperty(objectRef.value, p);
413
- },
414
- has(_, p) {
415
- return Reflect.has(objectRef.value, p);
416
- },
417
- ownKeys() {
418
- return Object.keys(objectRef.value);
419
- },
420
- getOwnPropertyDescriptor() {
421
- return {
422
- enumerable: true,
423
- configurable: true
424
- };
425
- }
426
- });
427
- return (0, vue.reactive)(proxy);
428
- }
677
+ * Converts ref to reactive.
678
+ *
679
+ * @see https://vueuse.org/toReactive
680
+ * @param objectRef A ref of object
681
+ */
682
+ function toReactive(objectRef) {
683
+ if (!(0, vue.isRef)(objectRef)) return (0, vue.reactive)(objectRef);
684
+ const proxy = new Proxy({}, {
685
+ get(_, p, receiver) {
686
+ return (0, vue.unref)(Reflect.get(objectRef.value, p, receiver));
687
+ },
688
+ set(_, p, value) {
689
+ if ((0, vue.isRef)(objectRef.value[p]) && !(0, vue.isRef)(value)) objectRef.value[p].value = value;
690
+ else objectRef.value[p] = value;
691
+ return true;
692
+ },
693
+ deleteProperty(_, p) {
694
+ return Reflect.deleteProperty(objectRef.value, p);
695
+ },
696
+ has(_, p) {
697
+ return Reflect.has(objectRef.value, p);
698
+ },
699
+ ownKeys() {
700
+ return Object.keys(objectRef.value);
701
+ },
702
+ getOwnPropertyDescriptor() {
703
+ return {
704
+ enumerable: true,
705
+ configurable: true
706
+ };
707
+ }
708
+ });
709
+ return (0, vue.reactive)(proxy);
710
+ }
429
711
 
430
712
  //#endregion
431
713
  //#region reactiveComputed/index.ts
432
714
  /**
433
- * Computed reactive object.
434
- */
435
- function reactiveComputed(fn) {
436
- return toReactive((0, vue.computed)(fn));
437
- }
715
+ * Computed reactive object.
716
+ */
717
+ function reactiveComputed(fn) {
718
+ return toReactive((0, vue.computed)(fn));
719
+ }
438
720
 
439
721
  //#endregion
440
722
  //#region reactiveOmit/index.ts
441
723
  /**
442
- * Reactively omit fields from a reactive object
443
- *
444
- * @see https://vueuse.org/reactiveOmit
445
- */
446
- function reactiveOmit(obj, ...keys) {
447
- const flatKeys = keys.flat();
448
- const predicate = flatKeys[0];
449
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter(([k, v]) => !predicate((0, vue.toValue)(v), k))) : Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter((e) => !flatKeys.includes(e[0]))));
450
- }
451
-
452
- //#endregion
453
- //#region utils/is.ts
454
- const isClient = typeof window !== "undefined" && typeof document !== "undefined";
455
- const isWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
456
- const isDef = (val) => typeof val !== "undefined";
457
- const notNullish = (val) => val != null;
458
- const assert = (condition, ...infos) => {
459
- if (!condition) console.warn(...infos);
460
- };
461
- const toString = Object.prototype.toString;
462
- const isObject = (val) => toString.call(val) === "[object Object]";
463
- const now = () => Date.now();
464
- const timestamp = () => +Date.now();
465
- const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
466
- const noop = () => {};
467
- const rand = (min, max) => {
468
- min = Math.ceil(min);
469
- max = Math.floor(max);
470
- return Math.floor(Math.random() * (max - min + 1)) + min;
471
- };
472
- const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
473
- const isIOS = /* @__PURE__ */ getIsIOS();
474
- function getIsIOS() {
475
- var _window, _window2, _window3;
476
- return isClient && ((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent));
477
- }
478
-
479
- //#endregion
480
- //#region toRef/index.ts
481
- function toRef(...args) {
482
- if (args.length !== 1) return (0, vue.toRef)(...args);
483
- const r = args[0];
484
- return typeof r === "function" ? (0, vue.readonly)((0, vue.customRef)(() => ({
485
- get: r,
486
- set: noop
487
- }))) : (0, vue.ref)(r);
488
- }
724
+ * Reactively omit fields from a reactive object
725
+ *
726
+ * @see https://vueuse.org/reactiveOmit
727
+ */
728
+ function reactiveOmit(obj, ...keys) {
729
+ const flatKeys = keys.flat();
730
+ const predicate = flatKeys[0];
731
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter(([k, v]) => !predicate((0, vue.toValue)(v), k))) : Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter((e) => !flatKeys.includes(e[0]))));
732
+ }
489
733
 
490
734
  //#endregion
491
735
  //#region reactivePick/index.ts
492
736
  /**
493
- * Reactively pick fields from a reactive object
494
- *
495
- * @see https://vueuse.org/reactivePick
496
- */
497
- function reactivePick(obj, ...keys) {
498
- const flatKeys = keys.flat();
499
- const predicate = flatKeys[0];
500
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter(([k, v]) => predicate((0, vue.toValue)(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
501
- }
737
+ * Reactively pick fields from a reactive object
738
+ *
739
+ * @see https://vueuse.org/reactivePick
740
+ */
741
+ function reactivePick(obj, ...keys) {
742
+ const flatKeys = keys.flat();
743
+ const predicate = flatKeys[0];
744
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries((0, vue.toRefs)(obj)).filter(([k, v]) => predicate((0, vue.toValue)(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
745
+ }
502
746
 
503
747
  //#endregion
504
748
  //#region refAutoReset/index.ts
505
749
  /**
506
- * Create a ref which will be reset to the default value after some time.
507
- *
508
- * @see https://vueuse.org/refAutoReset
509
- * @param defaultValue The value which will be set.
510
- * @param afterMs A zero-or-greater delay in milliseconds.
511
- */
512
- function refAutoReset(defaultValue, afterMs = 1e4) {
513
- return (0, vue.customRef)((track, trigger) => {
514
- let value = (0, vue.toValue)(defaultValue);
515
- let timer;
516
- const resetAfter = () => setTimeout(() => {
517
- value = (0, vue.toValue)(defaultValue);
518
- trigger();
519
- }, (0, vue.toValue)(afterMs));
520
- tryOnScopeDispose(() => {
521
- clearTimeout(timer);
522
- });
523
- return {
524
- get() {
525
- track();
526
- return value;
527
- },
528
- set(newValue) {
529
- value = newValue;
750
+ * Create a ref which will be reset to the default value after some time.
751
+ *
752
+ * @see https://vueuse.org/refAutoReset
753
+ * @param defaultValue The value which will be set.
754
+ * @param afterMs A zero-or-greater delay in milliseconds.
755
+ */
756
+ function refAutoReset(defaultValue, afterMs = 1e4) {
757
+ return (0, vue.customRef)((track, trigger) => {
758
+ let value = (0, vue.toValue)(defaultValue);
759
+ let timer;
760
+ const resetAfter = () => setTimeout(() => {
761
+ value = (0, vue.toValue)(defaultValue);
530
762
  trigger();
763
+ }, (0, vue.toValue)(afterMs));
764
+ tryOnScopeDispose(() => {
531
765
  clearTimeout(timer);
532
- timer = resetAfter();
533
- }
534
- };
535
- });
536
- }
537
- /** @deprecated use `refAutoReset` instead */
538
- const autoResetRef = refAutoReset;
539
-
540
- //#endregion
541
- //#region utils/filters.ts
542
- /**
543
- * @internal
544
- */
545
- function createFilterWrapper(filter, fn) {
546
- function wrapper(...args) {
547
- return new Promise((resolve, reject) => {
548
- Promise.resolve(filter(() => fn.apply(this, args), {
549
- fn,
550
- thisArg: this,
551
- args
552
- })).then(resolve).catch(reject);
766
+ });
767
+ return {
768
+ get() {
769
+ track();
770
+ return value;
771
+ },
772
+ set(newValue) {
773
+ value = newValue;
774
+ trigger();
775
+ clearTimeout(timer);
776
+ timer = resetAfter();
777
+ }
778
+ };
553
779
  });
554
780
  }
555
- return wrapper;
556
- }
557
- const bypassFilter = (invoke$1) => {
558
- return invoke$1();
559
- };
560
- /**
561
- * Create an EventFilter that debounce the events
562
- */
563
- function debounceFilter(ms, options = {}) {
564
- let timer;
565
- let maxTimer;
566
- let lastRejector = noop;
567
- const _clearTimeout = (timer$1) => {
568
- clearTimeout(timer$1);
569
- lastRejector();
570
- lastRejector = noop;
571
- };
572
- let lastInvoker;
573
- const filter = (invoke$1) => {
574
- const duration = (0, vue.toValue)(ms);
575
- const maxDuration = (0, vue.toValue)(options.maxWait);
576
- if (timer) _clearTimeout(timer);
577
- if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
578
- if (maxTimer) {
579
- _clearTimeout(maxTimer);
580
- maxTimer = void 0;
581
- }
582
- return Promise.resolve(invoke$1());
583
- }
584
- return new Promise((resolve, reject) => {
585
- lastRejector = options.rejectOnCancel ? reject : resolve;
586
- lastInvoker = invoke$1;
587
- if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
588
- if (timer) _clearTimeout(timer);
589
- maxTimer = void 0;
590
- resolve(lastInvoker());
591
- }, maxDuration);
592
- timer = setTimeout(() => {
593
- if (maxTimer) _clearTimeout(maxTimer);
594
- maxTimer = void 0;
595
- resolve(invoke$1());
596
- }, duration);
597
- });
598
- };
599
- return filter;
600
- }
601
- function throttleFilter(...args) {
602
- let lastExec = 0;
603
- let timer;
604
- let isLeading = true;
605
- let lastRejector = noop;
606
- let lastValue;
607
- let ms;
608
- let trailing;
609
- let leading;
610
- let rejectOnCancel;
611
- if (!(0, vue.isRef)(args[0]) && typeof args[0] === "object") ({delay: ms, trailing = true, leading = true, rejectOnCancel = false} = args[0]);
612
- else [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
613
- const clear = () => {
614
- if (timer) {
615
- clearTimeout(timer);
616
- timer = void 0;
617
- lastRejector();
618
- lastRejector = noop;
619
- }
620
- };
621
- const filter = (_invoke) => {
622
- const duration = (0, vue.toValue)(ms);
623
- const elapsed = Date.now() - lastExec;
624
- const invoke$1 = () => {
625
- return lastValue = _invoke();
626
- };
627
- clear();
628
- if (duration <= 0) {
629
- lastExec = Date.now();
630
- return invoke$1();
631
- }
632
- if (elapsed > duration) {
633
- lastExec = Date.now();
634
- if (leading || !isLeading) invoke$1();
635
- } else if (trailing) lastValue = new Promise((resolve, reject) => {
636
- lastRejector = rejectOnCancel ? reject : resolve;
637
- timer = setTimeout(() => {
638
- lastExec = Date.now();
639
- isLeading = true;
640
- resolve(invoke$1());
641
- clear();
642
- }, Math.max(0, duration - elapsed));
643
- });
644
- if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration);
645
- isLeading = false;
646
- return lastValue;
647
- };
648
- return filter;
649
- }
650
- /**
651
- * EventFilter that gives extra controls to pause and resume the filter
652
- *
653
- * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
654
- * @param options Options to configure the filter
655
- */
656
- function pausableFilter(extendFilter = bypassFilter, options = {}) {
657
- const { initialState = "active" } = options;
658
- const isActive = toRef(initialState === "active");
659
- function pause() {
660
- isActive.value = false;
661
- }
662
- function resume() {
663
- isActive.value = true;
664
- }
665
- const eventFilter = (...args) => {
666
- if (isActive.value) extendFilter(...args);
667
- };
668
- return {
669
- isActive: (0, vue.readonly)(isActive),
670
- pause,
671
- resume,
672
- eventFilter
673
- };
674
- }
675
-
676
- //#endregion
677
- //#region utils/general.ts
678
- function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
679
- return new Promise((resolve, reject) => {
680
- if (throwOnTimeout) setTimeout(() => reject(reason), ms);
681
- else setTimeout(resolve, ms);
682
- });
683
- }
684
- function identity(arg) {
685
- return arg;
686
- }
687
- /**
688
- * Create singleton promise function
689
- *
690
- * @example
691
- * ```
692
- * const promise = createSingletonPromise(async () => { ... })
693
- *
694
- * await promise()
695
- * await promise() // all of them will be bind to a single promise instance
696
- * await promise() // and be resolved together
697
- * ```
698
- */
699
- function createSingletonPromise(fn) {
700
- let _promise;
701
- function wrapper() {
702
- if (!_promise) _promise = fn();
703
- return _promise;
704
- }
705
- wrapper.reset = async () => {
706
- const _prev = _promise;
707
- _promise = void 0;
708
- if (_prev) await _prev;
709
- };
710
- return wrapper;
711
- }
712
- function invoke(fn) {
713
- return fn();
714
- }
715
- function containsProp(obj, ...props) {
716
- return props.some((k) => k in obj);
717
- }
718
- function increaseWithUnit(target, delta) {
719
- var _target$match;
720
- if (typeof target === "number") return target + delta;
721
- const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || "";
722
- const unit = target.slice(value.length);
723
- const result = Number.parseFloat(value) + delta;
724
- if (Number.isNaN(result)) return target;
725
- return result + unit;
726
- }
727
- /**
728
- * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client
729
- */
730
- function pxValue(px) {
731
- return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
732
- }
733
- /**
734
- * Create a new subset object by giving keys
735
- */
736
- function objectPick(obj, keys, omitUndefined = false) {
737
- return keys.reduce((n, k) => {
738
- if (k in obj) {
739
- if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k];
740
- }
741
- return n;
742
- }, {});
743
- }
744
- /**
745
- * Create a new subset object by omit giving keys
746
- */
747
- function objectOmit(obj, keys, omitUndefined = false) {
748
- return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
749
- return (!omitUndefined || value !== void 0) && !keys.includes(key);
750
- }));
751
- }
752
- function objectEntries(obj) {
753
- return Object.entries(obj);
754
- }
755
- function toArray(value) {
756
- return Array.isArray(value) ? value : [value];
757
- }
758
-
759
- //#endregion
760
- //#region utils/port.ts
761
- function cacheStringFunction(fn) {
762
- const cache = Object.create(null);
763
- return ((str) => {
764
- return cache[str] || (cache[str] = fn(str));
765
- });
766
- }
767
- const hyphenateRE = /\B([A-Z])/g;
768
- const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
769
- const camelizeRE = /-(\w)/g;
770
- const camelize = cacheStringFunction((str) => {
771
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
772
- });
773
-
774
- //#endregion
775
- //#region utils/vue.ts
776
- function getLifeCycleTarget(target) {
777
- return target || (0, vue.getCurrentInstance)();
778
- }
781
+ /** @deprecated use `refAutoReset` instead */
782
+ const autoResetRef = refAutoReset;
779
783
 
780
784
  //#endregion
781
785
  //#region useDebounceFn/index.ts
782
786
  /**
783
- * Debounce execution of a function.
784
- *
785
- * @see https://vueuse.org/useDebounceFn
786
- * @param fn A function to be executed after delay milliseconds debounced.
787
- * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
788
- * @param options Options
789
- *
790
- * @return A new, debounce, function.
791
- *
792
- * @__NO_SIDE_EFFECTS__
793
- */
794
- function useDebounceFn(fn, ms = 200, options = {}) {
795
- return createFilterWrapper(debounceFilter(ms, options), fn);
796
- }
787
+ * Debounce execution of a function.
788
+ *
789
+ * @see https://vueuse.org/useDebounceFn
790
+ * @param fn A function to be executed after delay milliseconds debounced.
791
+ * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
792
+ * @param options Options
793
+ *
794
+ * @return A new, debounce, function.
795
+ *
796
+ * @__NO_SIDE_EFFECTS__
797
+ */
798
+ function useDebounceFn(fn, ms = 200, options = {}) {
799
+ return createFilterWrapper(debounceFilter(ms, options), fn);
800
+ }
797
801
 
798
802
  //#endregion
799
803
  //#region refDebounced/index.ts
800
804
  /**
801
- * Debounce updates of a ref.
802
- *
803
- * @return A new debounced ref.
804
- */
805
- function refDebounced(value, ms = 200, options = {}) {
806
- const debounced = (0, vue.ref)((0, vue.toValue)(value));
807
- const updater = useDebounceFn(() => {
808
- debounced.value = value.value;
809
- }, ms, options);
810
- (0, vue.watch)(value, () => updater());
811
- return (0, vue.shallowReadonly)(debounced);
812
- }
813
- /** @deprecated use `refDebounced` instead */
814
- const debouncedRef = refDebounced;
815
- /** @deprecated use `refDebounced` instead */
816
- const useDebounce = refDebounced;
805
+ * Debounce updates of a ref.
806
+ *
807
+ * @return A new debounced ref.
808
+ */
809
+ function refDebounced(value, ms = 200, options = {}) {
810
+ const debounced = (0, vue.ref)((0, vue.toValue)(value));
811
+ const updater = useDebounceFn(() => {
812
+ debounced.value = value.value;
813
+ }, ms, options);
814
+ (0, vue.watch)(value, () => updater());
815
+ return (0, vue.shallowReadonly)(debounced);
816
+ }
817
+ /** @deprecated use `refDebounced` instead */
818
+ const debouncedRef = refDebounced;
819
+ /** @deprecated use `refDebounced` instead */
820
+ const useDebounce = refDebounced;
817
821
 
818
822
  //#endregion
819
823
  //#region refDefault/index.ts
820
824
  /**
821
- * Apply default value to a ref.
822
- *
823
- * @__NO_SIDE_EFFECTS__
824
- */
825
- function refDefault(source, defaultValue) {
826
- return (0, vue.computed)({
827
- get() {
828
- var _source$value;
829
- return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue;
830
- },
831
- set(value) {
832
- source.value = value;
833
- }
834
- });
835
- }
825
+ * Apply default value to a ref.
826
+ *
827
+ * @__NO_SIDE_EFFECTS__
828
+ */
829
+ function refDefault(source, defaultValue) {
830
+ return (0, vue.computed)({
831
+ get() {
832
+ var _source$value;
833
+ return (_source$value = source.value) !== null && _source$value !== void 0 ? _source$value : defaultValue;
834
+ },
835
+ set(value) {
836
+ source.value = value;
837
+ }
838
+ });
839
+ }
836
840
 
837
841
  //#endregion
838
842
  //#region refManualReset/index.ts
839
843
  /**
840
- * Create a ref with manual reset functionality.
841
- *
842
- * @see https://vueuse.org/refManualReset
843
- * @param defaultValue The value which will be set.
844
- */
845
- function refManualReset(defaultValue) {
846
- let value = (0, vue.toValue)(defaultValue);
847
- let trigger;
848
- const reset = () => {
849
- value = (0, vue.toValue)(defaultValue);
850
- trigger();
851
- };
852
- const refValue = (0, vue.customRef)((track, _trigger) => {
853
- trigger = _trigger;
854
- return {
855
- get() {
856
- track();
857
- return value;
858
- },
859
- set(newValue) {
860
- value = newValue;
861
- trigger();
862
- }
844
+ * Create a ref with manual reset functionality.
845
+ *
846
+ * @see https://vueuse.org/refManualReset
847
+ * @param defaultValue The value which will be set.
848
+ */
849
+ function refManualReset(defaultValue) {
850
+ let value = (0, vue.toValue)(defaultValue);
851
+ let trigger;
852
+ const reset = () => {
853
+ value = (0, vue.toValue)(defaultValue);
854
+ trigger();
863
855
  };
864
- });
865
- refValue.reset = reset;
866
- return refValue;
867
- }
856
+ const refValue = (0, vue.customRef)((track, _trigger) => {
857
+ trigger = _trigger;
858
+ return {
859
+ get() {
860
+ track();
861
+ return value;
862
+ },
863
+ set(newValue) {
864
+ value = newValue;
865
+ trigger();
866
+ }
867
+ };
868
+ });
869
+ refValue.reset = reset;
870
+ return refValue;
871
+ }
868
872
 
869
873
  //#endregion
870
874
  //#region useThrottleFn/index.ts
871
875
  /**
872
- * Throttle execution of a function. Especially useful for rate limiting
873
- * execution of handlers on events like resize and scroll.
874
- *
875
- * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
876
- * to `callback` when the throttled-function is executed.
877
- * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
878
- * (default value: 200)
879
- *
880
- * @param [trailing] if true, call fn again after the time is up (default value: false)
881
- *
882
- * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true)
883
- *
884
- * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false)
885
- *
886
- * @return A new, throttled, function.
887
- *
888
- * @__NO_SIDE_EFFECTS__
889
- */
890
- function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
891
- return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
892
- }
876
+ * Throttle execution of a function. Especially useful for rate limiting
877
+ * execution of handlers on events like resize and scroll.
878
+ *
879
+ * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
880
+ * to `callback` when the throttled-function is executed.
881
+ * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
882
+ * (default value: 200)
883
+ *
884
+ * @param [trailing] if true, call fn again after the time is up (default value: false)
885
+ *
886
+ * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true)
887
+ *
888
+ * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false)
889
+ *
890
+ * @return A new, throttled, function.
891
+ *
892
+ * @__NO_SIDE_EFFECTS__
893
+ */
894
+ function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
895
+ return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
896
+ }
893
897
 
894
898
  //#endregion
895
899
  //#region refThrottled/index.ts
896
900
  /**
897
- * Throttle execution of a function. Especially useful for rate limiting
898
- * execution of handlers on events like resize and scroll.
899
- *
900
- * @param value Ref value to be watched with throttle effect
901
- * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
902
- * @param trailing if true, update the value again after the delay time is up
903
- * @param leading if true, update the value on the leading edge of the ms timeout
904
- */
905
- function refThrottled(value, delay = 200, trailing = true, leading = true) {
906
- if (delay <= 0) return value;
907
- const throttled = (0, vue.ref)((0, vue.toValue)(value));
908
- const updater = useThrottleFn(() => {
909
- throttled.value = value.value;
910
- }, delay, trailing, leading);
911
- (0, vue.watch)(value, () => updater());
912
- return throttled;
913
- }
914
- /** @deprecated use `refThrottled` instead */
915
- const throttledRef = refThrottled;
916
- /** @deprecated use `refThrottled` instead */
917
- const useThrottle = refThrottled;
901
+ * Throttle execution of a function. Especially useful for rate limiting
902
+ * execution of handlers on events like resize and scroll.
903
+ *
904
+ * @param value Ref value to be watched with throttle effect
905
+ * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
906
+ * @param trailing if true, update the value again after the delay time is up
907
+ * @param leading if true, update the value on the leading edge of the ms timeout
908
+ */
909
+ function refThrottled(value, delay = 200, trailing = true, leading = true) {
910
+ if (delay <= 0) return value;
911
+ const throttled = (0, vue.ref)((0, vue.toValue)(value));
912
+ const updater = useThrottleFn(() => {
913
+ throttled.value = value.value;
914
+ }, delay, trailing, leading);
915
+ (0, vue.watch)(value, () => updater());
916
+ return throttled;
917
+ }
918
+ /** @deprecated use `refThrottled` instead */
919
+ const throttledRef = refThrottled;
920
+ /** @deprecated use `refThrottled` instead */
921
+ const useThrottle = refThrottled;
918
922
 
919
923
  //#endregion
920
924
  //#region refWithControl/index.ts
921
925
  /**
922
- * Fine-grained controls over ref and its reactivity.
923
- *
924
- * @__NO_SIDE_EFFECTS__
925
- */
926
- function refWithControl(initial, options = {}) {
927
- let source = initial;
928
- let track;
929
- let trigger;
930
- const ref = (0, vue.customRef)((_track, _trigger) => {
931
- track = _track;
932
- trigger = _trigger;
933
- return {
934
- get() {
935
- return get$1();
936
- },
937
- set(v) {
938
- set$1(v);
939
- }
940
- };
941
- });
942
- function get$1(tracking = true) {
943
- if (tracking) track();
944
- return source;
945
- }
946
- function set$1(value, triggering = true) {
947
- var _options$onBeforeChan, _options$onChanged;
948
- if (value === source) return;
949
- const old = source;
950
- if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return;
951
- source = value;
952
- (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old);
953
- if (triggering) trigger();
954
- }
955
- /**
956
- * Get the value without tracked in the reactivity system
957
- */
958
- const untrackedGet = () => get$1(false);
959
- /**
960
- * Set the value without triggering the reactivity system
961
- */
962
- const silentSet = (v) => set$1(v, false);
963
- /**
964
- * Get the value without tracked in the reactivity system.
965
- *
966
- * Alias for `untrackedGet()`
967
- */
968
- const peek = () => get$1(false);
969
- /**
970
- * Set the value without triggering the reactivity system
926
+ * Fine-grained controls over ref and its reactivity.
971
927
  *
972
- * Alias for `silentSet(v)`
928
+ * @__NO_SIDE_EFFECTS__
973
929
  */
974
- const lay = (v) => set$1(v, false);
975
- return extendRef(ref, {
976
- get: get$1,
977
- set: set$1,
978
- untrackedGet,
979
- silentSet,
980
- peek,
981
- lay
982
- }, { enumerable: true });
983
- }
984
- /** @deprecated use `refWithControl` instead */
985
- const controlledRef = refWithControl;
930
+ function refWithControl(initial, options = {}) {
931
+ let source = initial;
932
+ let track;
933
+ let trigger;
934
+ const ref = (0, vue.customRef)((_track, _trigger) => {
935
+ track = _track;
936
+ trigger = _trigger;
937
+ return {
938
+ get() {
939
+ return get$1();
940
+ },
941
+ set(v) {
942
+ set$1(v);
943
+ }
944
+ };
945
+ });
946
+ function get$1(tracking = true) {
947
+ if (tracking) track();
948
+ return source;
949
+ }
950
+ function set$1(value, triggering = true) {
951
+ var _options$onBeforeChan, _options$onChanged;
952
+ if (value === source) return;
953
+ const old = source;
954
+ if (((_options$onBeforeChan = options.onBeforeChange) === null || _options$onBeforeChan === void 0 ? void 0 : _options$onBeforeChan.call(options, value, old)) === false) return;
955
+ source = value;
956
+ (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, value, old);
957
+ if (triggering) trigger();
958
+ }
959
+ /**
960
+ * Get the value without tracked in the reactivity system
961
+ */
962
+ const untrackedGet = () => get$1(false);
963
+ /**
964
+ * Set the value without triggering the reactivity system
965
+ */
966
+ const silentSet = (v) => set$1(v, false);
967
+ /**
968
+ * Get the value without tracked in the reactivity system.
969
+ *
970
+ * Alias for `untrackedGet()`
971
+ */
972
+ const peek = () => get$1(false);
973
+ /**
974
+ * Set the value without triggering the reactivity system
975
+ *
976
+ * Alias for `silentSet(v)`
977
+ */
978
+ const lay = (v) => set$1(v, false);
979
+ return extendRef(ref, {
980
+ get: get$1,
981
+ set: set$1,
982
+ untrackedGet,
983
+ silentSet,
984
+ peek,
985
+ lay
986
+ }, { enumerable: true });
987
+ }
988
+ /** @deprecated use `refWithControl` instead */
989
+ const controlledRef = refWithControl;
986
990
 
987
991
  //#endregion
988
992
  //#region set/index.ts
989
993
  /**
990
- * Shorthand for `ref.value = x`
991
- */
992
- function set(...args) {
993
- if (args.length === 2) {
994
- const [ref, value] = args;
995
- ref.value = value;
996
- }
997
- if (args.length === 3) {
998
- const [target, key, value] = args;
999
- target[key] = value;
994
+ * Shorthand for `ref.value = x`
995
+ */
996
+ function set(...args) {
997
+ if (args.length === 2) {
998
+ const [ref, value] = args;
999
+ ref.value = value;
1000
+ }
1001
+ if (args.length === 3) {
1002
+ const [target, key, value] = args;
1003
+ target[key] = value;
1004
+ }
1000
1005
  }
1001
- }
1002
1006
 
1003
1007
  //#endregion
1004
1008
  //#region watchWithFilter/index.ts
1005
- function watchWithFilter(source, cb, options = {}) {
1006
- const { eventFilter = bypassFilter,...watchOptions } = options;
1007
- return (0, vue.watch)(source, createFilterWrapper(eventFilter, cb), watchOptions);
1008
- }
1009
+ function watchWithFilter(source, cb, options = {}) {
1010
+ const { eventFilter = bypassFilter,...watchOptions } = options;
1011
+ return (0, vue.watch)(source, createFilterWrapper(eventFilter, cb), watchOptions);
1012
+ }
1009
1013
 
1010
1014
  //#endregion
1011
1015
  //#region watchPausable/index.ts
1012
- function watchPausable(source, cb, options = {}) {
1013
- const { eventFilter: filter, initialState = "active",...watchOptions } = options;
1014
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
1015
- return {
1016
- stop: watchWithFilter(source, cb, {
1017
- ...watchOptions,
1018
- eventFilter
1019
- }),
1020
- pause,
1021
- resume,
1022
- isActive
1023
- };
1024
- }
1025
- /** @deprecated use `watchPausable` instead */
1026
- const pausableWatch = watchPausable;
1016
+ function watchPausable(source, cb, options = {}) {
1017
+ const { eventFilter: filter, initialState = "active",...watchOptions } = options;
1018
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
1019
+ return {
1020
+ stop: watchWithFilter(source, cb, {
1021
+ ...watchOptions,
1022
+ eventFilter
1023
+ }),
1024
+ pause,
1025
+ resume,
1026
+ isActive
1027
+ };
1028
+ }
1029
+ /** @deprecated use `watchPausable` instead */
1030
+ const pausableWatch = watchPausable;
1027
1031
 
1028
1032
  //#endregion
1029
1033
  //#region syncRef/index.ts
1030
1034
  /**
1031
- * Two-way refs synchronization.
1032
- * From the set theory perspective to restrict the option's type
1033
- * Check in the following order:
1034
- * 1. L = R
1035
- * 2. L ∩ R ≠ ∅
1036
- * 3. L ⊆ R
1037
- * 4. L ∩ R = ∅
1038
- */
1039
- function syncRef(left, right, ...[options]) {
1040
- const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {};
1041
- const watchers = [];
1042
- const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
1043
- const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
1044
- if (direction === "both" || direction === "ltr") watchers.push(pausableWatch(left, (newValue) => {
1045
- watchers.forEach((w) => w.pause());
1046
- right.value = transformLTR(newValue);
1047
- watchers.forEach((w) => w.resume());
1048
- }, {
1049
- flush,
1050
- deep,
1051
- immediate
1052
- }));
1053
- if (direction === "both" || direction === "rtl") watchers.push(pausableWatch(right, (newValue) => {
1054
- watchers.forEach((w) => w.pause());
1055
- left.value = transformRTL(newValue);
1056
- watchers.forEach((w) => w.resume());
1057
- }, {
1058
- flush,
1059
- deep,
1060
- immediate
1061
- }));
1062
- const stop = () => {
1063
- watchers.forEach((w) => w.stop());
1064
- };
1065
- return stop;
1066
- }
1035
+ * Two-way refs synchronization.
1036
+ * From the set theory perspective to restrict the option's type
1037
+ * Check in the following order:
1038
+ * 1. L = R
1039
+ * 2. L ∩ R ≠ ∅
1040
+ * 3. L ⊆ R
1041
+ * 4. L ∩ R = ∅
1042
+ */
1043
+ function syncRef(left, right, ...[options]) {
1044
+ const { flush = "sync", deep = false, immediate = true, direction = "both", transform = {} } = options || {};
1045
+ const watchers = [];
1046
+ const transformLTR = "ltr" in transform && transform.ltr || ((v) => v);
1047
+ const transformRTL = "rtl" in transform && transform.rtl || ((v) => v);
1048
+ if (direction === "both" || direction === "ltr") watchers.push(pausableWatch(left, (newValue) => {
1049
+ watchers.forEach((w) => w.pause());
1050
+ right.value = transformLTR(newValue);
1051
+ watchers.forEach((w) => w.resume());
1052
+ }, {
1053
+ flush,
1054
+ deep,
1055
+ immediate
1056
+ }));
1057
+ if (direction === "both" || direction === "rtl") watchers.push(pausableWatch(right, (newValue) => {
1058
+ watchers.forEach((w) => w.pause());
1059
+ left.value = transformRTL(newValue);
1060
+ watchers.forEach((w) => w.resume());
1061
+ }, {
1062
+ flush,
1063
+ deep,
1064
+ immediate
1065
+ }));
1066
+ const stop = () => {
1067
+ watchers.forEach((w) => w.stop());
1068
+ };
1069
+ return stop;
1070
+ }
1067
1071
 
1068
1072
  //#endregion
1069
1073
  //#region syncRefs/index.ts
1070
1074
  /**
1071
- * Keep target ref(s) in sync with the source ref
1072
- *
1073
- * @param source source ref
1074
- * @param targets
1075
- */
1076
- function syncRefs(source, targets, options = {}) {
1077
- const { flush = "sync", deep = false, immediate = true } = options;
1078
- const targetsArray = toArray(targets);
1079
- return (0, vue.watch)(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), {
1080
- flush,
1081
- deep,
1082
- immediate
1083
- });
1084
- }
1075
+ * Keep target ref(s) in sync with the source ref
1076
+ *
1077
+ * @param source source ref
1078
+ * @param targets
1079
+ */
1080
+ function syncRefs(source, targets, options = {}) {
1081
+ const { flush = "sync", deep = false, immediate = true } = options;
1082
+ const targetsArray = toArray(targets);
1083
+ return (0, vue.watch)(source, (newValue) => targetsArray.forEach((target) => target.value = newValue), {
1084
+ flush,
1085
+ deep,
1086
+ immediate
1087
+ });
1088
+ }
1085
1089
 
1086
1090
  //#endregion
1087
1091
  //#region toRefs/index.ts
1088
1092
  /**
1089
- * Extended `toRefs` that also accepts refs of an object.
1090
- *
1091
- * @see https://vueuse.org/toRefs
1092
- * @param objectRef A ref or normal object or array.
1093
- * @param options Options
1094
- */
1095
- function toRefs(objectRef, options = {}) {
1096
- if (!(0, vue.isRef)(objectRef)) return (0, vue.toRefs)(objectRef);
1097
- const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
1098
- for (const key in objectRef.value) result[key] = (0, vue.customRef)(() => ({
1099
- get() {
1100
- return objectRef.value[key];
1101
- },
1102
- set(v) {
1103
- var _toValue;
1104
- if ((_toValue = (0, vue.toValue)(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true) if (Array.isArray(objectRef.value)) {
1105
- const copy = [...objectRef.value];
1106
- copy[key] = v;
1107
- objectRef.value = copy;
1108
- } else {
1109
- const newObject = {
1110
- ...objectRef.value,
1111
- [key]: v
1112
- };
1113
- Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
1114
- objectRef.value = newObject;
1093
+ * Extended `toRefs` that also accepts refs of an object.
1094
+ *
1095
+ * @see https://vueuse.org/toRefs
1096
+ * @param objectRef A ref or normal object or array.
1097
+ * @param options Options
1098
+ */
1099
+ function toRefs(objectRef, options = {}) {
1100
+ if (!(0, vue.isRef)(objectRef)) return (0, vue.toRefs)(objectRef);
1101
+ const result = Array.isArray(objectRef.value) ? Array.from({ length: objectRef.value.length }) : {};
1102
+ for (const key in objectRef.value) result[key] = (0, vue.customRef)(() => ({
1103
+ get() {
1104
+ return objectRef.value[key];
1105
+ },
1106
+ set(v) {
1107
+ var _toValue;
1108
+ if ((_toValue = (0, vue.toValue)(options.replaceRef)) !== null && _toValue !== void 0 ? _toValue : true) if (Array.isArray(objectRef.value)) {
1109
+ const copy = [...objectRef.value];
1110
+ copy[key] = v;
1111
+ objectRef.value = copy;
1112
+ } else {
1113
+ const newObject = {
1114
+ ...objectRef.value,
1115
+ [key]: v
1116
+ };
1117
+ Object.setPrototypeOf(newObject, Object.getPrototypeOf(objectRef.value));
1118
+ objectRef.value = newObject;
1119
+ }
1120
+ else objectRef.value[key] = v;
1115
1121
  }
1116
- else objectRef.value[key] = v;
1117
- }
1118
- }));
1119
- return result;
1120
- }
1122
+ }));
1123
+ return result;
1124
+ }
1121
1125
 
1122
1126
  //#endregion
1123
1127
  //#region tryOnBeforeMount/index.ts
1124
1128
  /**
1125
- * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function
1126
- *
1127
- * @param fn
1128
- * @param sync if set to false, it will run in the nextTick() of Vue
1129
- * @param target
1130
- */
1131
- function tryOnBeforeMount(fn, sync = true, target) {
1132
- if (getLifeCycleTarget(target)) (0, vue.onBeforeMount)(fn, target);
1133
- else if (sync) fn();
1134
- else (0, vue.nextTick)(fn);
1135
- }
1129
+ * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function
1130
+ *
1131
+ * @param fn
1132
+ * @param sync if set to false, it will run in the nextTick() of Vue
1133
+ * @param target
1134
+ */
1135
+ function tryOnBeforeMount(fn, sync = true, target) {
1136
+ if (getLifeCycleTarget(target)) (0, vue.onBeforeMount)(fn, target);
1137
+ else if (sync) fn();
1138
+ else (0, vue.nextTick)(fn);
1139
+ }
1136
1140
 
1137
1141
  //#endregion
1138
1142
  //#region tryOnBeforeUnmount/index.ts
1139
1143
  /**
1140
- * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
1141
- *
1142
- * @param fn
1143
- * @param target
1144
- */
1145
- function tryOnBeforeUnmount(fn, target) {
1146
- if (getLifeCycleTarget(target)) (0, vue.onBeforeUnmount)(fn, target);
1147
- }
1148
-
1149
- //#endregion
1150
- //#region tryOnMounted/index.ts
1151
- /**
1152
- * Call onMounted() if it's inside a component lifecycle, if not, just call the function
1153
- *
1154
- * @param fn
1155
- * @param sync if set to false, it will run in the nextTick() of Vue
1156
- * @param target
1157
- */
1158
- function tryOnMounted(fn, sync = true, target) {
1159
- if (getLifeCycleTarget(target)) (0, vue.onMounted)(fn, target);
1160
- else if (sync) fn();
1161
- else (0, vue.nextTick)(fn);
1162
- }
1163
-
1164
- //#endregion
1165
- //#region tryOnUnmounted/index.ts
1166
- /**
1167
- * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing
1168
- *
1169
- * @param fn
1170
- * @param target
1171
- */
1172
- function tryOnUnmounted(fn, target) {
1173
- if (getLifeCycleTarget(target)) (0, vue.onUnmounted)(fn, target);
1174
- }
1175
-
1176
- //#endregion
1177
- //#region until/index.ts
1178
- function createUntil(r, isNot = false) {
1179
- function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
1180
- let stop = null;
1181
- const promises = [new Promise((resolve) => {
1182
- stop = (0, vue.watch)(r, (v) => {
1183
- if (condition(v) !== isNot) {
1184
- if (stop) stop();
1185
- else (0, vue.nextTick)(() => stop === null || stop === void 0 ? void 0 : stop());
1186
- resolve(v);
1187
- }
1188
- }, {
1189
- flush,
1190
- deep,
1191
- immediate: true
1192
- });
1193
- })];
1194
- if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => (0, vue.toValue)(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop()));
1195
- return Promise.race(promises);
1196
- }
1197
- function toBe(value, options) {
1198
- if (!(0, vue.isRef)(value)) return toMatch((v) => v === value, options);
1199
- const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {};
1200
- let stop = null;
1201
- const promises = [new Promise((resolve) => {
1202
- stop = (0, vue.watch)([r, value], ([v1, v2]) => {
1203
- if (isNot !== (v1 === v2)) {
1204
- if (stop) stop();
1205
- else (0, vue.nextTick)(() => stop === null || stop === void 0 ? void 0 : stop());
1206
- resolve(v1);
1207
- }
1208
- }, {
1209
- flush,
1210
- deep,
1211
- immediate: true
1212
- });
1213
- })];
1214
- if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => (0, vue.toValue)(r)).finally(() => {
1215
- stop === null || stop === void 0 || stop();
1216
- return (0, vue.toValue)(r);
1217
- }));
1218
- return Promise.race(promises);
1219
- }
1220
- function toBeTruthy(options) {
1221
- return toMatch((v) => Boolean(v), options);
1222
- }
1223
- function toBeNull(options) {
1224
- return toBe(null, options);
1225
- }
1226
- function toBeUndefined(options) {
1227
- return toBe(void 0, options);
1228
- }
1229
- function toBeNaN(options) {
1230
- return toMatch(Number.isNaN, options);
1231
- }
1232
- function toContains(value, options) {
1233
- return toMatch((v) => {
1234
- const array = Array.from(v);
1235
- return array.includes(value) || array.includes((0, vue.toValue)(value));
1236
- }, options);
1144
+ * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
1145
+ *
1146
+ * @param fn
1147
+ * @param target
1148
+ */
1149
+ function tryOnBeforeUnmount(fn, target) {
1150
+ if (getLifeCycleTarget(target)) (0, vue.onBeforeUnmount)(fn, target);
1237
1151
  }
1238
- function changed(options) {
1239
- return changedTimes(1, options);
1152
+
1153
+ //#endregion
1154
+ //#region tryOnMounted/index.ts
1155
+ /**
1156
+ * Call onMounted() if it's inside a component lifecycle, if not, just call the function
1157
+ *
1158
+ * @param fn
1159
+ * @param sync if set to false, it will run in the nextTick() of Vue
1160
+ * @param target
1161
+ */
1162
+ function tryOnMounted(fn, sync = true, target) {
1163
+ if (getLifeCycleTarget(target)) (0, vue.onMounted)(fn, target);
1164
+ else if (sync) fn();
1165
+ else (0, vue.nextTick)(fn);
1240
1166
  }
1241
- function changedTimes(n = 1, options) {
1242
- let count = -1;
1243
- return toMatch(() => {
1244
- count += 1;
1245
- return count >= n;
1246
- }, options);
1167
+
1168
+ //#endregion
1169
+ //#region tryOnUnmounted/index.ts
1170
+ /**
1171
+ * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing
1172
+ *
1173
+ * @param fn
1174
+ * @param target
1175
+ */
1176
+ function tryOnUnmounted(fn, target) {
1177
+ if (getLifeCycleTarget(target)) (0, vue.onUnmounted)(fn, target);
1247
1178
  }
1248
- if (Array.isArray((0, vue.toValue)(r))) return {
1249
- toMatch,
1250
- toContains,
1251
- changed,
1252
- changedTimes,
1253
- get not() {
1254
- return createUntil(r, !isNot);
1179
+
1180
+ //#endregion
1181
+ //#region until/index.ts
1182
+ function createUntil(r, isNot = false) {
1183
+ function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
1184
+ let stop = null;
1185
+ const promises = [new Promise((resolve) => {
1186
+ stop = (0, vue.watch)(r, (v) => {
1187
+ if (condition(v) !== isNot) {
1188
+ if (stop) stop();
1189
+ else (0, vue.nextTick)(() => stop === null || stop === void 0 ? void 0 : stop());
1190
+ resolve(v);
1191
+ }
1192
+ }, {
1193
+ flush,
1194
+ deep,
1195
+ immediate: true
1196
+ });
1197
+ })];
1198
+ if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => (0, vue.toValue)(r)).finally(() => stop === null || stop === void 0 ? void 0 : stop()));
1199
+ return Promise.race(promises);
1255
1200
  }
1256
- };
1257
- else return {
1258
- toMatch,
1259
- toBe,
1260
- toBeTruthy,
1261
- toBeNull,
1262
- toBeNaN,
1263
- toBeUndefined,
1264
- changed,
1265
- changedTimes,
1266
- get not() {
1267
- return createUntil(r, !isNot);
1201
+ function toBe(value, options) {
1202
+ if (!(0, vue.isRef)(value)) return toMatch((v) => v === value, options);
1203
+ const { flush = "sync", deep = false, timeout, throwOnTimeout } = options !== null && options !== void 0 ? options : {};
1204
+ let stop = null;
1205
+ const promises = [new Promise((resolve) => {
1206
+ stop = (0, vue.watch)([r, value], ([v1, v2]) => {
1207
+ if (isNot !== (v1 === v2)) {
1208
+ if (stop) stop();
1209
+ else (0, vue.nextTick)(() => stop === null || stop === void 0 ? void 0 : stop());
1210
+ resolve(v1);
1211
+ }
1212
+ }, {
1213
+ flush,
1214
+ deep,
1215
+ immediate: true
1216
+ });
1217
+ })];
1218
+ if (timeout != null) promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => (0, vue.toValue)(r)).finally(() => {
1219
+ stop === null || stop === void 0 || stop();
1220
+ return (0, vue.toValue)(r);
1221
+ }));
1222
+ return Promise.race(promises);
1268
1223
  }
1269
- };
1270
- }
1271
- function until(r) {
1272
- return createUntil(r);
1273
- }
1224
+ function toBeTruthy(options) {
1225
+ return toMatch((v) => Boolean(v), options);
1226
+ }
1227
+ function toBeNull(options) {
1228
+ return toBe(null, options);
1229
+ }
1230
+ function toBeUndefined(options) {
1231
+ return toBe(void 0, options);
1232
+ }
1233
+ function toBeNaN(options) {
1234
+ return toMatch(Number.isNaN, options);
1235
+ }
1236
+ function toContains(value, options) {
1237
+ return toMatch((v) => {
1238
+ const array = Array.from(v);
1239
+ return array.includes(value) || array.includes((0, vue.toValue)(value));
1240
+ }, options);
1241
+ }
1242
+ function changed(options) {
1243
+ return changedTimes(1, options);
1244
+ }
1245
+ function changedTimes(n = 1, options) {
1246
+ let count = -1;
1247
+ return toMatch(() => {
1248
+ count += 1;
1249
+ return count >= n;
1250
+ }, options);
1251
+ }
1252
+ if (Array.isArray((0, vue.toValue)(r))) return {
1253
+ toMatch,
1254
+ toContains,
1255
+ changed,
1256
+ changedTimes,
1257
+ get not() {
1258
+ return createUntil(r, !isNot);
1259
+ }
1260
+ };
1261
+ else return {
1262
+ toMatch,
1263
+ toBe,
1264
+ toBeTruthy,
1265
+ toBeNull,
1266
+ toBeNaN,
1267
+ toBeUndefined,
1268
+ changed,
1269
+ changedTimes,
1270
+ get not() {
1271
+ return createUntil(r, !isNot);
1272
+ }
1273
+ };
1274
+ }
1275
+ function until(r) {
1276
+ return createUntil(r);
1277
+ }
1274
1278
 
1275
1279
  //#endregion
1276
1280
  //#region useArrayDifference/index.ts
1277
- function defaultComparator(value, othVal) {
1278
- return value === othVal;
1279
- }
1280
- /**
1281
- * Reactive get array difference of two array
1282
- * @see https://vueuse.org/useArrayDifference
1283
- * @returns - the difference of two array
1284
- * @param args
1285
- *
1286
- * @__NO_SIDE_EFFECTS__
1287
- */
1288
- function useArrayDifference(...args) {
1289
- var _args$, _args$2;
1290
- const list = args[0];
1291
- const values = args[1];
1292
- let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator;
1293
- const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {};
1294
- if (typeof compareFn === "string") {
1295
- const key = compareFn;
1296
- compareFn = (value, othVal) => value[key] === othVal[key];
1297
- }
1298
- const diff1 = (0, vue.computed)(() => (0, vue.toValue)(list).filter((x) => (0, vue.toValue)(values).findIndex((y) => compareFn(x, y)) === -1));
1299
- if (symmetric) {
1300
- const diff2 = (0, vue.computed)(() => (0, vue.toValue)(values).filter((x) => (0, vue.toValue)(list).findIndex((y) => compareFn(x, y)) === -1));
1301
- return (0, vue.computed)(() => symmetric ? [...(0, vue.toValue)(diff1), ...(0, vue.toValue)(diff2)] : (0, vue.toValue)(diff1));
1302
- } else return diff1;
1303
- }
1281
+ function defaultComparator(value, othVal) {
1282
+ return value === othVal;
1283
+ }
1284
+ /**
1285
+ * Reactive get array difference of two array
1286
+ * @see https://vueuse.org/useArrayDifference
1287
+ * @returns - the difference of two array
1288
+ * @param args
1289
+ *
1290
+ * @__NO_SIDE_EFFECTS__
1291
+ */
1292
+ function useArrayDifference(...args) {
1293
+ var _args$, _args$2;
1294
+ const list = args[0];
1295
+ const values = args[1];
1296
+ let compareFn = (_args$ = args[2]) !== null && _args$ !== void 0 ? _args$ : defaultComparator;
1297
+ const { symmetric = false } = (_args$2 = args[3]) !== null && _args$2 !== void 0 ? _args$2 : {};
1298
+ if (typeof compareFn === "string") {
1299
+ const key = compareFn;
1300
+ compareFn = (value, othVal) => value[key] === othVal[key];
1301
+ }
1302
+ const diff1 = (0, vue.computed)(() => (0, vue.toValue)(list).filter((x) => (0, vue.toValue)(values).findIndex((y) => compareFn(x, y)) === -1));
1303
+ if (symmetric) {
1304
+ const diff2 = (0, vue.computed)(() => (0, vue.toValue)(values).filter((x) => (0, vue.toValue)(list).findIndex((y) => compareFn(x, y)) === -1));
1305
+ return (0, vue.computed)(() => symmetric ? [...(0, vue.toValue)(diff1), ...(0, vue.toValue)(diff2)] : (0, vue.toValue)(diff1));
1306
+ } else return diff1;
1307
+ }
1304
1308
 
1305
1309
  //#endregion
1306
1310
  //#region useArrayEvery/index.ts
1307
1311
  /**
1308
- * Reactive `Array.every`
1309
- *
1310
- * @see https://vueuse.org/useArrayEvery
1311
- * @param list - the array was called upon.
1312
- * @param fn - a function to test each element.
1313
- *
1314
- * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
1315
- *
1316
- * @__NO_SIDE_EFFECTS__
1317
- */
1318
- function useArrayEvery(list, fn) {
1319
- return (0, vue.computed)(() => (0, vue.toValue)(list).every((element, index, array) => fn((0, vue.toValue)(element), index, array)));
1320
- }
1312
+ * Reactive `Array.every`
1313
+ *
1314
+ * @see https://vueuse.org/useArrayEvery
1315
+ * @param list - the array was called upon.
1316
+ * @param fn - a function to test each element.
1317
+ *
1318
+ * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
1319
+ *
1320
+ * @__NO_SIDE_EFFECTS__
1321
+ */
1322
+ function useArrayEvery(list, fn) {
1323
+ return (0, vue.computed)(() => (0, vue.toValue)(list).every((element, index, array) => fn((0, vue.toValue)(element), index, array)));
1324
+ }
1321
1325
 
1322
1326
  //#endregion
1323
1327
  //#region useArrayFilter/index.ts
1324
1328
  /**
1325
- * Reactive `Array.filter`
1326
- *
1327
- * @see https://vueuse.org/useArrayFilter
1328
- * @param list - the array was called upon.
1329
- * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
1330
- *
1331
- * @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned.
1332
- *
1333
- * @__NO_SIDE_EFFECTS__
1334
- */
1335
- function useArrayFilter(list, fn) {
1336
- return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).filter(fn));
1337
- }
1329
+ * Reactive `Array.filter`
1330
+ *
1331
+ * @see https://vueuse.org/useArrayFilter
1332
+ * @param list - the array was called upon.
1333
+ * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
1334
+ *
1335
+ * @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned.
1336
+ *
1337
+ * @__NO_SIDE_EFFECTS__
1338
+ */
1339
+ function useArrayFilter(list, fn) {
1340
+ return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).filter(fn));
1341
+ }
1338
1342
 
1339
1343
  //#endregion
1340
1344
  //#region useArrayFind/index.ts
1341
1345
  /**
1342
- * Reactive `Array.find`
1343
- *
1344
- * @see https://vueuse.org/useArrayFind
1345
- * @param list - the array was called upon.
1346
- * @param fn - a function to test each element.
1347
- *
1348
- * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
1349
- *
1350
- * @__NO_SIDE_EFFECTS__
1351
- */
1352
- function useArrayFind(list, fn) {
1353
- return (0, vue.computed)(() => (0, vue.toValue)((0, vue.toValue)(list).find((element, index, array) => fn((0, vue.toValue)(element), index, array))));
1354
- }
1346
+ * Reactive `Array.find`
1347
+ *
1348
+ * @see https://vueuse.org/useArrayFind
1349
+ * @param list - the array was called upon.
1350
+ * @param fn - a function to test each element.
1351
+ *
1352
+ * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
1353
+ *
1354
+ * @__NO_SIDE_EFFECTS__
1355
+ */
1356
+ function useArrayFind(list, fn) {
1357
+ return (0, vue.computed)(() => (0, vue.toValue)((0, vue.toValue)(list).find((element, index, array) => fn((0, vue.toValue)(element), index, array))));
1358
+ }
1355
1359
 
1356
1360
  //#endregion
1357
1361
  //#region useArrayFindIndex/index.ts
1358
1362
  /**
1359
- * Reactive `Array.findIndex`
1360
- *
1361
- * @see https://vueuse.org/useArrayFindIndex
1362
- * @param list - the array was called upon.
1363
- * @param fn - a function to test each element.
1364
- *
1365
- * @returns the index of the first element in the array that passes the test. Otherwise, "-1".
1366
- *
1367
- * @__NO_SIDE_EFFECTS__
1368
- */
1369
- function useArrayFindIndex(list, fn) {
1370
- return (0, vue.computed)(() => (0, vue.toValue)(list).findIndex((element, index, array) => fn((0, vue.toValue)(element), index, array)));
1371
- }
1363
+ * Reactive `Array.findIndex`
1364
+ *
1365
+ * @see https://vueuse.org/useArrayFindIndex
1366
+ * @param list - the array was called upon.
1367
+ * @param fn - a function to test each element.
1368
+ *
1369
+ * @returns the index of the first element in the array that passes the test. Otherwise, "-1".
1370
+ *
1371
+ * @__NO_SIDE_EFFECTS__
1372
+ */
1373
+ function useArrayFindIndex(list, fn) {
1374
+ return (0, vue.computed)(() => (0, vue.toValue)(list).findIndex((element, index, array) => fn((0, vue.toValue)(element), index, array)));
1375
+ }
1372
1376
 
1373
1377
  //#endregion
1374
1378
  //#region useArrayFindLast/index.ts
1375
- function findLast(arr, cb) {
1376
- let index = arr.length;
1377
- while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index];
1378
- }
1379
- /**
1380
- * Reactive `Array.findLast`
1381
- *
1382
- * @see https://vueuse.org/useArrayFindLast
1383
- * @param list - the array was called upon.
1384
- * @param fn - a function to test each element.
1385
- *
1386
- * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
1387
- *
1388
- * @__NO_SIDE_EFFECTS__
1389
- */
1390
- function useArrayFindLast(list, fn) {
1391
- return (0, vue.computed)(() => (0, vue.toValue)(!Array.prototype.findLast ? findLast((0, vue.toValue)(list), (element, index, array) => fn((0, vue.toValue)(element), index, array)) : (0, vue.toValue)(list).findLast((element, index, array) => fn((0, vue.toValue)(element), index, array))));
1392
- }
1379
+ function findLast(arr, cb) {
1380
+ let index = arr.length;
1381
+ while (index-- > 0) if (cb(arr[index], index, arr)) return arr[index];
1382
+ }
1383
+ /**
1384
+ * Reactive `Array.findLast`
1385
+ *
1386
+ * @see https://vueuse.org/useArrayFindLast
1387
+ * @param list - the array was called upon.
1388
+ * @param fn - a function to test each element.
1389
+ *
1390
+ * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
1391
+ *
1392
+ * @__NO_SIDE_EFFECTS__
1393
+ */
1394
+ function useArrayFindLast(list, fn) {
1395
+ return (0, vue.computed)(() => (0, vue.toValue)(!Array.prototype.findLast ? findLast((0, vue.toValue)(list), (element, index, array) => fn((0, vue.toValue)(element), index, array)) : (0, vue.toValue)(list).findLast((element, index, array) => fn((0, vue.toValue)(element), index, array))));
1396
+ }
1393
1397
 
1394
1398
  //#endregion
1395
1399
  //#region useArrayIncludes/index.ts
1396
- function isArrayIncludesOptions(obj) {
1397
- return isObject(obj) && containsProp(obj, "formIndex", "comparator");
1398
- }
1399
- /**
1400
- * Reactive `Array.includes`
1401
- *
1402
- * @see https://vueuse.org/useArrayIncludes
1403
- *
1404
- * @returns true if the `value` is found in the array. Otherwise, false.
1405
- *
1406
- * @__NO_SIDE_EFFECTS__
1407
- */
1408
- function useArrayIncludes(...args) {
1409
- var _comparator;
1410
- const list = args[0];
1411
- const value = args[1];
1412
- let comparator = args[2];
1413
- let formIndex = 0;
1414
- if (isArrayIncludesOptions(comparator)) {
1415
- var _comparator$fromIndex;
1416
- formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0;
1417
- comparator = comparator.comparator;
1418
- }
1419
- if (typeof comparator === "string") {
1420
- const key = comparator;
1421
- comparator = (element, value$1) => element[key] === (0, vue.toValue)(value$1);
1422
- }
1423
- comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === (0, vue.toValue)(value$1));
1424
- return (0, vue.computed)(() => (0, vue.toValue)(list).slice(formIndex).some((element, index, array) => comparator((0, vue.toValue)(element), (0, vue.toValue)(value), index, (0, vue.toValue)(array))));
1425
- }
1400
+ function isArrayIncludesOptions(obj) {
1401
+ return isObject(obj) && containsProp(obj, "formIndex", "comparator");
1402
+ }
1403
+ /**
1404
+ * Reactive `Array.includes`
1405
+ *
1406
+ * @see https://vueuse.org/useArrayIncludes
1407
+ *
1408
+ * @returns true if the `value` is found in the array. Otherwise, false.
1409
+ *
1410
+ * @__NO_SIDE_EFFECTS__
1411
+ */
1412
+ function useArrayIncludes(...args) {
1413
+ var _comparator;
1414
+ const list = args[0];
1415
+ const value = args[1];
1416
+ let comparator = args[2];
1417
+ let formIndex = 0;
1418
+ if (isArrayIncludesOptions(comparator)) {
1419
+ var _comparator$fromIndex;
1420
+ formIndex = (_comparator$fromIndex = comparator.fromIndex) !== null && _comparator$fromIndex !== void 0 ? _comparator$fromIndex : 0;
1421
+ comparator = comparator.comparator;
1422
+ }
1423
+ if (typeof comparator === "string") {
1424
+ const key = comparator;
1425
+ comparator = (element, value$1) => element[key] === (0, vue.toValue)(value$1);
1426
+ }
1427
+ comparator = (_comparator = comparator) !== null && _comparator !== void 0 ? _comparator : ((element, value$1) => element === (0, vue.toValue)(value$1));
1428
+ return (0, vue.computed)(() => (0, vue.toValue)(list).slice(formIndex).some((element, index, array) => comparator((0, vue.toValue)(element), (0, vue.toValue)(value), index, (0, vue.toValue)(array))));
1429
+ }
1426
1430
 
1427
1431
  //#endregion
1428
1432
  //#region useArrayJoin/index.ts
1429
1433
  /**
1430
- * Reactive `Array.join`
1431
- *
1432
- * @see https://vueuse.org/useArrayJoin
1433
- * @param list - the array was called upon.
1434
- * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
1435
- *
1436
- * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.
1437
- *
1438
- * @__NO_SIDE_EFFECTS__
1439
- */
1440
- function useArrayJoin(list, separator) {
1441
- return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).join((0, vue.toValue)(separator)));
1442
- }
1434
+ * Reactive `Array.join`
1435
+ *
1436
+ * @see https://vueuse.org/useArrayJoin
1437
+ * @param list - the array was called upon.
1438
+ * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
1439
+ *
1440
+ * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.
1441
+ *
1442
+ * @__NO_SIDE_EFFECTS__
1443
+ */
1444
+ function useArrayJoin(list, separator) {
1445
+ return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).join((0, vue.toValue)(separator)));
1446
+ }
1443
1447
 
1444
1448
  //#endregion
1445
1449
  //#region useArrayMap/index.ts
1446
1450
  /**
1447
- * Reactive `Array.map`
1448
- *
1449
- * @see https://vueuse.org/useArrayMap
1450
- * @param list - the array was called upon.
1451
- * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
1452
- *
1453
- * @returns a new array with each element being the result of the callback function.
1454
- *
1455
- * @__NO_SIDE_EFFECTS__
1456
- */
1457
- function useArrayMap(list, fn) {
1458
- return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).map(fn));
1459
- }
1451
+ * Reactive `Array.map`
1452
+ *
1453
+ * @see https://vueuse.org/useArrayMap
1454
+ * @param list - the array was called upon.
1455
+ * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
1456
+ *
1457
+ * @returns a new array with each element being the result of the callback function.
1458
+ *
1459
+ * @__NO_SIDE_EFFECTS__
1460
+ */
1461
+ function useArrayMap(list, fn) {
1462
+ return (0, vue.computed)(() => (0, vue.toValue)(list).map((i) => (0, vue.toValue)(i)).map(fn));
1463
+ }
1460
1464
 
1461
1465
  //#endregion
1462
1466
  //#region useArrayReduce/index.ts
1463
1467
  /**
1464
- * Reactive `Array.reduce`
1465
- *
1466
- * @see https://vueuse.org/useArrayReduce
1467
- * @param list - the array was called upon.
1468
- * @param reducer - a "reducer" function.
1469
- * @param args
1470
- *
1471
- * @returns the value that results from running the "reducer" callback function to completion over the entire array.
1472
- *
1473
- * @__NO_SIDE_EFFECTS__
1474
- */
1475
- function useArrayReduce(list, reducer, ...args) {
1476
- const reduceCallback = (sum, value, index) => reducer((0, vue.toValue)(sum), (0, vue.toValue)(value), index);
1477
- return (0, vue.computed)(() => {
1478
- const resolved = (0, vue.toValue)(list);
1479
- return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? (0, vue.toValue)(args[0]()) : (0, vue.toValue)(args[0])) : resolved.reduce(reduceCallback);
1480
- });
1481
- }
1468
+ * Reactive `Array.reduce`
1469
+ *
1470
+ * @see https://vueuse.org/useArrayReduce
1471
+ * @param list - the array was called upon.
1472
+ * @param reducer - a "reducer" function.
1473
+ * @param args
1474
+ *
1475
+ * @returns the value that results from running the "reducer" callback function to completion over the entire array.
1476
+ *
1477
+ * @__NO_SIDE_EFFECTS__
1478
+ */
1479
+ function useArrayReduce(list, reducer, ...args) {
1480
+ const reduceCallback = (sum, value, index) => reducer((0, vue.toValue)(sum), (0, vue.toValue)(value), index);
1481
+ return (0, vue.computed)(() => {
1482
+ const resolved = (0, vue.toValue)(list);
1483
+ return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? (0, vue.toValue)(args[0]()) : (0, vue.toValue)(args[0])) : resolved.reduce(reduceCallback);
1484
+ });
1485
+ }
1482
1486
 
1483
1487
  //#endregion
1484
1488
  //#region useArraySome/index.ts
1485
1489
  /**
1486
- * Reactive `Array.some`
1487
- *
1488
- * @see https://vueuse.org/useArraySome
1489
- * @param list - the array was called upon.
1490
- * @param fn - a function to test each element.
1491
- *
1492
- * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
1493
- *
1494
- * @__NO_SIDE_EFFECTS__
1495
- */
1496
- function useArraySome(list, fn) {
1497
- return (0, vue.computed)(() => (0, vue.toValue)(list).some((element, index, array) => fn((0, vue.toValue)(element), index, array)));
1498
- }
1490
+ * Reactive `Array.some`
1491
+ *
1492
+ * @see https://vueuse.org/useArraySome
1493
+ * @param list - the array was called upon.
1494
+ * @param fn - a function to test each element.
1495
+ *
1496
+ * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
1497
+ *
1498
+ * @__NO_SIDE_EFFECTS__
1499
+ */
1500
+ function useArraySome(list, fn) {
1501
+ return (0, vue.computed)(() => (0, vue.toValue)(list).some((element, index, array) => fn((0, vue.toValue)(element), index, array)));
1502
+ }
1499
1503
 
1500
1504
  //#endregion
1501
1505
  //#region useArrayUnique/index.ts
1502
- function uniq(array) {
1503
- return Array.from(new Set(array));
1504
- }
1505
- function uniqueElementsBy(array, fn) {
1506
- return array.reduce((acc, v) => {
1507
- if (!acc.some((x) => fn(v, x, array))) acc.push(v);
1508
- return acc;
1509
- }, []);
1510
- }
1511
- /**
1512
- * reactive unique array
1513
- * @see https://vueuse.org/useArrayUnique
1514
- * @param list - the array was called upon.
1515
- * @param compareFn
1516
- * @returns A computed ref that returns a unique array of items.
1517
- *
1518
- * @__NO_SIDE_EFFECTS__
1519
- */
1520
- function useArrayUnique(list, compareFn) {
1521
- return (0, vue.computed)(() => {
1522
- const resolvedList = (0, vue.toValue)(list).map((element) => (0, vue.toValue)(element));
1523
- return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1524
- });
1525
- }
1506
+ function uniq(array) {
1507
+ return Array.from(new Set(array));
1508
+ }
1509
+ function uniqueElementsBy(array, fn) {
1510
+ return array.reduce((acc, v) => {
1511
+ if (!acc.some((x) => fn(v, x, array))) acc.push(v);
1512
+ return acc;
1513
+ }, []);
1514
+ }
1515
+ /**
1516
+ * reactive unique array
1517
+ * @see https://vueuse.org/useArrayUnique
1518
+ * @param list - the array was called upon.
1519
+ * @param compareFn
1520
+ * @returns A computed ref that returns a unique array of items.
1521
+ *
1522
+ * @__NO_SIDE_EFFECTS__
1523
+ */
1524
+ function useArrayUnique(list, compareFn) {
1525
+ return (0, vue.computed)(() => {
1526
+ const resolvedList = (0, vue.toValue)(list).map((element) => (0, vue.toValue)(element));
1527
+ return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1528
+ });
1529
+ }
1526
1530
 
1527
1531
  //#endregion
1528
1532
  //#region useCounter/index.ts
1529
1533
  /**
1530
- * Basic counter with utility functions.
1531
- *
1532
- * @see https://vueuse.org/useCounter
1533
- * @param [initialValue]
1534
- * @param options
1535
- */
1536
- function useCounter(initialValue = 0, options = {}) {
1537
- let _initialValue = (0, vue.unref)(initialValue);
1538
- const count = (0, vue.shallowRef)(initialValue);
1539
- const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options;
1540
- const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1541
- const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1542
- const get$1 = () => count.value;
1543
- const set$1 = (val) => count.value = Math.max(min, Math.min(max, val));
1544
- const reset = (val = _initialValue) => {
1545
- _initialValue = val;
1546
- return set$1(val);
1547
- };
1548
- return {
1549
- count: (0, vue.shallowReadonly)(count),
1550
- inc,
1551
- dec,
1552
- get: get$1,
1553
- set: set$1,
1554
- reset
1555
- };
1556
- }
1534
+ * Basic counter with utility functions.
1535
+ *
1536
+ * @see https://vueuse.org/useCounter
1537
+ * @param [initialValue]
1538
+ * @param options
1539
+ */
1540
+ function useCounter(initialValue = 0, options = {}) {
1541
+ let _initialValue = (0, vue.unref)(initialValue);
1542
+ const count = (0, vue.shallowRef)(initialValue);
1543
+ const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } = options;
1544
+ const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1545
+ const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1546
+ const get$1 = () => count.value;
1547
+ const set$1 = (val) => count.value = Math.max(min, Math.min(max, val));
1548
+ const reset = (val = _initialValue) => {
1549
+ _initialValue = val;
1550
+ return set$1(val);
1551
+ };
1552
+ return {
1553
+ count: (0, vue.shallowReadonly)(count),
1554
+ inc,
1555
+ dec,
1556
+ get: get$1,
1557
+ set: set$1,
1558
+ reset
1559
+ };
1560
+ }
1557
1561
 
1558
1562
  //#endregion
1559
1563
  //#region useDateFormat/index.ts
1560
- const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
1561
- const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
1562
- function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
1563
- let m = hours < 12 ? "AM" : "PM";
1564
- if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
1565
- return isLowercase ? m.toLowerCase() : m;
1566
- }
1567
- function formatOrdinal(num) {
1568
- const suffixes = [
1569
- "th",
1570
- "st",
1571
- "nd",
1572
- "rd"
1573
- ];
1574
- const v = num % 100;
1575
- return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
1576
- }
1577
- function formatDate(date, formatStr, options = {}) {
1578
- var _options$customMeridi;
1579
- const years = date.getFullYear();
1580
- const month = date.getMonth();
1581
- const days = date.getDate();
1582
- const hours = date.getHours();
1583
- const minutes = date.getMinutes();
1584
- const seconds = date.getSeconds();
1585
- const milliseconds = date.getMilliseconds();
1586
- const day = date.getDay();
1587
- const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem;
1588
- const stripTimeZone = (dateString) => {
1589
- var _dateString$split$;
1590
- return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : "";
1591
- };
1592
- const matches = {
1593
- Yo: () => formatOrdinal(years),
1594
- YY: () => String(years).slice(-2),
1595
- YYYY: () => years,
1596
- M: () => month + 1,
1597
- Mo: () => formatOrdinal(month + 1),
1598
- MM: () => `${month + 1}`.padStart(2, "0"),
1599
- MMM: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { month: "short" }),
1600
- MMMM: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { month: "long" }),
1601
- D: () => String(days),
1602
- Do: () => formatOrdinal(days),
1603
- DD: () => `${days}`.padStart(2, "0"),
1604
- H: () => String(hours),
1605
- Ho: () => formatOrdinal(hours),
1606
- HH: () => `${hours}`.padStart(2, "0"),
1607
- h: () => `${hours % 12 || 12}`.padStart(1, "0"),
1608
- ho: () => formatOrdinal(hours % 12 || 12),
1609
- hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
1610
- m: () => String(minutes),
1611
- mo: () => formatOrdinal(minutes),
1612
- mm: () => `${minutes}`.padStart(2, "0"),
1613
- s: () => String(seconds),
1614
- so: () => formatOrdinal(seconds),
1615
- ss: () => `${seconds}`.padStart(2, "0"),
1616
- SSS: () => `${milliseconds}`.padStart(3, "0"),
1617
- d: () => day,
1618
- dd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "narrow" }),
1619
- ddd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "short" }),
1620
- dddd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "long" }),
1621
- A: () => meridiem(hours, minutes),
1622
- AA: () => meridiem(hours, minutes, false, true),
1623
- a: () => meridiem(hours, minutes, true),
1624
- aa: () => meridiem(hours, minutes, true, true),
1625
- z: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })),
1626
- zz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })),
1627
- zzz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })),
1628
- zzzz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "longOffset" }))
1629
- };
1630
- return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1631
- var _ref, _matches$match;
1632
- return (_ref = $1 !== null && $1 !== void 0 ? $1 : (_matches$match = matches[match]) === null || _matches$match === void 0 ? void 0 : _matches$match.call(matches)) !== null && _ref !== void 0 ? _ref : match;
1633
- });
1634
- }
1635
- function normalizeDate(date) {
1636
- if (date === null) return /* @__PURE__ */ new Date(NaN);
1637
- if (date === void 0) return /* @__PURE__ */ new Date();
1638
- if (date instanceof Date) return new Date(date);
1639
- if (typeof date === "string" && !/Z$/i.test(date)) {
1640
- const d = date.match(REGEX_PARSE);
1641
- if (d) {
1642
- const m = d[2] - 1 || 0;
1643
- const ms = (d[7] || "0").substring(0, 3);
1644
- return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
1564
+ const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
1565
+ const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
1566
+ function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
1567
+ let m = hours < 12 ? "AM" : "PM";
1568
+ if (hasPeriod) m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
1569
+ return isLowercase ? m.toLowerCase() : m;
1570
+ }
1571
+ function formatOrdinal(num) {
1572
+ const suffixes = [
1573
+ "th",
1574
+ "st",
1575
+ "nd",
1576
+ "rd"
1577
+ ];
1578
+ const v = num % 100;
1579
+ return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
1580
+ }
1581
+ function formatDate(date, formatStr, options = {}) {
1582
+ var _options$customMeridi;
1583
+ const years = date.getFullYear();
1584
+ const month = date.getMonth();
1585
+ const days = date.getDate();
1586
+ const hours = date.getHours();
1587
+ const minutes = date.getMinutes();
1588
+ const seconds = date.getSeconds();
1589
+ const milliseconds = date.getMilliseconds();
1590
+ const day = date.getDay();
1591
+ const meridiem = (_options$customMeridi = options.customMeridiem) !== null && _options$customMeridi !== void 0 ? _options$customMeridi : defaultMeridiem;
1592
+ const stripTimeZone = (dateString) => {
1593
+ var _dateString$split$;
1594
+ return (_dateString$split$ = dateString.split(" ")[1]) !== null && _dateString$split$ !== void 0 ? _dateString$split$ : "";
1595
+ };
1596
+ const matches = {
1597
+ Yo: () => formatOrdinal(years),
1598
+ YY: () => String(years).slice(-2),
1599
+ YYYY: () => years,
1600
+ M: () => month + 1,
1601
+ Mo: () => formatOrdinal(month + 1),
1602
+ MM: () => `${month + 1}`.padStart(2, "0"),
1603
+ MMM: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { month: "short" }),
1604
+ MMMM: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { month: "long" }),
1605
+ D: () => String(days),
1606
+ Do: () => formatOrdinal(days),
1607
+ DD: () => `${days}`.padStart(2, "0"),
1608
+ H: () => String(hours),
1609
+ Ho: () => formatOrdinal(hours),
1610
+ HH: () => `${hours}`.padStart(2, "0"),
1611
+ h: () => `${hours % 12 || 12}`.padStart(1, "0"),
1612
+ ho: () => formatOrdinal(hours % 12 || 12),
1613
+ hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
1614
+ m: () => String(minutes),
1615
+ mo: () => formatOrdinal(minutes),
1616
+ mm: () => `${minutes}`.padStart(2, "0"),
1617
+ s: () => String(seconds),
1618
+ so: () => formatOrdinal(seconds),
1619
+ ss: () => `${seconds}`.padStart(2, "0"),
1620
+ SSS: () => `${milliseconds}`.padStart(3, "0"),
1621
+ d: () => day,
1622
+ dd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "narrow" }),
1623
+ ddd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "short" }),
1624
+ dddd: () => date.toLocaleDateString((0, vue.toValue)(options.locales), { weekday: "long" }),
1625
+ A: () => meridiem(hours, minutes),
1626
+ AA: () => meridiem(hours, minutes, false, true),
1627
+ a: () => meridiem(hours, minutes, true),
1628
+ aa: () => meridiem(hours, minutes, true, true),
1629
+ z: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })),
1630
+ zz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })),
1631
+ zzz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "shortOffset" })),
1632
+ zzzz: () => stripTimeZone(date.toLocaleDateString((0, vue.toValue)(options.locales), { timeZoneName: "longOffset" }))
1633
+ };
1634
+ return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1635
+ var _ref, _matches$match;
1636
+ return (_ref = $1 !== null && $1 !== void 0 ? $1 : (_matches$match = matches[match]) === null || _matches$match === void 0 ? void 0 : _matches$match.call(matches)) !== null && _ref !== void 0 ? _ref : match;
1637
+ });
1638
+ }
1639
+ function normalizeDate(date) {
1640
+ if (date === null) return /* @__PURE__ */ new Date(NaN);
1641
+ if (date === void 0) return /* @__PURE__ */ new Date();
1642
+ if (date instanceof Date) return new Date(date);
1643
+ if (typeof date === "string" && !/Z$/i.test(date)) {
1644
+ const d = date.match(REGEX_PARSE);
1645
+ if (d) {
1646
+ const m = d[2] - 1 || 0;
1647
+ const ms = (d[7] || "0").substring(0, 3);
1648
+ return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
1649
+ }
1645
1650
  }
1651
+ return new Date(date);
1652
+ }
1653
+ /**
1654
+ * Get the formatted date according to the string of tokens passed in.
1655
+ *
1656
+ * @see https://vueuse.org/useDateFormat
1657
+ * @param date - The date to format, can either be a `Date` object, a timestamp, or a string
1658
+ * @param formatStr - The combination of tokens to format the date
1659
+ * @param options - UseDateFormatOptions
1660
+ *
1661
+ * @__NO_SIDE_EFFECTS__
1662
+ */
1663
+ function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1664
+ return (0, vue.computed)(() => formatDate(normalizeDate((0, vue.toValue)(date)), (0, vue.toValue)(formatStr), options));
1646
1665
  }
1647
- return new Date(date);
1648
- }
1649
- /**
1650
- * Get the formatted date according to the string of tokens passed in.
1651
- *
1652
- * @see https://vueuse.org/useDateFormat
1653
- * @param date - The date to format, can either be a `Date` object, a timestamp, or a string
1654
- * @param formatStr - The combination of tokens to format the date
1655
- * @param options - UseDateFormatOptions
1656
- *
1657
- * @__NO_SIDE_EFFECTS__
1658
- */
1659
- function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1660
- return (0, vue.computed)(() => formatDate(normalizeDate((0, vue.toValue)(date)), (0, vue.toValue)(formatStr), options));
1661
- }
1662
1666
 
1663
1667
  //#endregion
1664
1668
  //#region useIntervalFn/index.ts
1665
1669
  /**
1666
- * Wrapper for `setInterval` with controls
1667
- *
1668
- * @see https://vueuse.org/useIntervalFn
1669
- * @param cb
1670
- * @param interval
1671
- * @param options
1672
- */
1673
- function useIntervalFn(cb, interval = 1e3, options = {}) {
1674
- const { immediate = true, immediateCallback = false } = options;
1675
- let timer = null;
1676
- const isActive = (0, vue.shallowRef)(false);
1677
- function clean() {
1678
- if (timer) {
1679
- clearInterval(timer);
1680
- timer = null;
1670
+ * Wrapper for `setInterval` with controls
1671
+ *
1672
+ * @see https://vueuse.org/useIntervalFn
1673
+ * @param cb
1674
+ * @param interval
1675
+ * @param options
1676
+ */
1677
+ function useIntervalFn(cb, interval = 1e3, options = {}) {
1678
+ const { immediate = true, immediateCallback = false } = options;
1679
+ let timer = null;
1680
+ const isActive = (0, vue.shallowRef)(false);
1681
+ function clean() {
1682
+ if (timer) {
1683
+ clearInterval(timer);
1684
+ timer = null;
1685
+ }
1681
1686
  }
1687
+ function pause() {
1688
+ isActive.value = false;
1689
+ clean();
1690
+ }
1691
+ function resume() {
1692
+ const intervalValue = (0, vue.toValue)(interval);
1693
+ if (intervalValue <= 0) return;
1694
+ isActive.value = true;
1695
+ if (immediateCallback) cb();
1696
+ clean();
1697
+ if (isActive.value) timer = setInterval(cb, intervalValue);
1698
+ }
1699
+ if (immediate && isClient) resume();
1700
+ if ((0, vue.isRef)(interval) || typeof interval === "function") {
1701
+ const stopWatch = (0, vue.watch)(interval, () => {
1702
+ if (isActive.value && isClient) resume();
1703
+ });
1704
+ tryOnScopeDispose(stopWatch);
1705
+ }
1706
+ tryOnScopeDispose(pause);
1707
+ return {
1708
+ isActive: (0, vue.shallowReadonly)(isActive),
1709
+ pause,
1710
+ resume
1711
+ };
1682
1712
  }
1683
- function pause() {
1684
- isActive.value = false;
1685
- clean();
1686
- }
1687
- function resume() {
1688
- const intervalValue = (0, vue.toValue)(interval);
1689
- if (intervalValue <= 0) return;
1690
- isActive.value = true;
1691
- if (immediateCallback) cb();
1692
- clean();
1693
- if (isActive.value) timer = setInterval(cb, intervalValue);
1694
- }
1695
- if (immediate && isClient) resume();
1696
- if ((0, vue.isRef)(interval) || typeof interval === "function") {
1697
- const stopWatch = (0, vue.watch)(interval, () => {
1698
- if (isActive.value && isClient) resume();
1699
- });
1700
- tryOnScopeDispose(stopWatch);
1701
- }
1702
- tryOnScopeDispose(pause);
1703
- return {
1704
- isActive: (0, vue.shallowReadonly)(isActive),
1705
- pause,
1706
- resume
1707
- };
1708
- }
1709
1713
 
1710
1714
  //#endregion
1711
1715
  //#region useInterval/index.ts
1712
- function useInterval(interval = 1e3, options = {}) {
1713
- const { controls: exposeControls = false, immediate = true, callback } = options;
1714
- const counter = (0, vue.shallowRef)(0);
1715
- const update = () => counter.value += 1;
1716
- const reset = () => {
1717
- counter.value = 0;
1718
- };
1719
- const controls = useIntervalFn(callback ? () => {
1720
- update();
1721
- callback(counter.value);
1722
- } : update, interval, { immediate });
1723
- if (exposeControls) return {
1724
- counter: (0, vue.shallowReadonly)(counter),
1725
- reset,
1726
- ...controls
1727
- };
1728
- else return (0, vue.shallowReadonly)(counter);
1729
- }
1716
+ function useInterval(interval = 1e3, options = {}) {
1717
+ const { controls: exposeControls = false, immediate = true, callback } = options;
1718
+ const counter = (0, vue.shallowRef)(0);
1719
+ const update = () => counter.value += 1;
1720
+ const reset = () => {
1721
+ counter.value = 0;
1722
+ };
1723
+ const controls = useIntervalFn(callback ? () => {
1724
+ update();
1725
+ callback(counter.value);
1726
+ } : update, interval, { immediate });
1727
+ if (exposeControls) return {
1728
+ counter: (0, vue.shallowReadonly)(counter),
1729
+ reset,
1730
+ ...controls
1731
+ };
1732
+ else return (0, vue.shallowReadonly)(counter);
1733
+ }
1730
1734
 
1731
1735
  //#endregion
1732
1736
  //#region useLastChanged/index.ts
1733
- function useLastChanged(source, options = {}) {
1734
- var _options$initialValue;
1735
- const ms = (0, vue.shallowRef)((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null);
1736
- (0, vue.watch)(source, () => ms.value = timestamp(), options);
1737
- return (0, vue.shallowReadonly)(ms);
1738
- }
1737
+ function useLastChanged(source, options = {}) {
1738
+ var _options$initialValue;
1739
+ const ms = (0, vue.shallowRef)((_options$initialValue = options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : null);
1740
+ (0, vue.watch)(source, () => ms.value = timestamp(), options);
1741
+ return (0, vue.shallowReadonly)(ms);
1742
+ }
1739
1743
 
1740
1744
  //#endregion
1741
1745
  //#region useTimeoutFn/index.ts
1742
1746
  /**
1743
- * Wrapper for `setTimeout` with controls.
1744
- *
1745
- * @param cb
1746
- * @param interval
1747
- * @param options
1748
- */
1749
- function useTimeoutFn(cb, interval, options = {}) {
1750
- const { immediate = true, immediateCallback = false } = options;
1751
- const isPending = (0, vue.shallowRef)(false);
1752
- let timer;
1753
- function clear() {
1754
- if (timer) {
1755
- clearTimeout(timer);
1756
- timer = void 0;
1747
+ * Wrapper for `setTimeout` with controls.
1748
+ *
1749
+ * @param cb
1750
+ * @param interval
1751
+ * @param options
1752
+ */
1753
+ function useTimeoutFn(cb, interval, options = {}) {
1754
+ const { immediate = true, immediateCallback = false } = options;
1755
+ const isPending = (0, vue.shallowRef)(false);
1756
+ let timer;
1757
+ function clear() {
1758
+ if (timer) {
1759
+ clearTimeout(timer);
1760
+ timer = void 0;
1761
+ }
1757
1762
  }
1758
- }
1759
- function stop() {
1760
- isPending.value = false;
1761
- clear();
1762
- }
1763
- function start(...args) {
1764
- if (immediateCallback) cb();
1765
- clear();
1766
- isPending.value = true;
1767
- timer = setTimeout(() => {
1763
+ function stop() {
1768
1764
  isPending.value = false;
1769
- timer = void 0;
1770
- cb(...args);
1771
- }, (0, vue.toValue)(interval));
1772
- }
1773
- if (immediate) {
1774
- isPending.value = true;
1775
- if (isClient) start();
1765
+ clear();
1766
+ }
1767
+ function start(...args) {
1768
+ if (immediateCallback) cb();
1769
+ clear();
1770
+ isPending.value = true;
1771
+ timer = setTimeout(() => {
1772
+ isPending.value = false;
1773
+ timer = void 0;
1774
+ cb(...args);
1775
+ }, (0, vue.toValue)(interval));
1776
+ }
1777
+ if (immediate) {
1778
+ isPending.value = true;
1779
+ if (isClient) start();
1780
+ }
1781
+ tryOnScopeDispose(stop);
1782
+ return {
1783
+ isPending: (0, vue.shallowReadonly)(isPending),
1784
+ start,
1785
+ stop
1786
+ };
1776
1787
  }
1777
- tryOnScopeDispose(stop);
1778
- return {
1779
- isPending: (0, vue.shallowReadonly)(isPending),
1780
- start,
1781
- stop
1782
- };
1783
- }
1784
1788
 
1785
1789
  //#endregion
1786
1790
  //#region useTimeout/index.ts
1787
- function useTimeout(interval = 1e3, options = {}) {
1788
- const { controls: exposeControls = false, callback } = options;
1789
- const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options);
1790
- const ready = (0, vue.computed)(() => !controls.isPending.value);
1791
- if (exposeControls) return {
1792
- ready,
1793
- ...controls
1794
- };
1795
- else return ready;
1796
- }
1791
+ function useTimeout(interval = 1e3, options = {}) {
1792
+ const { controls: exposeControls = false, callback } = options;
1793
+ const controls = useTimeoutFn(callback !== null && callback !== void 0 ? callback : noop, interval, options);
1794
+ const ready = (0, vue.computed)(() => !controls.isPending.value);
1795
+ if (exposeControls) return {
1796
+ ready,
1797
+ ...controls
1798
+ };
1799
+ else return ready;
1800
+ }
1797
1801
 
1798
1802
  //#endregion
1799
1803
  //#region useToNumber/index.ts
1800
1804
  /**
1801
- * Reactively convert a string ref to number.
1802
- *
1803
- * @__NO_SIDE_EFFECTS__
1804
- */
1805
- function useToNumber(value, options = {}) {
1806
- const { method = "parseFloat", radix, nanToZero } = options;
1807
- return (0, vue.computed)(() => {
1808
- let resolved = (0, vue.toValue)(value);
1809
- if (typeof method === "function") resolved = method(resolved);
1810
- else if (typeof resolved === "string") resolved = Number[method](resolved, radix);
1811
- if (nanToZero && Number.isNaN(resolved)) resolved = 0;
1812
- return resolved;
1813
- });
1814
- }
1805
+ * Reactively convert a string ref to number.
1806
+ *
1807
+ * @__NO_SIDE_EFFECTS__
1808
+ */
1809
+ function useToNumber(value, options = {}) {
1810
+ const { method = "parseFloat", radix, nanToZero } = options;
1811
+ return (0, vue.computed)(() => {
1812
+ let resolved = (0, vue.toValue)(value);
1813
+ if (typeof method === "function") resolved = method(resolved);
1814
+ else if (typeof resolved === "string") resolved = Number[method](resolved, radix);
1815
+ if (nanToZero && Number.isNaN(resolved)) resolved = 0;
1816
+ return resolved;
1817
+ });
1818
+ }
1815
1819
 
1816
1820
  //#endregion
1817
1821
  //#region useToString/index.ts
1818
1822
  /**
1819
- * Reactively convert a ref to string.
1820
- *
1821
- * @see https://vueuse.org/useToString
1822
- *
1823
- * @__NO_SIDE_EFFECTS__
1824
- */
1825
- function useToString(value) {
1826
- return (0, vue.computed)(() => `${(0, vue.toValue)(value)}`);
1827
- }
1823
+ * Reactively convert a ref to string.
1824
+ *
1825
+ * @see https://vueuse.org/useToString
1826
+ *
1827
+ * @__NO_SIDE_EFFECTS__
1828
+ */
1829
+ function useToString(value) {
1830
+ return (0, vue.computed)(() => `${(0, vue.toValue)(value)}`);
1831
+ }
1828
1832
 
1829
1833
  //#endregion
1830
1834
  //#region useToggle/index.ts
1831
1835
  /**
1832
- * A boolean ref with a toggler
1833
- *
1834
- * @see https://vueuse.org/useToggle
1835
- * @param [initialValue]
1836
- * @param options
1837
- *
1838
- * @__NO_SIDE_EFFECTS__
1839
- */
1840
- function useToggle(initialValue = false, options = {}) {
1841
- const { truthyValue = true, falsyValue = false } = options;
1842
- const valueIsRef = (0, vue.isRef)(initialValue);
1843
- const _value = (0, vue.shallowRef)(initialValue);
1844
- function toggle(value) {
1845
- if (arguments.length) {
1846
- _value.value = value;
1847
- return _value.value;
1848
- } else {
1849
- const truthy = (0, vue.toValue)(truthyValue);
1850
- _value.value = _value.value === truthy ? (0, vue.toValue)(falsyValue) : truthy;
1851
- return _value.value;
1836
+ * A boolean ref with a toggler
1837
+ *
1838
+ * @see https://vueuse.org/useToggle
1839
+ * @param [initialValue]
1840
+ * @param options
1841
+ *
1842
+ * @__NO_SIDE_EFFECTS__
1843
+ */
1844
+ function useToggle(initialValue = false, options = {}) {
1845
+ const { truthyValue = true, falsyValue = false } = options;
1846
+ const valueIsRef = (0, vue.isRef)(initialValue);
1847
+ const _value = (0, vue.shallowRef)(initialValue);
1848
+ function toggle(value) {
1849
+ if (arguments.length) {
1850
+ _value.value = value;
1851
+ return _value.value;
1852
+ } else {
1853
+ const truthy = (0, vue.toValue)(truthyValue);
1854
+ _value.value = _value.value === truthy ? (0, vue.toValue)(falsyValue) : truthy;
1855
+ return _value.value;
1856
+ }
1852
1857
  }
1858
+ if (valueIsRef) return toggle;
1859
+ else return [_value, toggle];
1853
1860
  }
1854
- if (valueIsRef) return toggle;
1855
- else return [_value, toggle];
1856
- }
1857
1861
 
1858
1862
  //#endregion
1859
1863
  //#region watchArray/index.ts
1860
1864
  /**
1861
- * Watch for an array with additions and removals.
1862
- *
1863
- * @see https://vueuse.org/watchArray
1864
- */
1865
- function watchArray(source, cb, options) {
1866
- let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : (0, vue.toValue)(source)];
1867
- return (0, vue.watch)(source, (newList, _, onCleanup) => {
1868
- const oldListRemains = Array.from({ length: oldList.length });
1869
- const added = [];
1870
- for (const obj of newList) {
1871
- let found = false;
1872
- for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) {
1873
- oldListRemains[i] = true;
1874
- found = true;
1875
- break;
1865
+ * Watch for an array with additions and removals.
1866
+ *
1867
+ * @see https://vueuse.org/watchArray
1868
+ */
1869
+ function watchArray(source, cb, options) {
1870
+ let oldList = (options === null || options === void 0 ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : (0, vue.toValue)(source)];
1871
+ return (0, vue.watch)(source, (newList, _, onCleanup) => {
1872
+ const oldListRemains = Array.from({ length: oldList.length });
1873
+ const added = [];
1874
+ for (const obj of newList) {
1875
+ let found = false;
1876
+ for (let i = 0; i < oldList.length; i++) if (!oldListRemains[i] && obj === oldList[i]) {
1877
+ oldListRemains[i] = true;
1878
+ found = true;
1879
+ break;
1880
+ }
1881
+ if (!found) added.push(obj);
1876
1882
  }
1877
- if (!found) added.push(obj);
1878
- }
1879
- const removed = oldList.filter((_$1, i) => !oldListRemains[i]);
1880
- cb(newList, oldList, added, removed, onCleanup);
1881
- oldList = [...newList];
1882
- }, options);
1883
- }
1883
+ const removed = oldList.filter((_$1, i) => !oldListRemains[i]);
1884
+ cb(newList, oldList, added, removed, onCleanup);
1885
+ oldList = [...newList];
1886
+ }, options);
1887
+ }
1884
1888
 
1885
1889
  //#endregion
1886
1890
  //#region watchAtMost/index.ts
1887
- function watchAtMost(source, cb, options) {
1888
- const { count,...watchOptions } = options;
1889
- const current = (0, vue.shallowRef)(0);
1890
- const stop = watchWithFilter(source, (...args) => {
1891
- current.value += 1;
1892
- if (current.value >= (0, vue.toValue)(count)) (0, vue.nextTick)(() => stop());
1893
- cb(...args);
1894
- }, watchOptions);
1895
- return {
1896
- count: current,
1897
- stop
1898
- };
1899
- }
1891
+ function watchAtMost(source, cb, options) {
1892
+ const { count,...watchOptions } = options;
1893
+ const current = (0, vue.shallowRef)(0);
1894
+ const { stop, resume, pause } = watchWithFilter(source, (...args) => {
1895
+ current.value += 1;
1896
+ if (current.value >= (0, vue.toValue)(count)) (0, vue.nextTick)(() => stop());
1897
+ cb(...args);
1898
+ }, watchOptions);
1899
+ return {
1900
+ count: current,
1901
+ stop,
1902
+ resume,
1903
+ pause
1904
+ };
1905
+ }
1900
1906
 
1901
1907
  //#endregion
1902
1908
  //#region watchDebounced/index.ts
1903
- function watchDebounced(source, cb, options = {}) {
1904
- const { debounce = 0, maxWait = void 0,...watchOptions } = options;
1905
- return watchWithFilter(source, cb, {
1906
- ...watchOptions,
1907
- eventFilter: debounceFilter(debounce, { maxWait })
1908
- });
1909
- }
1910
- /** @deprecated use `watchDebounced` instead */
1911
- const debouncedWatch = watchDebounced;
1909
+ function watchDebounced(source, cb, options = {}) {
1910
+ const { debounce = 0, maxWait = void 0,...watchOptions } = options;
1911
+ return watchWithFilter(source, cb, {
1912
+ ...watchOptions,
1913
+ eventFilter: debounceFilter(debounce, { maxWait })
1914
+ });
1915
+ }
1916
+ /** @deprecated use `watchDebounced` instead */
1917
+ const debouncedWatch = watchDebounced;
1912
1918
 
1913
1919
  //#endregion
1914
1920
  //#region watchDeep/index.ts
1915
1921
  /**
1916
- * Shorthand for watching value with {deep: true}
1917
- *
1918
- * @see https://vueuse.org/watchDeep
1919
- */
1920
- function watchDeep(source, cb, options) {
1921
- return (0, vue.watch)(source, cb, {
1922
- ...options,
1923
- deep: true
1924
- });
1925
- }
1922
+ * Shorthand for watching value with {deep: true}
1923
+ *
1924
+ * @see https://vueuse.org/watchDeep
1925
+ */
1926
+ function watchDeep(source, cb, options) {
1927
+ return (0, vue.watch)(source, cb, {
1928
+ ...options,
1929
+ deep: true
1930
+ });
1931
+ }
1926
1932
 
1927
1933
  //#endregion
1928
1934
  //#region watchIgnorable/index.ts
1929
- function watchIgnorable(source, cb, options = {}) {
1930
- const { eventFilter = bypassFilter,...watchOptions } = options;
1931
- const filteredCb = createFilterWrapper(eventFilter, cb);
1932
- let ignoreUpdates;
1933
- let ignorePrevAsyncUpdates;
1934
- let stop;
1935
- if (watchOptions.flush === "sync") {
1936
- let ignore = false;
1937
- ignorePrevAsyncUpdates = () => {};
1938
- ignoreUpdates = (updater) => {
1939
- ignore = true;
1940
- updater();
1941
- ignore = false;
1942
- };
1943
- stop = (0, vue.watch)(source, (...args) => {
1944
- if (!ignore) filteredCb(...args);
1945
- }, watchOptions);
1946
- } else {
1947
- const disposables = [];
1948
- let ignoreCounter = 0;
1949
- let syncCounter = 0;
1950
- ignorePrevAsyncUpdates = () => {
1951
- ignoreCounter = syncCounter;
1952
- };
1953
- disposables.push((0, vue.watch)(source, () => {
1954
- syncCounter++;
1955
- }, {
1956
- ...watchOptions,
1957
- flush: "sync"
1958
- }));
1959
- ignoreUpdates = (updater) => {
1960
- const syncCounterPrev = syncCounter;
1961
- updater();
1962
- ignoreCounter += syncCounter - syncCounterPrev;
1963
- };
1964
- disposables.push((0, vue.watch)(source, (...args) => {
1965
- const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
1966
- ignoreCounter = 0;
1967
- syncCounter = 0;
1968
- if (ignore) return;
1969
- filteredCb(...args);
1970
- }, watchOptions));
1971
- stop = () => {
1972
- disposables.forEach((fn) => fn());
1935
+ function watchIgnorable(source, cb, options = {}) {
1936
+ const { eventFilter = bypassFilter,...watchOptions } = options;
1937
+ const filteredCb = createFilterWrapper(eventFilter, cb);
1938
+ let ignoreUpdates;
1939
+ let ignorePrevAsyncUpdates;
1940
+ let stop;
1941
+ if (watchOptions.flush === "sync") {
1942
+ let ignore = false;
1943
+ ignorePrevAsyncUpdates = () => {};
1944
+ ignoreUpdates = (updater) => {
1945
+ ignore = true;
1946
+ updater();
1947
+ ignore = false;
1948
+ };
1949
+ stop = (0, vue.watch)(source, (...args) => {
1950
+ if (!ignore) filteredCb(...args);
1951
+ }, watchOptions);
1952
+ } else {
1953
+ const disposables = [];
1954
+ let ignoreCounter = 0;
1955
+ let syncCounter = 0;
1956
+ ignorePrevAsyncUpdates = () => {
1957
+ ignoreCounter = syncCounter;
1958
+ };
1959
+ disposables.push((0, vue.watch)(source, () => {
1960
+ syncCounter++;
1961
+ }, {
1962
+ ...watchOptions,
1963
+ flush: "sync"
1964
+ }));
1965
+ ignoreUpdates = (updater) => {
1966
+ const syncCounterPrev = syncCounter;
1967
+ updater();
1968
+ ignoreCounter += syncCounter - syncCounterPrev;
1969
+ };
1970
+ disposables.push((0, vue.watch)(source, (...args) => {
1971
+ const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
1972
+ ignoreCounter = 0;
1973
+ syncCounter = 0;
1974
+ if (ignore) return;
1975
+ filteredCb(...args);
1976
+ }, watchOptions));
1977
+ stop = () => {
1978
+ disposables.forEach((fn) => fn());
1979
+ };
1980
+ }
1981
+ return {
1982
+ stop,
1983
+ ignoreUpdates,
1984
+ ignorePrevAsyncUpdates
1973
1985
  };
1974
1986
  }
1975
- return {
1976
- stop,
1977
- ignoreUpdates,
1978
- ignorePrevAsyncUpdates
1979
- };
1980
- }
1981
- /** @deprecated use `watchIgnorable` instead */
1982
- const ignorableWatch = watchIgnorable;
1987
+ /** @deprecated use `watchIgnorable` instead */
1988
+ const ignorableWatch = watchIgnorable;
1983
1989
 
1984
1990
  //#endregion
1985
1991
  //#region watchImmediate/index.ts
1986
1992
  /**
1987
- * Shorthand for watching value with {immediate: true}
1988
- *
1989
- * @see https://vueuse.org/watchImmediate
1990
- */
1991
- function watchImmediate(source, cb, options) {
1992
- return (0, vue.watch)(source, cb, {
1993
- ...options,
1994
- immediate: true
1995
- });
1996
- }
1993
+ * Shorthand for watching value with {immediate: true}
1994
+ *
1995
+ * @see https://vueuse.org/watchImmediate
1996
+ */
1997
+ function watchImmediate(source, cb, options) {
1998
+ return (0, vue.watch)(source, cb, {
1999
+ ...options,
2000
+ immediate: true
2001
+ });
2002
+ }
1997
2003
 
1998
2004
  //#endregion
1999
2005
  //#region watchOnce/index.ts
2000
2006
  /**
2001
- * Shorthand for watching value with { once: true }
2002
- *
2003
- * @see https://vueuse.org/watchOnce
2004
- */
2005
- function watchOnce(source, cb, options) {
2006
- return (0, vue.watch)(source, cb, {
2007
- ...options,
2008
- once: true
2009
- });
2010
- }
2007
+ * Shorthand for watching value with { once: true }
2008
+ *
2009
+ * @see https://vueuse.org/watchOnce
2010
+ */
2011
+ function watchOnce(source, cb, options) {
2012
+ return (0, vue.watch)(source, cb, {
2013
+ ...options,
2014
+ once: true
2015
+ });
2016
+ }
2011
2017
 
2012
2018
  //#endregion
2013
2019
  //#region watchThrottled/index.ts
2014
- function watchThrottled(source, cb, options = {}) {
2015
- const { throttle = 0, trailing = true, leading = true,...watchOptions } = options;
2016
- return watchWithFilter(source, cb, {
2017
- ...watchOptions,
2018
- eventFilter: throttleFilter(throttle, trailing, leading)
2019
- });
2020
- }
2021
- /** @deprecated use `watchThrottled` instead */
2022
- const throttledWatch = watchThrottled;
2020
+ function watchThrottled(source, cb, options = {}) {
2021
+ const { throttle = 0, trailing = true, leading = true,...watchOptions } = options;
2022
+ return watchWithFilter(source, cb, {
2023
+ ...watchOptions,
2024
+ eventFilter: throttleFilter(throttle, trailing, leading)
2025
+ });
2026
+ }
2027
+ /** @deprecated use `watchThrottled` instead */
2028
+ const throttledWatch = watchThrottled;
2023
2029
 
2024
2030
  //#endregion
2025
2031
  //#region watchTriggerable/index.ts
2026
- function watchTriggerable(source, cb, options = {}) {
2027
- let cleanupFn;
2028
- function onEffect() {
2029
- if (!cleanupFn) return;
2030
- const fn = cleanupFn;
2031
- cleanupFn = void 0;
2032
- fn();
2033
- }
2034
- /** Register the function `cleanupFn` */
2035
- function onCleanup(callback) {
2036
- cleanupFn = callback;
2037
- }
2038
- const _cb = (value, oldValue) => {
2039
- onEffect();
2040
- return cb(value, oldValue, onCleanup);
2041
- };
2042
- const res = watchIgnorable(source, _cb, options);
2043
- const { ignoreUpdates } = res;
2044
- const trigger = () => {
2045
- let res$1;
2046
- ignoreUpdates(() => {
2047
- res$1 = _cb(getWatchSources(source), getOldValue(source));
2048
- });
2049
- return res$1;
2050
- };
2051
- return {
2052
- ...res,
2053
- trigger
2054
- };
2055
- }
2056
- function getWatchSources(sources) {
2057
- if ((0, vue.isReactive)(sources)) return sources;
2058
- if (Array.isArray(sources)) return sources.map((item) => (0, vue.toValue)(item));
2059
- return (0, vue.toValue)(sources);
2060
- }
2061
- function getOldValue(source) {
2062
- return Array.isArray(source) ? source.map(() => void 0) : void 0;
2063
- }
2032
+ function watchTriggerable(source, cb, options = {}) {
2033
+ let cleanupFn;
2034
+ function onEffect() {
2035
+ if (!cleanupFn) return;
2036
+ const fn = cleanupFn;
2037
+ cleanupFn = void 0;
2038
+ fn();
2039
+ }
2040
+ /** Register the function `cleanupFn` */
2041
+ function onCleanup(callback) {
2042
+ cleanupFn = callback;
2043
+ }
2044
+ const _cb = (value, oldValue) => {
2045
+ onEffect();
2046
+ return cb(value, oldValue, onCleanup);
2047
+ };
2048
+ const res = watchIgnorable(source, _cb, options);
2049
+ const { ignoreUpdates } = res;
2050
+ const trigger = () => {
2051
+ let res$1;
2052
+ ignoreUpdates(() => {
2053
+ res$1 = _cb(getWatchSources(source), getOldValue(source));
2054
+ });
2055
+ return res$1;
2056
+ };
2057
+ return {
2058
+ ...res,
2059
+ trigger
2060
+ };
2061
+ }
2062
+ function getWatchSources(sources) {
2063
+ if ((0, vue.isReactive)(sources)) return sources;
2064
+ if (Array.isArray(sources)) return sources.map((item) => (0, vue.toValue)(item));
2065
+ return (0, vue.toValue)(sources);
2066
+ }
2067
+ function getOldValue(source) {
2068
+ return Array.isArray(source) ? source.map(() => void 0) : void 0;
2069
+ }
2064
2070
 
2065
2071
  //#endregion
2066
2072
  //#region whenever/index.ts
2067
2073
  /**
2068
- * Shorthand for watching value to be truthy
2069
- *
2070
- * @see https://vueuse.org/whenever
2071
- */
2072
- function whenever(source, cb, options) {
2073
- const stop = (0, vue.watch)(source, (v, ov, onInvalidate) => {
2074
- if (v) {
2075
- if (options === null || options === void 0 ? void 0 : options.once) (0, vue.nextTick)(() => stop());
2076
- cb(v, ov, onInvalidate);
2077
- }
2078
- }, {
2079
- ...options,
2080
- once: false
2081
- });
2082
- return stop;
2083
- }
2074
+ * Shorthand for watching value to be truthy
2075
+ *
2076
+ * @see https://vueuse.org/whenever
2077
+ */
2078
+ function whenever(source, cb, options) {
2079
+ const stop = (0, vue.watch)(source, (v, ov, onInvalidate) => {
2080
+ if (v) {
2081
+ if (options === null || options === void 0 ? void 0 : options.once) (0, vue.nextTick)(() => stop());
2082
+ cb(v, ov, onInvalidate);
2083
+ }
2084
+ }, {
2085
+ ...options,
2086
+ once: false
2087
+ });
2088
+ return stop;
2089
+ }
2084
2090
 
2085
2091
  //#endregion
2086
2092
  exports.assert = assert;