index.iife.js 54 KB

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