index.iife.js 54 KB

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