index.cjs 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681
  1. 'use strict';
  2. var vueDemi = require('vue-demi');
  3. var __defProp$9 = Object.defineProperty;
  4. var __defProps$6 = Object.defineProperties;
  5. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  6. var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
  7. var __hasOwnProp$b = Object.prototype.hasOwnProperty;
  8. var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
  9. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  10. var __spreadValues$9 = (a, b) => {
  11. for (var prop in b || (b = {}))
  12. if (__hasOwnProp$b.call(b, prop))
  13. __defNormalProp$9(a, prop, b[prop]);
  14. if (__getOwnPropSymbols$b)
  15. for (var prop of __getOwnPropSymbols$b(b)) {
  16. if (__propIsEnum$b.call(b, prop))
  17. __defNormalProp$9(a, prop, b[prop]);
  18. }
  19. return a;
  20. };
  21. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  22. function computedEager(fn, options) {
  23. var _a;
  24. const result = vueDemi.shallowRef();
  25. vueDemi.watchEffect(() => {
  26. result.value = fn();
  27. }, __spreadProps$6(__spreadValues$9({}, options), {
  28. flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
  29. }));
  30. return vueDemi.readonly(result);
  31. }
  32. var _a;
  33. const isClient = typeof window !== "undefined";
  34. const isDef = (val) => typeof val !== "undefined";
  35. const assert = (condition, ...infos) => {
  36. if (!condition)
  37. console.warn(...infos);
  38. };
  39. const toString = Object.prototype.toString;
  40. const isBoolean = (val) => typeof val === "boolean";
  41. const isFunction = (val) => typeof val === "function";
  42. const isNumber = (val) => typeof val === "number";
  43. const isString = (val) => typeof val === "string";
  44. const isObject = (val) => toString.call(val) === "[object Object]";
  45. const isWindow = (val) => typeof window !== "undefined" && toString.call(val) === "[object Window]";
  46. const now = () => Date.now();
  47. const timestamp = () => +Date.now();
  48. const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
  49. const noop = () => {
  50. };
  51. const rand = (min, max) => {
  52. min = Math.ceil(min);
  53. max = Math.floor(max);
  54. return Math.floor(Math.random() * (max - min + 1)) + min;
  55. };
  56. const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
  57. const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
  58. function resolveUnref(r) {
  59. return typeof r === "function" ? r() : vueDemi.unref(r);
  60. }
  61. function createFilterWrapper(filter, fn) {
  62. function wrapper(...args) {
  63. return new Promise((resolve, reject) => {
  64. Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
  65. });
  66. }
  67. return wrapper;
  68. }
  69. const bypassFilter = (invoke) => {
  70. return invoke();
  71. };
  72. function debounceFilter(ms, options = {}) {
  73. let timer;
  74. let maxTimer;
  75. let lastRejector = noop;
  76. const _clearTimeout = (timer2) => {
  77. clearTimeout(timer2);
  78. lastRejector();
  79. lastRejector = noop;
  80. };
  81. const filter = (invoke) => {
  82. const duration = resolveUnref(ms);
  83. const maxDuration = resolveUnref(options.maxWait);
  84. if (timer)
  85. _clearTimeout(timer);
  86. if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
  87. if (maxTimer) {
  88. _clearTimeout(maxTimer);
  89. maxTimer = null;
  90. }
  91. return Promise.resolve(invoke());
  92. }
  93. return new Promise((resolve, reject) => {
  94. lastRejector = options.rejectOnCancel ? reject : resolve;
  95. if (maxDuration && !maxTimer) {
  96. maxTimer = setTimeout(() => {
  97. if (timer)
  98. _clearTimeout(timer);
  99. maxTimer = null;
  100. resolve(invoke());
  101. }, maxDuration);
  102. }
  103. timer = setTimeout(() => {
  104. if (maxTimer)
  105. _clearTimeout(maxTimer);
  106. maxTimer = null;
  107. resolve(invoke());
  108. }, duration);
  109. });
  110. };
  111. return filter;
  112. }
  113. function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
  114. let lastExec = 0;
  115. let timer;
  116. let isLeading = true;
  117. let lastRejector = noop;
  118. let lastValue;
  119. const clear = () => {
  120. if (timer) {
  121. clearTimeout(timer);
  122. timer = void 0;
  123. lastRejector();
  124. lastRejector = noop;
  125. }
  126. };
  127. const filter = (_invoke) => {
  128. const duration = resolveUnref(ms);
  129. const elapsed = Date.now() - lastExec;
  130. const invoke = () => {
  131. return lastValue = _invoke();
  132. };
  133. clear();
  134. if (duration <= 0) {
  135. lastExec = Date.now();
  136. return invoke();
  137. }
  138. if (elapsed > duration && (leading || !isLeading)) {
  139. lastExec = Date.now();
  140. invoke();
  141. } else if (trailing) {
  142. lastValue = new Promise((resolve, reject) => {
  143. lastRejector = rejectOnCancel ? reject : resolve;
  144. timer = setTimeout(() => {
  145. lastExec = Date.now();
  146. isLeading = true;
  147. resolve(invoke());
  148. clear();
  149. }, Math.max(0, duration - elapsed));
  150. });
  151. }
  152. if (!leading && !timer)
  153. timer = setTimeout(() => isLeading = true, duration);
  154. isLeading = false;
  155. return lastValue;
  156. };
  157. return filter;
  158. }
  159. function pausableFilter(extendFilter = bypassFilter) {
  160. const isActive = vueDemi.ref(true);
  161. function pause() {
  162. isActive.value = false;
  163. }
  164. function resume() {
  165. isActive.value = true;
  166. }
  167. const eventFilter = (...args) => {
  168. if (isActive.value)
  169. extendFilter(...args);
  170. };
  171. return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
  172. }
  173. function __onlyVue3(name = "this function") {
  174. if (vueDemi.isVue3)
  175. return;
  176. throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
  177. }
  178. function __onlyVue27Plus(name = "this function") {
  179. if (vueDemi.isVue3 || vueDemi.version.startsWith("2.7."))
  180. return;
  181. throw new Error(`[VueUse] ${name} is only works on Vue 2.7 or above.`);
  182. }
  183. const directiveHooks = {
  184. mounted: vueDemi.isVue3 ? "mounted" : "inserted",
  185. updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
  186. unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
  187. };
  188. function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
  189. return new Promise((resolve, reject) => {
  190. if (throwOnTimeout)
  191. setTimeout(() => reject(reason), ms);
  192. else
  193. setTimeout(resolve, ms);
  194. });
  195. }
  196. function identity(arg) {
  197. return arg;
  198. }
  199. function createSingletonPromise(fn) {
  200. let _promise;
  201. function wrapper() {
  202. if (!_promise)
  203. _promise = fn();
  204. return _promise;
  205. }
  206. wrapper.reset = async () => {
  207. const _prev = _promise;
  208. _promise = void 0;
  209. if (_prev)
  210. await _prev;
  211. };
  212. return wrapper;
  213. }
  214. function invoke(fn) {
  215. return fn();
  216. }
  217. function containsProp(obj, ...props) {
  218. return props.some((k) => k in obj);
  219. }
  220. function increaseWithUnit(target, delta) {
  221. var _a;
  222. if (typeof target === "number")
  223. return target + delta;
  224. const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
  225. const unit = target.slice(value.length);
  226. const result = parseFloat(value) + delta;
  227. if (Number.isNaN(result))
  228. return target;
  229. return result + unit;
  230. }
  231. function objectPick(obj, keys, omitUndefined = false) {
  232. return keys.reduce((n, k) => {
  233. if (k in obj) {
  234. if (!omitUndefined || obj[k] !== void 0)
  235. n[k] = obj[k];
  236. }
  237. return n;
  238. }, {});
  239. }
  240. function computedWithControl(source, fn) {
  241. let v = void 0;
  242. let track;
  243. let trigger;
  244. const dirty = vueDemi.ref(true);
  245. const update = () => {
  246. dirty.value = true;
  247. trigger();
  248. };
  249. vueDemi.watch(source, update, { flush: "sync" });
  250. const get = isFunction(fn) ? fn : fn.get;
  251. const set = isFunction(fn) ? void 0 : fn.set;
  252. const result = vueDemi.customRef((_track, _trigger) => {
  253. track = _track;
  254. trigger = _trigger;
  255. return {
  256. get() {
  257. if (dirty.value) {
  258. v = get();
  259. dirty.value = false;
  260. }
  261. track();
  262. return v;
  263. },
  264. set(v2) {
  265. set == null ? void 0 : set(v2);
  266. }
  267. };
  268. });
  269. if (Object.isExtensible(result))
  270. result.trigger = update;
  271. return result;
  272. }
  273. function tryOnScopeDispose(fn) {
  274. if (vueDemi.getCurrentScope()) {
  275. vueDemi.onScopeDispose(fn);
  276. return true;
  277. }
  278. return false;
  279. }
  280. function createEventHook() {
  281. const fns = [];
  282. const off = (fn) => {
  283. const index = fns.indexOf(fn);
  284. if (index !== -1)
  285. fns.splice(index, 1);
  286. };
  287. const on = (fn) => {
  288. fns.push(fn);
  289. const offFn = () => off(fn);
  290. tryOnScopeDispose(offFn);
  291. return {
  292. off: offFn
  293. };
  294. };
  295. const trigger = (param) => {
  296. fns.forEach((fn) => fn(param));
  297. };
  298. return {
  299. on,
  300. off,
  301. trigger
  302. };
  303. }
  304. function createGlobalState(stateFactory) {
  305. let initialized = false;
  306. let state;
  307. const scope = vueDemi.effectScope(true);
  308. return () => {
  309. if (!initialized) {
  310. state = scope.run(stateFactory);
  311. initialized = true;
  312. }
  313. return state;
  314. };
  315. }
  316. function createInjectionState(composable) {
  317. const key = Symbol("InjectionState");
  318. const useProvidingState = (...args) => {
  319. const state = composable(...args);
  320. vueDemi.provide(key, state);
  321. return state;
  322. };
  323. const useInjectedState = () => vueDemi.inject(key);
  324. return [useProvidingState, useInjectedState];
  325. }
  326. function createSharedComposable(composable) {
  327. let subscribers = 0;
  328. let state;
  329. let scope;
  330. const dispose = () => {
  331. subscribers -= 1;
  332. if (scope && subscribers <= 0) {
  333. scope.stop();
  334. state = void 0;
  335. scope = void 0;
  336. }
  337. };
  338. return (...args) => {
  339. subscribers += 1;
  340. if (!state) {
  341. scope = vueDemi.effectScope(true);
  342. state = scope.run(() => composable(...args));
  343. }
  344. tryOnScopeDispose(dispose);
  345. return state;
  346. };
  347. }
  348. function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
  349. __onlyVue27Plus();
  350. for (const [key, value] of Object.entries(extend)) {
  351. if (key === "value")
  352. continue;
  353. if (vueDemi.isRef(value) && unwrap) {
  354. Object.defineProperty(ref, key, {
  355. get() {
  356. return value.value;
  357. },
  358. set(v) {
  359. value.value = v;
  360. },
  361. enumerable
  362. });
  363. } else {
  364. Object.defineProperty(ref, key, { value, enumerable });
  365. }
  366. }
  367. return ref;
  368. }
  369. function get(obj, key) {
  370. if (key == null)
  371. return vueDemi.unref(obj);
  372. return vueDemi.unref(obj)[key];
  373. }
  374. function isDefined(v) {
  375. return vueDemi.unref(v) != null;
  376. }
  377. var __defProp$8 = Object.defineProperty;
  378. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  379. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  380. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  381. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  382. var __spreadValues$8 = (a, b) => {
  383. for (var prop in b || (b = {}))
  384. if (__hasOwnProp$a.call(b, prop))
  385. __defNormalProp$8(a, prop, b[prop]);
  386. if (__getOwnPropSymbols$a)
  387. for (var prop of __getOwnPropSymbols$a(b)) {
  388. if (__propIsEnum$a.call(b, prop))
  389. __defNormalProp$8(a, prop, b[prop]);
  390. }
  391. return a;
  392. };
  393. function makeDestructurable(obj, arr) {
  394. if (typeof Symbol !== "undefined") {
  395. const clone = __spreadValues$8({}, obj);
  396. Object.defineProperty(clone, Symbol.iterator, {
  397. enumerable: false,
  398. value() {
  399. let index = 0;
  400. return {
  401. next: () => ({
  402. value: arr[index++],
  403. done: index > arr.length
  404. })
  405. };
  406. }
  407. });
  408. return clone;
  409. } else {
  410. return Object.assign([...arr], obj);
  411. }
  412. }
  413. function reactify(fn, options) {
  414. const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : resolveUnref;
  415. return function(...args) {
  416. return vueDemi.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
  417. };
  418. }
  419. function reactifyObject(obj, optionsOrKeys = {}) {
  420. let keys = [];
  421. let options;
  422. if (Array.isArray(optionsOrKeys)) {
  423. keys = optionsOrKeys;
  424. } else {
  425. options = optionsOrKeys;
  426. const { includeOwnProperties = true } = optionsOrKeys;
  427. keys.push(...Object.keys(obj));
  428. if (includeOwnProperties)
  429. keys.push(...Object.getOwnPropertyNames(obj));
  430. }
  431. return Object.fromEntries(keys.map((key) => {
  432. const value = obj[key];
  433. return [
  434. key,
  435. typeof value === "function" ? reactify(value.bind(obj), options) : value
  436. ];
  437. }));
  438. }
  439. function toReactive(objectRef) {
  440. if (!vueDemi.isRef(objectRef))
  441. return vueDemi.reactive(objectRef);
  442. const proxy = new Proxy({}, {
  443. get(_, p, receiver) {
  444. return vueDemi.unref(Reflect.get(objectRef.value, p, receiver));
  445. },
  446. set(_, p, value) {
  447. if (vueDemi.isRef(objectRef.value[p]) && !vueDemi.isRef(value))
  448. objectRef.value[p].value = value;
  449. else
  450. objectRef.value[p] = value;
  451. return true;
  452. },
  453. deleteProperty(_, p) {
  454. return Reflect.deleteProperty(objectRef.value, p);
  455. },
  456. has(_, p) {
  457. return Reflect.has(objectRef.value, p);
  458. },
  459. ownKeys() {
  460. return Object.keys(objectRef.value);
  461. },
  462. getOwnPropertyDescriptor() {
  463. return {
  464. enumerable: true,
  465. configurable: true
  466. };
  467. }
  468. });
  469. return vueDemi.reactive(proxy);
  470. }
  471. function reactiveComputed(fn) {
  472. return toReactive(vueDemi.computed(fn));
  473. }
  474. function reactiveOmit(obj, ...keys) {
  475. const flatKeys = keys.flat();
  476. return reactiveComputed(() => Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
  477. }
  478. function reactivePick(obj, ...keys) {
  479. const flatKeys = keys.flat();
  480. return vueDemi.reactive(Object.fromEntries(flatKeys.map((k) => [k, vueDemi.toRef(obj, k)])));
  481. }
  482. function refAutoReset(defaultValue, afterMs = 1e4) {
  483. return vueDemi.customRef((track, trigger) => {
  484. let value = defaultValue;
  485. let timer;
  486. const resetAfter = () => setTimeout(() => {
  487. value = defaultValue;
  488. trigger();
  489. }, resolveUnref(afterMs));
  490. tryOnScopeDispose(() => {
  491. clearTimeout(timer);
  492. });
  493. return {
  494. get() {
  495. track();
  496. return value;
  497. },
  498. set(newValue) {
  499. value = newValue;
  500. trigger();
  501. clearTimeout(timer);
  502. timer = resetAfter();
  503. }
  504. };
  505. });
  506. }
  507. function useDebounceFn(fn, ms = 200, options = {}) {
  508. return createFilterWrapper(debounceFilter(ms, options), fn);
  509. }
  510. function refDebounced(value, ms = 200, options = {}) {
  511. const debounced = vueDemi.ref(value.value);
  512. const updater = useDebounceFn(() => {
  513. debounced.value = value.value;
  514. }, ms, options);
  515. vueDemi.watch(value, () => updater());
  516. return debounced;
  517. }
  518. function refDefault(source, defaultValue) {
  519. return vueDemi.computed({
  520. get() {
  521. var _a;
  522. return (_a = source.value) != null ? _a : defaultValue;
  523. },
  524. set(value) {
  525. source.value = value;
  526. }
  527. });
  528. }
  529. function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
  530. return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
  531. }
  532. function refThrottled(value, delay = 200, trailing = true, leading = true) {
  533. if (delay <= 0)
  534. return value;
  535. const throttled = vueDemi.ref(value.value);
  536. const updater = useThrottleFn(() => {
  537. throttled.value = value.value;
  538. }, delay, trailing, leading);
  539. vueDemi.watch(value, () => updater());
  540. return throttled;
  541. }
  542. function refWithControl(initial, options = {}) {
  543. let source = initial;
  544. let track;
  545. let trigger;
  546. const ref = vueDemi.customRef((_track, _trigger) => {
  547. track = _track;
  548. trigger = _trigger;
  549. return {
  550. get() {
  551. return get();
  552. },
  553. set(v) {
  554. set(v);
  555. }
  556. };
  557. });
  558. function get(tracking = true) {
  559. if (tracking)
  560. track();
  561. return source;
  562. }
  563. function set(value, triggering = true) {
  564. var _a, _b;
  565. if (value === source)
  566. return;
  567. const old = source;
  568. if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
  569. return;
  570. source = value;
  571. (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
  572. if (triggering)
  573. trigger();
  574. }
  575. const untrackedGet = () => get(false);
  576. const silentSet = (v) => set(v, false);
  577. const peek = () => get(false);
  578. const lay = (v) => set(v, false);
  579. return extendRef(ref, {
  580. get,
  581. set,
  582. untrackedGet,
  583. silentSet,
  584. peek,
  585. lay
  586. }, { enumerable: true });
  587. }
  588. const controlledRef = refWithControl;
  589. function resolveRef(r) {
  590. return typeof r === "function" ? vueDemi.computed(r) : vueDemi.ref(r);
  591. }
  592. function set(...args) {
  593. if (args.length === 2) {
  594. const [ref, value] = args;
  595. ref.value = value;
  596. }
  597. if (args.length === 3) {
  598. if (vueDemi.isVue2) {
  599. vueDemi.set(...args);
  600. } else {
  601. const [target, key, value] = args;
  602. target[key] = value;
  603. }
  604. }
  605. }
  606. function syncRef(left, right, options = {}) {
  607. var _a, _b;
  608. const {
  609. flush = "sync",
  610. deep = false,
  611. immediate = true,
  612. direction = "both",
  613. transform = {}
  614. } = options;
  615. let watchLeft;
  616. let watchRight;
  617. const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
  618. const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
  619. if (direction === "both" || direction === "ltr") {
  620. watchLeft = vueDemi.watch(left, (newValue) => right.value = transformLTR(newValue), { flush, deep, immediate });
  621. }
  622. if (direction === "both" || direction === "rtl") {
  623. watchRight = vueDemi.watch(right, (newValue) => left.value = transformRTL(newValue), { flush, deep, immediate });
  624. }
  625. return () => {
  626. watchLeft == null ? void 0 : watchLeft();
  627. watchRight == null ? void 0 : watchRight();
  628. };
  629. }
  630. function syncRefs(source, targets, options = {}) {
  631. const {
  632. flush = "sync",
  633. deep = false,
  634. immediate = true
  635. } = options;
  636. if (!Array.isArray(targets))
  637. targets = [targets];
  638. return vueDemi.watch(source, (newValue) => targets.forEach((target) => target.value = newValue), { flush, deep, immediate });
  639. }
  640. var __defProp$7 = Object.defineProperty;
  641. var __defProps$5 = Object.defineProperties;
  642. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  643. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  644. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  645. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  646. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  647. var __spreadValues$7 = (a, b) => {
  648. for (var prop in b || (b = {}))
  649. if (__hasOwnProp$9.call(b, prop))
  650. __defNormalProp$7(a, prop, b[prop]);
  651. if (__getOwnPropSymbols$9)
  652. for (var prop of __getOwnPropSymbols$9(b)) {
  653. if (__propIsEnum$9.call(b, prop))
  654. __defNormalProp$7(a, prop, b[prop]);
  655. }
  656. return a;
  657. };
  658. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  659. function toRefs(objectRef) {
  660. if (!vueDemi.isRef(objectRef))
  661. return vueDemi.toRefs(objectRef);
  662. const result = Array.isArray(objectRef.value) ? new Array(objectRef.value.length) : {};
  663. for (const key in objectRef.value) {
  664. result[key] = vueDemi.customRef(() => ({
  665. get() {
  666. return objectRef.value[key];
  667. },
  668. set(v) {
  669. if (Array.isArray(objectRef.value)) {
  670. const copy = [...objectRef.value];
  671. copy[key] = v;
  672. objectRef.value = copy;
  673. } else {
  674. const newObject = __spreadProps$5(__spreadValues$7({}, objectRef.value), { [key]: v });
  675. Object.setPrototypeOf(newObject, objectRef.value);
  676. objectRef.value = newObject;
  677. }
  678. }
  679. }));
  680. }
  681. return result;
  682. }
  683. function tryOnBeforeMount(fn, sync = true) {
  684. if (vueDemi.getCurrentInstance())
  685. vueDemi.onBeforeMount(fn);
  686. else if (sync)
  687. fn();
  688. else
  689. vueDemi.nextTick(fn);
  690. }
  691. function tryOnBeforeUnmount(fn) {
  692. if (vueDemi.getCurrentInstance())
  693. vueDemi.onBeforeUnmount(fn);
  694. }
  695. function tryOnMounted(fn, sync = true) {
  696. if (vueDemi.getCurrentInstance())
  697. vueDemi.onMounted(fn);
  698. else if (sync)
  699. fn();
  700. else
  701. vueDemi.nextTick(fn);
  702. }
  703. function tryOnUnmounted(fn) {
  704. if (vueDemi.getCurrentInstance())
  705. vueDemi.onUnmounted(fn);
  706. }
  707. function createUntil(r, isNot = false) {
  708. function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
  709. let stop = null;
  710. const watcher = new Promise((resolve) => {
  711. stop = vueDemi.watch(r, (v) => {
  712. if (condition(v) !== isNot) {
  713. stop == null ? void 0 : stop();
  714. resolve(v);
  715. }
  716. }, {
  717. flush,
  718. deep,
  719. immediate: true
  720. });
  721. });
  722. const promises = [watcher];
  723. if (timeout != null) {
  724. promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
  725. }
  726. return Promise.race(promises);
  727. }
  728. function toBe(value, options) {
  729. if (!vueDemi.isRef(value))
  730. return toMatch((v) => v === value, options);
  731. const { flush = "sync", deep = false, timeout, throwOnTimeout } = options != null ? options : {};
  732. let stop = null;
  733. const watcher = new Promise((resolve) => {
  734. stop = vueDemi.watch([r, value], ([v1, v2]) => {
  735. if (isNot !== (v1 === v2)) {
  736. stop == null ? void 0 : stop();
  737. resolve(v1);
  738. }
  739. }, {
  740. flush,
  741. deep,
  742. immediate: true
  743. });
  744. });
  745. const promises = [watcher];
  746. if (timeout != null) {
  747. promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
  748. stop == null ? void 0 : stop();
  749. return resolveUnref(r);
  750. }));
  751. }
  752. return Promise.race(promises);
  753. }
  754. function toBeTruthy(options) {
  755. return toMatch((v) => Boolean(v), options);
  756. }
  757. function toBeNull(options) {
  758. return toBe(null, options);
  759. }
  760. function toBeUndefined(options) {
  761. return toBe(void 0, options);
  762. }
  763. function toBeNaN(options) {
  764. return toMatch(Number.isNaN, options);
  765. }
  766. function toContains(value, options) {
  767. return toMatch((v) => {
  768. const array = Array.from(v);
  769. return array.includes(value) || array.includes(resolveUnref(value));
  770. }, options);
  771. }
  772. function changed(options) {
  773. return changedTimes(1, options);
  774. }
  775. function changedTimes(n = 1, options) {
  776. let count = -1;
  777. return toMatch(() => {
  778. count += 1;
  779. return count >= n;
  780. }, options);
  781. }
  782. if (Array.isArray(resolveUnref(r))) {
  783. const instance = {
  784. toMatch,
  785. toContains,
  786. changed,
  787. changedTimes,
  788. get not() {
  789. return createUntil(r, !isNot);
  790. }
  791. };
  792. return instance;
  793. } else {
  794. const instance = {
  795. toMatch,
  796. toBe,
  797. toBeTruthy,
  798. toBeNull,
  799. toBeNaN,
  800. toBeUndefined,
  801. changed,
  802. changedTimes,
  803. get not() {
  804. return createUntil(r, !isNot);
  805. }
  806. };
  807. return instance;
  808. }
  809. }
  810. function until(r) {
  811. return createUntil(r);
  812. }
  813. function useArrayEvery(list, fn) {
  814. return vueDemi.computed(() => resolveUnref(list).every((element, index, array) => fn(resolveUnref(element), index, array)));
  815. }
  816. function useArrayFilter(list, fn) {
  817. return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).filter(fn));
  818. }
  819. function useArrayFind(list, fn) {
  820. return vueDemi.computed(() => resolveUnref(resolveUnref(list).find((element, index, array) => fn(resolveUnref(element), index, array))));
  821. }
  822. function useArrayFindIndex(list, fn) {
  823. return vueDemi.computed(() => resolveUnref(list).findIndex((element, index, array) => fn(resolveUnref(element), index, array)));
  824. }
  825. function findLast(arr, cb) {
  826. let index = arr.length;
  827. while (index-- > 0) {
  828. if (cb(arr[index], index, arr))
  829. return arr[index];
  830. }
  831. return void 0;
  832. }
  833. function useArrayFindLast(list, fn) {
  834. return vueDemi.computed(() => resolveUnref(!Array.prototype.findLast ? findLast(resolveUnref(list), (element, index, array) => fn(resolveUnref(element), index, array)) : resolveUnref(list).findLast((element, index, array) => fn(resolveUnref(element), index, array))));
  835. }
  836. function useArrayJoin(list, separator) {
  837. return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).join(resolveUnref(separator)));
  838. }
  839. function useArrayMap(list, fn) {
  840. return vueDemi.computed(() => resolveUnref(list).map((i) => resolveUnref(i)).map(fn));
  841. }
  842. function useArrayReduce(list, reducer, ...args) {
  843. const reduceCallback = (sum, value, index) => reducer(resolveUnref(sum), resolveUnref(value), index);
  844. return vueDemi.computed(() => {
  845. const resolved = resolveUnref(list);
  846. return args.length ? resolved.reduce(reduceCallback, resolveUnref(args[0])) : resolved.reduce(reduceCallback);
  847. });
  848. }
  849. function useArraySome(list, fn) {
  850. return vueDemi.computed(() => resolveUnref(list).some((element, index, array) => fn(resolveUnref(element), index, array)));
  851. }
  852. function useArrayUnique(list) {
  853. return vueDemi.computed(() => [...new Set(resolveUnref(list).map((element) => resolveUnref(element)))]);
  854. }
  855. function useCounter(initialValue = 0, options = {}) {
  856. const count = vueDemi.ref(initialValue);
  857. const {
  858. max = Infinity,
  859. min = -Infinity
  860. } = options;
  861. const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
  862. const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
  863. const get = () => count.value;
  864. const set = (val) => count.value = Math.max(min, Math.min(max, val));
  865. const reset = (val = initialValue) => {
  866. initialValue = val;
  867. return set(val);
  868. };
  869. return { count, inc, dec, get, set, reset };
  870. }
  871. const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
  872. const REGEX_FORMAT = /\[([^\]]+)]|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}|SSS/g;
  873. const defaultMeridiem = (hours, minutes, isLowercase, hasPeriod) => {
  874. let m = hours < 12 ? "AM" : "PM";
  875. if (hasPeriod)
  876. m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
  877. return isLowercase ? m.toLowerCase() : m;
  878. };
  879. const formatDate = (date, formatStr, options = {}) => {
  880. var _a;
  881. const years = date.getFullYear();
  882. const month = date.getMonth();
  883. const days = date.getDate();
  884. const hours = date.getHours();
  885. const minutes = date.getMinutes();
  886. const seconds = date.getSeconds();
  887. const milliseconds = date.getMilliseconds();
  888. const day = date.getDay();
  889. const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
  890. const matches = {
  891. YY: () => String(years).slice(-2),
  892. YYYY: () => years,
  893. M: () => month + 1,
  894. MM: () => `${month + 1}`.padStart(2, "0"),
  895. MMM: () => date.toLocaleDateString(options.locales, { month: "short" }),
  896. MMMM: () => date.toLocaleDateString(options.locales, { month: "long" }),
  897. D: () => String(days),
  898. DD: () => `${days}`.padStart(2, "0"),
  899. H: () => String(hours),
  900. HH: () => `${hours}`.padStart(2, "0"),
  901. h: () => `${hours % 12 || 12}`.padStart(1, "0"),
  902. hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
  903. m: () => String(minutes),
  904. mm: () => `${minutes}`.padStart(2, "0"),
  905. s: () => String(seconds),
  906. ss: () => `${seconds}`.padStart(2, "0"),
  907. SSS: () => `${milliseconds}`.padStart(3, "0"),
  908. d: () => day,
  909. dd: () => date.toLocaleDateString(options.locales, { weekday: "narrow" }),
  910. ddd: () => date.toLocaleDateString(options.locales, { weekday: "short" }),
  911. dddd: () => date.toLocaleDateString(options.locales, { weekday: "long" }),
  912. A: () => meridiem(hours, minutes),
  913. AA: () => meridiem(hours, minutes, false, true),
  914. a: () => meridiem(hours, minutes, true),
  915. aa: () => meridiem(hours, minutes, true, true)
  916. };
  917. return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match]());
  918. };
  919. const normalizeDate = (date) => {
  920. if (date === null)
  921. return new Date(NaN);
  922. if (date === void 0)
  923. return new Date();
  924. if (date instanceof Date)
  925. return new Date(date);
  926. if (typeof date === "string" && !/Z$/i.test(date)) {
  927. const d = date.match(REGEX_PARSE);
  928. if (d) {
  929. const m = d[2] - 1 || 0;
  930. const ms = (d[7] || "0").substring(0, 3);
  931. return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
  932. }
  933. }
  934. return new Date(date);
  935. };
  936. function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
  937. return vueDemi.computed(() => formatDate(normalizeDate(resolveUnref(date)), resolveUnref(formatStr), options));
  938. }
  939. function useIntervalFn(cb, interval = 1e3, options = {}) {
  940. const {
  941. immediate = true,
  942. immediateCallback = false
  943. } = options;
  944. let timer = null;
  945. const isActive = vueDemi.ref(false);
  946. function clean() {
  947. if (timer) {
  948. clearInterval(timer);
  949. timer = null;
  950. }
  951. }
  952. function pause() {
  953. isActive.value = false;
  954. clean();
  955. }
  956. function resume() {
  957. const intervalValue = resolveUnref(interval);
  958. if (intervalValue <= 0)
  959. return;
  960. isActive.value = true;
  961. if (immediateCallback)
  962. cb();
  963. clean();
  964. timer = setInterval(cb, intervalValue);
  965. }
  966. if (immediate && isClient)
  967. resume();
  968. if (vueDemi.isRef(interval) || isFunction(interval)) {
  969. const stopWatch = vueDemi.watch(interval, () => {
  970. if (isActive.value && isClient)
  971. resume();
  972. });
  973. tryOnScopeDispose(stopWatch);
  974. }
  975. tryOnScopeDispose(pause);
  976. return {
  977. isActive,
  978. pause,
  979. resume
  980. };
  981. }
  982. var __defProp$6 = Object.defineProperty;
  983. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  984. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  985. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  986. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  987. var __spreadValues$6 = (a, b) => {
  988. for (var prop in b || (b = {}))
  989. if (__hasOwnProp$8.call(b, prop))
  990. __defNormalProp$6(a, prop, b[prop]);
  991. if (__getOwnPropSymbols$8)
  992. for (var prop of __getOwnPropSymbols$8(b)) {
  993. if (__propIsEnum$8.call(b, prop))
  994. __defNormalProp$6(a, prop, b[prop]);
  995. }
  996. return a;
  997. };
  998. function useInterval(interval = 1e3, options = {}) {
  999. const {
  1000. controls: exposeControls = false,
  1001. immediate = true,
  1002. callback
  1003. } = options;
  1004. const counter = vueDemi.ref(0);
  1005. const update = () => counter.value += 1;
  1006. const reset = () => {
  1007. counter.value = 0;
  1008. };
  1009. const controls = useIntervalFn(callback ? () => {
  1010. update();
  1011. callback(counter.value);
  1012. } : update, interval, { immediate });
  1013. if (exposeControls) {
  1014. return __spreadValues$6({
  1015. counter,
  1016. reset
  1017. }, controls);
  1018. } else {
  1019. return counter;
  1020. }
  1021. }
  1022. function useLastChanged(source, options = {}) {
  1023. var _a;
  1024. const ms = vueDemi.ref((_a = options.initialValue) != null ? _a : null);
  1025. vueDemi.watch(source, () => ms.value = timestamp(), options);
  1026. return ms;
  1027. }
  1028. function useTimeoutFn(cb, interval, options = {}) {
  1029. const {
  1030. immediate = true
  1031. } = options;
  1032. const isPending = vueDemi.ref(false);
  1033. let timer = null;
  1034. function clear() {
  1035. if (timer) {
  1036. clearTimeout(timer);
  1037. timer = null;
  1038. }
  1039. }
  1040. function stop() {
  1041. isPending.value = false;
  1042. clear();
  1043. }
  1044. function start(...args) {
  1045. clear();
  1046. isPending.value = true;
  1047. timer = setTimeout(() => {
  1048. isPending.value = false;
  1049. timer = null;
  1050. cb(...args);
  1051. }, resolveUnref(interval));
  1052. }
  1053. if (immediate) {
  1054. isPending.value = true;
  1055. if (isClient)
  1056. start();
  1057. }
  1058. tryOnScopeDispose(stop);
  1059. return {
  1060. isPending: vueDemi.readonly(isPending),
  1061. start,
  1062. stop
  1063. };
  1064. }
  1065. var __defProp$5 = Object.defineProperty;
  1066. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  1067. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  1068. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  1069. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1070. var __spreadValues$5 = (a, b) => {
  1071. for (var prop in b || (b = {}))
  1072. if (__hasOwnProp$7.call(b, prop))
  1073. __defNormalProp$5(a, prop, b[prop]);
  1074. if (__getOwnPropSymbols$7)
  1075. for (var prop of __getOwnPropSymbols$7(b)) {
  1076. if (__propIsEnum$7.call(b, prop))
  1077. __defNormalProp$5(a, prop, b[prop]);
  1078. }
  1079. return a;
  1080. };
  1081. function useTimeout(interval = 1e3, options = {}) {
  1082. const {
  1083. controls: exposeControls = false,
  1084. callback
  1085. } = options;
  1086. const controls = useTimeoutFn(callback != null ? callback : noop, interval, options);
  1087. const ready = vueDemi.computed(() => !controls.isPending.value);
  1088. if (exposeControls) {
  1089. return __spreadValues$5({
  1090. ready
  1091. }, controls);
  1092. } else {
  1093. return ready;
  1094. }
  1095. }
  1096. function useToNumber(value, options = {}) {
  1097. const {
  1098. method = "parseFloat",
  1099. radix,
  1100. nanToZero
  1101. } = options;
  1102. return vueDemi.computed(() => {
  1103. let resolved = resolveUnref(value);
  1104. if (typeof resolved === "string")
  1105. resolved = Number[method](resolved, radix);
  1106. if (nanToZero && isNaN(resolved))
  1107. resolved = 0;
  1108. return resolved;
  1109. });
  1110. }
  1111. function useToString(value) {
  1112. return vueDemi.computed(() => `${resolveUnref(value)}`);
  1113. }
  1114. function useToggle(initialValue = false, options = {}) {
  1115. const {
  1116. truthyValue = true,
  1117. falsyValue = false
  1118. } = options;
  1119. const valueIsRef = vueDemi.isRef(initialValue);
  1120. const _value = vueDemi.ref(initialValue);
  1121. function toggle(value) {
  1122. if (arguments.length) {
  1123. _value.value = value;
  1124. return _value.value;
  1125. } else {
  1126. const truthy = resolveUnref(truthyValue);
  1127. _value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
  1128. return _value.value;
  1129. }
  1130. }
  1131. if (valueIsRef)
  1132. return toggle;
  1133. else
  1134. return [_value, toggle];
  1135. }
  1136. function watchArray(source, cb, options) {
  1137. let oldList = (options == null ? void 0 : options.immediate) ? [] : [
  1138. ...source instanceof Function ? source() : Array.isArray(source) ? source : vueDemi.unref(source)
  1139. ];
  1140. return vueDemi.watch(source, (newList, _, onCleanup) => {
  1141. const oldListRemains = new Array(oldList.length);
  1142. const added = [];
  1143. for (const obj of newList) {
  1144. let found = false;
  1145. for (let i = 0; i < oldList.length; i++) {
  1146. if (!oldListRemains[i] && obj === oldList[i]) {
  1147. oldListRemains[i] = true;
  1148. found = true;
  1149. break;
  1150. }
  1151. }
  1152. if (!found)
  1153. added.push(obj);
  1154. }
  1155. const removed = oldList.filter((_2, i) => !oldListRemains[i]);
  1156. cb(newList, oldList, added, removed, onCleanup);
  1157. oldList = [...newList];
  1158. }, options);
  1159. }
  1160. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  1161. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  1162. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  1163. var __objRest$5 = (source, exclude) => {
  1164. var target = {};
  1165. for (var prop in source)
  1166. if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
  1167. target[prop] = source[prop];
  1168. if (source != null && __getOwnPropSymbols$6)
  1169. for (var prop of __getOwnPropSymbols$6(source)) {
  1170. if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
  1171. target[prop] = source[prop];
  1172. }
  1173. return target;
  1174. };
  1175. function watchWithFilter(source, cb, options = {}) {
  1176. const _a = options, {
  1177. eventFilter = bypassFilter
  1178. } = _a, watchOptions = __objRest$5(_a, [
  1179. "eventFilter"
  1180. ]);
  1181. return vueDemi.watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
  1182. }
  1183. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  1184. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  1185. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  1186. var __objRest$4 = (source, exclude) => {
  1187. var target = {};
  1188. for (var prop in source)
  1189. if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
  1190. target[prop] = source[prop];
  1191. if (source != null && __getOwnPropSymbols$5)
  1192. for (var prop of __getOwnPropSymbols$5(source)) {
  1193. if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
  1194. target[prop] = source[prop];
  1195. }
  1196. return target;
  1197. };
  1198. function watchAtMost(source, cb, options) {
  1199. const _a = options, {
  1200. count
  1201. } = _a, watchOptions = __objRest$4(_a, [
  1202. "count"
  1203. ]);
  1204. const current = vueDemi.ref(0);
  1205. const stop = watchWithFilter(source, (...args) => {
  1206. current.value += 1;
  1207. if (current.value >= resolveUnref(count))
  1208. vueDemi.nextTick(() => stop());
  1209. cb(...args);
  1210. }, watchOptions);
  1211. return { count: current, stop };
  1212. }
  1213. var __defProp$4 = Object.defineProperty;
  1214. var __defProps$4 = Object.defineProperties;
  1215. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  1216. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  1217. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  1218. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  1219. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1220. var __spreadValues$4 = (a, b) => {
  1221. for (var prop in b || (b = {}))
  1222. if (__hasOwnProp$4.call(b, prop))
  1223. __defNormalProp$4(a, prop, b[prop]);
  1224. if (__getOwnPropSymbols$4)
  1225. for (var prop of __getOwnPropSymbols$4(b)) {
  1226. if (__propIsEnum$4.call(b, prop))
  1227. __defNormalProp$4(a, prop, b[prop]);
  1228. }
  1229. return a;
  1230. };
  1231. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  1232. var __objRest$3 = (source, exclude) => {
  1233. var target = {};
  1234. for (var prop in source)
  1235. if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
  1236. target[prop] = source[prop];
  1237. if (source != null && __getOwnPropSymbols$4)
  1238. for (var prop of __getOwnPropSymbols$4(source)) {
  1239. if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
  1240. target[prop] = source[prop];
  1241. }
  1242. return target;
  1243. };
  1244. function watchDebounced(source, cb, options = {}) {
  1245. const _a = options, {
  1246. debounce = 0,
  1247. maxWait = void 0
  1248. } = _a, watchOptions = __objRest$3(_a, [
  1249. "debounce",
  1250. "maxWait"
  1251. ]);
  1252. return watchWithFilter(source, cb, __spreadProps$4(__spreadValues$4({}, watchOptions), {
  1253. eventFilter: debounceFilter(debounce, { maxWait })
  1254. }));
  1255. }
  1256. var __defProp$3 = Object.defineProperty;
  1257. var __defProps$3 = Object.defineProperties;
  1258. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  1259. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  1260. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  1261. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  1262. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1263. var __spreadValues$3 = (a, b) => {
  1264. for (var prop in b || (b = {}))
  1265. if (__hasOwnProp$3.call(b, prop))
  1266. __defNormalProp$3(a, prop, b[prop]);
  1267. if (__getOwnPropSymbols$3)
  1268. for (var prop of __getOwnPropSymbols$3(b)) {
  1269. if (__propIsEnum$3.call(b, prop))
  1270. __defNormalProp$3(a, prop, b[prop]);
  1271. }
  1272. return a;
  1273. };
  1274. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  1275. var __objRest$2 = (source, exclude) => {
  1276. var target = {};
  1277. for (var prop in source)
  1278. if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
  1279. target[prop] = source[prop];
  1280. if (source != null && __getOwnPropSymbols$3)
  1281. for (var prop of __getOwnPropSymbols$3(source)) {
  1282. if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
  1283. target[prop] = source[prop];
  1284. }
  1285. return target;
  1286. };
  1287. function watchIgnorable(source, cb, options = {}) {
  1288. const _a = options, {
  1289. eventFilter = bypassFilter
  1290. } = _a, watchOptions = __objRest$2(_a, [
  1291. "eventFilter"
  1292. ]);
  1293. const filteredCb = createFilterWrapper(eventFilter, cb);
  1294. let ignoreUpdates;
  1295. let ignorePrevAsyncUpdates;
  1296. let stop;
  1297. if (watchOptions.flush === "sync") {
  1298. const ignore = vueDemi.ref(false);
  1299. ignorePrevAsyncUpdates = () => {
  1300. };
  1301. ignoreUpdates = (updater) => {
  1302. ignore.value = true;
  1303. updater();
  1304. ignore.value = false;
  1305. };
  1306. stop = vueDemi.watch(source, (...args) => {
  1307. if (!ignore.value)
  1308. filteredCb(...args);
  1309. }, watchOptions);
  1310. } else {
  1311. const disposables = [];
  1312. const ignoreCounter = vueDemi.ref(0);
  1313. const syncCounter = vueDemi.ref(0);
  1314. ignorePrevAsyncUpdates = () => {
  1315. ignoreCounter.value = syncCounter.value;
  1316. };
  1317. disposables.push(vueDemi.watch(source, () => {
  1318. syncCounter.value++;
  1319. }, __spreadProps$3(__spreadValues$3({}, watchOptions), { flush: "sync" })));
  1320. ignoreUpdates = (updater) => {
  1321. const syncCounterPrev = syncCounter.value;
  1322. updater();
  1323. ignoreCounter.value += syncCounter.value - syncCounterPrev;
  1324. };
  1325. disposables.push(vueDemi.watch(source, (...args) => {
  1326. const ignore = ignoreCounter.value > 0 && ignoreCounter.value === syncCounter.value;
  1327. ignoreCounter.value = 0;
  1328. syncCounter.value = 0;
  1329. if (ignore)
  1330. return;
  1331. filteredCb(...args);
  1332. }, watchOptions));
  1333. stop = () => {
  1334. disposables.forEach((fn) => fn());
  1335. };
  1336. }
  1337. return { stop, ignoreUpdates, ignorePrevAsyncUpdates };
  1338. }
  1339. function watchOnce(source, cb, options) {
  1340. const stop = vueDemi.watch(source, (...args) => {
  1341. vueDemi.nextTick(() => stop());
  1342. return cb(...args);
  1343. }, options);
  1344. }
  1345. var __defProp$2 = Object.defineProperty;
  1346. var __defProps$2 = Object.defineProperties;
  1347. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  1348. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  1349. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  1350. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  1351. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1352. var __spreadValues$2 = (a, b) => {
  1353. for (var prop in b || (b = {}))
  1354. if (__hasOwnProp$2.call(b, prop))
  1355. __defNormalProp$2(a, prop, b[prop]);
  1356. if (__getOwnPropSymbols$2)
  1357. for (var prop of __getOwnPropSymbols$2(b)) {
  1358. if (__propIsEnum$2.call(b, prop))
  1359. __defNormalProp$2(a, prop, b[prop]);
  1360. }
  1361. return a;
  1362. };
  1363. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  1364. var __objRest$1 = (source, exclude) => {
  1365. var target = {};
  1366. for (var prop in source)
  1367. if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
  1368. target[prop] = source[prop];
  1369. if (source != null && __getOwnPropSymbols$2)
  1370. for (var prop of __getOwnPropSymbols$2(source)) {
  1371. if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
  1372. target[prop] = source[prop];
  1373. }
  1374. return target;
  1375. };
  1376. function watchPausable(source, cb, options = {}) {
  1377. const _a = options, {
  1378. eventFilter: filter
  1379. } = _a, watchOptions = __objRest$1(_a, [
  1380. "eventFilter"
  1381. ]);
  1382. const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
  1383. const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$2({}, watchOptions), {
  1384. eventFilter
  1385. }));
  1386. return { stop, pause, resume, isActive };
  1387. }
  1388. var __defProp$1 = Object.defineProperty;
  1389. var __defProps$1 = Object.defineProperties;
  1390. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  1391. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  1392. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  1393. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  1394. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1395. var __spreadValues$1 = (a, b) => {
  1396. for (var prop in b || (b = {}))
  1397. if (__hasOwnProp$1.call(b, prop))
  1398. __defNormalProp$1(a, prop, b[prop]);
  1399. if (__getOwnPropSymbols$1)
  1400. for (var prop of __getOwnPropSymbols$1(b)) {
  1401. if (__propIsEnum$1.call(b, prop))
  1402. __defNormalProp$1(a, prop, b[prop]);
  1403. }
  1404. return a;
  1405. };
  1406. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  1407. var __objRest = (source, exclude) => {
  1408. var target = {};
  1409. for (var prop in source)
  1410. if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
  1411. target[prop] = source[prop];
  1412. if (source != null && __getOwnPropSymbols$1)
  1413. for (var prop of __getOwnPropSymbols$1(source)) {
  1414. if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
  1415. target[prop] = source[prop];
  1416. }
  1417. return target;
  1418. };
  1419. function watchThrottled(source, cb, options = {}) {
  1420. const _a = options, {
  1421. throttle = 0,
  1422. trailing = true,
  1423. leading = true
  1424. } = _a, watchOptions = __objRest(_a, [
  1425. "throttle",
  1426. "trailing",
  1427. "leading"
  1428. ]);
  1429. return watchWithFilter(source, cb, __spreadProps$1(__spreadValues$1({}, watchOptions), {
  1430. eventFilter: throttleFilter(throttle, trailing, leading)
  1431. }));
  1432. }
  1433. var __defProp = Object.defineProperty;
  1434. var __defProps = Object.defineProperties;
  1435. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  1436. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  1437. var __hasOwnProp = Object.prototype.hasOwnProperty;
  1438. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  1439. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  1440. var __spreadValues = (a, b) => {
  1441. for (var prop in b || (b = {}))
  1442. if (__hasOwnProp.call(b, prop))
  1443. __defNormalProp(a, prop, b[prop]);
  1444. if (__getOwnPropSymbols)
  1445. for (var prop of __getOwnPropSymbols(b)) {
  1446. if (__propIsEnum.call(b, prop))
  1447. __defNormalProp(a, prop, b[prop]);
  1448. }
  1449. return a;
  1450. };
  1451. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  1452. function watchTriggerable(source, cb, options = {}) {
  1453. let cleanupFn;
  1454. function onEffect() {
  1455. if (!cleanupFn)
  1456. return;
  1457. const fn = cleanupFn;
  1458. cleanupFn = void 0;
  1459. fn();
  1460. }
  1461. function onCleanup(callback) {
  1462. cleanupFn = callback;
  1463. }
  1464. const _cb = (value, oldValue) => {
  1465. onEffect();
  1466. return cb(value, oldValue, onCleanup);
  1467. };
  1468. const res = watchIgnorable(source, _cb, options);
  1469. const { ignoreUpdates } = res;
  1470. const trigger = () => {
  1471. let res2;
  1472. ignoreUpdates(() => {
  1473. res2 = _cb(getWatchSources(source), getOldValue(source));
  1474. });
  1475. return res2;
  1476. };
  1477. return __spreadProps(__spreadValues({}, res), {
  1478. trigger
  1479. });
  1480. }
  1481. function getWatchSources(sources) {
  1482. if (vueDemi.isReactive(sources))
  1483. return sources;
  1484. if (Array.isArray(sources))
  1485. return sources.map((item) => getOneWatchSource(item));
  1486. return getOneWatchSource(sources);
  1487. }
  1488. function getOneWatchSource(source) {
  1489. return typeof source === "function" ? source() : vueDemi.unref(source);
  1490. }
  1491. function getOldValue(source) {
  1492. return Array.isArray(source) ? source.map(() => void 0) : void 0;
  1493. }
  1494. function whenever(source, cb, options) {
  1495. return vueDemi.watch(source, (v, ov, onInvalidate) => {
  1496. if (v)
  1497. cb(v, ov, onInvalidate);
  1498. }, options);
  1499. }
  1500. exports.__onlyVue27Plus = __onlyVue27Plus;
  1501. exports.__onlyVue3 = __onlyVue3;
  1502. exports.assert = assert;
  1503. exports.autoResetRef = refAutoReset;
  1504. exports.bypassFilter = bypassFilter;
  1505. exports.clamp = clamp;
  1506. exports.computedEager = computedEager;
  1507. exports.computedWithControl = computedWithControl;
  1508. exports.containsProp = containsProp;
  1509. exports.controlledComputed = computedWithControl;
  1510. exports.controlledRef = controlledRef;
  1511. exports.createEventHook = createEventHook;
  1512. exports.createFilterWrapper = createFilterWrapper;
  1513. exports.createGlobalState = createGlobalState;
  1514. exports.createInjectionState = createInjectionState;
  1515. exports.createReactiveFn = reactify;
  1516. exports.createSharedComposable = createSharedComposable;
  1517. exports.createSingletonPromise = createSingletonPromise;
  1518. exports.debounceFilter = debounceFilter;
  1519. exports.debouncedRef = refDebounced;
  1520. exports.debouncedWatch = watchDebounced;
  1521. exports.directiveHooks = directiveHooks;
  1522. exports.eagerComputed = computedEager;
  1523. exports.extendRef = extendRef;
  1524. exports.formatDate = formatDate;
  1525. exports.get = get;
  1526. exports.hasOwn = hasOwn;
  1527. exports.identity = identity;
  1528. exports.ignorableWatch = watchIgnorable;
  1529. exports.increaseWithUnit = increaseWithUnit;
  1530. exports.invoke = invoke;
  1531. exports.isBoolean = isBoolean;
  1532. exports.isClient = isClient;
  1533. exports.isDef = isDef;
  1534. exports.isDefined = isDefined;
  1535. exports.isFunction = isFunction;
  1536. exports.isIOS = isIOS;
  1537. exports.isNumber = isNumber;
  1538. exports.isObject = isObject;
  1539. exports.isString = isString;
  1540. exports.isWindow = isWindow;
  1541. exports.makeDestructurable = makeDestructurable;
  1542. exports.noop = noop;
  1543. exports.normalizeDate = normalizeDate;
  1544. exports.now = now;
  1545. exports.objectPick = objectPick;
  1546. exports.pausableFilter = pausableFilter;
  1547. exports.pausableWatch = watchPausable;
  1548. exports.promiseTimeout = promiseTimeout;
  1549. exports.rand = rand;
  1550. exports.reactify = reactify;
  1551. exports.reactifyObject = reactifyObject;
  1552. exports.reactiveComputed = reactiveComputed;
  1553. exports.reactiveOmit = reactiveOmit;
  1554. exports.reactivePick = reactivePick;
  1555. exports.refAutoReset = refAutoReset;
  1556. exports.refDebounced = refDebounced;
  1557. exports.refDefault = refDefault;
  1558. exports.refThrottled = refThrottled;
  1559. exports.refWithControl = refWithControl;
  1560. exports.resolveRef = resolveRef;
  1561. exports.resolveUnref = resolveUnref;
  1562. exports.set = set;
  1563. exports.syncRef = syncRef;
  1564. exports.syncRefs = syncRefs;
  1565. exports.throttleFilter = throttleFilter;
  1566. exports.throttledRef = refThrottled;
  1567. exports.throttledWatch = watchThrottled;
  1568. exports.timestamp = timestamp;
  1569. exports.toReactive = toReactive;
  1570. exports.toRefs = toRefs;
  1571. exports.tryOnBeforeMount = tryOnBeforeMount;
  1572. exports.tryOnBeforeUnmount = tryOnBeforeUnmount;
  1573. exports.tryOnMounted = tryOnMounted;
  1574. exports.tryOnScopeDispose = tryOnScopeDispose;
  1575. exports.tryOnUnmounted = tryOnUnmounted;
  1576. exports.until = until;
  1577. exports.useArrayEvery = useArrayEvery;
  1578. exports.useArrayFilter = useArrayFilter;
  1579. exports.useArrayFind = useArrayFind;
  1580. exports.useArrayFindIndex = useArrayFindIndex;
  1581. exports.useArrayFindLast = useArrayFindLast;
  1582. exports.useArrayJoin = useArrayJoin;
  1583. exports.useArrayMap = useArrayMap;
  1584. exports.useArrayReduce = useArrayReduce;
  1585. exports.useArraySome = useArraySome;
  1586. exports.useArrayUnique = useArrayUnique;
  1587. exports.useCounter = useCounter;
  1588. exports.useDateFormat = useDateFormat;
  1589. exports.useDebounce = refDebounced;
  1590. exports.useDebounceFn = useDebounceFn;
  1591. exports.useInterval = useInterval;
  1592. exports.useIntervalFn = useIntervalFn;
  1593. exports.useLastChanged = useLastChanged;
  1594. exports.useThrottle = refThrottled;
  1595. exports.useThrottleFn = useThrottleFn;
  1596. exports.useTimeout = useTimeout;
  1597. exports.useTimeoutFn = useTimeoutFn;
  1598. exports.useToNumber = useToNumber;
  1599. exports.useToString = useToString;
  1600. exports.useToggle = useToggle;
  1601. exports.watchArray = watchArray;
  1602. exports.watchAtMost = watchAtMost;
  1603. exports.watchDebounced = watchDebounced;
  1604. exports.watchIgnorable = watchIgnorable;
  1605. exports.watchOnce = watchOnce;
  1606. exports.watchPausable = watchPausable;
  1607. exports.watchThrottled = watchThrottled;
  1608. exports.watchTriggerable = watchTriggerable;
  1609. exports.watchWithFilter = watchWithFilter;
  1610. exports.whenever = whenever;