reactivity.esm-bundler.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018
  1. /**
  2. * @vue/reactivity v3.5.43
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. import { extend, hasChanged, isArray, isIntegerKey, isSymbol, isMap, hasOwn, isObject, makeMap, capitalize, toRawType, def, isFunction, EMPTY_OBJ, isSet, isPlainObject, remove, NOOP } from '@vue/shared';
  7. function warn(msg, ...args) {
  8. console.warn(`[Vue warn] ${msg}`, ...args);
  9. }
  10. let activeEffectScope;
  11. class EffectScope {
  12. // TODO isolatedDeclarations "__v_skip"
  13. constructor(detached = false) {
  14. this.detached = detached;
  15. /**
  16. * @internal
  17. */
  18. this._active = true;
  19. /**
  20. * @internal track `on` calls, allow `on` call multiple times
  21. */
  22. this._on = 0;
  23. /**
  24. * @internal
  25. */
  26. this.effects = [];
  27. /**
  28. * @internal
  29. */
  30. this.cleanups = [];
  31. this._isPaused = false;
  32. this._warnOnRun = true;
  33. this.__v_skip = true;
  34. if (!detached && activeEffectScope) {
  35. if (activeEffectScope.active) {
  36. this.parent = activeEffectScope;
  37. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  38. this
  39. ) - 1;
  40. } else {
  41. this._active = false;
  42. this._warnOnRun = false;
  43. }
  44. }
  45. }
  46. get active() {
  47. return this._active;
  48. }
  49. pause() {
  50. if (this._active) {
  51. this._isPaused = true;
  52. let i, l;
  53. if (this.scopes) {
  54. const scopes = this.scopes.slice();
  55. for (i = 0, l = scopes.length; i < l; i++) {
  56. scopes[i].pause();
  57. }
  58. }
  59. for (i = 0, l = this.effects.length; i < l; i++) {
  60. this.effects[i].pause();
  61. }
  62. }
  63. }
  64. /**
  65. * Resumes the effect scope, including all child scopes and effects.
  66. */
  67. resume() {
  68. if (this._active) {
  69. if (this._isPaused) {
  70. this._isPaused = false;
  71. let i, l;
  72. if (this.scopes) {
  73. const scopes = this.scopes.slice();
  74. for (i = 0, l = scopes.length; i < l; i++) {
  75. scopes[i].resume();
  76. }
  77. }
  78. const effects = this.effects.slice();
  79. for (i = 0, l = effects.length; i < l; i++) {
  80. effects[i].resume();
  81. }
  82. }
  83. }
  84. }
  85. run(fn) {
  86. if (this._active) {
  87. const currentEffectScope = activeEffectScope;
  88. try {
  89. activeEffectScope = this;
  90. return fn();
  91. } finally {
  92. activeEffectScope = currentEffectScope;
  93. }
  94. } else if (!!(process.env.NODE_ENV !== "production") && this._warnOnRun) {
  95. warn(`cannot run an inactive effect scope.`);
  96. }
  97. }
  98. /**
  99. * This should only be called on non-detached scopes
  100. * @internal
  101. */
  102. on() {
  103. if (++this._on === 1) {
  104. this.prevScope = activeEffectScope;
  105. activeEffectScope = this;
  106. }
  107. }
  108. /**
  109. * This should only be called on non-detached scopes
  110. * @internal
  111. */
  112. off() {
  113. if (this._on > 0 && --this._on === 0) {
  114. if (activeEffectScope === this) {
  115. activeEffectScope = this.prevScope;
  116. } else {
  117. let current = activeEffectScope;
  118. while (current) {
  119. if (current.prevScope === this) {
  120. current.prevScope = this.prevScope;
  121. break;
  122. }
  123. current = current.prevScope;
  124. }
  125. }
  126. this.prevScope = void 0;
  127. }
  128. }
  129. stop(fromParent) {
  130. if (this._active) {
  131. this._active = false;
  132. let i, l;
  133. for (i = 0, l = this.effects.length; i < l; i++) {
  134. this.effects[i].stop();
  135. }
  136. this.effects.length = 0;
  137. for (i = 0, l = this.cleanups.length; i < l; i++) {
  138. this.cleanups[i]();
  139. }
  140. this.cleanups.length = 0;
  141. if (this.scopes) {
  142. const scopes = this.scopes.slice();
  143. for (i = 0, l = scopes.length; i < l; i++) {
  144. scopes[i].stop(true);
  145. }
  146. this.scopes.length = 0;
  147. }
  148. if (!this.detached && this.parent && !fromParent) {
  149. const last = this.parent.scopes.pop();
  150. if (last && last !== this) {
  151. this.parent.scopes[this.index] = last;
  152. last.index = this.index;
  153. }
  154. }
  155. this.parent = void 0;
  156. }
  157. }
  158. }
  159. function effectScope(detached) {
  160. return new EffectScope(detached);
  161. }
  162. function getCurrentScope() {
  163. return activeEffectScope;
  164. }
  165. function onScopeDispose(fn, failSilently = false) {
  166. if (activeEffectScope) {
  167. activeEffectScope.cleanups.push(fn);
  168. } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
  169. warn(
  170. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  171. );
  172. }
  173. }
  174. let activeSub;
  175. const EffectFlags = {
  176. "ACTIVE": 1,
  177. "1": "ACTIVE",
  178. "RUNNING": 2,
  179. "2": "RUNNING",
  180. "TRACKING": 4,
  181. "4": "TRACKING",
  182. "NOTIFIED": 8,
  183. "8": "NOTIFIED",
  184. "DIRTY": 16,
  185. "16": "DIRTY",
  186. "ALLOW_RECURSE": 32,
  187. "32": "ALLOW_RECURSE",
  188. "PAUSED": 64,
  189. "64": "PAUSED",
  190. "EVALUATED": 128,
  191. "128": "EVALUATED"
  192. };
  193. const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
  194. class ReactiveEffect {
  195. constructor(fn) {
  196. this.fn = fn;
  197. /**
  198. * @internal
  199. */
  200. this.deps = void 0;
  201. /**
  202. * @internal
  203. */
  204. this.depsTail = void 0;
  205. /**
  206. * @internal
  207. */
  208. this.flags = 1 | 4;
  209. /**
  210. * @internal
  211. */
  212. this.next = void 0;
  213. /**
  214. * @internal
  215. */
  216. this.cleanup = void 0;
  217. this.scheduler = void 0;
  218. if (activeEffectScope) {
  219. if (activeEffectScope.active) {
  220. activeEffectScope.effects.push(this);
  221. } else {
  222. this.flags &= -2;
  223. }
  224. }
  225. }
  226. pause() {
  227. this.flags |= 64;
  228. }
  229. resume() {
  230. if (this.flags & 64) {
  231. this.flags &= -65;
  232. if (pausedQueueEffects.has(this)) {
  233. pausedQueueEffects.delete(this);
  234. this.trigger();
  235. }
  236. }
  237. }
  238. /**
  239. * @internal
  240. */
  241. notify() {
  242. if (this.flags & 2 && !(this.flags & 32)) {
  243. return;
  244. }
  245. if (!(this.flags & 8)) {
  246. batch(this);
  247. }
  248. }
  249. run() {
  250. if (!(this.flags & 1)) {
  251. return this.fn();
  252. }
  253. this.flags |= 2;
  254. cleanupEffect(this);
  255. prepareDeps(this);
  256. const prevEffect = activeSub;
  257. const prevShouldTrack = shouldTrack;
  258. activeSub = this;
  259. shouldTrack = true;
  260. try {
  261. return this.fn();
  262. } finally {
  263. if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) {
  264. warn(
  265. "Active effect was not restored correctly - this is likely a Vue internal bug."
  266. );
  267. }
  268. cleanupDeps(this);
  269. activeSub = prevEffect;
  270. shouldTrack = prevShouldTrack;
  271. this.flags &= -3;
  272. }
  273. }
  274. stop() {
  275. if (this.flags & 1) {
  276. for (let link = this.deps; link; link = link.nextDep) {
  277. removeSub(link);
  278. }
  279. this.deps = this.depsTail = void 0;
  280. cleanupEffect(this);
  281. this.onStop && this.onStop();
  282. this.flags &= -2;
  283. }
  284. }
  285. trigger() {
  286. if (this.flags & 64) {
  287. pausedQueueEffects.add(this);
  288. } else if (this.scheduler) {
  289. this.scheduler();
  290. } else {
  291. this.runIfDirty();
  292. }
  293. }
  294. /**
  295. * @internal
  296. */
  297. runIfDirty() {
  298. if (isDirty(this)) {
  299. this.run();
  300. }
  301. }
  302. get dirty() {
  303. return isDirty(this);
  304. }
  305. }
  306. let batchDepth = 0;
  307. let batchedSub;
  308. let batchedComputed;
  309. function batch(sub, isComputed = false) {
  310. sub.flags |= 8;
  311. if (isComputed) {
  312. sub.next = batchedComputed;
  313. batchedComputed = sub;
  314. return;
  315. }
  316. sub.next = batchedSub;
  317. batchedSub = sub;
  318. }
  319. function startBatch() {
  320. batchDepth++;
  321. }
  322. function endBatch() {
  323. if (--batchDepth > 0) {
  324. return;
  325. }
  326. if (batchedComputed) {
  327. let e = batchedComputed;
  328. batchedComputed = void 0;
  329. while (e) {
  330. const next = e.next;
  331. e.next = void 0;
  332. e.flags &= -9;
  333. e = next;
  334. }
  335. }
  336. let error;
  337. while (batchedSub) {
  338. let e = batchedSub;
  339. batchedSub = void 0;
  340. while (e) {
  341. const next = e.next;
  342. e.next = void 0;
  343. e.flags &= -9;
  344. if (e.flags & 1) {
  345. try {
  346. ;
  347. e.trigger();
  348. } catch (err) {
  349. if (!error) error = err;
  350. }
  351. }
  352. e = next;
  353. }
  354. }
  355. if (error) throw error;
  356. }
  357. function prepareDeps(sub) {
  358. for (let link = sub.deps; link; link = link.nextDep) {
  359. link.version = -1;
  360. link.prevActiveLink = link.dep.activeLink;
  361. link.dep.activeLink = link;
  362. }
  363. }
  364. function cleanupDeps(sub) {
  365. let head;
  366. let tail = sub.depsTail;
  367. let link = tail;
  368. while (link) {
  369. const prev = link.prevDep;
  370. if (link.version === -1) {
  371. if (link === tail) tail = prev;
  372. removeSub(link);
  373. removeDep(link);
  374. } else {
  375. head = link;
  376. }
  377. link.dep.activeLink = link.prevActiveLink;
  378. link.prevActiveLink = void 0;
  379. link = prev;
  380. }
  381. sub.deps = head;
  382. sub.depsTail = tail;
  383. }
  384. function isDirty(sub) {
  385. for (let link = sub.deps; link; link = link.nextDep) {
  386. if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
  387. return true;
  388. }
  389. }
  390. if (sub._dirty) {
  391. return true;
  392. }
  393. return false;
  394. }
  395. function refreshComputed(computed) {
  396. if (computed.flags & 4 && !(computed.flags & 16)) {
  397. return;
  398. }
  399. computed.flags &= -17;
  400. if (computed.globalVersion === globalVersion) {
  401. return;
  402. }
  403. computed.globalVersion = globalVersion;
  404. if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
  405. return;
  406. }
  407. computed.flags |= 2;
  408. const dep = computed.dep;
  409. const prevSub = activeSub;
  410. const prevShouldTrack = shouldTrack;
  411. activeSub = computed;
  412. shouldTrack = true;
  413. try {
  414. prepareDeps(computed);
  415. const value = computed.fn(computed._value);
  416. if (dep.version === 0 || hasChanged(value, computed._value)) {
  417. computed.flags |= 128;
  418. computed._value = value;
  419. dep.version++;
  420. }
  421. } catch (err) {
  422. dep.version++;
  423. throw err;
  424. } finally {
  425. activeSub = prevSub;
  426. shouldTrack = prevShouldTrack;
  427. cleanupDeps(computed);
  428. computed.flags &= -3;
  429. }
  430. }
  431. function removeSub(link, soft = false) {
  432. const { dep, prevSub, nextSub } = link;
  433. if (prevSub) {
  434. prevSub.nextSub = nextSub;
  435. link.prevSub = void 0;
  436. }
  437. if (nextSub) {
  438. nextSub.prevSub = prevSub;
  439. link.nextSub = void 0;
  440. }
  441. if (!!(process.env.NODE_ENV !== "production") && dep.subsHead === link) {
  442. dep.subsHead = nextSub;
  443. }
  444. if (dep.subs === link) {
  445. dep.subs = prevSub;
  446. if (!prevSub && dep.computed) {
  447. dep.computed.flags &= -5;
  448. for (let l = dep.computed.deps; l; l = l.nextDep) {
  449. removeSub(l, true);
  450. }
  451. }
  452. }
  453. if (!soft && !--dep.sc && dep.map) {
  454. dep.map.delete(dep.key);
  455. }
  456. }
  457. function removeDep(link) {
  458. const { prevDep, nextDep } = link;
  459. if (prevDep) {
  460. prevDep.nextDep = nextDep;
  461. link.prevDep = void 0;
  462. }
  463. if (nextDep) {
  464. nextDep.prevDep = prevDep;
  465. link.nextDep = void 0;
  466. }
  467. }
  468. function effect(fn, options) {
  469. if (fn.effect instanceof ReactiveEffect) {
  470. fn = fn.effect.fn;
  471. }
  472. const e = new ReactiveEffect(fn);
  473. if (options) {
  474. extend(e, options);
  475. }
  476. try {
  477. e.run();
  478. } catch (err) {
  479. e.stop();
  480. throw err;
  481. }
  482. const runner = e.run.bind(e);
  483. runner.effect = e;
  484. return runner;
  485. }
  486. function stop(runner) {
  487. runner.effect.stop();
  488. }
  489. let shouldTrack = true;
  490. const trackStack = [];
  491. function pauseTracking() {
  492. trackStack.push(shouldTrack);
  493. shouldTrack = false;
  494. }
  495. function enableTracking() {
  496. trackStack.push(shouldTrack);
  497. shouldTrack = true;
  498. }
  499. function resetTracking() {
  500. const last = trackStack.pop();
  501. shouldTrack = last === void 0 ? true : last;
  502. }
  503. function onEffectCleanup(fn, failSilently = false) {
  504. if (activeSub instanceof ReactiveEffect) {
  505. activeSub.cleanup = fn;
  506. } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
  507. warn(
  508. `onEffectCleanup() was called when there was no active effect to associate with.`
  509. );
  510. }
  511. }
  512. function cleanupEffect(e) {
  513. const { cleanup } = e;
  514. e.cleanup = void 0;
  515. if (cleanup) {
  516. const prevSub = activeSub;
  517. activeSub = void 0;
  518. try {
  519. cleanup();
  520. } finally {
  521. activeSub = prevSub;
  522. }
  523. }
  524. }
  525. let globalVersion = 0;
  526. class Link {
  527. constructor(sub, dep) {
  528. this.sub = sub;
  529. this.dep = dep;
  530. this.version = dep.version;
  531. this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
  532. }
  533. }
  534. class Dep {
  535. // TODO isolatedDeclarations "__v_skip"
  536. constructor(computed) {
  537. this.computed = computed;
  538. this.version = 0;
  539. /**
  540. * Link between this dep and the current active effect
  541. */
  542. this.activeLink = void 0;
  543. /**
  544. * Doubly linked list representing the subscribing effects (tail)
  545. */
  546. this.subs = void 0;
  547. /**
  548. * For object property deps cleanup
  549. */
  550. this.map = void 0;
  551. this.key = void 0;
  552. /**
  553. * Subscriber counter
  554. */
  555. this.sc = 0;
  556. /**
  557. * @internal
  558. */
  559. this.__v_skip = true;
  560. if (!!(process.env.NODE_ENV !== "production")) {
  561. this.subsHead = void 0;
  562. }
  563. }
  564. track(debugInfo) {
  565. if (!activeSub || !shouldTrack || activeSub === this.computed) {
  566. return;
  567. }
  568. let link = this.activeLink;
  569. if (link === void 0 || link.sub !== activeSub) {
  570. link = this.activeLink = new Link(activeSub, this);
  571. if (!activeSub.deps) {
  572. activeSub.deps = activeSub.depsTail = link;
  573. } else {
  574. link.prevDep = activeSub.depsTail;
  575. activeSub.depsTail.nextDep = link;
  576. activeSub.depsTail = link;
  577. }
  578. addSub(link);
  579. } else if (link.version === -1) {
  580. link.version = this.version;
  581. if (link.nextDep) {
  582. const next = link.nextDep;
  583. next.prevDep = link.prevDep;
  584. if (link.prevDep) {
  585. link.prevDep.nextDep = next;
  586. }
  587. link.prevDep = activeSub.depsTail;
  588. link.nextDep = void 0;
  589. activeSub.depsTail.nextDep = link;
  590. activeSub.depsTail = link;
  591. if (activeSub.deps === link) {
  592. activeSub.deps = next;
  593. }
  594. }
  595. }
  596. if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) {
  597. activeSub.onTrack(
  598. extend(
  599. {
  600. effect: activeSub
  601. },
  602. debugInfo
  603. )
  604. );
  605. }
  606. return link;
  607. }
  608. trigger(debugInfo) {
  609. this.version++;
  610. globalVersion++;
  611. this.notify(debugInfo);
  612. }
  613. notify(debugInfo) {
  614. startBatch();
  615. try {
  616. if (!!(process.env.NODE_ENV !== "production")) {
  617. for (let head = this.subsHead; head; head = head.nextSub) {
  618. if (head.sub.onTrigger && !(head.sub.flags & 8)) {
  619. head.sub.onTrigger(
  620. extend(
  621. {
  622. effect: head.sub
  623. },
  624. debugInfo
  625. )
  626. );
  627. }
  628. }
  629. }
  630. for (let link = this.subs; link; link = link.prevSub) {
  631. if (link.sub.notify()) {
  632. ;
  633. link.sub.dep.notify();
  634. }
  635. }
  636. } finally {
  637. endBatch();
  638. }
  639. }
  640. }
  641. function addSub(link) {
  642. link.dep.sc++;
  643. if (link.sub.flags & 4) {
  644. const computed = link.dep.computed;
  645. if (computed && !link.dep.subs) {
  646. computed.flags |= 4 | 16;
  647. for (let l = computed.deps; l; l = l.nextDep) {
  648. addSub(l);
  649. }
  650. }
  651. const currentTail = link.dep.subs;
  652. if (currentTail !== link) {
  653. link.prevSub = currentTail;
  654. if (currentTail) currentTail.nextSub = link;
  655. }
  656. if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) {
  657. link.dep.subsHead = link;
  658. }
  659. link.dep.subs = link;
  660. }
  661. }
  662. const targetMap = /* @__PURE__ */ new WeakMap();
  663. const ITERATE_KEY = /* @__PURE__ */ Symbol(
  664. !!(process.env.NODE_ENV !== "production") ? "Object iterate" : ""
  665. );
  666. const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  667. !!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : ""
  668. );
  669. const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
  670. !!(process.env.NODE_ENV !== "production") ? "Array iterate" : ""
  671. );
  672. function track(target, type, key) {
  673. if (shouldTrack && activeSub) {
  674. let depsMap = targetMap.get(target);
  675. if (!depsMap) {
  676. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  677. }
  678. let dep = depsMap.get(key);
  679. if (!dep) {
  680. depsMap.set(key, dep = new Dep());
  681. dep.map = depsMap;
  682. dep.key = key;
  683. }
  684. if (!!(process.env.NODE_ENV !== "production")) {
  685. dep.track({
  686. target,
  687. type,
  688. key
  689. });
  690. } else {
  691. dep.track();
  692. }
  693. }
  694. }
  695. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  696. const depsMap = targetMap.get(target);
  697. if (!depsMap) {
  698. globalVersion++;
  699. return;
  700. }
  701. const run = (dep) => {
  702. if (dep) {
  703. if (!!(process.env.NODE_ENV !== "production")) {
  704. dep.trigger({
  705. target,
  706. type,
  707. key,
  708. newValue,
  709. oldValue,
  710. oldTarget
  711. });
  712. } else {
  713. dep.trigger();
  714. }
  715. }
  716. };
  717. startBatch();
  718. if (type === "clear") {
  719. depsMap.forEach(run);
  720. } else {
  721. const targetIsArray = isArray(target);
  722. const isArrayIndex = targetIsArray && isIntegerKey(key);
  723. if (targetIsArray && key === "length") {
  724. const newLength = Number(newValue);
  725. depsMap.forEach((dep, key2) => {
  726. if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
  727. run(dep);
  728. }
  729. });
  730. } else {
  731. if (key !== void 0 || depsMap.has(void 0)) {
  732. run(depsMap.get(key));
  733. }
  734. if (isArrayIndex) {
  735. run(depsMap.get(ARRAY_ITERATE_KEY));
  736. }
  737. switch (type) {
  738. case "add":
  739. if (!targetIsArray) {
  740. run(depsMap.get(ITERATE_KEY));
  741. if (isMap(target)) {
  742. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  743. }
  744. } else if (isArrayIndex) {
  745. run(depsMap.get("length"));
  746. }
  747. break;
  748. case "delete":
  749. if (!targetIsArray) {
  750. run(depsMap.get(ITERATE_KEY));
  751. if (isMap(target)) {
  752. run(depsMap.get(MAP_KEY_ITERATE_KEY));
  753. }
  754. }
  755. break;
  756. case "set":
  757. if (isMap(target)) {
  758. run(depsMap.get(ITERATE_KEY));
  759. }
  760. break;
  761. }
  762. }
  763. }
  764. endBatch();
  765. }
  766. function getDepFromReactive(object, key) {
  767. const depMap = targetMap.get(object);
  768. return depMap && depMap.get(key);
  769. }
  770. function reactiveReadArray(array) {
  771. const raw = toRaw(array);
  772. if (raw === array) return raw;
  773. track(raw, "iterate", ARRAY_ITERATE_KEY);
  774. if (isShallow(array)) return raw;
  775. if (!isReadonly(array)) return raw.map(toReactive);
  776. return isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
  777. }
  778. function shallowReadArray(arr) {
  779. track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
  780. return arr;
  781. }
  782. function toWrapped(target, item) {
  783. if (isReadonly(target)) {
  784. return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
  785. }
  786. return toReactive(item);
  787. }
  788. const arrayInstrumentations = {
  789. __proto__: null,
  790. [Symbol.iterator]() {
  791. return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
  792. },
  793. concat(...args) {
  794. return reactiveReadArray(this).concat(
  795. ...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)
  796. );
  797. },
  798. entries() {
  799. return iterator(this, "entries", (value) => {
  800. value[1] = toWrapped(this, value[1]);
  801. return value;
  802. });
  803. },
  804. every(fn, thisArg) {
  805. return apply(this, "every", fn, thisArg, void 0, arguments);
  806. },
  807. filter(fn, thisArg) {
  808. return apply(
  809. this,
  810. "filter",
  811. fn,
  812. thisArg,
  813. (v) => v.map((item) => toWrapped(this, item)),
  814. arguments
  815. );
  816. },
  817. find(fn, thisArg) {
  818. return apply(
  819. this,
  820. "find",
  821. fn,
  822. thisArg,
  823. (item) => toWrapped(this, item),
  824. arguments
  825. );
  826. },
  827. findIndex(fn, thisArg) {
  828. return apply(this, "findIndex", fn, thisArg, void 0, arguments);
  829. },
  830. findLast(fn, thisArg) {
  831. return apply(
  832. this,
  833. "findLast",
  834. fn,
  835. thisArg,
  836. (item) => toWrapped(this, item),
  837. arguments
  838. );
  839. },
  840. findLastIndex(fn, thisArg) {
  841. return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
  842. },
  843. // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
  844. forEach(fn, thisArg) {
  845. return apply(this, "forEach", fn, thisArg, void 0, arguments);
  846. },
  847. includes(...args) {
  848. return searchProxy(this, "includes", args);
  849. },
  850. indexOf(...args) {
  851. return searchProxy(this, "indexOf", args);
  852. },
  853. join(separator) {
  854. return reactiveReadArray(this).join(separator);
  855. },
  856. // keys() iterator only reads `length`, no optimization required
  857. lastIndexOf(...args) {
  858. return searchProxy(this, "lastIndexOf", args);
  859. },
  860. map(fn, thisArg) {
  861. return apply(this, "map", fn, thisArg, void 0, arguments);
  862. },
  863. pop() {
  864. return noTracking(this, "pop");
  865. },
  866. push(...args) {
  867. return noTracking(this, "push", args);
  868. },
  869. reduce(fn, ...args) {
  870. return reduce(this, "reduce", fn, args);
  871. },
  872. reduceRight(fn, ...args) {
  873. return reduce(this, "reduceRight", fn, args);
  874. },
  875. shift() {
  876. return noTracking(this, "shift");
  877. },
  878. // slice could use ARRAY_ITERATE but also seems to beg for range tracking
  879. some(fn, thisArg) {
  880. return apply(this, "some", fn, thisArg, void 0, arguments);
  881. },
  882. splice(...args) {
  883. return noTracking(this, "splice", args);
  884. },
  885. toReversed() {
  886. return reactiveReadArray(this).toReversed();
  887. },
  888. toSorted(comparer) {
  889. return reactiveReadArray(this).toSorted(comparer);
  890. },
  891. toSpliced(...args) {
  892. return reactiveReadArray(this).toSpliced(...args);
  893. },
  894. unshift(...args) {
  895. return noTracking(this, "unshift", args);
  896. },
  897. values() {
  898. return iterator(this, "values", (item) => toWrapped(this, item));
  899. }
  900. };
  901. function iterator(self, method, wrapValue) {
  902. const arr = shallowReadArray(self);
  903. const iter = arr[method]();
  904. if (arr !== self && !isShallow(self)) {
  905. iter._next = iter.next;
  906. iter.next = () => {
  907. const result = iter._next();
  908. if (!result.done) {
  909. result.value = wrapValue(result.value);
  910. }
  911. return result;
  912. };
  913. }
  914. return iter;
  915. }
  916. const arrayProto = Array.prototype;
  917. function apply(self, method, fn, thisArg, wrappedRetFn, args) {
  918. const arr = shallowReadArray(self);
  919. const needsWrap = arr !== self && !isShallow(self);
  920. const methodFn = arr[method];
  921. if (methodFn !== arrayProto[method]) {
  922. const result2 = methodFn.apply(self, args);
  923. return needsWrap ? toReactive(result2) : result2;
  924. }
  925. let wrappedFn = fn;
  926. if (arr !== self) {
  927. if (needsWrap) {
  928. wrappedFn = function(item, index) {
  929. return fn.call(this, toWrapped(self, item), index, self);
  930. };
  931. } else if (fn.length > 2) {
  932. wrappedFn = function(item, index) {
  933. return fn.call(this, item, index, self);
  934. };
  935. }
  936. }
  937. const result = methodFn.call(arr, wrappedFn, thisArg);
  938. return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
  939. }
  940. function reduce(self, method, fn, args) {
  941. const arr = shallowReadArray(self);
  942. const needsWrap = arr !== self && !isShallow(self);
  943. let wrappedFn = fn;
  944. let wrapInitialAccumulator = false;
  945. if (arr !== self) {
  946. if (needsWrap) {
  947. wrapInitialAccumulator = args.length === 0;
  948. wrappedFn = function(acc, item, index) {
  949. if (wrapInitialAccumulator) {
  950. wrapInitialAccumulator = false;
  951. acc = toWrapped(self, acc);
  952. }
  953. return fn.call(this, acc, toWrapped(self, item), index, self);
  954. };
  955. } else if (fn.length > 3) {
  956. wrappedFn = function(acc, item, index) {
  957. return fn.call(this, acc, item, index, self);
  958. };
  959. }
  960. }
  961. const result = arr[method](wrappedFn, ...args);
  962. return wrapInitialAccumulator ? toWrapped(self, result) : result;
  963. }
  964. function searchProxy(self, method, args) {
  965. const arr = toRaw(self);
  966. track(arr, "iterate", ARRAY_ITERATE_KEY);
  967. const res = arr[method](...args);
  968. if ((res === -1 || res === false) && isProxy(args[0])) {
  969. args[0] = toRaw(args[0]);
  970. return arr[method](...args);
  971. }
  972. return res;
  973. }
  974. function noTracking(self, method, args = []) {
  975. pauseTracking();
  976. startBatch();
  977. const res = toRaw(self)[method].apply(self, args);
  978. endBatch();
  979. resetTracking();
  980. return res;
  981. }
  982. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  983. const builtInSymbols = new Set(
  984. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  985. );
  986. function hasOwnProperty(key) {
  987. if (!isSymbol(key)) key = String(key);
  988. const obj = toRaw(this);
  989. track(obj, "has", key);
  990. return obj.hasOwnProperty(key);
  991. }
  992. class BaseReactiveHandler {
  993. constructor(_isReadonly = false, _isShallow = false) {
  994. this._isReadonly = _isReadonly;
  995. this._isShallow = _isShallow;
  996. }
  997. get(target, key, receiver) {
  998. if (key === "__v_skip") return target["__v_skip"];
  999. const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
  1000. if (key === "__v_isReactive") {
  1001. return !isReadonly2;
  1002. } else if (key === "__v_isReadonly") {
  1003. return isReadonly2;
  1004. } else if (key === "__v_isShallow") {
  1005. return isShallow2;
  1006. } else if (key === "__v_raw") {
  1007. if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
  1008. // this means the receiver is a user proxy of the reactive proxy
  1009. Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
  1010. return target;
  1011. }
  1012. return;
  1013. }
  1014. const targetIsArray = isArray(target);
  1015. if (!isReadonly2) {
  1016. let fn;
  1017. if (targetIsArray && (fn = arrayInstrumentations[key])) {
  1018. return fn;
  1019. }
  1020. if (key === "hasOwnProperty") {
  1021. return hasOwnProperty;
  1022. }
  1023. }
  1024. const res = Reflect.get(
  1025. target,
  1026. key,
  1027. // if this is a proxy wrapping a ref, return methods using the raw ref
  1028. // as receiver so that we don't have to call `toRaw` on the ref in all
  1029. // its class methods
  1030. isRef(target) ? target : receiver
  1031. );
  1032. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  1033. return res;
  1034. }
  1035. if (!isReadonly2) {
  1036. track(target, "get", key);
  1037. }
  1038. if (isShallow2) {
  1039. return res;
  1040. }
  1041. if (isRef(res)) {
  1042. const value = targetIsArray && isIntegerKey(key) ? res : res.value;
  1043. return isReadonly2 && isObject(value) ? readonly(value) : value;
  1044. }
  1045. if (isObject(res)) {
  1046. return isReadonly2 ? readonly(res) : reactive(res);
  1047. }
  1048. return res;
  1049. }
  1050. }
  1051. class MutableReactiveHandler extends BaseReactiveHandler {
  1052. constructor(isShallow2 = false) {
  1053. super(false, isShallow2);
  1054. }
  1055. set(target, key, value, receiver) {
  1056. let oldValue = target[key];
  1057. const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
  1058. if (!this._isShallow) {
  1059. const isOldValueReadonly = isReadonly(oldValue);
  1060. if (!isShallow(value) && !isReadonly(value)) {
  1061. oldValue = toRaw(oldValue);
  1062. value = toRaw(value);
  1063. }
  1064. if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
  1065. if (isOldValueReadonly) {
  1066. if (!!(process.env.NODE_ENV !== "production")) {
  1067. warn(
  1068. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1069. target[key]
  1070. );
  1071. }
  1072. return true;
  1073. } else {
  1074. oldValue.value = value;
  1075. return true;
  1076. }
  1077. }
  1078. }
  1079. const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
  1080. const result = Reflect.set(
  1081. target,
  1082. key,
  1083. value,
  1084. isRef(target) ? target : receiver
  1085. );
  1086. if (target === toRaw(receiver) && result) {
  1087. if (!hadKey) {
  1088. trigger(target, "add", key, value);
  1089. } else if (hasChanged(value, oldValue)) {
  1090. trigger(target, "set", key, value, oldValue);
  1091. }
  1092. }
  1093. return result;
  1094. }
  1095. deleteProperty(target, key) {
  1096. const hadKey = hasOwn(target, key);
  1097. const oldValue = target[key];
  1098. const result = Reflect.deleteProperty(target, key);
  1099. if (result && hadKey) {
  1100. trigger(target, "delete", key, void 0, oldValue);
  1101. }
  1102. return result;
  1103. }
  1104. has(target, key) {
  1105. const result = Reflect.has(target, key);
  1106. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  1107. track(target, "has", key);
  1108. }
  1109. return result;
  1110. }
  1111. ownKeys(target) {
  1112. track(
  1113. target,
  1114. "iterate",
  1115. isArray(target) ? "length" : ITERATE_KEY
  1116. );
  1117. return Reflect.ownKeys(target);
  1118. }
  1119. }
  1120. class ReadonlyReactiveHandler extends BaseReactiveHandler {
  1121. constructor(isShallow2 = false) {
  1122. super(true, isShallow2);
  1123. }
  1124. set(target, key) {
  1125. if (!!(process.env.NODE_ENV !== "production")) {
  1126. warn(
  1127. `Set operation on key "${String(key)}" failed: target is readonly.`,
  1128. target
  1129. );
  1130. }
  1131. return true;
  1132. }
  1133. deleteProperty(target, key) {
  1134. if (!!(process.env.NODE_ENV !== "production")) {
  1135. warn(
  1136. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  1137. target
  1138. );
  1139. }
  1140. return true;
  1141. }
  1142. }
  1143. const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
  1144. const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
  1145. const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
  1146. const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
  1147. const toShallow = (value) => value;
  1148. const getProto = (v) => Reflect.getPrototypeOf(v);
  1149. function createIterableMethod(method, isReadonly2, isShallow2) {
  1150. return function(...args) {
  1151. const target = this["__v_raw"];
  1152. const rawTarget = toRaw(target);
  1153. const targetIsMap = isMap(rawTarget);
  1154. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  1155. const isKeyOnly = method === "keys" && targetIsMap;
  1156. const innerIterator = target[method](...args);
  1157. const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
  1158. !isReadonly2 && track(
  1159. rawTarget,
  1160. "iterate",
  1161. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  1162. );
  1163. return extend(
  1164. // inheriting all iterator properties
  1165. Object.create(innerIterator),
  1166. {
  1167. // iterator protocol
  1168. next() {
  1169. const { value, done } = innerIterator.next();
  1170. return done ? { value, done } : {
  1171. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1172. done
  1173. };
  1174. }
  1175. }
  1176. );
  1177. };
  1178. }
  1179. function createReadonlyMethod(type) {
  1180. return function(...args) {
  1181. if (!!(process.env.NODE_ENV !== "production")) {
  1182. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1183. warn(
  1184. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  1185. toRaw(this)
  1186. );
  1187. }
  1188. return type === "delete" ? false : type === "clear" ? void 0 : this;
  1189. };
  1190. }
  1191. function createInstrumentations(readonly, shallow) {
  1192. const instrumentations = {
  1193. get(key) {
  1194. const target = this["__v_raw"];
  1195. const rawTarget = toRaw(target);
  1196. const rawKey = toRaw(key);
  1197. if (!readonly) {
  1198. if (hasChanged(key, rawKey)) {
  1199. track(rawTarget, "get", key);
  1200. }
  1201. track(rawTarget, "get", rawKey);
  1202. }
  1203. const { has } = getProto(rawTarget);
  1204. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1205. if (has.call(rawTarget, key)) {
  1206. return wrap(target.get(key));
  1207. } else if (has.call(rawTarget, rawKey)) {
  1208. return wrap(target.get(rawKey));
  1209. } else if (target !== rawTarget) {
  1210. target.get(key);
  1211. }
  1212. },
  1213. get size() {
  1214. const target = this["__v_raw"];
  1215. !readonly && track(toRaw(target), "iterate", ITERATE_KEY);
  1216. return target.size;
  1217. },
  1218. has(key) {
  1219. const target = this["__v_raw"];
  1220. const rawTarget = toRaw(target);
  1221. const rawKey = toRaw(key);
  1222. if (!readonly) {
  1223. if (hasChanged(key, rawKey)) {
  1224. track(rawTarget, "has", key);
  1225. }
  1226. track(rawTarget, "has", rawKey);
  1227. }
  1228. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  1229. },
  1230. forEach(callback, thisArg) {
  1231. const observed = this;
  1232. const target = observed["__v_raw"];
  1233. const rawTarget = toRaw(target);
  1234. const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
  1235. !readonly && track(rawTarget, "iterate", ITERATE_KEY);
  1236. return target.forEach((value, key) => {
  1237. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1238. });
  1239. }
  1240. };
  1241. extend(
  1242. instrumentations,
  1243. readonly ? {
  1244. add: createReadonlyMethod("add"),
  1245. set: createReadonlyMethod("set"),
  1246. delete: createReadonlyMethod("delete"),
  1247. clear: createReadonlyMethod("clear")
  1248. } : {
  1249. add(value) {
  1250. const target = toRaw(this);
  1251. const proto = getProto(target);
  1252. const rawValue = toRaw(value);
  1253. const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
  1254. const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
  1255. if (!hadKey) {
  1256. target.add(valueToAdd);
  1257. trigger(target, "add", valueToAdd, valueToAdd);
  1258. }
  1259. return this;
  1260. },
  1261. set(key, value) {
  1262. if (!shallow && !isShallow(value) && !isReadonly(value)) {
  1263. value = toRaw(value);
  1264. }
  1265. const target = toRaw(this);
  1266. const { has, get } = getProto(target);
  1267. let hadKey = has.call(target, key);
  1268. if (!hadKey) {
  1269. key = toRaw(key);
  1270. hadKey = has.call(target, key);
  1271. } else if (!!(process.env.NODE_ENV !== "production")) {
  1272. checkIdentityKeys(target, has, key);
  1273. }
  1274. const oldValue = get.call(target, key);
  1275. target.set(key, value);
  1276. if (!hadKey) {
  1277. trigger(target, "add", key, value);
  1278. } else if (hasChanged(value, oldValue)) {
  1279. trigger(target, "set", key, value, oldValue);
  1280. }
  1281. return this;
  1282. },
  1283. delete(key) {
  1284. const target = toRaw(this);
  1285. const { has, get } = getProto(target);
  1286. let hadKey = has.call(target, key);
  1287. if (!hadKey) {
  1288. key = toRaw(key);
  1289. hadKey = has.call(target, key);
  1290. } else if (!!(process.env.NODE_ENV !== "production")) {
  1291. checkIdentityKeys(target, has, key);
  1292. }
  1293. const oldValue = get ? get.call(target, key) : void 0;
  1294. const result = target.delete(key);
  1295. if (hadKey) {
  1296. trigger(target, "delete", key, void 0, oldValue);
  1297. }
  1298. return result;
  1299. },
  1300. clear() {
  1301. const target = toRaw(this);
  1302. const hadItems = target.size !== 0;
  1303. const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
  1304. const result = target.clear();
  1305. if (hadItems) {
  1306. trigger(
  1307. target,
  1308. "clear",
  1309. void 0,
  1310. void 0,
  1311. oldTarget
  1312. );
  1313. }
  1314. return result;
  1315. }
  1316. }
  1317. );
  1318. const iteratorMethods = [
  1319. "keys",
  1320. "values",
  1321. "entries",
  1322. Symbol.iterator
  1323. ];
  1324. iteratorMethods.forEach((method) => {
  1325. instrumentations[method] = createIterableMethod(method, readonly, shallow);
  1326. });
  1327. return instrumentations;
  1328. }
  1329. function createInstrumentationGetter(isReadonly2, shallow) {
  1330. const instrumentations = createInstrumentations(isReadonly2, shallow);
  1331. return (target, key, receiver) => {
  1332. if (key === "__v_isReactive") {
  1333. return !isReadonly2;
  1334. } else if (key === "__v_isReadonly") {
  1335. return isReadonly2;
  1336. } else if (key === "__v_raw") {
  1337. return target;
  1338. }
  1339. return Reflect.get(
  1340. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1341. key,
  1342. receiver
  1343. );
  1344. };
  1345. }
  1346. const mutableCollectionHandlers = {
  1347. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1348. };
  1349. const shallowCollectionHandlers = {
  1350. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1351. };
  1352. const readonlyCollectionHandlers = {
  1353. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1354. };
  1355. const shallowReadonlyCollectionHandlers = {
  1356. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1357. };
  1358. function checkIdentityKeys(target, has, key) {
  1359. const rawKey = toRaw(key);
  1360. if (rawKey !== key && has.call(target, rawKey)) {
  1361. const type = toRawType(target);
  1362. warn(
  1363. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
  1364. );
  1365. }
  1366. }
  1367. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1368. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1369. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1370. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1371. function targetTypeMap(rawType) {
  1372. switch (rawType) {
  1373. case "Object":
  1374. case "Array":
  1375. return 1 /* COMMON */;
  1376. case "Map":
  1377. case "Set":
  1378. case "WeakMap":
  1379. case "WeakSet":
  1380. return 2 /* COLLECTION */;
  1381. default:
  1382. return 0 /* INVALID */;
  1383. }
  1384. }
  1385. // @__NO_SIDE_EFFECTS__
  1386. function reactive(target) {
  1387. if (/* @__PURE__ */ isReadonly(target)) {
  1388. return target;
  1389. }
  1390. return createReactiveObject(
  1391. target,
  1392. false,
  1393. mutableHandlers,
  1394. mutableCollectionHandlers,
  1395. reactiveMap
  1396. );
  1397. }
  1398. // @__NO_SIDE_EFFECTS__
  1399. function shallowReactive(target) {
  1400. return createReactiveObject(
  1401. target,
  1402. false,
  1403. shallowReactiveHandlers,
  1404. shallowCollectionHandlers,
  1405. shallowReactiveMap
  1406. );
  1407. }
  1408. // @__NO_SIDE_EFFECTS__
  1409. function readonly(target) {
  1410. return createReactiveObject(
  1411. target,
  1412. true,
  1413. readonlyHandlers,
  1414. readonlyCollectionHandlers,
  1415. readonlyMap
  1416. );
  1417. }
  1418. // @__NO_SIDE_EFFECTS__
  1419. function shallowReadonly(target) {
  1420. return createReactiveObject(
  1421. target,
  1422. true,
  1423. shallowReadonlyHandlers,
  1424. shallowReadonlyCollectionHandlers,
  1425. shallowReadonlyMap
  1426. );
  1427. }
  1428. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1429. if (!isObject(target)) {
  1430. if (!!(process.env.NODE_ENV !== "production")) {
  1431. warn(
  1432. `value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
  1433. target
  1434. )}`
  1435. );
  1436. }
  1437. return target;
  1438. }
  1439. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1440. return target;
  1441. }
  1442. if (target["__v_skip"] || !Object.isExtensible(target)) {
  1443. return target;
  1444. }
  1445. const existingProxy = proxyMap.get(target);
  1446. if (existingProxy) {
  1447. return existingProxy;
  1448. }
  1449. const targetType = targetTypeMap(toRawType(target));
  1450. if (targetType === 0 /* INVALID */) {
  1451. return target;
  1452. }
  1453. const proxy = new Proxy(
  1454. target,
  1455. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1456. );
  1457. proxyMap.set(target, proxy);
  1458. return proxy;
  1459. }
  1460. // @__NO_SIDE_EFFECTS__
  1461. function isReactive(value) {
  1462. if (/* @__PURE__ */ isReadonly(value)) {
  1463. return /* @__PURE__ */ isReactive(value["__v_raw"]);
  1464. }
  1465. return !!(value && value["__v_isReactive"]);
  1466. }
  1467. // @__NO_SIDE_EFFECTS__
  1468. function isReadonly(value) {
  1469. return !!(value && value["__v_isReadonly"]);
  1470. }
  1471. // @__NO_SIDE_EFFECTS__
  1472. function isShallow(value) {
  1473. return !!(value && value["__v_isShallow"]);
  1474. }
  1475. // @__NO_SIDE_EFFECTS__
  1476. function isProxy(value) {
  1477. return value ? !!value["__v_raw"] : false;
  1478. }
  1479. // @__NO_SIDE_EFFECTS__
  1480. function toRaw(observed) {
  1481. const raw = observed && observed["__v_raw"];
  1482. return raw ? /* @__PURE__ */ toRaw(raw) : observed;
  1483. }
  1484. function markRaw(value) {
  1485. if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
  1486. def(value, "__v_skip", true);
  1487. }
  1488. return value;
  1489. }
  1490. const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
  1491. const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
  1492. // @__NO_SIDE_EFFECTS__
  1493. function isRef(r) {
  1494. return r ? r["__v_isRef"] === true : false;
  1495. }
  1496. // @__NO_SIDE_EFFECTS__
  1497. function ref(value) {
  1498. return createRef(value, false);
  1499. }
  1500. // @__NO_SIDE_EFFECTS__
  1501. function shallowRef(value) {
  1502. return createRef(value, true);
  1503. }
  1504. function createRef(rawValue, shallow) {
  1505. if (/* @__PURE__ */ isRef(rawValue)) {
  1506. return rawValue;
  1507. }
  1508. return new RefImpl(rawValue, shallow);
  1509. }
  1510. class RefImpl {
  1511. constructor(value, isShallow2) {
  1512. this.dep = new Dep();
  1513. this["__v_isRef"] = true;
  1514. this["__v_isShallow"] = false;
  1515. this._rawValue = isShallow2 ? value : toRaw(value);
  1516. this._value = isShallow2 ? value : toReactive(value);
  1517. this["__v_isShallow"] = isShallow2;
  1518. }
  1519. get value() {
  1520. if (!!(process.env.NODE_ENV !== "production")) {
  1521. this.dep.track({
  1522. target: this,
  1523. type: "get",
  1524. key: "value"
  1525. });
  1526. } else {
  1527. this.dep.track();
  1528. }
  1529. return this._value;
  1530. }
  1531. set value(newValue) {
  1532. const oldValue = this._rawValue;
  1533. const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
  1534. newValue = useDirectValue ? newValue : toRaw(newValue);
  1535. if (hasChanged(newValue, oldValue)) {
  1536. this._rawValue = newValue;
  1537. this._value = useDirectValue ? newValue : toReactive(newValue);
  1538. if (!!(process.env.NODE_ENV !== "production")) {
  1539. this.dep.trigger({
  1540. target: this,
  1541. type: "set",
  1542. key: "value",
  1543. newValue,
  1544. oldValue
  1545. });
  1546. } else {
  1547. this.dep.trigger();
  1548. }
  1549. }
  1550. }
  1551. }
  1552. function triggerRef(ref2) {
  1553. if (ref2.dep) {
  1554. if (!!(process.env.NODE_ENV !== "production")) {
  1555. ref2.dep.trigger({
  1556. target: ref2,
  1557. type: "set",
  1558. key: "value",
  1559. newValue: ref2._value
  1560. });
  1561. } else {
  1562. ref2.dep.trigger();
  1563. }
  1564. }
  1565. }
  1566. function unref(ref2) {
  1567. return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2;
  1568. }
  1569. function toValue(source) {
  1570. return isFunction(source) ? source() : unref(source);
  1571. }
  1572. const shallowUnwrapHandlers = {
  1573. get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
  1574. set: (target, key, value, receiver) => {
  1575. const oldValue = target[key];
  1576. if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
  1577. oldValue.value = value;
  1578. return true;
  1579. } else {
  1580. return Reflect.set(target, key, value, receiver);
  1581. }
  1582. }
  1583. };
  1584. function proxyRefs(objectWithRefs) {
  1585. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1586. }
  1587. class CustomRefImpl {
  1588. constructor(factory) {
  1589. this["__v_isRef"] = true;
  1590. this._value = void 0;
  1591. const dep = this.dep = new Dep();
  1592. const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
  1593. this._get = get;
  1594. this._set = set;
  1595. }
  1596. get value() {
  1597. return this._value = this._get();
  1598. }
  1599. set value(newVal) {
  1600. this._set(newVal);
  1601. }
  1602. }
  1603. function customRef(factory) {
  1604. return new CustomRefImpl(factory);
  1605. }
  1606. // @__NO_SIDE_EFFECTS__
  1607. function toRefs(object) {
  1608. if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
  1609. warn(`toRefs() expects a reactive object but received a plain one.`);
  1610. }
  1611. const ret = isArray(object) ? new Array(object.length) : {};
  1612. for (const key in object) {
  1613. ret[key] = propertyToRef(object, key);
  1614. }
  1615. return ret;
  1616. }
  1617. class ObjectRefImpl {
  1618. constructor(_object, key, _defaultValue) {
  1619. this._object = _object;
  1620. this._defaultValue = _defaultValue;
  1621. this["__v_isRef"] = true;
  1622. this._value = void 0;
  1623. this._key = isSymbol(key) ? key : String(key);
  1624. this._raw = toRaw(_object);
  1625. let shallow = true;
  1626. let obj = _object;
  1627. if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
  1628. do {
  1629. shallow = !isProxy(obj) || isShallow(obj);
  1630. } while (shallow && (obj = obj["__v_raw"]));
  1631. }
  1632. this._shallow = shallow;
  1633. }
  1634. get value() {
  1635. let val = this._object[this._key];
  1636. if (this._shallow) {
  1637. val = unref(val);
  1638. }
  1639. return this._value = val === void 0 ? this._defaultValue : val;
  1640. }
  1641. set value(newVal) {
  1642. if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) {
  1643. const nestedRef = this._object[this._key];
  1644. if (/* @__PURE__ */ isRef(nestedRef)) {
  1645. nestedRef.value = newVal;
  1646. return;
  1647. }
  1648. }
  1649. this._object[this._key] = newVal;
  1650. }
  1651. get dep() {
  1652. return getDepFromReactive(this._raw, this._key);
  1653. }
  1654. }
  1655. class GetterRefImpl {
  1656. constructor(_getter) {
  1657. this._getter = _getter;
  1658. this["__v_isRef"] = true;
  1659. this["__v_isReadonly"] = true;
  1660. this._value = void 0;
  1661. }
  1662. get value() {
  1663. return this._value = this._getter();
  1664. }
  1665. }
  1666. // @__NO_SIDE_EFFECTS__
  1667. function toRef(source, key, defaultValue) {
  1668. if (/* @__PURE__ */ isRef(source)) {
  1669. return source;
  1670. } else if (isFunction(source)) {
  1671. return new GetterRefImpl(source);
  1672. } else if (isObject(source) && arguments.length > 1) {
  1673. return propertyToRef(source, key, defaultValue);
  1674. } else {
  1675. return /* @__PURE__ */ ref(source);
  1676. }
  1677. }
  1678. function propertyToRef(source, key, defaultValue) {
  1679. return new ObjectRefImpl(source, key, defaultValue);
  1680. }
  1681. class ComputedRefImpl {
  1682. constructor(fn, setter, isSSR) {
  1683. this.fn = fn;
  1684. this.setter = setter;
  1685. /**
  1686. * @internal
  1687. */
  1688. this._value = void 0;
  1689. /**
  1690. * @internal
  1691. */
  1692. this.dep = new Dep(this);
  1693. /**
  1694. * @internal
  1695. */
  1696. this.__v_isRef = true;
  1697. // TODO isolatedDeclarations "__v_isReadonly"
  1698. // A computed is also a subscriber that tracks other deps
  1699. /**
  1700. * @internal
  1701. */
  1702. this.deps = void 0;
  1703. /**
  1704. * @internal
  1705. */
  1706. this.depsTail = void 0;
  1707. /**
  1708. * @internal
  1709. */
  1710. this.flags = 16;
  1711. /**
  1712. * @internal
  1713. */
  1714. this.globalVersion = globalVersion - 1;
  1715. /**
  1716. * @internal
  1717. */
  1718. this.next = void 0;
  1719. // for backwards compat
  1720. this.effect = this;
  1721. this["__v_isReadonly"] = !setter;
  1722. this.isSSR = isSSR;
  1723. }
  1724. /**
  1725. * @internal
  1726. */
  1727. notify() {
  1728. this.flags |= 16;
  1729. if (!(this.flags & 8) && // avoid infinite self recursion
  1730. activeSub !== this) {
  1731. batch(this, true);
  1732. return true;
  1733. } else if (!!(process.env.NODE_ENV !== "production")) ;
  1734. }
  1735. get value() {
  1736. const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({
  1737. target: this,
  1738. type: "get",
  1739. key: "value"
  1740. }) : this.dep.track();
  1741. refreshComputed(this);
  1742. if (link) {
  1743. link.version = this.dep.version;
  1744. }
  1745. return this._value;
  1746. }
  1747. set value(newValue) {
  1748. if (this.setter) {
  1749. this.setter(newValue);
  1750. } else if (!!(process.env.NODE_ENV !== "production")) {
  1751. warn("Write operation failed: computed value is readonly");
  1752. }
  1753. }
  1754. }
  1755. // @__NO_SIDE_EFFECTS__
  1756. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1757. let getter;
  1758. let setter;
  1759. if (isFunction(getterOrOptions)) {
  1760. getter = getterOrOptions;
  1761. } else {
  1762. getter = getterOrOptions.get;
  1763. setter = getterOrOptions.set;
  1764. }
  1765. const cRef = new ComputedRefImpl(getter, setter, isSSR);
  1766. if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
  1767. cRef.onTrack = debugOptions.onTrack;
  1768. cRef.onTrigger = debugOptions.onTrigger;
  1769. }
  1770. return cRef;
  1771. }
  1772. const TrackOpTypes = {
  1773. "GET": "get",
  1774. "HAS": "has",
  1775. "ITERATE": "iterate"
  1776. };
  1777. const TriggerOpTypes = {
  1778. "SET": "set",
  1779. "ADD": "add",
  1780. "DELETE": "delete",
  1781. "CLEAR": "clear"
  1782. };
  1783. const ReactiveFlags = {
  1784. "SKIP": "__v_skip",
  1785. "IS_REACTIVE": "__v_isReactive",
  1786. "IS_READONLY": "__v_isReadonly",
  1787. "IS_SHALLOW": "__v_isShallow",
  1788. "RAW": "__v_raw",
  1789. "IS_REF": "__v_isRef"
  1790. };
  1791. const WatchErrorCodes = {
  1792. "WATCH_GETTER": 2,
  1793. "2": "WATCH_GETTER",
  1794. "WATCH_CALLBACK": 3,
  1795. "3": "WATCH_CALLBACK",
  1796. "WATCH_CLEANUP": 4,
  1797. "4": "WATCH_CLEANUP"
  1798. };
  1799. const INITIAL_WATCHER_VALUE = {};
  1800. const cleanupMap = /* @__PURE__ */ new WeakMap();
  1801. let activeWatcher = void 0;
  1802. function getCurrentWatcher() {
  1803. return activeWatcher;
  1804. }
  1805. function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
  1806. if (owner) {
  1807. let cleanups = cleanupMap.get(owner);
  1808. if (!cleanups) cleanupMap.set(owner, cleanups = []);
  1809. cleanups.push(cleanupFn);
  1810. } else if (!!(process.env.NODE_ENV !== "production") && !failSilently) {
  1811. warn(
  1812. `onWatcherCleanup() was called when there was no active watcher to associate with.`
  1813. );
  1814. }
  1815. }
  1816. function watch(source, cb, options = EMPTY_OBJ) {
  1817. const { immediate, deep, once, scheduler, augmentJob, call } = options;
  1818. const warnInvalidSource = (s) => {
  1819. (options.onWarn || warn)(
  1820. `Invalid watch source: `,
  1821. s,
  1822. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  1823. );
  1824. };
  1825. const reactiveGetter = (source2) => {
  1826. if (deep) return source2;
  1827. if (isShallow(source2) || deep === false || deep === 0)
  1828. return traverse(source2, 1);
  1829. return traverse(source2);
  1830. };
  1831. let effect;
  1832. let getter;
  1833. let cleanup;
  1834. let boundCleanup;
  1835. let forceTrigger = false;
  1836. let isMultiSource = false;
  1837. if (isRef(source)) {
  1838. getter = () => source.value;
  1839. forceTrigger = isShallow(source);
  1840. } else if (isReactive(source)) {
  1841. getter = () => reactiveGetter(source);
  1842. forceTrigger = true;
  1843. } else if (isArray(source)) {
  1844. isMultiSource = true;
  1845. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  1846. getter = () => source.map((s) => {
  1847. if (isRef(s)) {
  1848. return s.value;
  1849. } else if (isReactive(s)) {
  1850. return reactiveGetter(s);
  1851. } else if (isFunction(s)) {
  1852. return call ? call(s, 2) : s();
  1853. } else {
  1854. !!(process.env.NODE_ENV !== "production") && warnInvalidSource(s);
  1855. }
  1856. });
  1857. } else if (isFunction(source)) {
  1858. if (cb) {
  1859. getter = call ? () => call(source, 2) : source;
  1860. } else {
  1861. getter = () => {
  1862. if (cleanup) {
  1863. pauseTracking();
  1864. try {
  1865. cleanup();
  1866. } finally {
  1867. resetTracking();
  1868. }
  1869. }
  1870. const currentEffect = activeWatcher;
  1871. activeWatcher = effect;
  1872. try {
  1873. return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
  1874. } finally {
  1875. activeWatcher = currentEffect;
  1876. }
  1877. };
  1878. }
  1879. } else {
  1880. getter = NOOP;
  1881. !!(process.env.NODE_ENV !== "production") && warnInvalidSource(source);
  1882. }
  1883. if (cb && deep) {
  1884. const baseGetter = getter;
  1885. const depth = deep === true ? Infinity : deep;
  1886. getter = () => traverse(baseGetter(), depth);
  1887. }
  1888. const scope = getCurrentScope();
  1889. const watchHandle = () => {
  1890. effect.stop();
  1891. if (scope && scope.active) {
  1892. remove(scope.effects, effect);
  1893. }
  1894. };
  1895. if (once && cb) {
  1896. const _cb = cb;
  1897. cb = (...args) => {
  1898. const res = _cb(...args);
  1899. watchHandle();
  1900. return res;
  1901. };
  1902. }
  1903. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  1904. const job = (immediateFirstRun) => {
  1905. if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
  1906. return;
  1907. }
  1908. if (cb) {
  1909. const newValue = effect.run();
  1910. if (immediateFirstRun || deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
  1911. if (cleanup) {
  1912. cleanup();
  1913. }
  1914. const currentWatcher = activeWatcher;
  1915. activeWatcher = effect;
  1916. try {
  1917. const args = [
  1918. newValue,
  1919. // pass undefined as the old value when it's changed for the first time
  1920. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  1921. boundCleanup
  1922. ];
  1923. oldValue = newValue;
  1924. call ? call(cb, 3, args) : (
  1925. // @ts-expect-error
  1926. cb(...args)
  1927. );
  1928. } finally {
  1929. activeWatcher = currentWatcher;
  1930. }
  1931. }
  1932. } else {
  1933. effect.run();
  1934. }
  1935. };
  1936. if (augmentJob) {
  1937. augmentJob(job);
  1938. }
  1939. effect = new ReactiveEffect(getter);
  1940. effect.scheduler = scheduler ? () => scheduler(job, false) : job;
  1941. boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
  1942. cleanup = effect.onStop = () => {
  1943. const cleanups = cleanupMap.get(effect);
  1944. if (cleanups) {
  1945. if (call) {
  1946. call(cleanups, 4);
  1947. } else {
  1948. for (const cleanup2 of cleanups) cleanup2();
  1949. }
  1950. cleanupMap.delete(effect);
  1951. }
  1952. };
  1953. if (!!(process.env.NODE_ENV !== "production")) {
  1954. effect.onTrack = options.onTrack;
  1955. effect.onTrigger = options.onTrigger;
  1956. }
  1957. if (cb) {
  1958. if (immediate) {
  1959. job(true);
  1960. } else {
  1961. oldValue = effect.run();
  1962. }
  1963. } else if (scheduler) {
  1964. scheduler(job.bind(null, true), true);
  1965. } else {
  1966. effect.run();
  1967. }
  1968. watchHandle.pause = effect.pause.bind(effect);
  1969. watchHandle.resume = effect.resume.bind(effect);
  1970. watchHandle.stop = watchHandle;
  1971. return watchHandle;
  1972. }
  1973. function traverse(value, depth = Infinity, seen) {
  1974. if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
  1975. return value;
  1976. }
  1977. seen = seen || /* @__PURE__ */ new Map();
  1978. if ((seen.get(value) || 0) >= depth) {
  1979. return value;
  1980. }
  1981. seen.set(value, depth);
  1982. depth--;
  1983. if (isRef(value)) {
  1984. traverse(value.value, depth, seen);
  1985. } else if (isArray(value)) {
  1986. for (let i = 0; i < value.length; i++) {
  1987. traverse(value[i], depth, seen);
  1988. }
  1989. } else if (isSet(value) || isMap(value)) {
  1990. value.forEach((v) => {
  1991. traverse(v, depth, seen);
  1992. });
  1993. } else if (isPlainObject(value)) {
  1994. for (const key in value) {
  1995. traverse(value[key], depth, seen);
  1996. }
  1997. for (const key of Object.getOwnPropertySymbols(value)) {
  1998. if (Object.prototype.propertyIsEnumerable.call(value, key)) {
  1999. traverse(value[key], depth, seen);
  2000. }
  2001. }
  2002. }
  2003. return value;
  2004. }
  2005. export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch };