index.iife.js 61 KB

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