g(x,c))a[d]=x,a[n]=c,d=n;else break a}}return b}\nfunction g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}if(\"object\"===typeof performance&&\"function\"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()}}else{var p=Date,q=p.now();exports.unstable_now=function(){return p.now()-q}}var r=[],t=[],u=1,v=null,y=3,z=!1,A=!1,B=!1,D=\"function\"===typeof setTimeout?setTimeout:null,E=\"function\"===typeof clearTimeout?clearTimeout:null,F=\"undefined\"!==typeof setImmediate?setImmediate:null;\n\"undefined\"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(a){for(var b=h(t);null!==b;){if(null===b.callback)k(t);else if(b.startTime<=a)k(t),b.sortIndex=b.expirationTime,f(r,b);else break;b=h(t)}}function H(a){B=!1;G(a);if(!A)if(null!==h(r))A=!0,I(J);else{var b=h(t);null!==b&&K(H,b.startTime-a)}}\nfunction J(a,b){A=!1;B&&(B=!1,E(L),L=-1);z=!0;var c=y;try{G(b);for(v=h(r);null!==v&&(!(v.expirationTime>b)||a&&!M());){var d=v.callback;if(\"function\"===typeof d){v.callback=null;y=v.priorityLevel;var e=d(v.expirationTime<=b);b=exports.unstable_now();\"function\"===typeof e?v.callback=e:v===h(r)&&k(r);G(b)}else k(r);v=h(r)}if(null!==v)var w=!0;else{var m=h(t);null!==m&&K(H,m.startTime-b);w=!1}return w}finally{v=null,y=c,z=!1}}var N=!1,O=null,L=-1,P=5,Q=-1;\nfunction M(){return exports.unstable_now()-Qa||125d?(a.sortIndex=c,f(t,a),null===h(r)&&a===h(t)&&(B?(E(L),L=-1):B=!0,K(H,c-d))):(a.sortIndex=e,f(r,a),A||z||(A=!0,I(J)));return a};\nexports.unstable_shouldYield=M;exports.unstable_wrapCallback=function(a){var b=y;return function(){var c=y;y=b;try{return a.apply(this,arguments)}finally{y=c}}};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/scheduler.production.min.js');\n} else {\n module.exports = require('./cjs/scheduler.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\tloaded: false,\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Flag the module as loaded\n\tmodule.loaded = true;\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__; };\nvar leafPrototypes;\n// create a fake namespace object\n// mode & 1: value is a module id, require it\n// mode & 2: merge all properties of value into the ns\n// mode & 4: return value when already ns object\n// mode & 16: return value when it's Promise-like\n// mode & 8|1: behave like require\n__webpack_require__.t = function(value, mode) {\n\tif(mode & 1) value = this(value);\n\tif(mode & 8) return value;\n\tif(typeof value === 'object' && value) {\n\t\tif((mode & 4) && value.__esModule) return value;\n\t\tif((mode & 16) && typeof value.then === 'function') return value;\n\t}\n\tvar ns = Object.create(null);\n\t__webpack_require__.r(ns);\n\tvar def = {};\n\tleafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];\n\tfor(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {\n\t\tObject.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; });\n\t}\n\tdef['default'] = function() { return value; };\n\t__webpack_require__.d(ns, def);\n\treturn ns;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = function(chunkId) {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = function(chunkId) {\n\t// return url for filenames based on template\n\treturn \"static/js/\" + chunkId + \".\" + \"d1d4a2c2\" + \".chunk.js\";\n};","// This function allow to reference async chunks\n__webpack_require__.miniCssF = function(chunkId) {\n\t// return url for filenames based on template\n\treturn undefined;\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","var inProgress = {};\nvar dataWebpackPrefix = \"web:\";\n// loadScript function to load a script via script tag\n__webpack_require__.l = function(url, done, key, chunkId) {\n\tif(inProgress[url]) { inProgress[url].push(done); return; }\n\tvar script, needAttach;\n\tif(key !== undefined) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tfor(var i = 0; i < scripts.length; i++) {\n\t\t\tvar s = scripts[i];\n\t\t\tif(s.getAttribute(\"src\") == url || s.getAttribute(\"data-webpack\") == dataWebpackPrefix + key) { script = s; break; }\n\t\t}\n\t}\n\tif(!script) {\n\t\tneedAttach = true;\n\t\tscript = document.createElement('script');\n\n\t\tscript.charset = 'utf-8';\n\t\tscript.timeout = 120;\n\t\tif (__webpack_require__.nc) {\n\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n\t\t}\n\t\tscript.setAttribute(\"data-webpack\", dataWebpackPrefix + key);\n\n\t\tscript.src = url;\n\t}\n\tinProgress[url] = [done];\n\tvar onScriptComplete = function(prev, event) {\n\t\t// avoid mem leaks in IE.\n\t\tscript.onerror = script.onload = null;\n\t\tclearTimeout(timeout);\n\t\tvar doneFns = inProgress[url];\n\t\tdelete inProgress[url];\n\t\tscript.parentNode && script.parentNode.removeChild(script);\n\t\tdoneFns && doneFns.forEach(function(fn) { return fn(event); });\n\t\tif(prev) return prev(event);\n\t}\n\tvar timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);\n\tscript.onerror = onScriptComplete.bind(null, script.onerror);\n\tscript.onload = onScriptComplete.bind(null, script.onload);\n\tneedAttach && document.head.appendChild(script);\n};","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.nmd = function(module) {\n\tmodule.paths = [];\n\tif (!module.children) module.children = [];\n\treturn module;\n};","__webpack_require__.p = \"/\";","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t179: 0\n};\n\n__webpack_require__.f.j = function(chunkId, promises) {\n\t\t// JSONP chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[2]);\n\t\t\t} else {\n\t\t\t\tif(true) { // all chunks have JS\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = new Promise(function(resolve, reject) { installedChunkData = installedChunks[chunkId] = [resolve, reject]; });\n\t\t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n\t\t\t\t\t// start chunk loading\n\t\t\t\t\tvar url = __webpack_require__.p + __webpack_require__.u(chunkId);\n\t\t\t\t\t// create error before stack unwound to get useful stacktrace later\n\t\t\t\t\tvar error = new Error();\n\t\t\t\t\tvar loadingEnded = function(event) {\n\t\t\t\t\t\tif(__webpack_require__.o(installedChunks, chunkId)) {\n\t\t\t\t\t\t\tinstalledChunkData = installedChunks[chunkId];\n\t\t\t\t\t\t\tif(installedChunkData !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\t\tif(installedChunkData) {\n\t\t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n\t\t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n\t\t\t\t\t\t\t\terror.type = errorType;\n\t\t\t\t\t\t\t\terror.request = realSrc;\n\t\t\t\t\t\t\t\tinstalledChunkData[1](error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t__webpack_require__.l(url, loadingEnded, \"chunk-\" + chunkId, chunkId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n};\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n// no on chunks loaded\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = function(parentChunkLoadingFunction, data) {\n\tvar chunkIds = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkweb\"] = self[\"webpackChunkweb\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","export type ColorModeScriptProps = {\n type?: \"localStorage\" | \"cookie\"\n initialColorMode?: \"light\" | \"dark\" | \"system\"\n storageKey?: string\n nonce?: string\n}\n\nconst VALID_VALUES = new Set([\"dark\", \"light\", \"system\"])\n\n/**\n * runtime safe-guard against invalid color mode values\n */\nfunction normalize(initialColorMode: \"light\" | \"dark\" | \"system\") {\n let value = initialColorMode\n if (!VALID_VALUES.has(value)) value = \"light\"\n return value\n}\n\nexport function getScriptSrc(props: ColorModeScriptProps = {}) {\n const {\n initialColorMode = \"light\",\n type = \"localStorage\",\n storageKey: key = \"chakra-ui-color-mode\",\n } = props\n\n // runtime safe-guard against invalid color mode values\n const init = normalize(initialColorMode)\n\n const isCookie = type === \"cookie\"\n\n const cookieScript = `(function(){try{var a=function(o){var l=\"(prefers-color-scheme: dark)\",v=window.matchMedia(l).matches?\"dark\":\"light\",e=o===\"system\"?v:o,d=document.documentElement,m=document.body,i=\"chakra-ui-light\",n=\"chakra-ui-dark\",s=e===\"dark\";return m.classList.add(s?n:i),m.classList.remove(s?i:n),d.style.colorScheme=e,d.dataset.theme=e,e},u=a,h=\"${init}\",r=\"${key}\",t=document.cookie.match(new RegExp(\"(^| )\".concat(r,\"=([^;]+)\"))),c=t?t[2]:null;c?a(c):document.cookie=\"\".concat(r,\"=\").concat(a(h),\"; max-age=31536000; path=/\")}catch(a){}})();\n `\n\n const localStorageScript = `(function(){try{var a=function(c){var v=\"(prefers-color-scheme: dark)\",h=window.matchMedia(v).matches?\"dark\":\"light\",r=c===\"system\"?h:c,o=document.documentElement,s=document.body,l=\"chakra-ui-light\",d=\"chakra-ui-dark\",i=r===\"dark\";return s.classList.add(i?d:l),s.classList.remove(i?l:d),o.style.colorScheme=r,o.dataset.theme=r,r},n=a,m=\"${init}\",e=\"${key}\",t=localStorage.getItem(e);t?a(t):localStorage.setItem(e,a(m))}catch(a){}})();\n `\n\n const fn = isCookie ? cookieScript : localStorageScript\n return `!${fn}`.trim()\n}\n\nexport function ColorModeScript(props: ColorModeScriptProps = {}) {\n const { nonce } = props\n\n return (\n \n )\n}\n","export default function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nexport default function _defineProperty(obj, key, value) {\n key = toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","import defineProperty from \"./defineProperty.js\";\nfunction ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nexport default function _objectSpread2(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {\n defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\n}","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","export default function _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = !0,\n o = !1;\n try {\n if (i = (t = t.call(r)).next, 0 === l) {\n if (Object(t) !== t) return;\n f = !1;\n } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = !0, n = r;\n } finally {\n try {\n if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}","export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);\n }\n}\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}","import type { Mutation } from './mutation'\nimport type { Query } from './query'\nimport type {\n FetchStatus,\n MutationFunction,\n MutationKey,\n MutationOptions,\n QueryFunction,\n QueryKey,\n QueryOptions,\n} from './types'\n\n// TYPES\n\nexport interface QueryFilters {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: QueryKey\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (mutation: Mutation) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: MutationKey\n /**\n * Include or exclude fetching mutations\n */\n fetching?: boolean\n}\n\nexport type DataUpdateFunction = (input: TInput) => TOutput\n\nexport type Updater =\n | TOutput\n | DataUpdateFunction\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\nexport const isServer = typeof window === 'undefined' || 'Deno' in window\n\nexport function noop(): undefined {\n return undefined\n}\n\nexport function functionalUpdate(\n updater: Updater,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as DataUpdateFunction)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function difference(array1: T[], array2: T[]): T[] {\n return array1.filter((x) => !array2.includes(x))\n}\n\nexport function replaceAt(array: T[], index: number, value: T): T[] {\n const copy = array.slice(0)\n copy[index] = value\n return copy\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function parseQueryArgs<\n TOptions extends QueryOptions,\n TQueryKey extends QueryKey = QueryKey,\n>(\n arg1: TQueryKey | TOptions,\n arg2?: QueryFunction | TOptions,\n arg3?: TOptions,\n): TOptions {\n if (!isQueryKey(arg1)) {\n return arg1 as TOptions\n }\n\n if (typeof arg2 === 'function') {\n return { ...arg3, queryKey: arg1, queryFn: arg2 } as TOptions\n }\n\n return { ...arg2, queryKey: arg1 } as TOptions\n}\n\nexport function parseMutationArgs<\n TOptions extends MutationOptions,\n>(\n arg1: MutationKey | MutationFunction | TOptions,\n arg2?: MutationFunction | TOptions,\n arg3?: TOptions,\n): TOptions {\n if (isQueryKey(arg1)) {\n if (typeof arg2 === 'function') {\n return { ...arg3, mutationKey: arg1, mutationFn: arg2 } as TOptions\n }\n return { ...arg2, mutationKey: arg1 } as TOptions\n }\n\n if (typeof arg1 === 'function') {\n return { ...arg2, mutationFn: arg1 } as TOptions\n }\n\n return { ...arg1 } as TOptions\n}\n\nexport function parseFilterArgs<\n TFilters extends QueryFilters,\n TOptions = unknown,\n>(\n arg1?: QueryKey | TFilters,\n arg2?: TFilters | TOptions,\n arg3?: TOptions,\n): [TFilters, TOptions | undefined] {\n return (\n isQueryKey(arg1) ? [{ ...arg2, queryKey: arg1 }, arg3] : [arg1 || {}, arg2]\n ) as [TFilters, TOptions]\n}\n\nexport function parseMutationFilterArgs<\n TFilters extends MutationFilters,\n TOptions = unknown,\n>(\n arg1?: QueryKey | TFilters,\n arg2?: TFilters | TOptions,\n arg3?: TOptions,\n): [TFilters, TOptions | undefined] {\n return (\n isQueryKey(arg1)\n ? [{ ...arg2, mutationKey: arg1 }, arg3]\n : [arg1 || {}, arg2]\n ) as [TFilters, TOptions]\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (isQueryKey(queryKey)) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (\n typeof fetchStatus !== 'undefined' &&\n fetchStatus !== query.state.fetchStatus\n ) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation,\n): boolean {\n const { exact, fetching, predicate, mutationKey } = filters\n if (isQueryKey(mutationKey)) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (\n hashQueryKey(mutation.options.mutationKey) !== hashQueryKey(mutationKey)\n ) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (\n typeof fetching === 'boolean' &&\n (mutation.state.status === 'loading') !== fetching\n ) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions(\n queryKey: TQueryKey,\n options?: QueryOptions,\n): string {\n const hashFn = options?.queryKeyHashFn || hashQueryKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashQueryKey(queryKey: QueryKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean {\n return partialDeepEqual(a, b)\n}\n\n/**\n * Checks if `b` partially matches with `a`.\n */\nexport function partialDeepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return !Object.keys(b).some((key) => !partialDeepEqual(a[key], b[key]))\n }\n\n return false\n}\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep(a: unknown, b: T): T\nexport function replaceEqualDeep(a: any, b: any): any {\n if (a === b) {\n return a\n }\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (array || (isPlainObject(a) && isPlainObject(b))) {\n const aSize = array ? a.length : Object.keys(a).length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i]\n copy[key] = replaceEqualDeep(a[key], b[key])\n if (copy[key] === a[key]) {\n equalItems++\n }\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n }\n\n return b\n}\n\n/**\n * Shallow compare objects. Only works with objects that always have the same properties.\n */\nexport function shallowEqualObjects(a: T, b: T): boolean {\n if ((a && !b) || (b && !a)) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown) {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Object {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has modified constructor\n const ctor = o.constructor\n if (typeof ctor === 'undefined') {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function isQueryKey(value: unknown): value is QueryKey {\n return Array.isArray(value)\n}\n\nexport function isError(value: any): value is Error {\n return value instanceof Error\n}\n\nexport function sleep(timeout: number): Promise {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout)\n })\n}\n\n/**\n * Schedules a microtask.\n * This can be useful to schedule state updates after rendering.\n */\nexport function scheduleMicrotask(callback: () => void) {\n sleep(0).then(callback)\n}\n\nexport function getAbortController(): AbortController | undefined {\n if (typeof AbortController === 'function') {\n return new AbortController()\n }\n return\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n // Use prev data if an isDataEqual function is defined and returns `true`\n if (options.isDataEqual?.(prevData, data)) {\n return prevData as TData\n } else if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data)\n } else if (options.structuralSharing !== false) {\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}","export default function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}","export default function _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n try {\n Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n}","import getPrototypeOf from \"./getPrototypeOf.js\";\nimport isNativeReflectConstruct from \"./isNativeReflectConstruct.js\";\nimport possibleConstructorReturn from \"./possibleConstructorReturn.js\";\nexport default function _createSuper(Derived) {\n var hasNativeReflectConstruct = isNativeReflectConstruct();\n return function _createSuperInternal() {\n var Super = getPrototypeOf(Derived),\n result;\n if (hasNativeReflectConstruct) {\n var NewTarget = getPrototypeOf(this).constructor;\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n return possibleConstructorReturn(this, result);\n };\n}","import _typeof from \"./typeof.js\";\nimport assertThisInitialized from \"./assertThisInitialized.js\";\nexport default function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n return assertThisInitialized(self);\n}","import superPropBase from \"./superPropBase.js\";\nexport default function _get() {\n if (typeof Reflect !== \"undefined\" && Reflect.get) {\n _get = Reflect.get.bind();\n } else {\n _get = function _get(target, property, receiver) {\n var base = superPropBase(target, property);\n if (!base) return;\n var desc = Object.getOwnPropertyDescriptor(base, property);\n if (desc.get) {\n return desc.get.call(arguments.length < 3 ? target : receiver);\n }\n return desc.value;\n };\n }\n return _get.apply(this, arguments);\n}","import getPrototypeOf from \"./getPrototypeOf.js\";\nexport default function _superPropBase(object, property) {\n while (!Object.prototype.hasOwnProperty.call(object, property)) {\n object = getPrototypeOf(object);\n if (object === null) break;\n }\n return object;\n}","export interface Logger {\n log: LogFunction\n warn: LogFunction\n error: LogFunction\n}\n\ntype LogFunction = (...args: any[]) => void\n\nexport const defaultLogger: Logger = console\n","import { scheduleMicrotask } from './utils'\n\n// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback = (...args: T) => void\n\nexport function createNotifyManager() {\n let queue: NotifyCallback[] = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n\n const batch = (callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleMicrotask(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = (\n callback: BatchCallsCallback,\n ): BatchCallsCallback => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleMicrotask(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n","type Listener = () => void\n\nexport class Subscribable {\n protected listeners: Set<{ listener: TListener }>\n\n constructor() {\n this.listeners = new Set()\n this.subscribe = this.subscribe.bind(this)\n }\n\n subscribe(listener: TListener): () => void {\n const identity = { listener }\n this.listeners.add(identity)\n\n this.onSubscribe()\n\n return () => {\n this.listeners.delete(identity)\n this.onUnsubscribe()\n }\n }\n\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n protected onSubscribe(): void {\n // Do nothing\n }\n\n protected onUnsubscribe(): void {\n // Do nothing\n }\n}\n","import { Subscribable } from './subscribable'\nimport { isServer } from './utils'\n\ntype SetupFn = (\n setFocused: (focused?: boolean) => void,\n) => (() => void) | undefined\n\nexport class FocusManager extends Subscribable {\n private focused?: boolean\n private cleanup?: () => void\n\n private setup: SetupFn\n\n constructor() {\n super()\n this.setup = (onFocus) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!isServer && window.addEventListener) {\n const listener = () => onFocus()\n // Listen to visibillitychange and focus\n window.addEventListener('visibilitychange', listener, false)\n window.addEventListener('focus', listener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('visibilitychange', listener)\n window.removeEventListener('focus', listener)\n }\n }\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.cleanup) {\n this.setEventListener(this.setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.cleanup?.()\n this.cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.setup = setup\n this.cleanup?.()\n this.cleanup = setup((focused) => {\n if (typeof focused === 'boolean') {\n this.setFocused(focused)\n } else {\n this.onFocus()\n }\n })\n }\n\n setFocused(focused?: boolean): void {\n const changed = this.focused !== focused\n if (changed) {\n this.focused = focused\n this.onFocus()\n }\n }\n\n onFocus(): void {\n this.listeners.forEach(({ listener }) => {\n listener()\n })\n }\n\n isFocused(): boolean {\n if (typeof this.focused === 'boolean') {\n return this.focused\n }\n\n // document global can be unavailable in react native\n if (typeof document === 'undefined') {\n return true\n }\n\n return [undefined, 'visible', 'prerender'].includes(\n document.visibilityState,\n )\n }\n}\n\nexport const focusManager = new FocusManager()\n","import { Subscribable } from './subscribable'\nimport { isServer } from './utils'\n\ntype SetupFn = (\n setOnline: (online?: boolean) => void,\n) => (() => void) | undefined\n\nconst onlineEvents = ['online', 'offline'] as const\n\nexport class OnlineManager extends Subscribable {\n private online?: boolean\n private cleanup?: () => void\n\n private setup: SetupFn\n\n constructor() {\n super()\n this.setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!isServer && window.addEventListener) {\n const listener = () => onOnline()\n // Listen to online\n onlineEvents.forEach((event) => {\n window.addEventListener(event, listener, false)\n })\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n onlineEvents.forEach((event) => {\n window.removeEventListener(event, listener)\n })\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.cleanup) {\n this.setEventListener(this.setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.cleanup?.()\n this.cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.setup = setup\n this.cleanup?.()\n this.cleanup = setup((online?: boolean) => {\n if (typeof online === 'boolean') {\n this.setOnline(online)\n } else {\n this.onOnline()\n }\n })\n }\n\n setOnline(online?: boolean): void {\n const changed = this.online !== online\n\n if (changed) {\n this.online = online\n this.onOnline()\n }\n }\n\n onOnline(): void {\n this.listeners.forEach(({ listener }) => {\n listener()\n })\n }\n\n isOnline(): boolean {\n if (typeof this.online === 'boolean') {\n return this.online\n }\n\n if (\n typeof navigator === 'undefined' ||\n typeof navigator.onLine === 'undefined'\n ) {\n return true\n }\n\n return navigator.onLine\n }\n}\n\nexport const onlineManager = new OnlineManager()\n","import { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { sleep } from './utils'\nimport type { CancelOptions, NetworkMode } from './types'\n\n// TYPES\n\ninterface RetryerConfig {\n fn: () => TData | Promise\n abort?: () => void\n onError?: (error: TError) => void\n onSuccess?: (data: TData) => void\n onFail?: (failureCount: number, error: TError) => void\n onPause?: () => void\n onContinue?: () => void\n retry?: RetryValue\n retryDelay?: RetryDelayValue\n networkMode: NetworkMode | undefined\n}\n\nexport interface Retryer {\n promise: Promise\n cancel: (cancelOptions?: CancelOptions) => void\n continue: () => Promise\n cancelRetry: () => void\n continueRetry: () => void\n}\n\nexport type RetryValue = boolean | number | ShouldRetryFunction\n\ntype ShouldRetryFunction = (\n failureCount: number,\n error: TError,\n) => boolean\n\nexport type RetryDelayValue = number | RetryDelayFunction\n\ntype RetryDelayFunction = (\n failureCount: number,\n error: TError,\n) => number\n\nfunction defaultRetryDelay(failureCount: number) {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\nexport function canFetch(networkMode: NetworkMode | undefined): boolean {\n return (networkMode ?? 'online') === 'online'\n ? onlineManager.isOnline()\n : true\n}\n\nexport class CancelledError {\n revert?: boolean\n silent?: boolean\n constructor(options?: CancelOptions) {\n this.revert = options?.revert\n this.silent = options?.silent\n }\n}\n\nexport function isCancelledError(value: any): value is CancelledError {\n return value instanceof CancelledError\n}\n\nexport function createRetryer(\n config: RetryerConfig,\n): Retryer {\n let isRetryCancelled = false\n let failureCount = 0\n let isResolved = false\n let continueFn: ((value?: unknown) => boolean) | undefined\n let promiseResolve: (data: TData) => void\n let promiseReject: (error: TError) => void\n\n const promise = new Promise((outerResolve, outerReject) => {\n promiseResolve = outerResolve\n promiseReject = outerReject\n })\n\n const cancel = (cancelOptions?: CancelOptions): void => {\n if (!isResolved) {\n reject(new CancelledError(cancelOptions))\n\n config.abort?.()\n }\n }\n const cancelRetry = () => {\n isRetryCancelled = true\n }\n\n const continueRetry = () => {\n isRetryCancelled = false\n }\n\n const shouldPause = () =>\n !focusManager.isFocused() ||\n (config.networkMode !== 'always' && !onlineManager.isOnline())\n\n const resolve = (value: any) => {\n if (!isResolved) {\n isResolved = true\n config.onSuccess?.(value)\n continueFn?.()\n promiseResolve(value)\n }\n }\n\n const reject = (value: any) => {\n if (!isResolved) {\n isResolved = true\n config.onError?.(value)\n continueFn?.()\n promiseReject(value)\n }\n }\n\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n const canContinue = isResolved || !shouldPause()\n if (canContinue) {\n continueResolve(value)\n }\n return canContinue\n }\n config.onPause?.()\n }).then(() => {\n continueFn = undefined\n if (!isResolved) {\n config.onContinue?.()\n }\n })\n }\n\n // Create loop function\n const run = () => {\n // Do nothing if already resolved\n if (isResolved) {\n return\n }\n\n let promiseOrValue: any\n\n // Execute query\n try {\n promiseOrValue = config.fn()\n } catch (error) {\n promiseOrValue = Promise.reject(error)\n }\n\n Promise.resolve(promiseOrValue)\n .then(resolve)\n .catch((error) => {\n // Stop if the fetch is already resolved\n if (isResolved) {\n return\n }\n\n // Do we need to retry the request?\n const retry = config.retry ?? 3\n const retryDelay = config.retryDelay ?? defaultRetryDelay\n const delay =\n typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n const shouldRetry =\n retry === true ||\n (typeof retry === 'number' && failureCount < retry) ||\n (typeof retry === 'function' && retry(failureCount, error))\n\n if (isRetryCancelled || !shouldRetry) {\n // We are done if the query does not need to be retried\n reject(error)\n return\n }\n\n failureCount++\n\n // Notify on fail\n config.onFail?.(failureCount, error)\n\n // Delay\n sleep(delay)\n // Pause if the document is not visible or when the device is offline\n .then(() => {\n if (shouldPause()) {\n return pause()\n }\n return\n })\n .then(() => {\n if (isRetryCancelled) {\n reject(error)\n } else {\n run()\n }\n })\n })\n }\n\n // Start loop\n if (canFetch(config.networkMode)) {\n run()\n } else {\n pause().then(run)\n }\n\n return {\n promise,\n cancel,\n continue: () => {\n const didContinue = continueFn?.()\n return didContinue ? promise : Promise.resolve()\n },\n cancelRetry,\n continueRetry,\n }\n}\n","import { isServer, isValidTimeout } from './utils'\n\nexport abstract class Removable {\n cacheTime!: number\n private gcTimeout?: ReturnType\n\n destroy(): void {\n this.clearGcTimeout()\n }\n\n protected scheduleGc(): void {\n this.clearGcTimeout()\n\n if (isValidTimeout(this.cacheTime)) {\n this.gcTimeout = setTimeout(() => {\n this.optionalRemove()\n }, this.cacheTime)\n }\n }\n\n protected updateCacheTime(newCacheTime: number | undefined): void {\n // Default to 5 minutes (Infinity for server-side) if no cache time is set\n this.cacheTime = Math.max(\n this.cacheTime || 0,\n newCacheTime ?? (isServer ? Infinity : 5 * 60 * 1000),\n )\n }\n\n protected clearGcTimeout() {\n if (this.gcTimeout) {\n clearTimeout(this.gcTimeout)\n this.gcTimeout = undefined\n }\n }\n\n protected abstract optionalRemove(): void\n}\n","import { getAbortController, noop, replaceData, timeUntilStale } from './utils'\nimport { defaultLogger } from './logger'\nimport { notifyManager } from './notifyManager'\nimport { canFetch, createRetryer, isCancelledError } from './retryer'\nimport { Removable } from './removable'\nimport type {\n CancelOptions,\n FetchStatus,\n InitialDataFunction,\n QueryFunctionContext,\n QueryKey,\n QueryMeta,\n QueryOptions,\n QueryStatus,\n SetDataOptions,\n} from './types'\nimport type { QueryCache } from './queryCache'\nimport type { QueryObserver } from './queryObserver'\nimport type { Logger } from './logger'\nimport type { Retryer } from './retryer'\n\n// TYPES\n\ninterface QueryConfig<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey = QueryKey,\n> {\n cache: QueryCache\n queryKey: TQueryKey\n queryHash: string\n logger?: Logger\n options?: QueryOptions\n defaultOptions?: QueryOptions\n state?: QueryState\n}\n\nexport interface QueryState {\n data: TData | undefined\n dataUpdateCount: number\n dataUpdatedAt: number\n error: TError | null\n errorUpdateCount: number\n errorUpdatedAt: number\n fetchFailureCount: number\n fetchFailureReason: TError | null\n fetchMeta: any\n isInvalidated: boolean\n status: QueryStatus\n fetchStatus: FetchStatus\n}\n\nexport interface FetchContext<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey = QueryKey,\n> {\n fetchFn: () => unknown | Promise\n fetchOptions?: FetchOptions\n signal?: AbortSignal\n options: QueryOptions\n queryKey: TQueryKey\n state: QueryState\n}\n\nexport interface QueryBehavior<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> {\n onFetch: (\n context: FetchContext,\n ) => void\n}\n\nexport interface FetchOptions {\n cancelRefetch?: boolean\n meta?: any\n}\n\ninterface FailedAction {\n type: 'failed'\n failureCount: number\n error: TError\n}\n\ninterface FetchAction {\n type: 'fetch'\n meta?: any\n}\n\ninterface SuccessAction {\n data: TData | undefined\n type: 'success'\n dataUpdatedAt?: number\n manual?: boolean\n}\n\ninterface ErrorAction {\n type: 'error'\n error: TError\n}\n\ninterface InvalidateAction {\n type: 'invalidate'\n}\n\ninterface PauseAction {\n type: 'pause'\n}\n\ninterface ContinueAction {\n type: 'continue'\n}\n\ninterface SetStateAction {\n type: 'setState'\n state: Partial>\n setStateOptions?: SetStateOptions\n}\n\nexport type Action =\n | ContinueAction\n | ErrorAction\n | FailedAction\n | FetchAction\n | InvalidateAction\n | PauseAction\n | SetStateAction\n | SuccessAction\n\nexport interface SetStateOptions {\n meta?: any\n}\n\n// CLASS\n\nexport class Query<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends Removable {\n queryKey: TQueryKey\n queryHash: string\n options!: QueryOptions\n initialState: QueryState\n revertState?: QueryState\n state: QueryState\n isFetchingOptimistic?: boolean\n\n private cache: QueryCache\n private logger: Logger\n private promise?: Promise\n private retryer?: Retryer\n private observers: QueryObserver[]\n private defaultOptions?: QueryOptions\n private abortSignalConsumed: boolean\n\n constructor(config: QueryConfig) {\n super()\n\n this.abortSignalConsumed = false\n this.defaultOptions = config.defaultOptions\n this.setOptions(config.options)\n this.observers = []\n this.cache = config.cache\n this.logger = config.logger || defaultLogger\n this.queryKey = config.queryKey\n this.queryHash = config.queryHash\n this.initialState = config.state || getDefaultState(this.options)\n this.state = this.initialState\n this.scheduleGc()\n }\n\n get meta(): QueryMeta | undefined {\n return this.options.meta\n }\n\n private setOptions(\n options?: QueryOptions,\n ): void {\n this.options = { ...this.defaultOptions, ...options }\n\n this.updateCacheTime(this.options.cacheTime)\n }\n\n protected optionalRemove() {\n if (!this.observers.length && this.state.fetchStatus === 'idle') {\n this.cache.remove(this)\n }\n }\n\n setData(\n newData: TData,\n options?: SetDataOptions & { manual: boolean },\n ): TData {\n const data = replaceData(this.state.data, newData, this.options)\n\n // Set data and mark it as cached\n this.dispatch({\n data,\n type: 'success',\n dataUpdatedAt: options?.updatedAt,\n manual: options?.manual,\n })\n\n return data\n }\n\n setState(\n state: Partial>,\n setStateOptions?: SetStateOptions,\n ): void {\n this.dispatch({ type: 'setState', state, setStateOptions })\n }\n\n cancel(options?: CancelOptions): Promise {\n const promise = this.promise\n this.retryer?.cancel(options)\n return promise ? promise.then(noop).catch(noop) : Promise.resolve()\n }\n\n destroy(): void {\n super.destroy()\n\n this.cancel({ silent: true })\n }\n\n reset(): void {\n this.destroy()\n this.setState(this.initialState)\n }\n\n isActive(): boolean {\n return this.observers.some((observer) => observer.options.enabled !== false)\n }\n\n isDisabled(): boolean {\n return this.getObserversCount() > 0 && !this.isActive()\n }\n\n isStale(): boolean {\n return (\n this.state.isInvalidated ||\n !this.state.dataUpdatedAt ||\n this.observers.some((observer) => observer.getCurrentResult().isStale)\n )\n }\n\n isStaleByTime(staleTime = 0): boolean {\n return (\n this.state.isInvalidated ||\n !this.state.dataUpdatedAt ||\n !timeUntilStale(this.state.dataUpdatedAt, staleTime)\n )\n }\n\n onFocus(): void {\n const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus())\n\n if (observer) {\n observer.refetch({ cancelRefetch: false })\n }\n\n // Continue fetch if currently paused\n this.retryer?.continue()\n }\n\n onOnline(): void {\n const observer = this.observers.find((x) => x.shouldFetchOnReconnect())\n\n if (observer) {\n observer.refetch({ cancelRefetch: false })\n }\n\n // Continue fetch if currently paused\n this.retryer?.continue()\n }\n\n addObserver(observer: QueryObserver): void {\n if (!this.observers.includes(observer)) {\n this.observers.push(observer)\n\n // Stop the query from being garbage collected\n this.clearGcTimeout()\n\n this.cache.notify({ type: 'observerAdded', query: this, observer })\n }\n }\n\n removeObserver(observer: QueryObserver): void {\n if (this.observers.includes(observer)) {\n this.observers = this.observers.filter((x) => x !== observer)\n\n if (!this.observers.length) {\n // If the transport layer does not support cancellation\n // we'll let the query continue so the result can be cached\n if (this.retryer) {\n if (this.abortSignalConsumed) {\n this.retryer.cancel({ revert: true })\n } else {\n this.retryer.cancelRetry()\n }\n }\n\n this.scheduleGc()\n }\n\n this.cache.notify({ type: 'observerRemoved', query: this, observer })\n }\n }\n\n getObserversCount(): number {\n return this.observers.length\n }\n\n invalidate(): void {\n if (!this.state.isInvalidated) {\n this.dispatch({ type: 'invalidate' })\n }\n }\n\n fetch(\n options?: QueryOptions,\n fetchOptions?: FetchOptions,\n ): Promise {\n if (this.state.fetchStatus !== 'idle') {\n if (this.state.dataUpdatedAt && fetchOptions?.cancelRefetch) {\n // Silently cancel current fetch if the user wants to cancel refetches\n this.cancel({ silent: true })\n } else if (this.promise) {\n // make sure that retries that were potentially cancelled due to unmounts can continue\n this.retryer?.continueRetry()\n // Return current promise if we are already fetching\n return this.promise\n }\n }\n\n // Update config if passed, otherwise the config from the last execution is used\n if (options) {\n this.setOptions(options)\n }\n\n // Use the options from the first observer with a query function if no function is found.\n // This can happen when the query is hydrated or created with setQueryData.\n if (!this.options.queryFn) {\n const observer = this.observers.find((x) => x.options.queryFn)\n if (observer) {\n this.setOptions(observer.options)\n }\n }\n\n if (!Array.isArray(this.options.queryKey)) {\n if (process.env.NODE_ENV !== 'production') {\n this.logger.error(\n `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`,\n )\n }\n }\n\n const abortController = getAbortController()\n\n // Create query function context\n const queryFnContext: QueryFunctionContext = {\n queryKey: this.queryKey,\n pageParam: undefined,\n meta: this.meta,\n }\n\n // Adds an enumerable signal property to the object that\n // which sets abortSignalConsumed to true when the signal\n // is read.\n const addSignalProperty = (object: unknown) => {\n Object.defineProperty(object, 'signal', {\n enumerable: true,\n get: () => {\n if (abortController) {\n this.abortSignalConsumed = true\n return abortController.signal\n }\n return undefined\n },\n })\n }\n\n addSignalProperty(queryFnContext)\n\n // Create fetch function\n const fetchFn = () => {\n if (!this.options.queryFn) {\n return Promise.reject(\n `Missing queryFn for queryKey '${this.options.queryHash}'`,\n )\n }\n this.abortSignalConsumed = false\n return this.options.queryFn(queryFnContext)\n }\n\n // Trigger behavior hook\n const context: FetchContext = {\n fetchOptions,\n options: this.options,\n queryKey: this.queryKey,\n state: this.state,\n fetchFn,\n }\n\n addSignalProperty(context)\n\n this.options.behavior?.onFetch(context)\n\n // Store state in case the current fetch needs to be reverted\n this.revertState = this.state\n\n // Set to fetching state if not already in it\n if (\n this.state.fetchStatus === 'idle' ||\n this.state.fetchMeta !== context.fetchOptions?.meta\n ) {\n this.dispatch({ type: 'fetch', meta: context.fetchOptions?.meta })\n }\n\n const onError = (error: TError | { silent?: boolean }) => {\n // Optimistically update state if needed\n if (!(isCancelledError(error) && error.silent)) {\n this.dispatch({\n type: 'error',\n error: error as TError,\n })\n }\n\n if (!isCancelledError(error)) {\n // Notify cache callback\n this.cache.config.onError?.(error, this as Query)\n this.cache.config.onSettled?.(\n this.state.data,\n error,\n this as Query,\n )\n\n if (process.env.NODE_ENV !== 'production') {\n this.logger.error(error)\n }\n }\n\n if (!this.isFetchingOptimistic) {\n // Schedule query gc after fetching\n this.scheduleGc()\n }\n this.isFetchingOptimistic = false\n }\n\n // Try to fetch the data\n this.retryer = createRetryer({\n fn: context.fetchFn as () => TData,\n abort: abortController?.abort.bind(abortController),\n onSuccess: (data) => {\n if (typeof data === 'undefined') {\n if (process.env.NODE_ENV !== 'production') {\n this.logger.error(\n `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`,\n )\n }\n onError(new Error(`${this.queryHash} data is undefined`) as any)\n return\n }\n\n this.setData(data as TData)\n\n // Notify cache callback\n this.cache.config.onSuccess?.(data, this as Query)\n this.cache.config.onSettled?.(\n data,\n this.state.error,\n this as Query,\n )\n\n if (!this.isFetchingOptimistic) {\n // Schedule query gc after fetching\n this.scheduleGc()\n }\n this.isFetchingOptimistic = false\n },\n onError,\n onFail: (failureCount, error) => {\n this.dispatch({ type: 'failed', failureCount, error })\n },\n onPause: () => {\n this.dispatch({ type: 'pause' })\n },\n onContinue: () => {\n this.dispatch({ type: 'continue' })\n },\n retry: context.options.retry,\n retryDelay: context.options.retryDelay,\n networkMode: context.options.networkMode,\n })\n\n this.promise = this.retryer.promise\n\n return this.promise\n }\n\n private dispatch(action: Action): void {\n const reducer = (\n state: QueryState,\n ): QueryState => {\n switch (action.type) {\n case 'failed':\n return {\n ...state,\n fetchFailureCount: action.failureCount,\n fetchFailureReason: action.error,\n }\n case 'pause':\n return {\n ...state,\n fetchStatus: 'paused',\n }\n case 'continue':\n return {\n ...state,\n fetchStatus: 'fetching',\n }\n case 'fetch':\n return {\n ...state,\n fetchFailureCount: 0,\n fetchFailureReason: null,\n fetchMeta: action.meta ?? null,\n fetchStatus: canFetch(this.options.networkMode)\n ? 'fetching'\n : 'paused',\n ...(!state.dataUpdatedAt && {\n error: null,\n status: 'loading',\n }),\n }\n case 'success':\n return {\n ...state,\n data: action.data,\n dataUpdateCount: state.dataUpdateCount + 1,\n dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),\n error: null,\n isInvalidated: false,\n status: 'success',\n ...(!action.manual && {\n fetchStatus: 'idle',\n fetchFailureCount: 0,\n fetchFailureReason: null,\n }),\n }\n case 'error':\n const error = action.error as unknown\n\n if (isCancelledError(error) && error.revert && this.revertState) {\n return { ...this.revertState }\n }\n\n return {\n ...state,\n error: error as TError,\n errorUpdateCount: state.errorUpdateCount + 1,\n errorUpdatedAt: Date.now(),\n fetchFailureCount: state.fetchFailureCount + 1,\n fetchFailureReason: error as TError,\n fetchStatus: 'idle',\n status: 'error',\n }\n case 'invalidate':\n return {\n ...state,\n isInvalidated: true,\n }\n case 'setState':\n return {\n ...state,\n ...action.state,\n }\n }\n }\n\n this.state = reducer(this.state)\n\n notifyManager.batch(() => {\n this.observers.forEach((observer) => {\n observer.onQueryUpdate(action)\n })\n\n this.cache.notify({ query: this, type: 'updated', action })\n })\n }\n}\n\nfunction getDefaultState<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n>(\n options: QueryOptions,\n): QueryState {\n const data =\n typeof options.initialData === 'function'\n ? (options.initialData as InitialDataFunction)()\n : options.initialData\n\n const hasData = typeof data !== 'undefined'\n\n const initialDataUpdatedAt = hasData\n ? typeof options.initialDataUpdatedAt === 'function'\n ? (options.initialDataUpdatedAt as () => number | undefined)()\n : options.initialDataUpdatedAt\n : 0\n\n return {\n data,\n dataUpdateCount: 0,\n dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,\n error: null,\n errorUpdateCount: 0,\n errorUpdatedAt: 0,\n fetchFailureCount: 0,\n fetchFailureReason: null,\n fetchMeta: null,\n isInvalidated: false,\n status: hasData ? 'success' : 'loading',\n fetchStatus: 'idle',\n }\n}\n","import { hashQueryKeyByOptions, matchQuery, parseFilterArgs } from './utils'\nimport { Query } from './query'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport type { QueryFilters } from './utils'\nimport type { Action, QueryState } from './query'\nimport type { NotifyEvent, QueryKey, QueryOptions } from './types'\nimport type { QueryClient } from './queryClient'\nimport type { QueryObserver } from './queryObserver'\n\n// TYPES\n\ninterface QueryCacheConfig {\n onError?: (error: unknown, query: Query) => void\n onSuccess?: (data: unknown, query: Query) => void\n onSettled?: (\n data: unknown | undefined,\n error: unknown | null,\n query: Query,\n ) => void\n}\n\ninterface QueryHashMap {\n [hash: string]: Query\n}\n\ninterface NotifyEventQueryAdded extends NotifyEvent {\n type: 'added'\n query: Query\n}\n\ninterface NotifyEventQueryRemoved extends NotifyEvent {\n type: 'removed'\n query: Query\n}\n\ninterface NotifyEventQueryUpdated extends NotifyEvent {\n type: 'updated'\n query: Query\n action: Action\n}\n\ninterface NotifyEventQueryObserverAdded extends NotifyEvent {\n type: 'observerAdded'\n query: Query\n observer: QueryObserver\n}\n\ninterface NotifyEventQueryObserverRemoved extends NotifyEvent {\n type: 'observerRemoved'\n query: Query\n observer: QueryObserver\n}\n\ninterface NotifyEventQueryObserverResultsUpdated extends NotifyEvent {\n type: 'observerResultsUpdated'\n query: Query\n}\n\ninterface NotifyEventQueryObserverOptionsUpdated extends NotifyEvent {\n type: 'observerOptionsUpdated'\n query: Query\n observer: QueryObserver\n}\n\nexport type QueryCacheNotifyEvent =\n | NotifyEventQueryAdded\n | NotifyEventQueryRemoved\n | NotifyEventQueryUpdated\n | NotifyEventQueryObserverAdded\n | NotifyEventQueryObserverRemoved\n | NotifyEventQueryObserverResultsUpdated\n | NotifyEventQueryObserverOptionsUpdated\n\ntype QueryCacheListener = (event: QueryCacheNotifyEvent) => void\n\n// CLASS\n\nexport class QueryCache extends Subscribable {\n config: QueryCacheConfig\n\n private queries: Query[]\n private queriesMap: QueryHashMap\n\n constructor(config?: QueryCacheConfig) {\n super()\n this.config = config || {}\n this.queries = []\n this.queriesMap = {}\n }\n\n build(\n client: QueryClient,\n options: QueryOptions,\n state?: QueryState,\n ): Query {\n const queryKey = options.queryKey!\n const queryHash =\n options.queryHash ?? hashQueryKeyByOptions(queryKey, options)\n let query = this.get(queryHash)\n\n if (!query) {\n query = new Query({\n cache: this,\n logger: client.getLogger(),\n queryKey,\n queryHash,\n options: client.defaultQueryOptions(options),\n state,\n defaultOptions: client.getQueryDefaults(queryKey),\n })\n this.add(query)\n }\n\n return query\n }\n\n add(query: Query): void {\n if (!this.queriesMap[query.queryHash]) {\n this.queriesMap[query.queryHash] = query\n this.queries.push(query)\n this.notify({\n type: 'added',\n query,\n })\n }\n }\n\n remove(query: Query): void {\n const queryInMap = this.queriesMap[query.queryHash]\n\n if (queryInMap) {\n query.destroy()\n\n this.queries = this.queries.filter((x) => x !== query)\n\n if (queryInMap === query) {\n delete this.queriesMap[query.queryHash]\n }\n\n this.notify({ type: 'removed', query })\n }\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.queries.forEach((query) => {\n this.remove(query)\n })\n })\n }\n\n get<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n queryHash: string,\n ): Query | undefined {\n return this.queriesMap[queryHash]\n }\n\n getAll(): Query[] {\n return this.queries\n }\n\n find(\n arg1: QueryKey,\n arg2?: QueryFilters,\n ): Query | undefined {\n const [filters] = parseFilterArgs(arg1, arg2)\n\n if (typeof filters.exact === 'undefined') {\n filters.exact = true\n }\n\n return this.queries.find((query) => matchQuery(filters, query))\n }\n\n findAll(queryKey?: QueryKey, filters?: QueryFilters): Query[]\n findAll(filters?: QueryFilters): Query[]\n findAll(arg1?: QueryKey | QueryFilters, arg2?: QueryFilters): Query[]\n findAll(arg1?: QueryKey | QueryFilters, arg2?: QueryFilters): Query[] {\n const [filters] = parseFilterArgs(arg1, arg2)\n return Object.keys(filters).length > 0\n ? this.queries.filter((query) => matchQuery(filters, query))\n : this.queries\n }\n\n notify(event: QueryCacheNotifyEvent) {\n notifyManager.batch(() => {\n this.listeners.forEach(({ listener }) => {\n listener(event)\n })\n })\n }\n\n onFocus(): void {\n notifyManager.batch(() => {\n this.queries.forEach((query) => {\n query.onFocus()\n })\n })\n }\n\n onOnline(): void {\n notifyManager.batch(() => {\n this.queries.forEach((query) => {\n query.onOnline()\n })\n })\n }\n}\n","import _typeof from \"./typeof.js\";\nexport default function _regeneratorRuntime() {\n \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */\n _regeneratorRuntime = function _regeneratorRuntime() {\n return e;\n };\n var t,\n e = {},\n r = Object.prototype,\n n = r.hasOwnProperty,\n o = Object.defineProperty || function (t, e, r) {\n t[e] = r.value;\n },\n i = \"function\" == typeof Symbol ? Symbol : {},\n a = i.iterator || \"@@iterator\",\n c = i.asyncIterator || \"@@asyncIterator\",\n u = i.toStringTag || \"@@toStringTag\";\n function define(t, e, r) {\n return Object.defineProperty(t, e, {\n value: r,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }), t[e];\n }\n try {\n define({}, \"\");\n } catch (t) {\n define = function define(t, e, r) {\n return t[e] = r;\n };\n }\n function wrap(t, e, r, n) {\n var i = e && e.prototype instanceof Generator ? e : Generator,\n a = Object.create(i.prototype),\n c = new Context(n || []);\n return o(a, \"_invoke\", {\n value: makeInvokeMethod(t, r, c)\n }), a;\n }\n function tryCatch(t, e, r) {\n try {\n return {\n type: \"normal\",\n arg: t.call(e, r)\n };\n } catch (t) {\n return {\n type: \"throw\",\n arg: t\n };\n }\n }\n e.wrap = wrap;\n var h = \"suspendedStart\",\n l = \"suspendedYield\",\n f = \"executing\",\n s = \"completed\",\n y = {};\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n var p = {};\n define(p, a, function () {\n return this;\n });\n var d = Object.getPrototypeOf,\n v = d && d(d(values([])));\n v && v !== r && n.call(v, a) && (p = v);\n var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);\n function defineIteratorMethods(t) {\n [\"next\", \"throw\", \"return\"].forEach(function (e) {\n define(t, e, function (t) {\n return this._invoke(e, t);\n });\n });\n }\n function AsyncIterator(t, e) {\n function invoke(r, o, i, a) {\n var c = tryCatch(t[r], t, o);\n if (\"throw\" !== c.type) {\n var u = c.arg,\n h = u.value;\n return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) {\n invoke(\"next\", t, i, a);\n }, function (t) {\n invoke(\"throw\", t, i, a);\n }) : e.resolve(h).then(function (t) {\n u.value = t, i(u);\n }, function (t) {\n return invoke(\"throw\", t, i, a);\n });\n }\n a(c.arg);\n }\n var r;\n o(this, \"_invoke\", {\n value: function value(t, n) {\n function callInvokeWithMethodAndArg() {\n return new e(function (e, r) {\n invoke(t, n, e, r);\n });\n }\n return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();\n }\n });\n }\n function makeInvokeMethod(e, r, n) {\n var o = h;\n return function (i, a) {\n if (o === f) throw new Error(\"Generator is already running\");\n if (o === s) {\n if (\"throw\" === i) throw a;\n return {\n value: t,\n done: !0\n };\n }\n for (n.method = i, n.arg = a;;) {\n var c = n.delegate;\n if (c) {\n var u = maybeInvokeDelegate(c, n);\n if (u) {\n if (u === y) continue;\n return u;\n }\n }\n if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) {\n if (o === h) throw o = s, n.arg;\n n.dispatchException(n.arg);\n } else \"return\" === n.method && n.abrupt(\"return\", n.arg);\n o = f;\n var p = tryCatch(e, r, n);\n if (\"normal\" === p.type) {\n if (o = n.done ? s : l, p.arg === y) continue;\n return {\n value: p.arg,\n done: n.done\n };\n }\n \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg);\n }\n };\n }\n function maybeInvokeDelegate(e, r) {\n var n = r.method,\n o = e.iterator[n];\n if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y;\n var i = tryCatch(o, e.iterator, r.arg);\n if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y;\n var a = i.arg;\n return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y);\n }\n function pushTryEntry(t) {\n var e = {\n tryLoc: t[0]\n };\n 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);\n }\n function resetTryEntry(t) {\n var e = t.completion || {};\n e.type = \"normal\", delete e.arg, t.completion = e;\n }\n function Context(t) {\n this.tryEntries = [{\n tryLoc: \"root\"\n }], t.forEach(pushTryEntry, this), this.reset(!0);\n }\n function values(e) {\n if (e || \"\" === e) {\n var r = e[a];\n if (r) return r.call(e);\n if (\"function\" == typeof e.next) return e;\n if (!isNaN(e.length)) {\n var o = -1,\n i = function next() {\n for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;\n return next.value = t, next.done = !0, next;\n };\n return i.next = i;\n }\n }\n throw new TypeError(_typeof(e) + \" is not iterable\");\n }\n return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", {\n value: GeneratorFunctionPrototype,\n configurable: !0\n }), o(GeneratorFunctionPrototype, \"constructor\", {\n value: GeneratorFunction,\n configurable: !0\n }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) {\n var e = \"function\" == typeof t && t.constructor;\n return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name));\n }, e.mark = function (t) {\n return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t;\n }, e.awrap = function (t) {\n return {\n __await: t\n };\n }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {\n return this;\n }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {\n void 0 === i && (i = Promise);\n var a = new AsyncIterator(wrap(t, r, n, o), i);\n return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {\n return t.done ? t.value : a.next();\n });\n }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () {\n return this;\n }), define(g, \"toString\", function () {\n return \"[object Generator]\";\n }), e.keys = function (t) {\n var e = Object(t),\n r = [];\n for (var n in e) r.push(n);\n return r.reverse(), function next() {\n for (; r.length;) {\n var t = r.pop();\n if (t in e) return next.value = t, next.done = !1, next;\n }\n return next.done = !0, next;\n };\n }, e.values = values, Context.prototype = {\n constructor: Context,\n reset: function reset(e) {\n if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);\n },\n stop: function stop() {\n this.done = !0;\n var t = this.tryEntries[0].completion;\n if (\"throw\" === t.type) throw t.arg;\n return this.rval;\n },\n dispatchException: function dispatchException(e) {\n if (this.done) throw e;\n var r = this;\n function handle(n, o) {\n return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o;\n }\n for (var o = this.tryEntries.length - 1; o >= 0; --o) {\n var i = this.tryEntries[o],\n a = i.completion;\n if (\"root\" === i.tryLoc) return handle(\"end\");\n if (i.tryLoc <= this.prev) {\n var c = n.call(i, \"catchLoc\"),\n u = n.call(i, \"finallyLoc\");\n if (c && u) {\n if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);\n if (this.prev < i.finallyLoc) return handle(i.finallyLoc);\n } else if (c) {\n if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);\n } else {\n if (!u) throw new Error(\"try statement without catch or finally\");\n if (this.prev < i.finallyLoc) return handle(i.finallyLoc);\n }\n }\n }\n },\n abrupt: function abrupt(t, e) {\n for (var r = this.tryEntries.length - 1; r >= 0; --r) {\n var o = this.tryEntries[r];\n if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) {\n var i = o;\n break;\n }\n }\n i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);\n var a = i ? i.completion : {};\n return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a);\n },\n complete: function complete(t, e) {\n if (\"throw\" === t.type) throw t.arg;\n return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y;\n },\n finish: function finish(t) {\n for (var e = this.tryEntries.length - 1; e >= 0; --e) {\n var r = this.tryEntries[e];\n if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;\n }\n },\n \"catch\": function _catch(t) {\n for (var e = this.tryEntries.length - 1; e >= 0; --e) {\n var r = this.tryEntries[e];\n if (r.tryLoc === t) {\n var n = r.completion;\n if (\"throw\" === n.type) {\n var o = n.arg;\n resetTryEntry(r);\n }\n return o;\n }\n }\n throw new Error(\"illegal catch attempt\");\n },\n delegateYield: function delegateYield(e, r, n) {\n return this.delegate = {\n iterator: values(e),\n resultName: r,\n nextLoc: n\n }, \"next\" === this.method && (this.arg = t), y;\n }\n }, e;\n}","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nexport default function _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(undefined);\n });\n };\n}","import { defaultLogger } from './logger'\nimport { notifyManager } from './notifyManager'\nimport { Removable } from './removable'\nimport { canFetch, createRetryer } from './retryer'\nimport type { MutationMeta, MutationOptions, MutationStatus } from './types'\nimport type { MutationCache } from './mutationCache'\nimport type { MutationObserver } from './mutationObserver'\nimport type { Logger } from './logger'\nimport type { Retryer } from './retryer'\n\n// TYPES\n\ninterface MutationConfig {\n mutationId: number\n mutationCache: MutationCache\n options: MutationOptions\n logger?: Logger\n defaultOptions?: MutationOptions\n state?: MutationState\n meta?: MutationMeta\n}\n\nexport interface MutationState<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n> {\n context: TContext | undefined\n data: TData | undefined\n error: TError | null\n failureCount: number\n failureReason: TError | null\n isPaused: boolean\n status: MutationStatus\n variables: TVariables | undefined\n}\n\ninterface FailedAction {\n type: 'failed'\n failureCount: number\n error: TError | null\n}\n\ninterface LoadingAction {\n type: 'loading'\n variables?: TVariables\n context?: TContext\n}\n\ninterface SuccessAction {\n type: 'success'\n data: TData\n}\n\ninterface ErrorAction {\n type: 'error'\n error: TError\n}\n\ninterface PauseAction {\n type: 'pause'\n}\n\ninterface ContinueAction {\n type: 'continue'\n}\n\ninterface SetStateAction {\n type: 'setState'\n state: MutationState\n}\n\nexport type Action =\n | ContinueAction\n | ErrorAction\n | FailedAction\n | LoadingAction\n | PauseAction\n | SetStateAction\n | SuccessAction\n\n// CLASS\n\nexport class Mutation<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n> extends Removable {\n state: MutationState\n options!: MutationOptions\n mutationId: number\n\n private observers: MutationObserver[]\n private defaultOptions?: MutationOptions\n private mutationCache: MutationCache\n private logger: Logger\n private retryer?: Retryer\n\n constructor(config: MutationConfig) {\n super()\n\n this.defaultOptions = config.defaultOptions\n this.mutationId = config.mutationId\n this.mutationCache = config.mutationCache\n this.logger = config.logger || defaultLogger\n this.observers = []\n this.state = config.state || getDefaultState()\n\n this.setOptions(config.options)\n this.scheduleGc()\n }\n\n setOptions(\n options?: MutationOptions,\n ): void {\n this.options = { ...this.defaultOptions, ...options }\n\n this.updateCacheTime(this.options.cacheTime)\n }\n\n get meta(): MutationMeta | undefined {\n return this.options.meta\n }\n\n setState(state: MutationState): void {\n this.dispatch({ type: 'setState', state })\n }\n\n addObserver(observer: MutationObserver): void {\n if (!this.observers.includes(observer)) {\n this.observers.push(observer)\n\n // Stop the mutation from being garbage collected\n this.clearGcTimeout()\n\n this.mutationCache.notify({\n type: 'observerAdded',\n mutation: this,\n observer,\n })\n }\n }\n\n removeObserver(observer: MutationObserver): void {\n this.observers = this.observers.filter((x) => x !== observer)\n\n this.scheduleGc()\n\n this.mutationCache.notify({\n type: 'observerRemoved',\n mutation: this,\n observer,\n })\n }\n\n protected optionalRemove() {\n if (!this.observers.length) {\n if (this.state.status === 'loading') {\n this.scheduleGc()\n } else {\n this.mutationCache.remove(this)\n }\n }\n }\n\n continue(): Promise {\n return this.retryer?.continue() ?? this.execute()\n }\n\n async execute(): Promise {\n const executeMutation = () => {\n this.retryer = createRetryer({\n fn: () => {\n if (!this.options.mutationFn) {\n return Promise.reject('No mutationFn found')\n }\n return this.options.mutationFn(this.state.variables!)\n },\n onFail: (failureCount, error) => {\n this.dispatch({ type: 'failed', failureCount, error })\n },\n onPause: () => {\n this.dispatch({ type: 'pause' })\n },\n onContinue: () => {\n this.dispatch({ type: 'continue' })\n },\n retry: this.options.retry ?? 0,\n retryDelay: this.options.retryDelay,\n networkMode: this.options.networkMode,\n })\n\n return this.retryer.promise\n }\n\n const restored = this.state.status === 'loading'\n try {\n if (!restored) {\n this.dispatch({ type: 'loading', variables: this.options.variables! })\n // Notify cache callback\n await this.mutationCache.config.onMutate?.(\n this.state.variables,\n this as Mutation,\n )\n const context = await this.options.onMutate?.(this.state.variables!)\n if (context !== this.state.context) {\n this.dispatch({\n type: 'loading',\n context,\n variables: this.state.variables,\n })\n }\n }\n const data = await executeMutation()\n\n // Notify cache callback\n await this.mutationCache.config.onSuccess?.(\n data,\n this.state.variables,\n this.state.context,\n this as Mutation,\n )\n\n await this.options.onSuccess?.(\n data,\n this.state.variables!,\n this.state.context!,\n )\n\n // Notify cache callback\n await this.mutationCache.config.onSettled?.(\n data,\n null,\n this.state.variables,\n this.state.context,\n this as Mutation,\n )\n\n await this.options.onSettled?.(\n data,\n null,\n this.state.variables!,\n this.state.context,\n )\n\n this.dispatch({ type: 'success', data })\n return data\n } catch (error) {\n try {\n // Notify cache callback\n await this.mutationCache.config.onError?.(\n error,\n this.state.variables,\n this.state.context,\n this as Mutation,\n )\n\n if (process.env.NODE_ENV !== 'production') {\n this.logger.error(error)\n }\n\n await this.options.onError?.(\n error as TError,\n this.state.variables!,\n this.state.context,\n )\n\n // Notify cache callback\n await this.mutationCache.config.onSettled?.(\n undefined,\n error,\n this.state.variables,\n this.state.context,\n this as Mutation,\n )\n\n await this.options.onSettled?.(\n undefined,\n error as TError,\n this.state.variables!,\n this.state.context,\n )\n throw error\n } finally {\n this.dispatch({ type: 'error', error: error as TError })\n }\n }\n }\n\n private dispatch(action: Action): void {\n const reducer = (\n state: MutationState,\n ): MutationState => {\n switch (action.type) {\n case 'failed':\n return {\n ...state,\n failureCount: action.failureCount,\n failureReason: action.error,\n }\n case 'pause':\n return {\n ...state,\n isPaused: true,\n }\n case 'continue':\n return {\n ...state,\n isPaused: false,\n }\n case 'loading':\n return {\n ...state,\n context: action.context,\n data: undefined,\n failureCount: 0,\n failureReason: null,\n error: null,\n isPaused: !canFetch(this.options.networkMode),\n status: 'loading',\n variables: action.variables,\n }\n case 'success':\n return {\n ...state,\n data: action.data,\n failureCount: 0,\n failureReason: null,\n error: null,\n status: 'success',\n isPaused: false,\n }\n case 'error':\n return {\n ...state,\n data: undefined,\n error: action.error,\n failureCount: state.failureCount + 1,\n failureReason: action.error,\n isPaused: false,\n status: 'error',\n }\n case 'setState':\n return {\n ...state,\n ...action.state,\n }\n }\n }\n this.state = reducer(this.state)\n\n notifyManager.batch(() => {\n this.observers.forEach((observer) => {\n observer.onMutationUpdate(action)\n })\n this.mutationCache.notify({\n mutation: this,\n type: 'updated',\n action,\n })\n })\n }\n}\n\nexport function getDefaultState<\n TData,\n TError,\n TVariables,\n TContext,\n>(): MutationState {\n return {\n context: undefined,\n data: undefined,\n error: null,\n failureCount: 0,\n failureReason: null,\n isPaused: false,\n status: 'idle',\n variables: undefined,\n }\n}\n","import { notifyManager } from './notifyManager'\nimport { Mutation } from './mutation'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\nimport type { MutationObserver } from './mutationObserver'\nimport type { MutationOptions, NotifyEvent } from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Action, MutationState } from './mutation'\nimport type { MutationFilters } from './utils'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation,\n ) => Promise | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation,\n ) => Promise | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation,\n ) => Promise | unknown\n onSettled?: (\n data: unknown | undefined,\n error: unknown | null,\n variables: unknown,\n context: unknown,\n mutation: Mutation,\n ) => Promise | unknown\n}\n\ninterface NotifyEventMutationAdded extends NotifyEvent {\n type: 'added'\n mutation: Mutation\n}\ninterface NotifyEventMutationRemoved extends NotifyEvent {\n type: 'removed'\n mutation: Mutation\n}\n\ninterface NotifyEventMutationObserverAdded extends NotifyEvent {\n type: 'observerAdded'\n mutation: Mutation\n observer: MutationObserver\n}\n\ninterface NotifyEventMutationObserverRemoved extends NotifyEvent {\n type: 'observerRemoved'\n mutation: Mutation\n observer: MutationObserver\n}\n\ninterface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {\n type: 'observerOptionsUpdated'\n mutation?: Mutation\n observer: MutationObserver\n}\n\ninterface NotifyEventMutationUpdated extends NotifyEvent {\n type: 'updated'\n mutation: Mutation\n action: Action\n}\n\ntype MutationCacheNotifyEvent =\n | NotifyEventMutationAdded\n | NotifyEventMutationRemoved\n | NotifyEventMutationObserverAdded\n | NotifyEventMutationObserverRemoved\n | NotifyEventMutationObserverOptionsUpdated\n | NotifyEventMutationUpdated\n\ntype MutationCacheListener = (event: MutationCacheNotifyEvent) => void\n\n// CLASS\n\nexport class MutationCache extends Subscribable {\n config: MutationCacheConfig\n\n private mutations: Mutation[]\n private mutationId: number\n private resuming: Promise | undefined\n\n constructor(config?: MutationCacheConfig) {\n super()\n this.config = config || {}\n this.mutations = []\n this.mutationId = 0\n }\n\n build(\n client: QueryClient,\n options: MutationOptions,\n state?: MutationState,\n ): Mutation {\n const mutation = new Mutation({\n mutationCache: this,\n logger: client.getLogger(),\n mutationId: ++this.mutationId,\n options: client.defaultMutationOptions(options),\n state,\n defaultOptions: options.mutationKey\n ? client.getMutationDefaults(options.mutationKey)\n : undefined,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation): void {\n this.mutations.push(mutation)\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation): void {\n this.mutations = this.mutations.filter((x) => x !== mutation)\n this.notify({ type: 'removed', mutation })\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.mutations.forEach((mutation) => {\n this.remove(mutation)\n })\n })\n }\n\n getAll(): Mutation[] {\n return this.mutations\n }\n\n find(\n filters: MutationFilters,\n ): Mutation | undefined {\n if (typeof filters.exact === 'undefined') {\n filters.exact = true\n }\n\n return this.mutations.find((mutation) => matchMutation(filters, mutation))\n }\n\n findAll(filters: MutationFilters): Mutation[] {\n return this.mutations.filter((mutation) => matchMutation(filters, mutation))\n }\n\n notify(event: MutationCacheNotifyEvent) {\n notifyManager.batch(() => {\n this.listeners.forEach(({ listener }) => {\n listener(event)\n })\n })\n }\n\n resumePausedMutations(): Promise {\n this.resuming = (this.resuming ?? Promise.resolve())\n .then(() => {\n const pausedMutations = this.mutations.filter((x) => x.state.isPaused)\n return notifyManager.batch(() =>\n pausedMutations.reduce(\n (promise, mutation) =>\n promise.then(() => mutation.continue().catch(noop)),\n Promise.resolve() as Promise,\n ),\n )\n })\n .then(() => {\n this.resuming = undefined\n })\n\n return this.resuming\n }\n}\n","export default function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}","import arrayWithoutHoles from \"./arrayWithoutHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableSpread from \"./nonIterableSpread.js\";\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import type { QueryBehavior } from './query'\n\nimport type {\n InfiniteData,\n QueryFunctionContext,\n QueryOptions,\n RefetchQueryFilters,\n} from './types'\n\nexport function infiniteQueryBehavior<\n TQueryFnData,\n TError,\n TData,\n>(): QueryBehavior> {\n return {\n onFetch: (context) => {\n context.fetchFn = () => {\n const refetchPage: RefetchQueryFilters['refetchPage'] | undefined =\n context.fetchOptions?.meta?.refetchPage\n const fetchMore = context.fetchOptions?.meta?.fetchMore\n const pageParam = fetchMore?.pageParam\n const isFetchingNextPage = fetchMore?.direction === 'forward'\n const isFetchingPreviousPage = fetchMore?.direction === 'backward'\n const oldPages = context.state.data?.pages || []\n const oldPageParams = context.state.data?.pageParams || []\n let newPageParams = oldPageParams\n let cancelled = false\n\n const addSignalProperty = (object: unknown) => {\n Object.defineProperty(object, 'signal', {\n enumerable: true,\n get: () => {\n if (context.signal?.aborted) {\n cancelled = true\n } else {\n context.signal?.addEventListener('abort', () => {\n cancelled = true\n })\n }\n return context.signal\n },\n })\n }\n\n // Get query function\n const queryFn =\n context.options.queryFn ||\n (() =>\n Promise.reject(\n `Missing queryFn for queryKey '${context.options.queryHash}'`,\n ))\n\n const buildNewPages = (\n pages: unknown[],\n param: unknown,\n page: unknown,\n previous?: boolean,\n ) => {\n newPageParams = previous\n ? [param, ...newPageParams]\n : [...newPageParams, param]\n return previous ? [page, ...pages] : [...pages, page]\n }\n\n // Create function to fetch a page\n const fetchPage = (\n pages: unknown[],\n manual?: boolean,\n param?: unknown,\n previous?: boolean,\n ): Promise => {\n if (cancelled) {\n return Promise.reject('Cancelled')\n }\n\n if (typeof param === 'undefined' && !manual && pages.length) {\n return Promise.resolve(pages)\n }\n\n const queryFnContext: QueryFunctionContext = {\n queryKey: context.queryKey,\n pageParam: param,\n meta: context.options.meta,\n }\n\n addSignalProperty(queryFnContext)\n\n const queryFnResult = queryFn(queryFnContext)\n\n const promise = Promise.resolve(queryFnResult).then((page) =>\n buildNewPages(pages, param, page, previous),\n )\n\n return promise\n }\n\n let promise: Promise\n\n // Fetch first page?\n if (!oldPages.length) {\n promise = fetchPage([])\n }\n\n // Fetch next page?\n else if (isFetchingNextPage) {\n const manual = typeof pageParam !== 'undefined'\n const param = manual\n ? pageParam\n : getNextPageParam(context.options, oldPages)\n promise = fetchPage(oldPages, manual, param)\n }\n\n // Fetch previous page?\n else if (isFetchingPreviousPage) {\n const manual = typeof pageParam !== 'undefined'\n const param = manual\n ? pageParam\n : getPreviousPageParam(context.options, oldPages)\n promise = fetchPage(oldPages, manual, param, true)\n }\n\n // Refetch pages\n else {\n newPageParams = []\n\n const manual = typeof context.options.getNextPageParam === 'undefined'\n\n const shouldFetchFirstPage =\n refetchPage && oldPages[0]\n ? refetchPage(oldPages[0], 0, oldPages)\n : true\n\n // Fetch first page\n promise = shouldFetchFirstPage\n ? fetchPage([], manual, oldPageParams[0])\n : Promise.resolve(buildNewPages([], oldPageParams[0], oldPages[0]))\n\n // Fetch remaining pages\n for (let i = 1; i < oldPages.length; i++) {\n promise = promise.then((pages) => {\n const shouldFetchNextPage =\n refetchPage && oldPages[i]\n ? refetchPage(oldPages[i], i, oldPages)\n : true\n\n if (shouldFetchNextPage) {\n const param = manual\n ? oldPageParams[i]\n : getNextPageParam(context.options, pages)\n return fetchPage(pages, manual, param)\n }\n return Promise.resolve(\n buildNewPages(pages, oldPageParams[i], oldPages[i]),\n )\n })\n }\n }\n\n const finalPromise = promise.then((pages) => ({\n pages,\n pageParams: newPageParams,\n }))\n\n return finalPromise\n }\n },\n }\n}\n\nexport function getNextPageParam(\n options: QueryOptions,\n pages: unknown[],\n): unknown | undefined {\n return options.getNextPageParam?.(pages[pages.length - 1], pages)\n}\n\nexport function getPreviousPageParam(\n options: QueryOptions,\n pages: unknown[],\n): unknown | undefined {\n return options.getPreviousPageParam?.(pages[0], pages)\n}\n\n/**\n * Checks if there is a next page.\n * Returns `undefined` if it cannot be determined.\n */\nexport function hasNextPage(\n options: QueryOptions,\n pages?: unknown,\n): boolean | undefined {\n if (options.getNextPageParam && Array.isArray(pages)) {\n const nextPageParam = getNextPageParam(options, pages)\n return (\n typeof nextPageParam !== 'undefined' &&\n nextPageParam !== null &&\n nextPageParam !== false\n )\n }\n return\n}\n\n/**\n * Checks if there is a previous page.\n * Returns `undefined` if it cannot be determined.\n */\nexport function hasPreviousPage(\n options: QueryOptions,\n pages?: unknown,\n): boolean | undefined {\n if (options.getPreviousPageParam && Array.isArray(pages)) {\n const previousPageParam = getPreviousPageParam(options, pages)\n return (\n typeof previousPageParam !== 'undefined' &&\n previousPageParam !== null &&\n previousPageParam !== false\n )\n }\n return\n}\n","import {\n functionalUpdate,\n hashQueryKey,\n hashQueryKeyByOptions,\n noop,\n parseFilterArgs,\n parseQueryArgs,\n partialMatchKey,\n} from './utils'\nimport { QueryCache } from './queryCache'\nimport { MutationCache } from './mutationCache'\nimport { focusManager } from './focusManager'\nimport { onlineManager } from './onlineManager'\nimport { notifyManager } from './notifyManager'\nimport { infiniteQueryBehavior } from './infiniteQueryBehavior'\nimport { defaultLogger } from './logger'\nimport type { CancelOptions, DefaultedQueryObserverOptions } from './types'\nimport type { Logger } from './logger'\nimport type { QueryState } from './query'\nimport type {\n DefaultOptions,\n FetchInfiniteQueryOptions,\n FetchQueryOptions,\n InfiniteData,\n InvalidateOptions,\n InvalidateQueryFilters,\n MutationKey,\n MutationObserverOptions,\n MutationOptions,\n QueryClientConfig,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryOptions,\n RefetchOptions,\n RefetchQueryFilters,\n ResetOptions,\n ResetQueryFilters,\n SetDataOptions,\n WithRequired,\n} from './types'\nimport type { MutationFilters, QueryFilters, Updater } from './utils'\n\n// TYPES\n\ninterface QueryDefaults {\n queryKey: QueryKey\n defaultOptions: QueryOptions\n}\n\ninterface MutationDefaults {\n mutationKey: MutationKey\n defaultOptions: MutationOptions\n}\n\n// CLASS\n\nexport class QueryClient {\n private queryCache: QueryCache\n private mutationCache: MutationCache\n private logger: Logger\n private defaultOptions: DefaultOptions\n private queryDefaults: QueryDefaults[]\n private mutationDefaults: MutationDefaults[]\n private mountCount: number\n private unsubscribeFocus?: () => void\n private unsubscribeOnline?: () => void\n\n constructor(config: QueryClientConfig = {}) {\n this.queryCache = config.queryCache || new QueryCache()\n this.mutationCache = config.mutationCache || new MutationCache()\n this.logger = config.logger || defaultLogger\n this.defaultOptions = config.defaultOptions || {}\n this.queryDefaults = []\n this.mutationDefaults = []\n this.mountCount = 0\n\n if (process.env.NODE_ENV !== 'production' && config.logger) {\n this.logger.error(\n `Passing a custom logger has been deprecated and will be removed in the next major version.`,\n )\n }\n }\n\n mount(): void {\n this.mountCount++\n if (this.mountCount !== 1) return\n\n this.unsubscribeFocus = focusManager.subscribe(() => {\n if (focusManager.isFocused()) {\n this.resumePausedMutations()\n this.queryCache.onFocus()\n }\n })\n this.unsubscribeOnline = onlineManager.subscribe(() => {\n if (onlineManager.isOnline()) {\n this.resumePausedMutations()\n this.queryCache.onOnline()\n }\n })\n }\n\n unmount(): void {\n this.mountCount--\n if (this.mountCount !== 0) return\n\n this.unsubscribeFocus?.()\n this.unsubscribeFocus = undefined\n\n this.unsubscribeOnline?.()\n this.unsubscribeOnline = undefined\n }\n\n isFetching(filters?: QueryFilters): number\n isFetching(queryKey?: QueryKey, filters?: QueryFilters): number\n isFetching(arg1?: QueryKey | QueryFilters, arg2?: QueryFilters): number {\n const [filters] = parseFilterArgs(arg1, arg2)\n filters.fetchStatus = 'fetching'\n return this.queryCache.findAll(filters).length\n }\n\n isMutating(filters?: MutationFilters): number {\n return this.mutationCache.findAll({ ...filters, fetching: true }).length\n }\n\n getQueryData(\n queryKey: QueryKey,\n filters?: QueryFilters,\n ): TQueryFnData | undefined {\n return this.queryCache.find(queryKey, filters)?.state.data\n }\n\n ensureQueryData<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n options: WithRequired<\n FetchQueryOptions,\n 'queryKey'\n >,\n ): Promise\n ensureQueryData<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n queryKey: TQueryKey,\n options?: Omit<\n FetchQueryOptions,\n 'queryKey'\n >,\n ): Promise\n ensureQueryData<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n queryKey: TQueryKey,\n queryFn: QueryFunction,\n options?: Omit<\n FetchQueryOptions,\n 'queryKey' | 'queryFn'\n >,\n ): Promise\n ensureQueryData<\n TQueryFnData,\n TError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n >(\n arg1:\n | TQueryKey\n | WithRequired<\n FetchQueryOptions,\n 'queryKey'\n >,\n arg2?:\n | QueryFunction\n | FetchQueryOptions,\n arg3?: FetchQueryOptions,\n ): Promise {\n const parsedOptions = parseQueryArgs(arg1, arg2, arg3)\n const cachedData = this.getQueryData(parsedOptions.queryKey!)\n\n return cachedData\n ? Promise.resolve(cachedData)\n : this.fetchQuery(parsedOptions)\n }\n\n getQueriesData(\n queryKey: QueryKey,\n ): [QueryKey, TQueryFnData | undefined][]\n getQueriesData(\n filters: QueryFilters,\n ): [QueryKey, TQueryFnData | undefined][]\n getQueriesData(\n queryKeyOrFilters: QueryKey | QueryFilters,\n ): [QueryKey, TQueryFnData | undefined][] {\n return this.getQueryCache()\n .findAll(queryKeyOrFilters)\n .map(({ queryKey, state }) => {\n const data = state.data as TQueryFnData | undefined\n return [queryKey, data]\n })\n }\n\n setQueryData(\n queryKey: QueryKey,\n updater: Updater,\n options?: SetDataOptions,\n ): TQueryFnData | undefined {\n const query = this.queryCache.find(queryKey)\n const prevData = query?.state.data\n const data = functionalUpdate(updater, prevData)\n\n if (typeof data === 'undefined') {\n return undefined\n }\n\n const parsedOptions = parseQueryArgs(queryKey)\n const defaultedOptions = this.defaultQueryOptions(parsedOptions)\n return this.queryCache\n .build(this, defaultedOptions)\n .setData(data, { ...options, manual: true })\n }\n\n setQueriesData(\n queryKey: QueryKey,\n updater: Updater,\n options?: SetDataOptions,\n ): [QueryKey, TQueryFnData | undefined][]\n\n setQueriesData(\n filters: QueryFilters,\n updater: Updater,\n options?: SetDataOptions,\n ): [QueryKey, TQueryFnData | undefined][]\n\n setQueriesData(\n queryKeyOrFilters: QueryKey | QueryFilters,\n updater: Updater,\n options?: SetDataOptions,\n ): [QueryKey, TQueryFnData | undefined][] {\n return notifyManager.batch(() =>\n this.getQueryCache()\n .findAll(queryKeyOrFilters)\n .map(({ queryKey }) => [\n queryKey,\n this.setQueryData(queryKey, updater, options),\n ]),\n )\n }\n\n getQueryState