chunk-6366KF45.js 42 KB

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