智慧水务管理系统 - 精河县供水工程综合管理平台

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