| 1 |
(function(react) { |
| 2 |
|
| 3 |
//#region \0rolldown/runtime.js |
| 4 |
var __create = Object.create; |
| 5 |
var __defProp = Object.defineProperty; |
| 6 |
var __name = (target, value) => __defProp(target, "name", { |
| 7 |
value, |
| 8 |
configurable: true |
| 9 |
}); |
| 10 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 11 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 12 |
var __getProtoOf = Object.getPrototypeOf; |
| 13 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 14 |
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports); |
| 15 |
var __exportAll = (all, no_symbols) => { |
| 16 |
let target = {}; |
| 17 |
for (var name in all) { |
| 18 |
__defProp(target, name, { |
| 19 |
get: all[name], |
| 20 |
enumerable: true |
| 21 |
}); |
| 22 |
} |
| 23 |
if (!no_symbols) { |
| 24 |
__defProp(target, Symbol.toStringTag, { value: "Module" }); |
| 25 |
} |
| 26 |
return target; |
| 27 |
}; |
| 28 |
var __copyProps = (to, from, except, desc) => { |
| 29 |
if (from && typeof from === "object" || typeof from === "function") { |
| 30 |
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { |
| 31 |
key = keys[i]; |
| 32 |
if (!__hasOwnProp.call(to, key) && key !== except) { |
| 33 |
__defProp(to, key, { |
| 34 |
get: ((k) => from[k]).bind(null, key), |
| 35 |
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable |
| 36 |
}); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
return to; |
| 41 |
}; |
| 42 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { |
| 43 |
value: mod, |
| 44 |
enumerable: true |
| 45 |
}) : target, mod)); |
| 46 |
|
| 47 |
//#endregion |
| 48 |
react = __toESM(react, 1); |
| 49 |
|
| 50 |
//#region node_modules/@tanstack/query-core/build/modern/subscribable.js |
| 51 |
var Subscribable = class { |
| 52 |
constructor() { |
| 53 |
this.listeners = /* @__PURE__ */ new Set(); |
| 54 |
this.subscribe = this.subscribe.bind(this); |
| 55 |
} |
| 56 |
subscribe(listener) { |
| 57 |
this.listeners.add(listener); |
| 58 |
this.onSubscribe(); |
| 59 |
return () => { |
| 60 |
this.listeners.delete(listener); |
| 61 |
this.onUnsubscribe(); |
| 62 |
}; |
| 63 |
} |
| 64 |
hasListeners() { |
| 65 |
return this.listeners.size > 0; |
| 66 |
} |
| 67 |
onSubscribe() {} |
| 68 |
onUnsubscribe() {} |
| 69 |
}; |
| 70 |
|
| 71 |
//#endregion |
| 72 |
//#region node_modules/@tanstack/query-core/build/modern/timeoutManager.js |
| 73 |
var defaultTimeoutProvider = { |
| 74 |
setTimeout: (callback, delay) => setTimeout(callback, delay), |
| 75 |
clearTimeout: (timeoutId) => clearTimeout(timeoutId), |
| 76 |
setInterval: (callback, delay) => setInterval(callback, delay), |
| 77 |
clearInterval: (intervalId) => clearInterval(intervalId) |
| 78 |
}; |
| 79 |
var TimeoutManager = class { |
| 80 |
#provider = defaultTimeoutProvider; |
| 81 |
#providerCalled = false; |
| 82 |
setTimeoutProvider(provider) { |
| 83 |
if (this.#providerCalled && provider !== this.#provider) console.error(`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`, { |
| 84 |
previous: this.#provider, |
| 85 |
provider |
| 86 |
}); |
| 87 |
this.#provider = provider; |
| 88 |
this.#providerCalled = false; |
| 89 |
} |
| 90 |
setTimeout(callback, delay) { |
| 91 |
this.#providerCalled = true; |
| 92 |
return this.#provider.setTimeout(callback, delay); |
| 93 |
} |
| 94 |
clearTimeout(timeoutId) { |
| 95 |
this.#provider.clearTimeout(timeoutId); |
| 96 |
} |
| 97 |
setInterval(callback, delay) { |
| 98 |
this.#providerCalled = true; |
| 99 |
return this.#provider.setInterval(callback, delay); |
| 100 |
} |
| 101 |
clearInterval(intervalId) { |
| 102 |
this.#provider.clearInterval(intervalId); |
| 103 |
} |
| 104 |
}; |
| 105 |
var timeoutManager = new TimeoutManager(); |
| 106 |
function systemSetTimeoutZero(callback) { |
| 107 |
setTimeout(callback, 0); |
| 108 |
} |
| 109 |
|
| 110 |
//#endregion |
| 111 |
//#region node_modules/@tanstack/query-core/build/modern/utils.js |
| 112 |
var isServer = typeof window === "undefined" || "Deno" in globalThis; |
| 113 |
function noop() {} |
| 114 |
function functionalUpdate(updater, input) { |
| 115 |
return typeof updater === "function" ? updater(input) : updater; |
| 116 |
} |
| 117 |
function isValidTimeout(value) { |
| 118 |
return typeof value === "number" && value >= 0 && value !== Infinity; |
| 119 |
} |
| 120 |
function timeUntilStale(updatedAt, staleTime) { |
| 121 |
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); |
| 122 |
} |
| 123 |
function resolveStaleTime(staleTime, query) { |
| 124 |
return typeof staleTime === "function" ? staleTime(query) : staleTime; |
| 125 |
} |
| 126 |
function resolveEnabled(enabled, query) { |
| 127 |
return typeof enabled === "function" ? enabled(query) : enabled; |
| 128 |
} |
| 129 |
function matchQuery(filters, query) { |
| 130 |
const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters; |
| 131 |
if (queryKey) { |
| 132 |
if (exact) { |
| 133 |
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) return false; |
| 134 |
} else if (!partialMatchKey(query.queryKey, queryKey)) return false; |
| 135 |
} |
| 136 |
if (type !== "all") { |
| 137 |
const isActive = query.isActive(); |
| 138 |
if (type === "active" && !isActive) return false; |
| 139 |
if (type === "inactive" && isActive) return false; |
| 140 |
} |
| 141 |
if (typeof stale === "boolean" && query.isStale() !== stale) return false; |
| 142 |
if (fetchStatus && fetchStatus !== query.state.fetchStatus) return false; |
| 143 |
if (predicate && !predicate(query)) return false; |
| 144 |
return true; |
| 145 |
} |
| 146 |
function matchMutation(filters, mutation) { |
| 147 |
const { exact, status, predicate, mutationKey } = filters; |
| 148 |
if (mutationKey) { |
| 149 |
if (!mutation.options.mutationKey) return false; |
| 150 |
if (exact) { |
| 151 |
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) return false; |
| 152 |
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) return false; |
| 153 |
} |
| 154 |
if (status && mutation.state.status !== status) return false; |
| 155 |
if (predicate && !predicate(mutation)) return false; |
| 156 |
return true; |
| 157 |
} |
| 158 |
function hashQueryKeyByOptions(queryKey, options) { |
| 159 |
return (options?.queryKeyHashFn || hashKey)(queryKey); |
| 160 |
} |
| 161 |
function hashKey(queryKey) { |
| 162 |
return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => { |
| 163 |
result[key] = val[key]; |
| 164 |
return result; |
| 165 |
}, {}) : val); |
| 166 |
} |
| 167 |
function partialMatchKey(a, b) { |
| 168 |
if (a === b) return true; |
| 169 |
if (typeof a !== typeof b) return false; |
| 170 |
if (a && b && typeof a === "object" && typeof b === "object") return Object.keys(b).every((key) => partialMatchKey(a[key], b[key])); |
| 171 |
return false; |
| 172 |
} |
| 173 |
var hasOwn = Object.prototype.hasOwnProperty; |
| 174 |
function replaceEqualDeep(a, b) { |
| 175 |
if (a === b) return a; |
| 176 |
const array = isPlainArray(a) && isPlainArray(b); |
| 177 |
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b; |
| 178 |
const aSize = (array ? a : Object.keys(a)).length; |
| 179 |
const bItems = array ? b : Object.keys(b); |
| 180 |
const bSize = bItems.length; |
| 181 |
const copy = array ? new Array(bSize) : {}; |
| 182 |
let equalItems = 0; |
| 183 |
for (let i = 0; i < bSize; i++) { |
| 184 |
const key = array ? i : bItems[i]; |
| 185 |
const aItem = a[key]; |
| 186 |
const bItem = b[key]; |
| 187 |
if (aItem === bItem) { |
| 188 |
copy[key] = aItem; |
| 189 |
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++; |
| 190 |
continue; |
| 191 |
} |
| 192 |
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") { |
| 193 |
copy[key] = bItem; |
| 194 |
continue; |
| 195 |
} |
| 196 |
const v = replaceEqualDeep(aItem, bItem); |
| 197 |
copy[key] = v; |
| 198 |
if (v === aItem) equalItems++; |
| 199 |
} |
| 200 |
return aSize === bSize && equalItems === aSize ? a : copy; |
| 201 |
} |
| 202 |
function shallowEqualObjects(a, b) { |
| 203 |
if (!b || Object.keys(a).length !== Object.keys(b).length) return false; |
| 204 |
for (const key in a) if (a[key] !== b[key]) return false; |
| 205 |
return true; |
| 206 |
} |
| 207 |
function isPlainArray(value) { |
| 208 |
return Array.isArray(value) && value.length === Object.keys(value).length; |
| 209 |
} |
| 210 |
function isPlainObject(o) { |
| 211 |
if (!hasObjectPrototype(o)) return false; |
| 212 |
const ctor = o.constructor; |
| 213 |
if (ctor === void 0) return true; |
| 214 |
const prot = ctor.prototype; |
| 215 |
if (!hasObjectPrototype(prot)) return false; |
| 216 |
if (!prot.hasOwnProperty("isPrototypeOf")) return false; |
| 217 |
if (Object.getPrototypeOf(o) !== Object.prototype) return false; |
| 218 |
return true; |
| 219 |
} |
| 220 |
function hasObjectPrototype(o) { |
| 221 |
return Object.prototype.toString.call(o) === "[object Object]"; |
| 222 |
} |
| 223 |
function sleep(timeout) { |
| 224 |
return new Promise((resolve) => { |
| 225 |
timeoutManager.setTimeout(resolve, timeout); |
| 226 |
}); |
| 227 |
} |
| 228 |
function replaceData(prevData, data, options) { |
| 229 |
if (typeof options.structuralSharing === "function") return options.structuralSharing(prevData, data); |
| 230 |
else if (options.structuralSharing !== false) try { |
| 231 |
return replaceEqualDeep(prevData, data); |
| 232 |
} catch (error) { |
| 233 |
console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`); |
| 234 |
throw error; |
| 235 |
} |
| 236 |
return data; |
| 237 |
} |
| 238 |
function addToEnd(items, item, max = 0) { |
| 239 |
const newItems = [...items, item]; |
| 240 |
return max && newItems.length > max ? newItems.slice(1) : newItems; |
| 241 |
} |
| 242 |
function addToStart(items, item, max = 0) { |
| 243 |
const newItems = [item, ...items]; |
| 244 |
return max && newItems.length > max ? newItems.slice(0, -1) : newItems; |
| 245 |
} |
| 246 |
var skipToken = Symbol(); |
| 247 |
function ensureQueryFn(options, fetchOptions) { |
| 248 |
if (options.queryFn === skipToken) console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`); |
| 249 |
if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise; |
| 250 |
if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`)); |
| 251 |
return options.queryFn; |
| 252 |
} |
| 253 |
function shouldThrowError(throwOnError, params) { |
| 254 |
if (typeof throwOnError === "function") return throwOnError(...params); |
| 255 |
return !!throwOnError; |
| 256 |
} |
| 257 |
function addConsumeAwareSignal(object, getSignal, onCancelled) { |
| 258 |
let consumed = false; |
| 259 |
let signal; |
| 260 |
Object.defineProperty(object, "signal", { |
| 261 |
enumerable: true, |
| 262 |
get: () => { |
| 263 |
signal ??= getSignal(); |
| 264 |
if (consumed) return signal; |
| 265 |
consumed = true; |
| 266 |
if (signal.aborted) onCancelled(); |
| 267 |
else signal.addEventListener("abort", onCancelled, { once: true }); |
| 268 |
return signal; |
| 269 |
} |
| 270 |
}); |
| 271 |
return object; |
| 272 |
} |
| 273 |
|
| 274 |
//#endregion |
| 275 |
//#region node_modules/@tanstack/query-core/build/modern/focusManager.js |
| 276 |
var FocusManager = class extends Subscribable { |
| 277 |
#focused; |
| 278 |
#cleanup; |
| 279 |
#setup; |
| 280 |
constructor() { |
| 281 |
super(); |
| 282 |
this.#setup = (onFocus) => { |
| 283 |
if (!isServer && window.addEventListener) { |
| 284 |
const listener = () => onFocus(); |
| 285 |
window.addEventListener("visibilitychange", listener, false); |
| 286 |
return () => { |
| 287 |
window.removeEventListener("visibilitychange", listener); |
| 288 |
}; |
| 289 |
} |
| 290 |
}; |
| 291 |
} |
| 292 |
onSubscribe() { |
| 293 |
if (!this.#cleanup) this.setEventListener(this.#setup); |
| 294 |
} |
| 295 |
onUnsubscribe() { |
| 296 |
if (!this.hasListeners()) { |
| 297 |
this.#cleanup?.(); |
| 298 |
this.#cleanup = void 0; |
| 299 |
} |
| 300 |
} |
| 301 |
setEventListener(setup) { |
| 302 |
this.#setup = setup; |
| 303 |
this.#cleanup?.(); |
| 304 |
this.#cleanup = setup((focused) => { |
| 305 |
if (typeof focused === "boolean") this.setFocused(focused); |
| 306 |
else this.onFocus(); |
| 307 |
}); |
| 308 |
} |
| 309 |
setFocused(focused) { |
| 310 |
if (this.#focused !== focused) { |
| 311 |
this.#focused = focused; |
| 312 |
this.onFocus(); |
| 313 |
} |
| 314 |
} |
| 315 |
onFocus() { |
| 316 |
const isFocused = this.isFocused(); |
| 317 |
this.listeners.forEach((listener) => { |
| 318 |
listener(isFocused); |
| 319 |
}); |
| 320 |
} |
| 321 |
isFocused() { |
| 322 |
if (typeof this.#focused === "boolean") return this.#focused; |
| 323 |
return globalThis.document?.visibilityState !== "hidden"; |
| 324 |
} |
| 325 |
}; |
| 326 |
var focusManager = new FocusManager(); |
| 327 |
|
| 328 |
//#endregion |
| 329 |
//#region node_modules/@tanstack/query-core/build/modern/thenable.js |
| 330 |
function pendingThenable() { |
| 331 |
let resolve; |
| 332 |
let reject; |
| 333 |
const thenable = new Promise((_resolve, _reject) => { |
| 334 |
resolve = _resolve; |
| 335 |
reject = _reject; |
| 336 |
}); |
| 337 |
thenable.status = "pending"; |
| 338 |
thenable.catch(() => {}); |
| 339 |
function finalize(data) { |
| 340 |
Object.assign(thenable, data); |
| 341 |
delete thenable.resolve; |
| 342 |
delete thenable.reject; |
| 343 |
} |
| 344 |
thenable.resolve = (value) => { |
| 345 |
finalize({ |
| 346 |
status: "fulfilled", |
| 347 |
value |
| 348 |
}); |
| 349 |
resolve(value); |
| 350 |
}; |
| 351 |
thenable.reject = (reason) => { |
| 352 |
finalize({ |
| 353 |
status: "rejected", |
| 354 |
reason |
| 355 |
}); |
| 356 |
reject(reason); |
| 357 |
}; |
| 358 |
return thenable; |
| 359 |
} |
| 360 |
|
| 361 |
//#endregion |
| 362 |
//#region node_modules/@tanstack/query-core/build/modern/notifyManager.js |
| 363 |
var defaultScheduler = systemSetTimeoutZero; |
| 364 |
function createNotifyManager() { |
| 365 |
let queue = []; |
| 366 |
let transactions = 0; |
| 367 |
let notifyFn = (callback) => { |
| 368 |
callback(); |
| 369 |
}; |
| 370 |
let batchNotifyFn = (callback) => { |
| 371 |
callback(); |
| 372 |
}; |
| 373 |
let scheduleFn = defaultScheduler; |
| 374 |
const schedule = (callback) => { |
| 375 |
if (transactions) queue.push(callback); |
| 376 |
else scheduleFn(() => { |
| 377 |
notifyFn(callback); |
| 378 |
}); |
| 379 |
}; |
| 380 |
const flush = () => { |
| 381 |
const originalQueue = queue; |
| 382 |
queue = []; |
| 383 |
if (originalQueue.length) scheduleFn(() => { |
| 384 |
batchNotifyFn(() => { |
| 385 |
originalQueue.forEach((callback) => { |
| 386 |
notifyFn(callback); |
| 387 |
}); |
| 388 |
}); |
| 389 |
}); |
| 390 |
}; |
| 391 |
return { |
| 392 |
batch: (callback) => { |
| 393 |
let result; |
| 394 |
transactions++; |
| 395 |
try { |
| 396 |
result = callback(); |
| 397 |
} finally { |
| 398 |
transactions--; |
| 399 |
if (!transactions) flush(); |
| 400 |
} |
| 401 |
return result; |
| 402 |
}, |
| 403 |
/** |
| 404 |
* All calls to the wrapped function will be batched. |
| 405 |
*/ |
| 406 |
batchCalls: (callback) => { |
| 407 |
return (...args) => { |
| 408 |
schedule(() => { |
| 409 |
callback(...args); |
| 410 |
}); |
| 411 |
}; |
| 412 |
}, |
| 413 |
schedule, |
| 414 |
/** |
| 415 |
* Use this method to set a custom notify function. |
| 416 |
* This can be used to for example wrap notifications with `React.act` while running tests. |
| 417 |
*/ |
| 418 |
setNotifyFunction: (fn) => { |
| 419 |
notifyFn = fn; |
| 420 |
}, |
| 421 |
/** |
| 422 |
* Use this method to set a custom function to batch notifications together into a single tick. |
| 423 |
* By default React Query will use the batch function provided by ReactDOM or React Native. |
| 424 |
*/ |
| 425 |
setBatchNotifyFunction: (fn) => { |
| 426 |
batchNotifyFn = fn; |
| 427 |
}, |
| 428 |
setScheduler: (fn) => { |
| 429 |
scheduleFn = fn; |
| 430 |
} |
| 431 |
}; |
| 432 |
} |
| 433 |
var notifyManager = createNotifyManager(); |
| 434 |
|
| 435 |
//#endregion |
| 436 |
//#region node_modules/@tanstack/query-core/build/modern/onlineManager.js |
| 437 |
var OnlineManager = class extends Subscribable { |
| 438 |
#online = true; |
| 439 |
#cleanup; |
| 440 |
#setup; |
| 441 |
constructor() { |
| 442 |
super(); |
| 443 |
this.#setup = (onOnline) => { |
| 444 |
if (!isServer && window.addEventListener) { |
| 445 |
const onlineListener = () => onOnline(true); |
| 446 |
const offlineListener = () => onOnline(false); |
| 447 |
window.addEventListener("online", onlineListener, false); |
| 448 |
window.addEventListener("offline", offlineListener, false); |
| 449 |
return () => { |
| 450 |
window.removeEventListener("online", onlineListener); |
| 451 |
window.removeEventListener("offline", offlineListener); |
| 452 |
}; |
| 453 |
} |
| 454 |
}; |
| 455 |
} |
| 456 |
onSubscribe() { |
| 457 |
if (!this.#cleanup) this.setEventListener(this.#setup); |
| 458 |
} |
| 459 |
onUnsubscribe() { |
| 460 |
if (!this.hasListeners()) { |
| 461 |
this.#cleanup?.(); |
| 462 |
this.#cleanup = void 0; |
| 463 |
} |
| 464 |
} |
| 465 |
setEventListener(setup) { |
| 466 |
this.#setup = setup; |
| 467 |
this.#cleanup?.(); |
| 468 |
this.#cleanup = setup(this.setOnline.bind(this)); |
| 469 |
} |
| 470 |
setOnline(online) { |
| 471 |
if (this.#online !== online) { |
| 472 |
this.#online = online; |
| 473 |
this.listeners.forEach((listener) => { |
| 474 |
listener(online); |
| 475 |
}); |
| 476 |
} |
| 477 |
} |
| 478 |
isOnline() { |
| 479 |
return this.#online; |
| 480 |
} |
| 481 |
}; |
| 482 |
var onlineManager = new OnlineManager(); |
| 483 |
|
| 484 |
//#endregion |
| 485 |
//#region node_modules/@tanstack/query-core/build/modern/retryer.js |
| 486 |
function defaultRetryDelay(failureCount) { |
| 487 |
return Math.min(1e3 * 2 ** failureCount, 3e4); |
| 488 |
} |
| 489 |
function canFetch(networkMode) { |
| 490 |
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true; |
| 491 |
} |
| 492 |
var CancelledError = class extends Error { |
| 493 |
constructor(options) { |
| 494 |
super("CancelledError"); |
| 495 |
this.revert = options?.revert; |
| 496 |
this.silent = options?.silent; |
| 497 |
} |
| 498 |
}; |
| 499 |
function createRetryer(config) { |
| 500 |
let isRetryCancelled = false; |
| 501 |
let failureCount = 0; |
| 502 |
let continueFn; |
| 503 |
const thenable = pendingThenable(); |
| 504 |
const isResolved = () => thenable.status !== "pending"; |
| 505 |
const cancel = (cancelOptions) => { |
| 506 |
if (!isResolved()) { |
| 507 |
const error = new CancelledError(cancelOptions); |
| 508 |
reject(error); |
| 509 |
config.onCancel?.(error); |
| 510 |
} |
| 511 |
}; |
| 512 |
const cancelRetry = () => { |
| 513 |
isRetryCancelled = true; |
| 514 |
}; |
| 515 |
const continueRetry = () => { |
| 516 |
isRetryCancelled = false; |
| 517 |
}; |
| 518 |
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun(); |
| 519 |
const canStart = () => canFetch(config.networkMode) && config.canRun(); |
| 520 |
const resolve = (value) => { |
| 521 |
if (!isResolved()) { |
| 522 |
continueFn?.(); |
| 523 |
thenable.resolve(value); |
| 524 |
} |
| 525 |
}; |
| 526 |
const reject = (value) => { |
| 527 |
if (!isResolved()) { |
| 528 |
continueFn?.(); |
| 529 |
thenable.reject(value); |
| 530 |
} |
| 531 |
}; |
| 532 |
const pause = () => { |
| 533 |
return new Promise((continueResolve) => { |
| 534 |
continueFn = (value) => { |
| 535 |
if (isResolved() || canContinue()) continueResolve(value); |
| 536 |
}; |
| 537 |
config.onPause?.(); |
| 538 |
}).then(() => { |
| 539 |
continueFn = void 0; |
| 540 |
if (!isResolved()) config.onContinue?.(); |
| 541 |
}); |
| 542 |
}; |
| 543 |
const run = () => { |
| 544 |
if (isResolved()) return; |
| 545 |
let promiseOrValue; |
| 546 |
const initialPromise = failureCount === 0 ? config.initialPromise : void 0; |
| 547 |
try { |
| 548 |
promiseOrValue = initialPromise ?? config.fn(); |
| 549 |
} catch (error) { |
| 550 |
promiseOrValue = Promise.reject(error); |
| 551 |
} |
| 552 |
Promise.resolve(promiseOrValue).then(resolve).catch((error) => { |
| 553 |
if (isResolved()) return; |
| 554 |
const retry = config.retry ?? (isServer ? 0 : 3); |
| 555 |
const retryDelay = config.retryDelay ?? defaultRetryDelay; |
| 556 |
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay; |
| 557 |
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error); |
| 558 |
if (isRetryCancelled || !shouldRetry) { |
| 559 |
reject(error); |
| 560 |
return; |
| 561 |
} |
| 562 |
failureCount++; |
| 563 |
config.onFail?.(failureCount, error); |
| 564 |
sleep(delay).then(() => { |
| 565 |
return canContinue() ? void 0 : pause(); |
| 566 |
}).then(() => { |
| 567 |
if (isRetryCancelled) reject(error); |
| 568 |
else run(); |
| 569 |
}); |
| 570 |
}); |
| 571 |
}; |
| 572 |
return { |
| 573 |
promise: thenable, |
| 574 |
status: () => thenable.status, |
| 575 |
cancel, |
| 576 |
continue: () => { |
| 577 |
continueFn?.(); |
| 578 |
return thenable; |
| 579 |
}, |
| 580 |
cancelRetry, |
| 581 |
continueRetry, |
| 582 |
canStart, |
| 583 |
start: () => { |
| 584 |
if (canStart()) run(); |
| 585 |
else pause().then(run); |
| 586 |
return thenable; |
| 587 |
} |
| 588 |
}; |
| 589 |
} |
| 590 |
|
| 591 |
//#endregion |
| 592 |
//#region node_modules/@tanstack/query-core/build/modern/removable.js |
| 593 |
var Removable = class { |
| 594 |
#gcTimeout; |
| 595 |
destroy() { |
| 596 |
this.clearGcTimeout(); |
| 597 |
} |
| 598 |
scheduleGc() { |
| 599 |
this.clearGcTimeout(); |
| 600 |
if (isValidTimeout(this.gcTime)) this.#gcTimeout = timeoutManager.setTimeout(() => { |
| 601 |
this.optionalRemove(); |
| 602 |
}, this.gcTime); |
| 603 |
} |
| 604 |
updateGcTime(newGcTime) { |
| 605 |
this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer ? Infinity : 300 * 1e3)); |
| 606 |
} |
| 607 |
clearGcTimeout() { |
| 608 |
if (this.#gcTimeout) { |
| 609 |
timeoutManager.clearTimeout(this.#gcTimeout); |
| 610 |
this.#gcTimeout = void 0; |
| 611 |
} |
| 612 |
} |
| 613 |
}; |
| 614 |
|
| 615 |
//#endregion |
| 616 |
//#region node_modules/@tanstack/query-core/build/modern/query.js |
| 617 |
var Query = class extends Removable { |
| 618 |
#initialState; |
| 619 |
#revertState; |
| 620 |
#cache; |
| 621 |
#client; |
| 622 |
#retryer; |
| 623 |
#defaultOptions; |
| 624 |
#abortSignalConsumed; |
| 625 |
constructor(config) { |
| 626 |
super(); |
| 627 |
this.#abortSignalConsumed = false; |
| 628 |
this.#defaultOptions = config.defaultOptions; |
| 629 |
this.setOptions(config.options); |
| 630 |
this.observers = []; |
| 631 |
this.#client = config.client; |
| 632 |
this.#cache = this.#client.getQueryCache(); |
| 633 |
this.queryKey = config.queryKey; |
| 634 |
this.queryHash = config.queryHash; |
| 635 |
this.#initialState = getDefaultState$1(this.options); |
| 636 |
this.state = config.state ?? this.#initialState; |
| 637 |
this.scheduleGc(); |
| 638 |
} |
| 639 |
get meta() { |
| 640 |
return this.options.meta; |
| 641 |
} |
| 642 |
get promise() { |
| 643 |
return this.#retryer?.promise; |
| 644 |
} |
| 645 |
setOptions(options) { |
| 646 |
this.options = { |
| 647 |
...this.#defaultOptions, |
| 648 |
...options |
| 649 |
}; |
| 650 |
this.updateGcTime(this.options.gcTime); |
| 651 |
if (this.state && this.state.data === void 0) { |
| 652 |
const defaultState = getDefaultState$1(this.options); |
| 653 |
if (defaultState.data !== void 0) { |
| 654 |
this.setState(successState(defaultState.data, defaultState.dataUpdatedAt)); |
| 655 |
this.#initialState = defaultState; |
| 656 |
} |
| 657 |
} |
| 658 |
} |
| 659 |
optionalRemove() { |
| 660 |
if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this); |
| 661 |
} |
| 662 |
setData(newData, options) { |
| 663 |
const data = replaceData(this.state.data, newData, this.options); |
| 664 |
this.#dispatch({ |
| 665 |
data, |
| 666 |
type: "success", |
| 667 |
dataUpdatedAt: options?.updatedAt, |
| 668 |
manual: options?.manual |
| 669 |
}); |
| 670 |
return data; |
| 671 |
} |
| 672 |
setState(state, setStateOptions) { |
| 673 |
this.#dispatch({ |
| 674 |
type: "setState", |
| 675 |
state, |
| 676 |
setStateOptions |
| 677 |
}); |
| 678 |
} |
| 679 |
cancel(options) { |
| 680 |
const promise = this.#retryer?.promise; |
| 681 |
this.#retryer?.cancel(options); |
| 682 |
return promise ? promise.then(noop).catch(noop) : Promise.resolve(); |
| 683 |
} |
| 684 |
destroy() { |
| 685 |
super.destroy(); |
| 686 |
this.cancel({ silent: true }); |
| 687 |
} |
| 688 |
reset() { |
| 689 |
this.destroy(); |
| 690 |
this.setState(this.#initialState); |
| 691 |
} |
| 692 |
isActive() { |
| 693 |
return this.observers.some((observer) => resolveEnabled(observer.options.enabled, this) !== false); |
| 694 |
} |
| 695 |
isDisabled() { |
| 696 |
if (this.getObserversCount() > 0) return !this.isActive(); |
| 697 |
return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0; |
| 698 |
} |
| 699 |
isStatic() { |
| 700 |
if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveStaleTime(observer.options.staleTime, this) === "static"); |
| 701 |
return false; |
| 702 |
} |
| 703 |
isStale() { |
| 704 |
if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale); |
| 705 |
return this.state.data === void 0 || this.state.isInvalidated; |
| 706 |
} |
| 707 |
isStaleByTime(staleTime = 0) { |
| 708 |
if (this.state.data === void 0) return true; |
| 709 |
if (staleTime === "static") return false; |
| 710 |
if (this.state.isInvalidated) return true; |
| 711 |
return !timeUntilStale(this.state.dataUpdatedAt, staleTime); |
| 712 |
} |
| 713 |
onFocus() { |
| 714 |
this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false }); |
| 715 |
this.#retryer?.continue(); |
| 716 |
} |
| 717 |
onOnline() { |
| 718 |
this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false }); |
| 719 |
this.#retryer?.continue(); |
| 720 |
} |
| 721 |
addObserver(observer) { |
| 722 |
if (!this.observers.includes(observer)) { |
| 723 |
this.observers.push(observer); |
| 724 |
this.clearGcTimeout(); |
| 725 |
this.#cache.notify({ |
| 726 |
type: "observerAdded", |
| 727 |
query: this, |
| 728 |
observer |
| 729 |
}); |
| 730 |
} |
| 731 |
} |
| 732 |
removeObserver(observer) { |
| 733 |
if (this.observers.includes(observer)) { |
| 734 |
this.observers = this.observers.filter((x) => x !== observer); |
| 735 |
if (!this.observers.length) { |
| 736 |
if (this.#retryer) if (this.#abortSignalConsumed) this.#retryer.cancel({ revert: true }); |
| 737 |
else this.#retryer.cancelRetry(); |
| 738 |
this.scheduleGc(); |
| 739 |
} |
| 740 |
this.#cache.notify({ |
| 741 |
type: "observerRemoved", |
| 742 |
query: this, |
| 743 |
observer |
| 744 |
}); |
| 745 |
} |
| 746 |
} |
| 747 |
getObserversCount() { |
| 748 |
return this.observers.length; |
| 749 |
} |
| 750 |
invalidate() { |
| 751 |
if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" }); |
| 752 |
} |
| 753 |
async fetch(options, fetchOptions) { |
| 754 |
if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") { |
| 755 |
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true }); |
| 756 |
else if (this.#retryer) { |
| 757 |
this.#retryer.continueRetry(); |
| 758 |
return this.#retryer.promise; |
| 759 |
} |
| 760 |
} |
| 761 |
if (options) this.setOptions(options); |
| 762 |
if (!this.options.queryFn) { |
| 763 |
const observer = this.observers.find((x) => x.options.queryFn); |
| 764 |
if (observer) this.setOptions(observer.options); |
| 765 |
} |
| 766 |
if (!Array.isArray(this.options.queryKey)) console.error(`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']`); |
| 767 |
const abortController = new AbortController(); |
| 768 |
const addSignalProperty = (object) => { |
| 769 |
Object.defineProperty(object, "signal", { |
| 770 |
enumerable: true, |
| 771 |
get: () => { |
| 772 |
this.#abortSignalConsumed = true; |
| 773 |
return abortController.signal; |
| 774 |
} |
| 775 |
}); |
| 776 |
}; |
| 777 |
const fetchFn = () => { |
| 778 |
const queryFn = ensureQueryFn(this.options, fetchOptions); |
| 779 |
const createQueryFnContext = () => { |
| 780 |
const queryFnContext2 = { |
| 781 |
client: this.#client, |
| 782 |
queryKey: this.queryKey, |
| 783 |
meta: this.meta |
| 784 |
}; |
| 785 |
addSignalProperty(queryFnContext2); |
| 786 |
return queryFnContext2; |
| 787 |
}; |
| 788 |
const queryFnContext = createQueryFnContext(); |
| 789 |
this.#abortSignalConsumed = false; |
| 790 |
if (this.options.persister) return this.options.persister(queryFn, queryFnContext, this); |
| 791 |
return queryFn(queryFnContext); |
| 792 |
}; |
| 793 |
const createFetchContext = () => { |
| 794 |
const context2 = { |
| 795 |
fetchOptions, |
| 796 |
options: this.options, |
| 797 |
queryKey: this.queryKey, |
| 798 |
client: this.#client, |
| 799 |
state: this.state, |
| 800 |
fetchFn |
| 801 |
}; |
| 802 |
addSignalProperty(context2); |
| 803 |
return context2; |
| 804 |
}; |
| 805 |
const context = createFetchContext(); |
| 806 |
this.options.behavior?.onFetch(context, this); |
| 807 |
this.#revertState = this.state; |
| 808 |
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) this.#dispatch({ |
| 809 |
type: "fetch", |
| 810 |
meta: context.fetchOptions?.meta |
| 811 |
}); |
| 812 |
this.#retryer = createRetryer({ |
| 813 |
initialPromise: fetchOptions?.initialPromise, |
| 814 |
fn: context.fetchFn, |
| 815 |
onCancel: (error) => { |
| 816 |
if (error instanceof CancelledError && error.revert) this.setState({ |
| 817 |
...this.#revertState, |
| 818 |
fetchStatus: "idle" |
| 819 |
}); |
| 820 |
abortController.abort(); |
| 821 |
}, |
| 822 |
onFail: (failureCount, error) => { |
| 823 |
this.#dispatch({ |
| 824 |
type: "failed", |
| 825 |
failureCount, |
| 826 |
error |
| 827 |
}); |
| 828 |
}, |
| 829 |
onPause: () => { |
| 830 |
this.#dispatch({ type: "pause" }); |
| 831 |
}, |
| 832 |
onContinue: () => { |
| 833 |
this.#dispatch({ type: "continue" }); |
| 834 |
}, |
| 835 |
retry: context.options.retry, |
| 836 |
retryDelay: context.options.retryDelay, |
| 837 |
networkMode: context.options.networkMode, |
| 838 |
canRun: () => true |
| 839 |
}); |
| 840 |
try { |
| 841 |
const data = await this.#retryer.start(); |
| 842 |
if (data === void 0) { |
| 843 |
console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`); |
| 844 |
throw new Error(`${this.queryHash} data is undefined`); |
| 845 |
} |
| 846 |
this.setData(data); |
| 847 |
this.#cache.config.onSuccess?.(data, this); |
| 848 |
this.#cache.config.onSettled?.(data, this.state.error, this); |
| 849 |
return data; |
| 850 |
} catch (error) { |
| 851 |
if (error instanceof CancelledError) { |
| 852 |
if (error.silent) return this.#retryer.promise; |
| 853 |
else if (error.revert) { |
| 854 |
if (this.state.data === void 0) throw error; |
| 855 |
return this.state.data; |
| 856 |
} |
| 857 |
} |
| 858 |
this.#dispatch({ |
| 859 |
type: "error", |
| 860 |
error |
| 861 |
}); |
| 862 |
this.#cache.config.onError?.(error, this); |
| 863 |
this.#cache.config.onSettled?.(this.state.data, error, this); |
| 864 |
throw error; |
| 865 |
} finally { |
| 866 |
this.scheduleGc(); |
| 867 |
} |
| 868 |
} |
| 869 |
#dispatch(action) { |
| 870 |
const reducer = (state) => { |
| 871 |
switch (action.type) { |
| 872 |
case "failed": return { |
| 873 |
...state, |
| 874 |
fetchFailureCount: action.failureCount, |
| 875 |
fetchFailureReason: action.error |
| 876 |
}; |
| 877 |
case "pause": return { |
| 878 |
...state, |
| 879 |
fetchStatus: "paused" |
| 880 |
}; |
| 881 |
case "continue": return { |
| 882 |
...state, |
| 883 |
fetchStatus: "fetching" |
| 884 |
}; |
| 885 |
case "fetch": return { |
| 886 |
...state, |
| 887 |
...fetchState(state.data, this.options), |
| 888 |
fetchMeta: action.meta ?? null |
| 889 |
}; |
| 890 |
case "success": |
| 891 |
const newState = { |
| 892 |
...state, |
| 893 |
...successState(action.data, action.dataUpdatedAt), |
| 894 |
dataUpdateCount: state.dataUpdateCount + 1, |
| 895 |
...!action.manual && { |
| 896 |
fetchStatus: "idle", |
| 897 |
fetchFailureCount: 0, |
| 898 |
fetchFailureReason: null |
| 899 |
} |
| 900 |
}; |
| 901 |
this.#revertState = action.manual ? newState : void 0; |
| 902 |
return newState; |
| 903 |
case "error": |
| 904 |
const error = action.error; |
| 905 |
return { |
| 906 |
...state, |
| 907 |
error, |
| 908 |
errorUpdateCount: state.errorUpdateCount + 1, |
| 909 |
errorUpdatedAt: Date.now(), |
| 910 |
fetchFailureCount: state.fetchFailureCount + 1, |
| 911 |
fetchFailureReason: error, |
| 912 |
fetchStatus: "idle", |
| 913 |
status: "error" |
| 914 |
}; |
| 915 |
case "invalidate": return { |
| 916 |
...state, |
| 917 |
isInvalidated: true |
| 918 |
}; |
| 919 |
case "setState": return { |
| 920 |
...state, |
| 921 |
...action.state |
| 922 |
}; |
| 923 |
} |
| 924 |
}; |
| 925 |
this.state = reducer(this.state); |
| 926 |
notifyManager.batch(() => { |
| 927 |
this.observers.forEach((observer) => { |
| 928 |
observer.onQueryUpdate(); |
| 929 |
}); |
| 930 |
this.#cache.notify({ |
| 931 |
query: this, |
| 932 |
type: "updated", |
| 933 |
action |
| 934 |
}); |
| 935 |
}); |
| 936 |
} |
| 937 |
}; |
| 938 |
function fetchState(data, options) { |
| 939 |
return { |
| 940 |
fetchFailureCount: 0, |
| 941 |
fetchFailureReason: null, |
| 942 |
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused", |
| 943 |
...data === void 0 && { |
| 944 |
error: null, |
| 945 |
status: "pending" |
| 946 |
} |
| 947 |
}; |
| 948 |
} |
| 949 |
function successState(data, dataUpdatedAt) { |
| 950 |
return { |
| 951 |
data, |
| 952 |
dataUpdatedAt: dataUpdatedAt ?? Date.now(), |
| 953 |
error: null, |
| 954 |
isInvalidated: false, |
| 955 |
status: "success" |
| 956 |
}; |
| 957 |
} |
| 958 |
function getDefaultState$1(options) { |
| 959 |
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData; |
| 960 |
const hasData = data !== void 0; |
| 961 |
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; |
| 962 |
return { |
| 963 |
data, |
| 964 |
dataUpdateCount: 0, |
| 965 |
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0, |
| 966 |
error: null, |
| 967 |
errorUpdateCount: 0, |
| 968 |
errorUpdatedAt: 0, |
| 969 |
fetchFailureCount: 0, |
| 970 |
fetchFailureReason: null, |
| 971 |
fetchMeta: null, |
| 972 |
isInvalidated: false, |
| 973 |
status: hasData ? "success" : "pending", |
| 974 |
fetchStatus: "idle" |
| 975 |
}; |
| 976 |
} |
| 977 |
__name(getDefaultState$1, "getDefaultState"); |
| 978 |
|
| 979 |
//#endregion |
| 980 |
//#region node_modules/@tanstack/query-core/build/modern/queryObserver.js |
| 981 |
var QueryObserver = class extends Subscribable { |
| 982 |
constructor(client, options) { |
| 983 |
super(); |
| 984 |
this.options = options; |
| 985 |
this.#client = client; |
| 986 |
this.#selectError = null; |
| 987 |
this.#currentThenable = pendingThenable(); |
| 988 |
this.bindMethods(); |
| 989 |
this.setOptions(options); |
| 990 |
} |
| 991 |
#client; |
| 992 |
#currentQuery = void 0; |
| 993 |
#currentQueryInitialState = void 0; |
| 994 |
#currentResult = void 0; |
| 995 |
#currentResultState; |
| 996 |
#currentResultOptions; |
| 997 |
#currentThenable; |
| 998 |
#selectError; |
| 999 |
#selectFn; |
| 1000 |
#selectResult; |
| 1001 |
#lastQueryWithDefinedData; |
| 1002 |
#staleTimeoutId; |
| 1003 |
#refetchIntervalId; |
| 1004 |
#currentRefetchInterval; |
| 1005 |
#trackedProps = /* @__PURE__ */ new Set(); |
| 1006 |
bindMethods() { |
| 1007 |
this.refetch = this.refetch.bind(this); |
| 1008 |
} |
| 1009 |
onSubscribe() { |
| 1010 |
if (this.listeners.size === 1) { |
| 1011 |
this.#currentQuery.addObserver(this); |
| 1012 |
if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch(); |
| 1013 |
else this.updateResult(); |
| 1014 |
this.#updateTimers(); |
| 1015 |
} |
| 1016 |
} |
| 1017 |
onUnsubscribe() { |
| 1018 |
if (!this.hasListeners()) this.destroy(); |
| 1019 |
} |
| 1020 |
shouldFetchOnReconnect() { |
| 1021 |
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect); |
| 1022 |
} |
| 1023 |
shouldFetchOnWindowFocus() { |
| 1024 |
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus); |
| 1025 |
} |
| 1026 |
destroy() { |
| 1027 |
this.listeners = /* @__PURE__ */ new Set(); |
| 1028 |
this.#clearStaleTimeout(); |
| 1029 |
this.#clearRefetchInterval(); |
| 1030 |
this.#currentQuery.removeObserver(this); |
| 1031 |
} |
| 1032 |
setOptions(options) { |
| 1033 |
const prevOptions = this.options; |
| 1034 |
const prevQuery = this.#currentQuery; |
| 1035 |
this.options = this.#client.defaultQueryOptions(options); |
| 1036 |
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean"); |
| 1037 |
this.#updateQuery(); |
| 1038 |
this.#currentQuery.setOptions(this.options); |
| 1039 |
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({ |
| 1040 |
type: "observerOptionsUpdated", |
| 1041 |
query: this.#currentQuery, |
| 1042 |
observer: this |
| 1043 |
}); |
| 1044 |
const mounted = this.hasListeners(); |
| 1045 |
if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch(); |
| 1046 |
this.updateResult(); |
| 1047 |
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout(); |
| 1048 |
const nextRefetchInterval = this.#computeRefetchInterval(); |
| 1049 |
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval); |
| 1050 |
} |
| 1051 |
getOptimisticResult(options) { |
| 1052 |
const query = this.#client.getQueryCache().build(this.#client, options); |
| 1053 |
const result = this.createResult(query, options); |
| 1054 |
if (shouldAssignObserverCurrentProperties(this, result)) { |
| 1055 |
this.#currentResult = result; |
| 1056 |
this.#currentResultOptions = this.options; |
| 1057 |
this.#currentResultState = this.#currentQuery.state; |
| 1058 |
} |
| 1059 |
return result; |
| 1060 |
} |
| 1061 |
getCurrentResult() { |
| 1062 |
return this.#currentResult; |
| 1063 |
} |
| 1064 |
trackResult(result, onPropTracked) { |
| 1065 |
return new Proxy(result, { get: (target, key) => { |
| 1066 |
this.trackProp(key); |
| 1067 |
onPropTracked?.(key); |
| 1068 |
if (key === "promise") { |
| 1069 |
this.trackProp("data"); |
| 1070 |
if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled")); |
| 1071 |
} |
| 1072 |
return Reflect.get(target, key); |
| 1073 |
} }); |
| 1074 |
} |
| 1075 |
trackProp(key) { |
| 1076 |
this.#trackedProps.add(key); |
| 1077 |
} |
| 1078 |
getCurrentQuery() { |
| 1079 |
return this.#currentQuery; |
| 1080 |
} |
| 1081 |
refetch({ ...options } = {}) { |
| 1082 |
return this.fetch({ ...options }); |
| 1083 |
} |
| 1084 |
fetchOptimistic(options) { |
| 1085 |
const defaultedOptions = this.#client.defaultQueryOptions(options); |
| 1086 |
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions); |
| 1087 |
return query.fetch().then(() => this.createResult(query, defaultedOptions)); |
| 1088 |
} |
| 1089 |
fetch(fetchOptions) { |
| 1090 |
return this.#executeFetch({ |
| 1091 |
...fetchOptions, |
| 1092 |
cancelRefetch: fetchOptions.cancelRefetch ?? true |
| 1093 |
}).then(() => { |
| 1094 |
this.updateResult(); |
| 1095 |
return this.#currentResult; |
| 1096 |
}); |
| 1097 |
} |
| 1098 |
#executeFetch(fetchOptions) { |
| 1099 |
this.#updateQuery(); |
| 1100 |
let promise = this.#currentQuery.fetch(this.options, fetchOptions); |
| 1101 |
if (!fetchOptions?.throwOnError) promise = promise.catch(noop); |
| 1102 |
return promise; |
| 1103 |
} |
| 1104 |
#updateStaleTimeout() { |
| 1105 |
this.#clearStaleTimeout(); |
| 1106 |
const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery); |
| 1107 |
if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) return; |
| 1108 |
const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1; |
| 1109 |
this.#staleTimeoutId = timeoutManager.setTimeout(() => { |
| 1110 |
if (!this.#currentResult.isStale) this.updateResult(); |
| 1111 |
}, timeout); |
| 1112 |
} |
| 1113 |
#computeRefetchInterval() { |
| 1114 |
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false; |
| 1115 |
} |
| 1116 |
#updateRefetchInterval(nextInterval) { |
| 1117 |
this.#clearRefetchInterval(); |
| 1118 |
this.#currentRefetchInterval = nextInterval; |
| 1119 |
if (isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return; |
| 1120 |
this.#refetchIntervalId = timeoutManager.setInterval(() => { |
| 1121 |
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch(); |
| 1122 |
}, this.#currentRefetchInterval); |
| 1123 |
} |
| 1124 |
#updateTimers() { |
| 1125 |
this.#updateStaleTimeout(); |
| 1126 |
this.#updateRefetchInterval(this.#computeRefetchInterval()); |
| 1127 |
} |
| 1128 |
#clearStaleTimeout() { |
| 1129 |
if (this.#staleTimeoutId) { |
| 1130 |
timeoutManager.clearTimeout(this.#staleTimeoutId); |
| 1131 |
this.#staleTimeoutId = void 0; |
| 1132 |
} |
| 1133 |
} |
| 1134 |
#clearRefetchInterval() { |
| 1135 |
if (this.#refetchIntervalId) { |
| 1136 |
timeoutManager.clearInterval(this.#refetchIntervalId); |
| 1137 |
this.#refetchIntervalId = void 0; |
| 1138 |
} |
| 1139 |
} |
| 1140 |
createResult(query, options) { |
| 1141 |
const prevQuery = this.#currentQuery; |
| 1142 |
const prevOptions = this.options; |
| 1143 |
const prevResult = this.#currentResult; |
| 1144 |
const prevResultState = this.#currentResultState; |
| 1145 |
const prevResultOptions = this.#currentResultOptions; |
| 1146 |
const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState; |
| 1147 |
const { state } = query; |
| 1148 |
let newState = { ...state }; |
| 1149 |
let isPlaceholderData = false; |
| 1150 |
let data; |
| 1151 |
if (options._optimisticResults) { |
| 1152 |
const mounted = this.hasListeners(); |
| 1153 |
const fetchOnMount = !mounted && shouldFetchOnMount(query, options); |
| 1154 |
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions); |
| 1155 |
if (fetchOnMount || fetchOptionally) newState = { |
| 1156 |
...newState, |
| 1157 |
...fetchState(state.data, query.options) |
| 1158 |
}; |
| 1159 |
if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle"; |
| 1160 |
} |
| 1161 |
let { error, errorUpdatedAt, status } = newState; |
| 1162 |
data = newState.data; |
| 1163 |
let skipSelect = false; |
| 1164 |
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") { |
| 1165 |
let placeholderData; |
| 1166 |
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) { |
| 1167 |
placeholderData = prevResult.data; |
| 1168 |
skipSelect = true; |
| 1169 |
} else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData; |
| 1170 |
if (placeholderData !== void 0) { |
| 1171 |
status = "success"; |
| 1172 |
data = replaceData(prevResult?.data, placeholderData, options); |
| 1173 |
isPlaceholderData = true; |
| 1174 |
} |
| 1175 |
} |
| 1176 |
if (options.select && data !== void 0 && !skipSelect) if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult; |
| 1177 |
else try { |
| 1178 |
this.#selectFn = options.select; |
| 1179 |
data = options.select(data); |
| 1180 |
data = replaceData(prevResult?.data, data, options); |
| 1181 |
this.#selectResult = data; |
| 1182 |
this.#selectError = null; |
| 1183 |
} catch (selectError) { |
| 1184 |
this.#selectError = selectError; |
| 1185 |
} |
| 1186 |
if (this.#selectError) { |
| 1187 |
error = this.#selectError; |
| 1188 |
data = this.#selectResult; |
| 1189 |
errorUpdatedAt = Date.now(); |
| 1190 |
status = "error"; |
| 1191 |
} |
| 1192 |
const isFetching = newState.fetchStatus === "fetching"; |
| 1193 |
const isPending = status === "pending"; |
| 1194 |
const isError = status === "error"; |
| 1195 |
const isLoading = isPending && isFetching; |
| 1196 |
const hasData = data !== void 0; |
| 1197 |
const nextResult = { |
| 1198 |
status, |
| 1199 |
fetchStatus: newState.fetchStatus, |
| 1200 |
isPending, |
| 1201 |
isSuccess: status === "success", |
| 1202 |
isError, |
| 1203 |
isInitialLoading: isLoading, |
| 1204 |
isLoading, |
| 1205 |
data, |
| 1206 |
dataUpdatedAt: newState.dataUpdatedAt, |
| 1207 |
error, |
| 1208 |
errorUpdatedAt, |
| 1209 |
failureCount: newState.fetchFailureCount, |
| 1210 |
failureReason: newState.fetchFailureReason, |
| 1211 |
errorUpdateCount: newState.errorUpdateCount, |
| 1212 |
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0, |
| 1213 |
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount, |
| 1214 |
isFetching, |
| 1215 |
isRefetching: isFetching && !isPending, |
| 1216 |
isLoadingError: isError && !hasData, |
| 1217 |
isPaused: newState.fetchStatus === "paused", |
| 1218 |
isPlaceholderData, |
| 1219 |
isRefetchError: isError && hasData, |
| 1220 |
isStale: isStale(query, options), |
| 1221 |
refetch: this.refetch, |
| 1222 |
promise: this.#currentThenable, |
| 1223 |
isEnabled: resolveEnabled(options.enabled, query) !== false |
| 1224 |
}; |
| 1225 |
if (this.options.experimental_prefetchInRender) { |
| 1226 |
const finalizeThenableIfPossible = (thenable) => { |
| 1227 |
if (nextResult.status === "error") thenable.reject(nextResult.error); |
| 1228 |
else if (nextResult.data !== void 0) thenable.resolve(nextResult.data); |
| 1229 |
}; |
| 1230 |
const recreateThenable = () => { |
| 1231 |
const pending = this.#currentThenable = nextResult.promise = pendingThenable(); |
| 1232 |
finalizeThenableIfPossible(pending); |
| 1233 |
}; |
| 1234 |
const prevThenable = this.#currentThenable; |
| 1235 |
switch (prevThenable.status) { |
| 1236 |
case "pending": |
| 1237 |
if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable); |
| 1238 |
break; |
| 1239 |
case "fulfilled": |
| 1240 |
if (nextResult.status === "error" || nextResult.data !== prevThenable.value) recreateThenable(); |
| 1241 |
break; |
| 1242 |
case "rejected": |
| 1243 |
if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) recreateThenable(); |
| 1244 |
break; |
| 1245 |
} |
| 1246 |
} |
| 1247 |
return nextResult; |
| 1248 |
} |
| 1249 |
updateResult() { |
| 1250 |
const prevResult = this.#currentResult; |
| 1251 |
const nextResult = this.createResult(this.#currentQuery, this.options); |
| 1252 |
this.#currentResultState = this.#currentQuery.state; |
| 1253 |
this.#currentResultOptions = this.options; |
| 1254 |
if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery; |
| 1255 |
if (shallowEqualObjects(nextResult, prevResult)) return; |
| 1256 |
this.#currentResult = nextResult; |
| 1257 |
const shouldNotifyListeners = () => { |
| 1258 |
if (!prevResult) return true; |
| 1259 |
const { notifyOnChangeProps } = this.options; |
| 1260 |
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps; |
| 1261 |
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true; |
| 1262 |
const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps); |
| 1263 |
if (this.options.throwOnError) includedProps.add("error"); |
| 1264 |
return Object.keys(this.#currentResult).some((key) => { |
| 1265 |
const typedKey = key; |
| 1266 |
return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey); |
| 1267 |
}); |
| 1268 |
}; |
| 1269 |
this.#notify({ listeners: shouldNotifyListeners() }); |
| 1270 |
} |
| 1271 |
#updateQuery() { |
| 1272 |
const query = this.#client.getQueryCache().build(this.#client, this.options); |
| 1273 |
if (query === this.#currentQuery) return; |
| 1274 |
const prevQuery = this.#currentQuery; |
| 1275 |
this.#currentQuery = query; |
| 1276 |
this.#currentQueryInitialState = query.state; |
| 1277 |
if (this.hasListeners()) { |
| 1278 |
prevQuery?.removeObserver(this); |
| 1279 |
query.addObserver(this); |
| 1280 |
} |
| 1281 |
} |
| 1282 |
onQueryUpdate() { |
| 1283 |
this.updateResult(); |
| 1284 |
if (this.hasListeners()) this.#updateTimers(); |
| 1285 |
} |
| 1286 |
#notify(notifyOptions) { |
| 1287 |
notifyManager.batch(() => { |
| 1288 |
if (notifyOptions.listeners) this.listeners.forEach((listener) => { |
| 1289 |
listener(this.#currentResult); |
| 1290 |
}); |
| 1291 |
this.#client.getQueryCache().notify({ |
| 1292 |
query: this.#currentQuery, |
| 1293 |
type: "observerResultsUpdated" |
| 1294 |
}); |
| 1295 |
}); |
| 1296 |
} |
| 1297 |
}; |
| 1298 |
function shouldLoadOnMount(query, options) { |
| 1299 |
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false); |
| 1300 |
} |
| 1301 |
function shouldFetchOnMount(query, options) { |
| 1302 |
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount); |
| 1303 |
} |
| 1304 |
function shouldFetchOn(query, options, field) { |
| 1305 |
if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") { |
| 1306 |
const value = typeof field === "function" ? field(query) : field; |
| 1307 |
return value === "always" || value !== false && isStale(query, options); |
| 1308 |
} |
| 1309 |
return false; |
| 1310 |
} |
| 1311 |
function shouldFetchOptionally(query, prevQuery, options, prevOptions) { |
| 1312 |
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); |
| 1313 |
} |
| 1314 |
function isStale(query, options) { |
| 1315 |
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query)); |
| 1316 |
} |
| 1317 |
function shouldAssignObserverCurrentProperties(observer, optimisticResult) { |
| 1318 |
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true; |
| 1319 |
return false; |
| 1320 |
} |
| 1321 |
|
| 1322 |
//#endregion |
| 1323 |
//#region node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js |
| 1324 |
function infiniteQueryBehavior(pages) { |
| 1325 |
return { onFetch: (context, query) => { |
| 1326 |
const options = context.options; |
| 1327 |
const direction = context.fetchOptions?.meta?.fetchMore?.direction; |
| 1328 |
const oldPages = context.state.data?.pages || []; |
| 1329 |
const oldPageParams = context.state.data?.pageParams || []; |
| 1330 |
let result = { |
| 1331 |
pages: [], |
| 1332 |
pageParams: [] |
| 1333 |
}; |
| 1334 |
let currentPage = 0; |
| 1335 |
const fetchFn = async () => { |
| 1336 |
let cancelled = false; |
| 1337 |
const addSignalProperty = (object) => { |
| 1338 |
addConsumeAwareSignal(object, () => context.signal, () => cancelled = true); |
| 1339 |
}; |
| 1340 |
const queryFn = ensureQueryFn(context.options, context.fetchOptions); |
| 1341 |
const fetchPage = async (data, param, previous) => { |
| 1342 |
if (cancelled) return Promise.reject(); |
| 1343 |
if (param == null && data.pages.length) return Promise.resolve(data); |
| 1344 |
const createQueryFnContext = () => { |
| 1345 |
const queryFnContext2 = { |
| 1346 |
client: context.client, |
| 1347 |
queryKey: context.queryKey, |
| 1348 |
pageParam: param, |
| 1349 |
direction: previous ? "backward" : "forward", |
| 1350 |
meta: context.options.meta |
| 1351 |
}; |
| 1352 |
addSignalProperty(queryFnContext2); |
| 1353 |
return queryFnContext2; |
| 1354 |
}; |
| 1355 |
const queryFnContext = createQueryFnContext(); |
| 1356 |
const page = await queryFn(queryFnContext); |
| 1357 |
const { maxPages } = context.options; |
| 1358 |
const addTo = previous ? addToStart : addToEnd; |
| 1359 |
return { |
| 1360 |
pages: addTo(data.pages, page, maxPages), |
| 1361 |
pageParams: addTo(data.pageParams, param, maxPages) |
| 1362 |
}; |
| 1363 |
}; |
| 1364 |
if (direction && oldPages.length) { |
| 1365 |
const previous = direction === "backward"; |
| 1366 |
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam; |
| 1367 |
const oldData = { |
| 1368 |
pages: oldPages, |
| 1369 |
pageParams: oldPageParams |
| 1370 |
}; |
| 1371 |
result = await fetchPage(oldData, pageParamFn(options, oldData), previous); |
| 1372 |
} else { |
| 1373 |
const remainingPages = pages ?? oldPages.length; |
| 1374 |
do { |
| 1375 |
const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result); |
| 1376 |
if (currentPage > 0 && param == null) break; |
| 1377 |
result = await fetchPage(result, param); |
| 1378 |
currentPage++; |
| 1379 |
} while (currentPage < remainingPages); |
| 1380 |
} |
| 1381 |
return result; |
| 1382 |
}; |
| 1383 |
if (context.options.persister) context.fetchFn = () => { |
| 1384 |
return context.options.persister?.(fetchFn, { |
| 1385 |
client: context.client, |
| 1386 |
queryKey: context.queryKey, |
| 1387 |
meta: context.options.meta, |
| 1388 |
signal: context.signal |
| 1389 |
}, query); |
| 1390 |
}; |
| 1391 |
else context.fetchFn = fetchFn; |
| 1392 |
} }; |
| 1393 |
} |
| 1394 |
function getNextPageParam(options, { pages, pageParams }) { |
| 1395 |
const lastIndex = pages.length - 1; |
| 1396 |
return pages.length > 0 ? options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams) : void 0; |
| 1397 |
} |
| 1398 |
function getPreviousPageParam(options, { pages, pageParams }) { |
| 1399 |
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0; |
| 1400 |
} |
| 1401 |
function hasNextPage(options, data) { |
| 1402 |
if (!data) return false; |
| 1403 |
return getNextPageParam(options, data) != null; |
| 1404 |
} |
| 1405 |
function hasPreviousPage(options, data) { |
| 1406 |
if (!data || !options.getPreviousPageParam) return false; |
| 1407 |
return getPreviousPageParam(options, data) != null; |
| 1408 |
} |
| 1409 |
|
| 1410 |
//#endregion |
| 1411 |
//#region node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js |
| 1412 |
var InfiniteQueryObserver = class extends QueryObserver { |
| 1413 |
constructor(client, options) { |
| 1414 |
super(client, options); |
| 1415 |
} |
| 1416 |
bindMethods() { |
| 1417 |
super.bindMethods(); |
| 1418 |
this.fetchNextPage = this.fetchNextPage.bind(this); |
| 1419 |
this.fetchPreviousPage = this.fetchPreviousPage.bind(this); |
| 1420 |
} |
| 1421 |
setOptions(options) { |
| 1422 |
super.setOptions({ |
| 1423 |
...options, |
| 1424 |
behavior: infiniteQueryBehavior() |
| 1425 |
}); |
| 1426 |
} |
| 1427 |
getOptimisticResult(options) { |
| 1428 |
options.behavior = infiniteQueryBehavior(); |
| 1429 |
return super.getOptimisticResult(options); |
| 1430 |
} |
| 1431 |
fetchNextPage(options) { |
| 1432 |
return this.fetch({ |
| 1433 |
...options, |
| 1434 |
meta: { fetchMore: { direction: "forward" } } |
| 1435 |
}); |
| 1436 |
} |
| 1437 |
fetchPreviousPage(options) { |
| 1438 |
return this.fetch({ |
| 1439 |
...options, |
| 1440 |
meta: { fetchMore: { direction: "backward" } } |
| 1441 |
}); |
| 1442 |
} |
| 1443 |
createResult(query, options) { |
| 1444 |
const { state } = query; |
| 1445 |
const parentResult = super.createResult(query, options); |
| 1446 |
const { isFetching, isRefetching, isError, isRefetchError } = parentResult; |
| 1447 |
const fetchDirection = state.fetchMeta?.fetchMore?.direction; |
| 1448 |
const isFetchNextPageError = isError && fetchDirection === "forward"; |
| 1449 |
const isFetchingNextPage = isFetching && fetchDirection === "forward"; |
| 1450 |
const isFetchPreviousPageError = isError && fetchDirection === "backward"; |
| 1451 |
const isFetchingPreviousPage = isFetching && fetchDirection === "backward"; |
| 1452 |
return { |
| 1453 |
...parentResult, |
| 1454 |
fetchNextPage: this.fetchNextPage, |
| 1455 |
fetchPreviousPage: this.fetchPreviousPage, |
| 1456 |
hasNextPage: hasNextPage(options, state.data), |
| 1457 |
hasPreviousPage: hasPreviousPage(options, state.data), |
| 1458 |
isFetchNextPageError, |
| 1459 |
isFetchingNextPage, |
| 1460 |
isFetchPreviousPageError, |
| 1461 |
isFetchingPreviousPage, |
| 1462 |
isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError, |
| 1463 |
isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage |
| 1464 |
}; |
| 1465 |
} |
| 1466 |
}; |
| 1467 |
|
| 1468 |
//#endregion |
| 1469 |
//#region node_modules/@tanstack/query-core/build/modern/mutation.js |
| 1470 |
var Mutation = class extends Removable { |
| 1471 |
#client; |
| 1472 |
#observers; |
| 1473 |
#mutationCache; |
| 1474 |
#retryer; |
| 1475 |
constructor(config) { |
| 1476 |
super(); |
| 1477 |
this.#client = config.client; |
| 1478 |
this.mutationId = config.mutationId; |
| 1479 |
this.#mutationCache = config.mutationCache; |
| 1480 |
this.#observers = []; |
| 1481 |
this.state = config.state || getDefaultState(); |
| 1482 |
this.setOptions(config.options); |
| 1483 |
this.scheduleGc(); |
| 1484 |
} |
| 1485 |
setOptions(options) { |
| 1486 |
this.options = options; |
| 1487 |
this.updateGcTime(this.options.gcTime); |
| 1488 |
} |
| 1489 |
get meta() { |
| 1490 |
return this.options.meta; |
| 1491 |
} |
| 1492 |
addObserver(observer) { |
| 1493 |
if (!this.#observers.includes(observer)) { |
| 1494 |
this.#observers.push(observer); |
| 1495 |
this.clearGcTimeout(); |
| 1496 |
this.#mutationCache.notify({ |
| 1497 |
type: "observerAdded", |
| 1498 |
mutation: this, |
| 1499 |
observer |
| 1500 |
}); |
| 1501 |
} |
| 1502 |
} |
| 1503 |
removeObserver(observer) { |
| 1504 |
this.#observers = this.#observers.filter((x) => x !== observer); |
| 1505 |
this.scheduleGc(); |
| 1506 |
this.#mutationCache.notify({ |
| 1507 |
type: "observerRemoved", |
| 1508 |
mutation: this, |
| 1509 |
observer |
| 1510 |
}); |
| 1511 |
} |
| 1512 |
optionalRemove() { |
| 1513 |
if (!this.#observers.length) if (this.state.status === "pending") this.scheduleGc(); |
| 1514 |
else this.#mutationCache.remove(this); |
| 1515 |
} |
| 1516 |
continue() { |
| 1517 |
return this.#retryer?.continue() ?? this.execute(this.state.variables); |
| 1518 |
} |
| 1519 |
async execute(variables) { |
| 1520 |
const onContinue = () => { |
| 1521 |
this.#dispatch({ type: "continue" }); |
| 1522 |
}; |
| 1523 |
const mutationFnContext = { |
| 1524 |
client: this.#client, |
| 1525 |
meta: this.options.meta, |
| 1526 |
mutationKey: this.options.mutationKey |
| 1527 |
}; |
| 1528 |
this.#retryer = createRetryer({ |
| 1529 |
fn: () => { |
| 1530 |
if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found")); |
| 1531 |
return this.options.mutationFn(variables, mutationFnContext); |
| 1532 |
}, |
| 1533 |
onFail: (failureCount, error) => { |
| 1534 |
this.#dispatch({ |
| 1535 |
type: "failed", |
| 1536 |
failureCount, |
| 1537 |
error |
| 1538 |
}); |
| 1539 |
}, |
| 1540 |
onPause: () => { |
| 1541 |
this.#dispatch({ type: "pause" }); |
| 1542 |
}, |
| 1543 |
onContinue, |
| 1544 |
retry: this.options.retry ?? 0, |
| 1545 |
retryDelay: this.options.retryDelay, |
| 1546 |
networkMode: this.options.networkMode, |
| 1547 |
canRun: () => this.#mutationCache.canRun(this) |
| 1548 |
}); |
| 1549 |
const restored = this.state.status === "pending"; |
| 1550 |
const isPaused = !this.#retryer.canStart(); |
| 1551 |
try { |
| 1552 |
if (restored) onContinue(); |
| 1553 |
else { |
| 1554 |
this.#dispatch({ |
| 1555 |
type: "pending", |
| 1556 |
variables, |
| 1557 |
isPaused |
| 1558 |
}); |
| 1559 |
await this.#mutationCache.config.onMutate?.(variables, this, mutationFnContext); |
| 1560 |
const context = await this.options.onMutate?.(variables, mutationFnContext); |
| 1561 |
if (context !== this.state.context) this.#dispatch({ |
| 1562 |
type: "pending", |
| 1563 |
context, |
| 1564 |
variables, |
| 1565 |
isPaused |
| 1566 |
}); |
| 1567 |
} |
| 1568 |
const data = await this.#retryer.start(); |
| 1569 |
await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext); |
| 1570 |
await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext); |
| 1571 |
await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext); |
| 1572 |
await this.options.onSettled?.(data, null, variables, this.state.context, mutationFnContext); |
| 1573 |
this.#dispatch({ |
| 1574 |
type: "success", |
| 1575 |
data |
| 1576 |
}); |
| 1577 |
return data; |
| 1578 |
} catch (error) { |
| 1579 |
try { |
| 1580 |
await this.#mutationCache.config.onError?.(error, variables, this.state.context, this, mutationFnContext); |
| 1581 |
await this.options.onError?.(error, variables, this.state.context, mutationFnContext); |
| 1582 |
await this.#mutationCache.config.onSettled?.(void 0, error, this.state.variables, this.state.context, this, mutationFnContext); |
| 1583 |
await this.options.onSettled?.(void 0, error, variables, this.state.context, mutationFnContext); |
| 1584 |
throw error; |
| 1585 |
} finally { |
| 1586 |
this.#dispatch({ |
| 1587 |
type: "error", |
| 1588 |
error |
| 1589 |
}); |
| 1590 |
} |
| 1591 |
} finally { |
| 1592 |
this.#mutationCache.runNext(this); |
| 1593 |
} |
| 1594 |
} |
| 1595 |
#dispatch(action) { |
| 1596 |
const reducer = (state) => { |
| 1597 |
switch (action.type) { |
| 1598 |
case "failed": return { |
| 1599 |
...state, |
| 1600 |
failureCount: action.failureCount, |
| 1601 |
failureReason: action.error |
| 1602 |
}; |
| 1603 |
case "pause": return { |
| 1604 |
...state, |
| 1605 |
isPaused: true |
| 1606 |
}; |
| 1607 |
case "continue": return { |
| 1608 |
...state, |
| 1609 |
isPaused: false |
| 1610 |
}; |
| 1611 |
case "pending": return { |
| 1612 |
...state, |
| 1613 |
context: action.context, |
| 1614 |
data: void 0, |
| 1615 |
failureCount: 0, |
| 1616 |
failureReason: null, |
| 1617 |
error: null, |
| 1618 |
isPaused: action.isPaused, |
| 1619 |
status: "pending", |
| 1620 |
variables: action.variables, |
| 1621 |
submittedAt: Date.now() |
| 1622 |
}; |
| 1623 |
case "success": return { |
| 1624 |
...state, |
| 1625 |
data: action.data, |
| 1626 |
failureCount: 0, |
| 1627 |
failureReason: null, |
| 1628 |
error: null, |
| 1629 |
status: "success", |
| 1630 |
isPaused: false |
| 1631 |
}; |
| 1632 |
case "error": return { |
| 1633 |
...state, |
| 1634 |
data: void 0, |
| 1635 |
error: action.error, |
| 1636 |
failureCount: state.failureCount + 1, |
| 1637 |
failureReason: action.error, |
| 1638 |
isPaused: false, |
| 1639 |
status: "error" |
| 1640 |
}; |
| 1641 |
} |
| 1642 |
}; |
| 1643 |
this.state = reducer(this.state); |
| 1644 |
notifyManager.batch(() => { |
| 1645 |
this.#observers.forEach((observer) => { |
| 1646 |
observer.onMutationUpdate(action); |
| 1647 |
}); |
| 1648 |
this.#mutationCache.notify({ |
| 1649 |
mutation: this, |
| 1650 |
type: "updated", |
| 1651 |
action |
| 1652 |
}); |
| 1653 |
}); |
| 1654 |
} |
| 1655 |
}; |
| 1656 |
function getDefaultState() { |
| 1657 |
return { |
| 1658 |
context: void 0, |
| 1659 |
data: void 0, |
| 1660 |
error: null, |
| 1661 |
failureCount: 0, |
| 1662 |
failureReason: null, |
| 1663 |
isPaused: false, |
| 1664 |
status: "idle", |
| 1665 |
variables: void 0, |
| 1666 |
submittedAt: 0 |
| 1667 |
}; |
| 1668 |
} |
| 1669 |
|
| 1670 |
//#endregion |
| 1671 |
//#region node_modules/@tanstack/query-core/build/modern/mutationCache.js |
| 1672 |
var MutationCache = class extends Subscribable { |
| 1673 |
constructor(config = {}) { |
| 1674 |
super(); |
| 1675 |
this.config = config; |
| 1676 |
this.#mutations = /* @__PURE__ */ new Set(); |
| 1677 |
this.#scopes = /* @__PURE__ */ new Map(); |
| 1678 |
this.#mutationId = 0; |
| 1679 |
} |
| 1680 |
#mutations; |
| 1681 |
#scopes; |
| 1682 |
#mutationId; |
| 1683 |
build(client, options, state) { |
| 1684 |
const mutation = new Mutation({ |
| 1685 |
client, |
| 1686 |
mutationCache: this, |
| 1687 |
mutationId: ++this.#mutationId, |
| 1688 |
options: client.defaultMutationOptions(options), |
| 1689 |
state |
| 1690 |
}); |
| 1691 |
this.add(mutation); |
| 1692 |
return mutation; |
| 1693 |
} |
| 1694 |
add(mutation) { |
| 1695 |
this.#mutations.add(mutation); |
| 1696 |
const scope = scopeFor(mutation); |
| 1697 |
if (typeof scope === "string") { |
| 1698 |
const scopedMutations = this.#scopes.get(scope); |
| 1699 |
if (scopedMutations) scopedMutations.push(mutation); |
| 1700 |
else this.#scopes.set(scope, [mutation]); |
| 1701 |
} |
| 1702 |
this.notify({ |
| 1703 |
type: "added", |
| 1704 |
mutation |
| 1705 |
}); |
| 1706 |
} |
| 1707 |
remove(mutation) { |
| 1708 |
if (this.#mutations.delete(mutation)) { |
| 1709 |
const scope = scopeFor(mutation); |
| 1710 |
if (typeof scope === "string") { |
| 1711 |
const scopedMutations = this.#scopes.get(scope); |
| 1712 |
if (scopedMutations) { |
| 1713 |
if (scopedMutations.length > 1) { |
| 1714 |
const index = scopedMutations.indexOf(mutation); |
| 1715 |
if (index !== -1) scopedMutations.splice(index, 1); |
| 1716 |
} else if (scopedMutations[0] === mutation) this.#scopes.delete(scope); |
| 1717 |
} |
| 1718 |
} |
| 1719 |
} |
| 1720 |
this.notify({ |
| 1721 |
type: "removed", |
| 1722 |
mutation |
| 1723 |
}); |
| 1724 |
} |
| 1725 |
canRun(mutation) { |
| 1726 |
const scope = scopeFor(mutation); |
| 1727 |
if (typeof scope === "string") { |
| 1728 |
const firstPendingMutation = this.#scopes.get(scope)?.find((m) => m.state.status === "pending"); |
| 1729 |
return !firstPendingMutation || firstPendingMutation === mutation; |
| 1730 |
} else return true; |
| 1731 |
} |
| 1732 |
runNext(mutation) { |
| 1733 |
const scope = scopeFor(mutation); |
| 1734 |
if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve(); |
| 1735 |
else return Promise.resolve(); |
| 1736 |
} |
| 1737 |
clear() { |
| 1738 |
notifyManager.batch(() => { |
| 1739 |
this.#mutations.forEach((mutation) => { |
| 1740 |
this.notify({ |
| 1741 |
type: "removed", |
| 1742 |
mutation |
| 1743 |
}); |
| 1744 |
}); |
| 1745 |
this.#mutations.clear(); |
| 1746 |
this.#scopes.clear(); |
| 1747 |
}); |
| 1748 |
} |
| 1749 |
getAll() { |
| 1750 |
return Array.from(this.#mutations); |
| 1751 |
} |
| 1752 |
find(filters) { |
| 1753 |
const defaultedFilters = { |
| 1754 |
exact: true, |
| 1755 |
...filters |
| 1756 |
}; |
| 1757 |
return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation)); |
| 1758 |
} |
| 1759 |
findAll(filters = {}) { |
| 1760 |
return this.getAll().filter((mutation) => matchMutation(filters, mutation)); |
| 1761 |
} |
| 1762 |
notify(event) { |
| 1763 |
notifyManager.batch(() => { |
| 1764 |
this.listeners.forEach((listener) => { |
| 1765 |
listener(event); |
| 1766 |
}); |
| 1767 |
}); |
| 1768 |
} |
| 1769 |
resumePausedMutations() { |
| 1770 |
const pausedMutations = this.getAll().filter((x) => x.state.isPaused); |
| 1771 |
return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop)))); |
| 1772 |
} |
| 1773 |
}; |
| 1774 |
function scopeFor(mutation) { |
| 1775 |
return mutation.options.scope?.id; |
| 1776 |
} |
| 1777 |
|
| 1778 |
//#endregion |
| 1779 |
//#region node_modules/@tanstack/query-core/build/modern/mutationObserver.js |
| 1780 |
var MutationObserver = class extends Subscribable { |
| 1781 |
#client; |
| 1782 |
#currentResult = void 0; |
| 1783 |
#currentMutation; |
| 1784 |
#mutateOptions; |
| 1785 |
constructor(client, options) { |
| 1786 |
super(); |
| 1787 |
this.#client = client; |
| 1788 |
this.setOptions(options); |
| 1789 |
this.bindMethods(); |
| 1790 |
this.#updateResult(); |
| 1791 |
} |
| 1792 |
bindMethods() { |
| 1793 |
this.mutate = this.mutate.bind(this); |
| 1794 |
this.reset = this.reset.bind(this); |
| 1795 |
} |
| 1796 |
setOptions(options) { |
| 1797 |
const prevOptions = this.options; |
| 1798 |
this.options = this.#client.defaultMutationOptions(options); |
| 1799 |
if (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({ |
| 1800 |
type: "observerOptionsUpdated", |
| 1801 |
mutation: this.#currentMutation, |
| 1802 |
observer: this |
| 1803 |
}); |
| 1804 |
if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset(); |
| 1805 |
else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options); |
| 1806 |
} |
| 1807 |
onUnsubscribe() { |
| 1808 |
if (!this.hasListeners()) this.#currentMutation?.removeObserver(this); |
| 1809 |
} |
| 1810 |
onMutationUpdate(action) { |
| 1811 |
this.#updateResult(); |
| 1812 |
this.#notify(action); |
| 1813 |
} |
| 1814 |
getCurrentResult() { |
| 1815 |
return this.#currentResult; |
| 1816 |
} |
| 1817 |
reset() { |
| 1818 |
this.#currentMutation?.removeObserver(this); |
| 1819 |
this.#currentMutation = void 0; |
| 1820 |
this.#updateResult(); |
| 1821 |
this.#notify(); |
| 1822 |
} |
| 1823 |
mutate(variables, options) { |
| 1824 |
this.#mutateOptions = options; |
| 1825 |
this.#currentMutation?.removeObserver(this); |
| 1826 |
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options); |
| 1827 |
this.#currentMutation.addObserver(this); |
| 1828 |
return this.#currentMutation.execute(variables); |
| 1829 |
} |
| 1830 |
#updateResult() { |
| 1831 |
const state = this.#currentMutation?.state ?? getDefaultState(); |
| 1832 |
this.#currentResult = { |
| 1833 |
...state, |
| 1834 |
isPending: state.status === "pending", |
| 1835 |
isSuccess: state.status === "success", |
| 1836 |
isError: state.status === "error", |
| 1837 |
isIdle: state.status === "idle", |
| 1838 |
mutate: this.mutate, |
| 1839 |
reset: this.reset |
| 1840 |
}; |
| 1841 |
} |
| 1842 |
#notify(action) { |
| 1843 |
notifyManager.batch(() => { |
| 1844 |
if (this.#mutateOptions && this.hasListeners()) { |
| 1845 |
const variables = this.#currentResult.variables; |
| 1846 |
const onMutateResult = this.#currentResult.context; |
| 1847 |
const context = { |
| 1848 |
client: this.#client, |
| 1849 |
meta: this.options.meta, |
| 1850 |
mutationKey: this.options.mutationKey |
| 1851 |
}; |
| 1852 |
if (action?.type === "success") { |
| 1853 |
this.#mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context); |
| 1854 |
this.#mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context); |
| 1855 |
} else if (action?.type === "error") { |
| 1856 |
this.#mutateOptions.onError?.(action.error, variables, onMutateResult, context); |
| 1857 |
this.#mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context); |
| 1858 |
} |
| 1859 |
} |
| 1860 |
this.listeners.forEach((listener) => { |
| 1861 |
listener(this.#currentResult); |
| 1862 |
}); |
| 1863 |
}); |
| 1864 |
} |
| 1865 |
}; |
| 1866 |
|
| 1867 |
//#endregion |
| 1868 |
//#region node_modules/@tanstack/query-core/build/modern/queryCache.js |
| 1869 |
var QueryCache = class extends Subscribable { |
| 1870 |
constructor(config = {}) { |
| 1871 |
super(); |
| 1872 |
this.config = config; |
| 1873 |
this.#queries = /* @__PURE__ */ new Map(); |
| 1874 |
} |
| 1875 |
#queries; |
| 1876 |
build(client, options, state) { |
| 1877 |
const queryKey = options.queryKey; |
| 1878 |
const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options); |
| 1879 |
let query = this.get(queryHash); |
| 1880 |
if (!query) { |
| 1881 |
query = new Query({ |
| 1882 |
client, |
| 1883 |
queryKey, |
| 1884 |
queryHash, |
| 1885 |
options: client.defaultQueryOptions(options), |
| 1886 |
state, |
| 1887 |
defaultOptions: client.getQueryDefaults(queryKey) |
| 1888 |
}); |
| 1889 |
this.add(query); |
| 1890 |
} |
| 1891 |
return query; |
| 1892 |
} |
| 1893 |
add(query) { |
| 1894 |
if (!this.#queries.has(query.queryHash)) { |
| 1895 |
this.#queries.set(query.queryHash, query); |
| 1896 |
this.notify({ |
| 1897 |
type: "added", |
| 1898 |
query |
| 1899 |
}); |
| 1900 |
} |
| 1901 |
} |
| 1902 |
remove(query) { |
| 1903 |
const queryInMap = this.#queries.get(query.queryHash); |
| 1904 |
if (queryInMap) { |
| 1905 |
query.destroy(); |
| 1906 |
if (queryInMap === query) this.#queries.delete(query.queryHash); |
| 1907 |
this.notify({ |
| 1908 |
type: "removed", |
| 1909 |
query |
| 1910 |
}); |
| 1911 |
} |
| 1912 |
} |
| 1913 |
clear() { |
| 1914 |
notifyManager.batch(() => { |
| 1915 |
this.getAll().forEach((query) => { |
| 1916 |
this.remove(query); |
| 1917 |
}); |
| 1918 |
}); |
| 1919 |
} |
| 1920 |
get(queryHash) { |
| 1921 |
return this.#queries.get(queryHash); |
| 1922 |
} |
| 1923 |
getAll() { |
| 1924 |
return [...this.#queries.values()]; |
| 1925 |
} |
| 1926 |
find(filters) { |
| 1927 |
const defaultedFilters = { |
| 1928 |
exact: true, |
| 1929 |
...filters |
| 1930 |
}; |
| 1931 |
return this.getAll().find((query) => matchQuery(defaultedFilters, query)); |
| 1932 |
} |
| 1933 |
findAll(filters = {}) { |
| 1934 |
const queries = this.getAll(); |
| 1935 |
return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries; |
| 1936 |
} |
| 1937 |
notify(event) { |
| 1938 |
notifyManager.batch(() => { |
| 1939 |
this.listeners.forEach((listener) => { |
| 1940 |
listener(event); |
| 1941 |
}); |
| 1942 |
}); |
| 1943 |
} |
| 1944 |
onFocus() { |
| 1945 |
notifyManager.batch(() => { |
| 1946 |
this.getAll().forEach((query) => { |
| 1947 |
query.onFocus(); |
| 1948 |
}); |
| 1949 |
}); |
| 1950 |
} |
| 1951 |
onOnline() { |
| 1952 |
notifyManager.batch(() => { |
| 1953 |
this.getAll().forEach((query) => { |
| 1954 |
query.onOnline(); |
| 1955 |
}); |
| 1956 |
}); |
| 1957 |
} |
| 1958 |
}; |
| 1959 |
|
| 1960 |
//#endregion |
| 1961 |
//#region node_modules/@tanstack/query-core/build/modern/queryClient.js |
| 1962 |
var QueryClient = class { |
| 1963 |
#queryCache; |
| 1964 |
#mutationCache; |
| 1965 |
#defaultOptions; |
| 1966 |
#queryDefaults; |
| 1967 |
#mutationDefaults; |
| 1968 |
#mountCount; |
| 1969 |
#unsubscribeFocus; |
| 1970 |
#unsubscribeOnline; |
| 1971 |
constructor(config = {}) { |
| 1972 |
this.#queryCache = config.queryCache || new QueryCache(); |
| 1973 |
this.#mutationCache = config.mutationCache || new MutationCache(); |
| 1974 |
this.#defaultOptions = config.defaultOptions || {}; |
| 1975 |
this.#queryDefaults = /* @__PURE__ */ new Map(); |
| 1976 |
this.#mutationDefaults = /* @__PURE__ */ new Map(); |
| 1977 |
this.#mountCount = 0; |
| 1978 |
} |
| 1979 |
mount() { |
| 1980 |
this.#mountCount++; |
| 1981 |
if (this.#mountCount !== 1) return; |
| 1982 |
this.#unsubscribeFocus = focusManager.subscribe(async (focused) => { |
| 1983 |
if (focused) { |
| 1984 |
await this.resumePausedMutations(); |
| 1985 |
this.#queryCache.onFocus(); |
| 1986 |
} |
| 1987 |
}); |
| 1988 |
this.#unsubscribeOnline = onlineManager.subscribe(async (online) => { |
| 1989 |
if (online) { |
| 1990 |
await this.resumePausedMutations(); |
| 1991 |
this.#queryCache.onOnline(); |
| 1992 |
} |
| 1993 |
}); |
| 1994 |
} |
| 1995 |
unmount() { |
| 1996 |
this.#mountCount--; |
| 1997 |
if (this.#mountCount !== 0) return; |
| 1998 |
this.#unsubscribeFocus?.(); |
| 1999 |
this.#unsubscribeFocus = void 0; |
| 2000 |
this.#unsubscribeOnline?.(); |
| 2001 |
this.#unsubscribeOnline = void 0; |
| 2002 |
} |
| 2003 |
isFetching(filters) { |
| 2004 |
return this.#queryCache.findAll({ |
| 2005 |
...filters, |
| 2006 |
fetchStatus: "fetching" |
| 2007 |
}).length; |
| 2008 |
} |
| 2009 |
isMutating(filters) { |
| 2010 |
return this.#mutationCache.findAll({ |
| 2011 |
...filters, |
| 2012 |
status: "pending" |
| 2013 |
}).length; |
| 2014 |
} |
| 2015 |
/** |
| 2016 |
* Imperative (non-reactive) way to retrieve data for a QueryKey. |
| 2017 |
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. |
| 2018 |
* |
| 2019 |
* Hint: Do not use this function inside a component, because it won't receive updates. |
| 2020 |
* Use `useQuery` to create a `QueryObserver` that subscribes to changes. |
| 2021 |
*/ |
| 2022 |
getQueryData(queryKey) { |
| 2023 |
const options = this.defaultQueryOptions({ queryKey }); |
| 2024 |
return this.#queryCache.get(options.queryHash)?.state.data; |
| 2025 |
} |
| 2026 |
ensureQueryData(options) { |
| 2027 |
const defaultedOptions = this.defaultQueryOptions(options); |
| 2028 |
const query = this.#queryCache.build(this, defaultedOptions); |
| 2029 |
const cachedData = query.state.data; |
| 2030 |
if (cachedData === void 0) return this.fetchQuery(options); |
| 2031 |
if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions); |
| 2032 |
return Promise.resolve(cachedData); |
| 2033 |
} |
| 2034 |
getQueriesData(filters) { |
| 2035 |
return this.#queryCache.findAll(filters).map(({ queryKey, state }) => { |
| 2036 |
return [queryKey, state.data]; |
| 2037 |
}); |
| 2038 |
} |
| 2039 |
setQueryData(queryKey, updater, options) { |
| 2040 |
const defaultedOptions = this.defaultQueryOptions({ queryKey }); |
| 2041 |
const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data; |
| 2042 |
const data = functionalUpdate(updater, prevData); |
| 2043 |
if (data === void 0) return; |
| 2044 |
return this.#queryCache.build(this, defaultedOptions).setData(data, { |
| 2045 |
...options, |
| 2046 |
manual: true |
| 2047 |
}); |
| 2048 |
} |
| 2049 |
setQueriesData(filters, updater, options) { |
| 2050 |
return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)])); |
| 2051 |
} |
| 2052 |
getQueryState(queryKey) { |
| 2053 |
const options = this.defaultQueryOptions({ queryKey }); |
| 2054 |
return this.#queryCache.get(options.queryHash)?.state; |
| 2055 |
} |
| 2056 |
removeQueries(filters) { |
| 2057 |
const queryCache = this.#queryCache; |
| 2058 |
notifyManager.batch(() => { |
| 2059 |
queryCache.findAll(filters).forEach((query) => { |
| 2060 |
queryCache.remove(query); |
| 2061 |
}); |
| 2062 |
}); |
| 2063 |
} |
| 2064 |
resetQueries(filters, options) { |
| 2065 |
const queryCache = this.#queryCache; |
| 2066 |
return notifyManager.batch(() => { |
| 2067 |
queryCache.findAll(filters).forEach((query) => { |
| 2068 |
query.reset(); |
| 2069 |
}); |
| 2070 |
return this.refetchQueries({ |
| 2071 |
type: "active", |
| 2072 |
...filters |
| 2073 |
}, options); |
| 2074 |
}); |
| 2075 |
} |
| 2076 |
cancelQueries(filters, cancelOptions = {}) { |
| 2077 |
const defaultedCancelOptions = { |
| 2078 |
revert: true, |
| 2079 |
...cancelOptions |
| 2080 |
}; |
| 2081 |
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))); |
| 2082 |
return Promise.all(promises).then(noop).catch(noop); |
| 2083 |
} |
| 2084 |
invalidateQueries(filters, options = {}) { |
| 2085 |
return notifyManager.batch(() => { |
| 2086 |
this.#queryCache.findAll(filters).forEach((query) => { |
| 2087 |
query.invalidate(); |
| 2088 |
}); |
| 2089 |
if (filters?.refetchType === "none") return Promise.resolve(); |
| 2090 |
return this.refetchQueries({ |
| 2091 |
...filters, |
| 2092 |
type: filters?.refetchType ?? filters?.type ?? "active" |
| 2093 |
}, options); |
| 2094 |
}); |
| 2095 |
} |
| 2096 |
refetchQueries(filters, options = {}) { |
| 2097 |
const fetchOptions = { |
| 2098 |
...options, |
| 2099 |
cancelRefetch: options.cancelRefetch ?? true |
| 2100 |
}; |
| 2101 |
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => { |
| 2102 |
let promise = query.fetch(void 0, fetchOptions); |
| 2103 |
if (!fetchOptions.throwOnError) promise = promise.catch(noop); |
| 2104 |
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise; |
| 2105 |
})); |
| 2106 |
return Promise.all(promises).then(noop); |
| 2107 |
} |
| 2108 |
fetchQuery(options) { |
| 2109 |
const defaultedOptions = this.defaultQueryOptions(options); |
| 2110 |
if (defaultedOptions.retry === void 0) defaultedOptions.retry = false; |
| 2111 |
const query = this.#queryCache.build(this, defaultedOptions); |
| 2112 |
return query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); |
| 2113 |
} |
| 2114 |
prefetchQuery(options) { |
| 2115 |
return this.fetchQuery(options).then(noop).catch(noop); |
| 2116 |
} |
| 2117 |
fetchInfiniteQuery(options) { |
| 2118 |
options.behavior = infiniteQueryBehavior(options.pages); |
| 2119 |
return this.fetchQuery(options); |
| 2120 |
} |
| 2121 |
prefetchInfiniteQuery(options) { |
| 2122 |
return this.fetchInfiniteQuery(options).then(noop).catch(noop); |
| 2123 |
} |
| 2124 |
ensureInfiniteQueryData(options) { |
| 2125 |
options.behavior = infiniteQueryBehavior(options.pages); |
| 2126 |
return this.ensureQueryData(options); |
| 2127 |
} |
| 2128 |
resumePausedMutations() { |
| 2129 |
if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations(); |
| 2130 |
return Promise.resolve(); |
| 2131 |
} |
| 2132 |
getQueryCache() { |
| 2133 |
return this.#queryCache; |
| 2134 |
} |
| 2135 |
getMutationCache() { |
| 2136 |
return this.#mutationCache; |
| 2137 |
} |
| 2138 |
getDefaultOptions() { |
| 2139 |
return this.#defaultOptions; |
| 2140 |
} |
| 2141 |
setDefaultOptions(options) { |
| 2142 |
this.#defaultOptions = options; |
| 2143 |
} |
| 2144 |
setQueryDefaults(queryKey, options) { |
| 2145 |
this.#queryDefaults.set(hashKey(queryKey), { |
| 2146 |
queryKey, |
| 2147 |
defaultOptions: options |
| 2148 |
}); |
| 2149 |
} |
| 2150 |
getQueryDefaults(queryKey) { |
| 2151 |
const defaults = [...this.#queryDefaults.values()]; |
| 2152 |
const result = {}; |
| 2153 |
defaults.forEach((queryDefault) => { |
| 2154 |
if (partialMatchKey(queryKey, queryDefault.queryKey)) Object.assign(result, queryDefault.defaultOptions); |
| 2155 |
}); |
| 2156 |
return result; |
| 2157 |
} |
| 2158 |
setMutationDefaults(mutationKey, options) { |
| 2159 |
this.#mutationDefaults.set(hashKey(mutationKey), { |
| 2160 |
mutationKey, |
| 2161 |
defaultOptions: options |
| 2162 |
}); |
| 2163 |
} |
| 2164 |
getMutationDefaults(mutationKey) { |
| 2165 |
const defaults = [...this.#mutationDefaults.values()]; |
| 2166 |
const result = {}; |
| 2167 |
defaults.forEach((queryDefault) => { |
| 2168 |
if (partialMatchKey(mutationKey, queryDefault.mutationKey)) Object.assign(result, queryDefault.defaultOptions); |
| 2169 |
}); |
| 2170 |
return result; |
| 2171 |
} |
| 2172 |
defaultQueryOptions(options) { |
| 2173 |
if (options._defaulted) return options; |
| 2174 |
const defaultedOptions = { |
| 2175 |
...this.#defaultOptions.queries, |
| 2176 |
...this.getQueryDefaults(options.queryKey), |
| 2177 |
...options, |
| 2178 |
_defaulted: true |
| 2179 |
}; |
| 2180 |
if (!defaultedOptions.queryHash) defaultedOptions.queryHash = hashQueryKeyByOptions(defaultedOptions.queryKey, defaultedOptions); |
| 2181 |
if (defaultedOptions.refetchOnReconnect === void 0) defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always"; |
| 2182 |
if (defaultedOptions.throwOnError === void 0) defaultedOptions.throwOnError = !!defaultedOptions.suspense; |
| 2183 |
if (!defaultedOptions.networkMode && defaultedOptions.persister) defaultedOptions.networkMode = "offlineFirst"; |
| 2184 |
if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false; |
| 2185 |
return defaultedOptions; |
| 2186 |
} |
| 2187 |
defaultMutationOptions(options) { |
| 2188 |
if (options?._defaulted) return options; |
| 2189 |
return { |
| 2190 |
...this.#defaultOptions.mutations, |
| 2191 |
...options?.mutationKey && this.getMutationDefaults(options.mutationKey), |
| 2192 |
...options, |
| 2193 |
_defaulted: true |
| 2194 |
}; |
| 2195 |
} |
| 2196 |
clear() { |
| 2197 |
this.#queryCache.clear(); |
| 2198 |
this.#mutationCache.clear(); |
| 2199 |
} |
| 2200 |
}; |
| 2201 |
|
| 2202 |
//#endregion |
| 2203 |
//#region node_modules/react/cjs/react-jsx-runtime.development.js |
| 2204 |
/** |
| 2205 |
* @license React |
| 2206 |
* react-jsx-runtime.development.js |
| 2207 |
* |
| 2208 |
* Copyright (c) Facebook, Inc. and its affiliates. |
| 2209 |
* |
| 2210 |
* This source code is licensed under the MIT license found in the |
| 2211 |
* LICENSE file in the root directory of this source tree. |
| 2212 |
*/ |
| 2213 |
var require_react_jsx_runtime_development = /* @__PURE__ */ __commonJSMin(((exports) => { |
| 2214 |
(function() { |
| 2215 |
"use strict"; |
| 2216 |
var React = (globalThis.React); |
| 2217 |
var REACT_ELEMENT_TYPE = Symbol.for("react.element"); |
| 2218 |
var REACT_PORTAL_TYPE = Symbol.for("react.portal"); |
| 2219 |
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"); |
| 2220 |
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"); |
| 2221 |
var REACT_PROFILER_TYPE = Symbol.for("react.profiler"); |
| 2222 |
var REACT_PROVIDER_TYPE = Symbol.for("react.provider"); |
| 2223 |
var REACT_CONTEXT_TYPE = Symbol.for("react.context"); |
| 2224 |
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"); |
| 2225 |
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"); |
| 2226 |
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"); |
| 2227 |
var REACT_MEMO_TYPE = Symbol.for("react.memo"); |
| 2228 |
var REACT_LAZY_TYPE = Symbol.for("react.lazy"); |
| 2229 |
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"); |
| 2230 |
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; |
| 2231 |
var FAUX_ITERATOR_SYMBOL = "@@iterator"; |
| 2232 |
function getIteratorFn(maybeIterable) { |
| 2233 |
if (maybeIterable === null || typeof maybeIterable !== "object") return null; |
| 2234 |
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; |
| 2235 |
if (typeof maybeIterator === "function") return maybeIterator; |
| 2236 |
return null; |
| 2237 |
} |
| 2238 |
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; |
| 2239 |
function error(format) { |
| 2240 |
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2]; |
| 2241 |
printWarning("error", format, args); |
| 2242 |
} |
| 2243 |
function printWarning(level, format, args) { |
| 2244 |
var stack = ReactSharedInternals.ReactDebugCurrentFrame.getStackAddendum(); |
| 2245 |
if (stack !== "") { |
| 2246 |
format += "%s"; |
| 2247 |
args = args.concat([stack]); |
| 2248 |
} |
| 2249 |
var argsWithFormat = args.map(function(item) { |
| 2250 |
return String(item); |
| 2251 |
}); |
| 2252 |
argsWithFormat.unshift("Warning: " + format); |
| 2253 |
Function.prototype.apply.call(console[level], console, argsWithFormat); |
| 2254 |
} |
| 2255 |
var enableScopeAPI = false; |
| 2256 |
var enableCacheElement = false; |
| 2257 |
var enableTransitionTracing = false; |
| 2258 |
var enableLegacyHidden = false; |
| 2259 |
var enableDebugTracing = false; |
| 2260 |
var REACT_MODULE_REFERENCE = Symbol.for("react.module.reference"); |
| 2261 |
function isValidElementType(type) { |
| 2262 |
if (typeof type === "string" || typeof type === "function") return true; |
| 2263 |
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) return true; |
| 2264 |
if (typeof type === "object" && type !== null) { |
| 2265 |
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) return true; |
| 2266 |
} |
| 2267 |
return false; |
| 2268 |
} |
| 2269 |
function getWrappedName(outerType, innerType, wrapperName) { |
| 2270 |
var displayName = outerType.displayName; |
| 2271 |
if (displayName) return displayName; |
| 2272 |
var functionName = innerType.displayName || innerType.name || ""; |
| 2273 |
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName; |
| 2274 |
} |
| 2275 |
function getContextName(type) { |
| 2276 |
return type.displayName || "Context"; |
| 2277 |
} |
| 2278 |
function getComponentNameFromType(type) { |
| 2279 |
if (type == null) return null; |
| 2280 |
if (typeof type.tag === "number") error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."); |
| 2281 |
if (typeof type === "function") return type.displayName || type.name || null; |
| 2282 |
if (typeof type === "string") return type; |
| 2283 |
switch (type) { |
| 2284 |
case REACT_FRAGMENT_TYPE: return "Fragment"; |
| 2285 |
case REACT_PORTAL_TYPE: return "Portal"; |
| 2286 |
case REACT_PROFILER_TYPE: return "Profiler"; |
| 2287 |
case REACT_STRICT_MODE_TYPE: return "StrictMode"; |
| 2288 |
case REACT_SUSPENSE_TYPE: return "Suspense"; |
| 2289 |
case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; |
| 2290 |
} |
| 2291 |
if (typeof type === "object") switch (type.$$typeof) { |
| 2292 |
case REACT_CONTEXT_TYPE: return getContextName(type) + ".Consumer"; |
| 2293 |
case REACT_PROVIDER_TYPE: return getContextName(type._context) + ".Provider"; |
| 2294 |
case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); |
| 2295 |
case REACT_MEMO_TYPE: |
| 2296 |
var outerName = type.displayName || null; |
| 2297 |
if (outerName !== null) return outerName; |
| 2298 |
return getComponentNameFromType(type.type) || "Memo"; |
| 2299 |
case REACT_LAZY_TYPE: |
| 2300 |
var lazyComponent = type; |
| 2301 |
var payload = lazyComponent._payload; |
| 2302 |
var init = lazyComponent._init; |
| 2303 |
try { |
| 2304 |
return getComponentNameFromType(init(payload)); |
| 2305 |
} catch (x) { |
| 2306 |
return null; |
| 2307 |
} |
| 2308 |
} |
| 2309 |
return null; |
| 2310 |
} |
| 2311 |
var assign = Object.assign; |
| 2312 |
var disabledDepth = 0; |
| 2313 |
var prevLog; |
| 2314 |
var prevInfo; |
| 2315 |
var prevWarn; |
| 2316 |
var prevError; |
| 2317 |
var prevGroup; |
| 2318 |
var prevGroupCollapsed; |
| 2319 |
var prevGroupEnd; |
| 2320 |
function disabledLog() {} |
| 2321 |
disabledLog.__reactDisabledLog = true; |
| 2322 |
function disableLogs() { |
| 2323 |
if (disabledDepth === 0) { |
| 2324 |
prevLog = console.log; |
| 2325 |
prevInfo = console.info; |
| 2326 |
prevWarn = console.warn; |
| 2327 |
prevError = console.error; |
| 2328 |
prevGroup = console.group; |
| 2329 |
prevGroupCollapsed = console.groupCollapsed; |
| 2330 |
prevGroupEnd = console.groupEnd; |
| 2331 |
var props = { |
| 2332 |
configurable: true, |
| 2333 |
enumerable: true, |
| 2334 |
value: disabledLog, |
| 2335 |
writable: true |
| 2336 |
}; |
| 2337 |
Object.defineProperties(console, { |
| 2338 |
info: props, |
| 2339 |
log: props, |
| 2340 |
warn: props, |
| 2341 |
error: props, |
| 2342 |
group: props, |
| 2343 |
groupCollapsed: props, |
| 2344 |
groupEnd: props |
| 2345 |
}); |
| 2346 |
} |
| 2347 |
disabledDepth++; |
| 2348 |
} |
| 2349 |
function reenableLogs() { |
| 2350 |
disabledDepth--; |
| 2351 |
if (disabledDepth === 0) { |
| 2352 |
var props = { |
| 2353 |
configurable: true, |
| 2354 |
enumerable: true, |
| 2355 |
writable: true |
| 2356 |
}; |
| 2357 |
Object.defineProperties(console, { |
| 2358 |
log: assign({}, props, { value: prevLog }), |
| 2359 |
info: assign({}, props, { value: prevInfo }), |
| 2360 |
warn: assign({}, props, { value: prevWarn }), |
| 2361 |
error: assign({}, props, { value: prevError }), |
| 2362 |
group: assign({}, props, { value: prevGroup }), |
| 2363 |
groupCollapsed: assign({}, props, { value: prevGroupCollapsed }), |
| 2364 |
groupEnd: assign({}, props, { value: prevGroupEnd }) |
| 2365 |
}); |
| 2366 |
} |
| 2367 |
if (disabledDepth < 0) error("disabledDepth fell below zero. This is a bug in React. Please file an issue."); |
| 2368 |
} |
| 2369 |
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; |
| 2370 |
var prefix; |
| 2371 |
function describeBuiltInComponentFrame(name, source, ownerFn) { |
| 2372 |
if (prefix === void 0) try { |
| 2373 |
throw Error(); |
| 2374 |
} catch (x) { |
| 2375 |
var match = x.stack.trim().match(/\n( *(at )?)/); |
| 2376 |
prefix = match && match[1] || ""; |
| 2377 |
} |
| 2378 |
return "\n" + prefix + name; |
| 2379 |
} |
| 2380 |
var reentry = false; |
| 2381 |
var componentFrameCache = new (typeof WeakMap === "function" ? WeakMap : Map)(); |
| 2382 |
function describeNativeComponentFrame(fn, construct) { |
| 2383 |
if (!fn || reentry) return ""; |
| 2384 |
var frame = componentFrameCache.get(fn); |
| 2385 |
if (frame !== void 0) return frame; |
| 2386 |
var control; |
| 2387 |
reentry = true; |
| 2388 |
var previousPrepareStackTrace = Error.prepareStackTrace; |
| 2389 |
Error.prepareStackTrace = void 0; |
| 2390 |
var previousDispatcher = ReactCurrentDispatcher.current; |
| 2391 |
ReactCurrentDispatcher.current = null; |
| 2392 |
disableLogs(); |
| 2393 |
try { |
| 2394 |
if (construct) { |
| 2395 |
var Fake = function() { |
| 2396 |
throw Error(); |
| 2397 |
}; |
| 2398 |
Object.defineProperty(Fake.prototype, "props", { set: function() { |
| 2399 |
throw Error(); |
| 2400 |
} }); |
| 2401 |
if (typeof Reflect === "object" && Reflect.construct) { |
| 2402 |
try { |
| 2403 |
Reflect.construct(Fake, []); |
| 2404 |
} catch (x) { |
| 2405 |
control = x; |
| 2406 |
} |
| 2407 |
Reflect.construct(fn, [], Fake); |
| 2408 |
} else { |
| 2409 |
try { |
| 2410 |
Fake.call(); |
| 2411 |
} catch (x) { |
| 2412 |
control = x; |
| 2413 |
} |
| 2414 |
fn.call(Fake.prototype); |
| 2415 |
} |
| 2416 |
} else { |
| 2417 |
try { |
| 2418 |
throw Error(); |
| 2419 |
} catch (x) { |
| 2420 |
control = x; |
| 2421 |
} |
| 2422 |
fn(); |
| 2423 |
} |
| 2424 |
} catch (sample) { |
| 2425 |
if (sample && control && typeof sample.stack === "string") { |
| 2426 |
var sampleLines = sample.stack.split("\n"); |
| 2427 |
var controlLines = control.stack.split("\n"); |
| 2428 |
var s = sampleLines.length - 1; |
| 2429 |
var c = controlLines.length - 1; |
| 2430 |
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) c--; |
| 2431 |
for (; s >= 1 && c >= 0; s--, c--) if (sampleLines[s] !== controlLines[c]) { |
| 2432 |
if (s !== 1 || c !== 1) do { |
| 2433 |
s--; |
| 2434 |
c--; |
| 2435 |
if (c < 0 || sampleLines[s] !== controlLines[c]) { |
| 2436 |
var _frame = "\n" + sampleLines[s].replace(" at new ", " at "); |
| 2437 |
if (fn.displayName && _frame.includes("<anonymous>")) _frame = _frame.replace("<anonymous>", fn.displayName); |
| 2438 |
if (typeof fn === "function") componentFrameCache.set(fn, _frame); |
| 2439 |
return _frame; |
| 2440 |
} |
| 2441 |
} while (s >= 1 && c >= 0); |
| 2442 |
break; |
| 2443 |
} |
| 2444 |
} |
| 2445 |
} finally { |
| 2446 |
reentry = false; |
| 2447 |
ReactCurrentDispatcher.current = previousDispatcher; |
| 2448 |
reenableLogs(); |
| 2449 |
Error.prepareStackTrace = previousPrepareStackTrace; |
| 2450 |
} |
| 2451 |
var name = fn ? fn.displayName || fn.name : ""; |
| 2452 |
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ""; |
| 2453 |
if (typeof fn === "function") componentFrameCache.set(fn, syntheticFrame); |
| 2454 |
return syntheticFrame; |
| 2455 |
} |
| 2456 |
function describeFunctionComponentFrame(fn, source, ownerFn) { |
| 2457 |
return describeNativeComponentFrame(fn, false); |
| 2458 |
} |
| 2459 |
function shouldConstruct(Component) { |
| 2460 |
var prototype = Component.prototype; |
| 2461 |
return !!(prototype && prototype.isReactComponent); |
| 2462 |
} |
| 2463 |
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { |
| 2464 |
if (type == null) return ""; |
| 2465 |
if (typeof type === "function") return describeNativeComponentFrame(type, shouldConstruct(type)); |
| 2466 |
if (typeof type === "string") return describeBuiltInComponentFrame(type); |
| 2467 |
switch (type) { |
| 2468 |
case REACT_SUSPENSE_TYPE: return describeBuiltInComponentFrame("Suspense"); |
| 2469 |
case REACT_SUSPENSE_LIST_TYPE: return describeBuiltInComponentFrame("SuspenseList"); |
| 2470 |
} |
| 2471 |
if (typeof type === "object") switch (type.$$typeof) { |
| 2472 |
case REACT_FORWARD_REF_TYPE: return describeFunctionComponentFrame(type.render); |
| 2473 |
case REACT_MEMO_TYPE: return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); |
| 2474 |
case REACT_LAZY_TYPE: |
| 2475 |
var lazyComponent = type; |
| 2476 |
var payload = lazyComponent._payload; |
| 2477 |
var init = lazyComponent._init; |
| 2478 |
try { |
| 2479 |
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); |
| 2480 |
} catch (x) {} |
| 2481 |
} |
| 2482 |
return ""; |
| 2483 |
} |
| 2484 |
var hasOwnProperty = Object.prototype.hasOwnProperty; |
| 2485 |
var loggedTypeFailures = {}; |
| 2486 |
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; |
| 2487 |
function setCurrentlyValidatingElement(element) { |
| 2488 |
if (element) { |
| 2489 |
var owner = element._owner; |
| 2490 |
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); |
| 2491 |
ReactDebugCurrentFrame.setExtraStackFrame(stack); |
| 2492 |
} else ReactDebugCurrentFrame.setExtraStackFrame(null); |
| 2493 |
} |
| 2494 |
function checkPropTypes(typeSpecs, values, location, componentName, element) { |
| 2495 |
var has = Function.call.bind(hasOwnProperty); |
| 2496 |
for (var typeSpecName in typeSpecs) if (has(typeSpecs, typeSpecName)) { |
| 2497 |
var error$1 = void 0; |
| 2498 |
try { |
| 2499 |
if (typeof typeSpecs[typeSpecName] !== "function") { |
| 2500 |
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); |
| 2501 |
err.name = "Invariant Violation"; |
| 2502 |
throw err; |
| 2503 |
} |
| 2504 |
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); |
| 2505 |
} catch (ex) { |
| 2506 |
error$1 = ex; |
| 2507 |
} |
| 2508 |
if (error$1 && !(error$1 instanceof Error)) { |
| 2509 |
setCurrentlyValidatingElement(element); |
| 2510 |
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1); |
| 2511 |
setCurrentlyValidatingElement(null); |
| 2512 |
} |
| 2513 |
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { |
| 2514 |
loggedTypeFailures[error$1.message] = true; |
| 2515 |
setCurrentlyValidatingElement(element); |
| 2516 |
error("Failed %s type: %s", location, error$1.message); |
| 2517 |
setCurrentlyValidatingElement(null); |
| 2518 |
} |
| 2519 |
} |
| 2520 |
} |
| 2521 |
var isArrayImpl = Array.isArray; |
| 2522 |
function isArray(a) { |
| 2523 |
return isArrayImpl(a); |
| 2524 |
} |
| 2525 |
function typeName(value) { |
| 2526 |
return typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object"; |
| 2527 |
} |
| 2528 |
function willCoercionThrow(value) { |
| 2529 |
try { |
| 2530 |
testStringCoercion(value); |
| 2531 |
return false; |
| 2532 |
} catch (e) { |
| 2533 |
return true; |
| 2534 |
} |
| 2535 |
} |
| 2536 |
function testStringCoercion(value) { |
| 2537 |
return "" + value; |
| 2538 |
} |
| 2539 |
function checkKeyStringCoercion(value) { |
| 2540 |
if (willCoercionThrow(value)) { |
| 2541 |
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value)); |
| 2542 |
return testStringCoercion(value); |
| 2543 |
} |
| 2544 |
} |
| 2545 |
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; |
| 2546 |
var RESERVED_PROPS = { |
| 2547 |
key: true, |
| 2548 |
ref: true, |
| 2549 |
__self: true, |
| 2550 |
__source: true |
| 2551 |
}; |
| 2552 |
var specialPropKeyWarningShown; |
| 2553 |
var specialPropRefWarningShown; |
| 2554 |
var didWarnAboutStringRefs = {}; |
| 2555 |
function hasValidRef(config) { |
| 2556 |
if (hasOwnProperty.call(config, "ref")) { |
| 2557 |
var getter = Object.getOwnPropertyDescriptor(config, "ref").get; |
| 2558 |
if (getter && getter.isReactWarning) return false; |
| 2559 |
} |
| 2560 |
return config.ref !== void 0; |
| 2561 |
} |
| 2562 |
function hasValidKey(config) { |
| 2563 |
if (hasOwnProperty.call(config, "key")) { |
| 2564 |
var getter = Object.getOwnPropertyDescriptor(config, "key").get; |
| 2565 |
if (getter && getter.isReactWarning) return false; |
| 2566 |
} |
| 2567 |
return config.key !== void 0; |
| 2568 |
} |
| 2569 |
function warnIfStringRefCannotBeAutoConverted(config, self) { |
| 2570 |
if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) { |
| 2571 |
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type); |
| 2572 |
if (!didWarnAboutStringRefs[componentName]) { |
| 2573 |
error("Component \"%s\" contains the string ref \"%s\". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref", getComponentNameFromType(ReactCurrentOwner.current.type), config.ref); |
| 2574 |
didWarnAboutStringRefs[componentName] = true; |
| 2575 |
} |
| 2576 |
} |
| 2577 |
} |
| 2578 |
function defineKeyPropWarningGetter(props, displayName) { |
| 2579 |
var warnAboutAccessingKey = function() { |
| 2580 |
if (!specialPropKeyWarningShown) { |
| 2581 |
specialPropKeyWarningShown = true; |
| 2582 |
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName); |
| 2583 |
} |
| 2584 |
}; |
| 2585 |
warnAboutAccessingKey.isReactWarning = true; |
| 2586 |
Object.defineProperty(props, "key", { |
| 2587 |
get: warnAboutAccessingKey, |
| 2588 |
configurable: true |
| 2589 |
}); |
| 2590 |
} |
| 2591 |
function defineRefPropWarningGetter(props, displayName) { |
| 2592 |
var warnAboutAccessingRef = function() { |
| 2593 |
if (!specialPropRefWarningShown) { |
| 2594 |
specialPropRefWarningShown = true; |
| 2595 |
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName); |
| 2596 |
} |
| 2597 |
}; |
| 2598 |
warnAboutAccessingRef.isReactWarning = true; |
| 2599 |
Object.defineProperty(props, "ref", { |
| 2600 |
get: warnAboutAccessingRef, |
| 2601 |
configurable: true |
| 2602 |
}); |
| 2603 |
} |
| 2604 |
/** |
| 2605 |
* Factory method to create a new React element. This no longer adheres to |
| 2606 |
* the class pattern, so do not use new to call it. Also, instanceof check |
| 2607 |
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check |
| 2608 |
* if something is a React Element. |
| 2609 |
* |
| 2610 |
* @param {*} type |
| 2611 |
* @param {*} props |
| 2612 |
* @param {*} key |
| 2613 |
* @param {string|object} ref |
| 2614 |
* @param {*} owner |
| 2615 |
* @param {*} self A *temporary* helper to detect places where `this` is |
| 2616 |
* different from the `owner` when React.createElement is called, so that we |
| 2617 |
* can warn. We want to get rid of owner and replace string `ref`s with arrow |
| 2618 |
* functions, and as long as `this` and owner are the same, there will be no |
| 2619 |
* change in behavior. |
| 2620 |
* @param {*} source An annotation object (added by a transpiler or otherwise) |
| 2621 |
* indicating filename, line number, and/or other information. |
| 2622 |
* @internal |
| 2623 |
*/ |
| 2624 |
var ReactElement = function(type, key, ref, self, source, owner, props) { |
| 2625 |
var element = { |
| 2626 |
$$typeof: REACT_ELEMENT_TYPE, |
| 2627 |
type, |
| 2628 |
key, |
| 2629 |
ref, |
| 2630 |
props, |
| 2631 |
_owner: owner |
| 2632 |
}; |
| 2633 |
element._store = {}; |
| 2634 |
Object.defineProperty(element._store, "validated", { |
| 2635 |
configurable: false, |
| 2636 |
enumerable: false, |
| 2637 |
writable: true, |
| 2638 |
value: false |
| 2639 |
}); |
| 2640 |
Object.defineProperty(element, "_self", { |
| 2641 |
configurable: false, |
| 2642 |
enumerable: false, |
| 2643 |
writable: false, |
| 2644 |
value: self |
| 2645 |
}); |
| 2646 |
Object.defineProperty(element, "_source", { |
| 2647 |
configurable: false, |
| 2648 |
enumerable: false, |
| 2649 |
writable: false, |
| 2650 |
value: source |
| 2651 |
}); |
| 2652 |
if (Object.freeze) { |
| 2653 |
Object.freeze(element.props); |
| 2654 |
Object.freeze(element); |
| 2655 |
} |
| 2656 |
return element; |
| 2657 |
}; |
| 2658 |
/** |
| 2659 |
* https://github.com/reactjs/rfcs/pull/107 |
| 2660 |
* @param {*} type |
| 2661 |
* @param {object} props |
| 2662 |
* @param {string} key |
| 2663 |
*/ |
| 2664 |
function jsxDEV(type, config, maybeKey, source, self) { |
| 2665 |
var propName; |
| 2666 |
var props = {}; |
| 2667 |
var key = null; |
| 2668 |
var ref = null; |
| 2669 |
if (maybeKey !== void 0) { |
| 2670 |
checkKeyStringCoercion(maybeKey); |
| 2671 |
key = "" + maybeKey; |
| 2672 |
} |
| 2673 |
if (hasValidKey(config)) { |
| 2674 |
checkKeyStringCoercion(config.key); |
| 2675 |
key = "" + config.key; |
| 2676 |
} |
| 2677 |
if (hasValidRef(config)) { |
| 2678 |
ref = config.ref; |
| 2679 |
warnIfStringRefCannotBeAutoConverted(config, self); |
| 2680 |
} |
| 2681 |
for (propName in config) if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) props[propName] = config[propName]; |
| 2682 |
if (type && type.defaultProps) { |
| 2683 |
var defaultProps = type.defaultProps; |
| 2684 |
for (propName in defaultProps) if (props[propName] === void 0) props[propName] = defaultProps[propName]; |
| 2685 |
} |
| 2686 |
if (key || ref) { |
| 2687 |
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type; |
| 2688 |
if (key) defineKeyPropWarningGetter(props, displayName); |
| 2689 |
if (ref) defineRefPropWarningGetter(props, displayName); |
| 2690 |
} |
| 2691 |
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); |
| 2692 |
} |
| 2693 |
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; |
| 2694 |
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; |
| 2695 |
function setCurrentlyValidatingElement$1(element) { |
| 2696 |
if (element) { |
| 2697 |
var owner = element._owner; |
| 2698 |
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); |
| 2699 |
ReactDebugCurrentFrame$1.setExtraStackFrame(stack); |
| 2700 |
} else ReactDebugCurrentFrame$1.setExtraStackFrame(null); |
| 2701 |
} |
| 2702 |
var propTypesMisspellWarningShown = false; |
| 2703 |
/** |
| 2704 |
* Verifies the object is a ReactElement. |
| 2705 |
* See https://reactjs.org/docs/react-api.html#isvalidelement |
| 2706 |
* @param {?object} object |
| 2707 |
* @return {boolean} True if `object` is a ReactElement. |
| 2708 |
* @final |
| 2709 |
*/ |
| 2710 |
function isValidElement(object) { |
| 2711 |
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
| 2712 |
} |
| 2713 |
function getDeclarationErrorAddendum() { |
| 2714 |
if (ReactCurrentOwner$1.current) { |
| 2715 |
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type); |
| 2716 |
if (name) return "\n\nCheck the render method of `" + name + "`."; |
| 2717 |
} |
| 2718 |
return ""; |
| 2719 |
} |
| 2720 |
function getSourceInfoErrorAddendum(source) { |
| 2721 |
if (source !== void 0) { |
| 2722 |
var fileName = source.fileName.replace(/^.*[\\\/]/, ""); |
| 2723 |
var lineNumber = source.lineNumber; |
| 2724 |
return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; |
| 2725 |
} |
| 2726 |
return ""; |
| 2727 |
} |
| 2728 |
/** |
| 2729 |
* Warn if there's no key explicitly set on dynamic arrays of children or |
| 2730 |
* object keys are not valid. This allows us to keep track of children between |
| 2731 |
* updates. |
| 2732 |
*/ |
| 2733 |
var ownerHasKeyUseWarning = {}; |
| 2734 |
function getCurrentComponentErrorInfo(parentType) { |
| 2735 |
var info = getDeclarationErrorAddendum(); |
| 2736 |
if (!info) { |
| 2737 |
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name; |
| 2738 |
if (parentName) info = "\n\nCheck the top-level render call using <" + parentName + ">."; |
| 2739 |
} |
| 2740 |
return info; |
| 2741 |
} |
| 2742 |
/** |
| 2743 |
* Warn if the element doesn't have an explicit key assigned to it. |
| 2744 |
* This element is in an array. The array could grow and shrink or be |
| 2745 |
* reordered. All children that haven't already been validated are required to |
| 2746 |
* have a "key" property assigned to it. Error statuses are cached so a warning |
| 2747 |
* will only be shown once. |
| 2748 |
* |
| 2749 |
* @internal |
| 2750 |
* @param {ReactElement} element Element that requires a key. |
| 2751 |
* @param {*} parentType element's parent's type. |
| 2752 |
*/ |
| 2753 |
function validateExplicitKey(element, parentType) { |
| 2754 |
if (!element._store || element._store.validated || element.key != null) return; |
| 2755 |
element._store.validated = true; |
| 2756 |
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); |
| 2757 |
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) return; |
| 2758 |
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; |
| 2759 |
var childOwner = ""; |
| 2760 |
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + "."; |
| 2761 |
setCurrentlyValidatingElement$1(element); |
| 2762 |
error("Each child in a list should have a unique \"key\" prop.%s%s See https://reactjs.org/link/warning-keys for more information.", currentComponentErrorInfo, childOwner); |
| 2763 |
setCurrentlyValidatingElement$1(null); |
| 2764 |
} |
| 2765 |
/** |
| 2766 |
* Ensure that every element either is passed in a static location, in an |
| 2767 |
* array with an explicit keys property defined, or in an object literal |
| 2768 |
* with valid key property. |
| 2769 |
* |
| 2770 |
* @internal |
| 2771 |
* @param {ReactNode} node Statically passed child of any type. |
| 2772 |
* @param {*} parentType node's parent's type. |
| 2773 |
*/ |
| 2774 |
function validateChildKeys(node, parentType) { |
| 2775 |
if (typeof node !== "object") return; |
| 2776 |
if (isArray(node)) for (var i = 0; i < node.length; i++) { |
| 2777 |
var child = node[i]; |
| 2778 |
if (isValidElement(child)) validateExplicitKey(child, parentType); |
| 2779 |
} |
| 2780 |
else if (isValidElement(node)) { |
| 2781 |
if (node._store) node._store.validated = true; |
| 2782 |
} else if (node) { |
| 2783 |
var iteratorFn = getIteratorFn(node); |
| 2784 |
if (typeof iteratorFn === "function") { |
| 2785 |
if (iteratorFn !== node.entries) { |
| 2786 |
var iterator = iteratorFn.call(node); |
| 2787 |
var step; |
| 2788 |
while (!(step = iterator.next()).done) if (isValidElement(step.value)) validateExplicitKey(step.value, parentType); |
| 2789 |
} |
| 2790 |
} |
| 2791 |
} |
| 2792 |
} |
| 2793 |
/** |
| 2794 |
* Given an element, validate that its props follow the propTypes definition, |
| 2795 |
* provided by the type. |
| 2796 |
* |
| 2797 |
* @param {ReactElement} element |
| 2798 |
*/ |
| 2799 |
function validatePropTypes(element) { |
| 2800 |
var type = element.type; |
| 2801 |
if (type === null || type === void 0 || typeof type === "string") return; |
| 2802 |
var propTypes; |
| 2803 |
if (typeof type === "function") propTypes = type.propTypes; |
| 2804 |
else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MEMO_TYPE)) propTypes = type.propTypes; |
| 2805 |
else return; |
| 2806 |
if (propTypes) { |
| 2807 |
var name = getComponentNameFromType(type); |
| 2808 |
checkPropTypes(propTypes, element.props, "prop", name, element); |
| 2809 |
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) { |
| 2810 |
propTypesMisspellWarningShown = true; |
| 2811 |
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", getComponentNameFromType(type) || "Unknown"); |
| 2812 |
} |
| 2813 |
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); |
| 2814 |
} |
| 2815 |
/** |
| 2816 |
* Given a fragment, validate that it can only be provided with fragment props |
| 2817 |
* @param {ReactElement} fragment |
| 2818 |
*/ |
| 2819 |
function validateFragmentProps(fragment) { |
| 2820 |
var keys = Object.keys(fragment.props); |
| 2821 |
for (var i = 0; i < keys.length; i++) { |
| 2822 |
var key = keys[i]; |
| 2823 |
if (key !== "children" && key !== "key") { |
| 2824 |
setCurrentlyValidatingElement$1(fragment); |
| 2825 |
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key); |
| 2826 |
setCurrentlyValidatingElement$1(null); |
| 2827 |
break; |
| 2828 |
} |
| 2829 |
} |
| 2830 |
if (fragment.ref !== null) { |
| 2831 |
setCurrentlyValidatingElement$1(fragment); |
| 2832 |
error("Invalid attribute `ref` supplied to `React.Fragment`."); |
| 2833 |
setCurrentlyValidatingElement$1(null); |
| 2834 |
} |
| 2835 |
} |
| 2836 |
var didWarnAboutKeySpread = {}; |
| 2837 |
function jsxWithValidation(type, props, key, isStaticChildren, source, self) { |
| 2838 |
var validType = isValidElementType(type); |
| 2839 |
if (!validType) { |
| 2840 |
var info = ""; |
| 2841 |
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."; |
| 2842 |
var sourceInfo = getSourceInfoErrorAddendum(source); |
| 2843 |
if (sourceInfo) info += sourceInfo; |
| 2844 |
else info += getDeclarationErrorAddendum(); |
| 2845 |
var typeString; |
| 2846 |
if (type === null) typeString = "null"; |
| 2847 |
else if (isArray(type)) typeString = "array"; |
| 2848 |
else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) { |
| 2849 |
typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; |
| 2850 |
info = " Did you accidentally export a JSX literal instead of a component?"; |
| 2851 |
} else typeString = typeof type; |
| 2852 |
error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info); |
| 2853 |
} |
| 2854 |
var element = jsxDEV(type, props, key, source, self); |
| 2855 |
if (element == null) return element; |
| 2856 |
if (validType) { |
| 2857 |
var children = props.children; |
| 2858 |
if (children !== void 0) if (isStaticChildren) if (isArray(children)) { |
| 2859 |
for (var i = 0; i < children.length; i++) validateChildKeys(children[i], type); |
| 2860 |
if (Object.freeze) Object.freeze(children); |
| 2861 |
} else error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); |
| 2862 |
else validateChildKeys(children, type); |
| 2863 |
} |
| 2864 |
if (hasOwnProperty.call(props, "key")) { |
| 2865 |
var componentName = getComponentNameFromType(type); |
| 2866 |
var keys = Object.keys(props).filter(function(k) { |
| 2867 |
return k !== "key"; |
| 2868 |
}); |
| 2869 |
var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}"; |
| 2870 |
if (!didWarnAboutKeySpread[componentName + beforeExample]) { |
| 2871 |
error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", beforeExample, componentName, keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}", componentName); |
| 2872 |
didWarnAboutKeySpread[componentName + beforeExample] = true; |
| 2873 |
} |
| 2874 |
} |
| 2875 |
if (type === REACT_FRAGMENT_TYPE) validateFragmentProps(element); |
| 2876 |
else validatePropTypes(element); |
| 2877 |
return element; |
| 2878 |
} |
| 2879 |
function jsxWithValidationStatic(type, props, key) { |
| 2880 |
return jsxWithValidation(type, props, key, true); |
| 2881 |
} |
| 2882 |
function jsxWithValidationDynamic(type, props, key) { |
| 2883 |
return jsxWithValidation(type, props, key, false); |
| 2884 |
} |
| 2885 |
var jsx = jsxWithValidationDynamic; |
| 2886 |
var jsxs = jsxWithValidationStatic; |
| 2887 |
exports.Fragment = REACT_FRAGMENT_TYPE; |
| 2888 |
exports.jsx = jsx; |
| 2889 |
exports.jsxs = jsxs; |
| 2890 |
})(); |
| 2891 |
})); |
| 2892 |
|
| 2893 |
//#endregion |
| 2894 |
//#region node_modules/react/jsx-runtime.js |
| 2895 |
var require_jsx_runtime = /* @__PURE__ */ __commonJSMin(((exports, module) => { |
| 2896 |
module.exports = require_react_jsx_runtime_development(); |
| 2897 |
})); |
| 2898 |
|
| 2899 |
//#endregion |
| 2900 |
//#region node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js |
| 2901 |
var import_jsx_runtime = require_jsx_runtime(); |
| 2902 |
var QueryClientContext = react.createContext(void 0); |
| 2903 |
var useQueryClient = (queryClient) => { |
| 2904 |
const client = react.useContext(QueryClientContext); |
| 2905 |
if (queryClient) return queryClient; |
| 2906 |
if (!client) throw new Error("No QueryClient set, use QueryClientProvider to set one"); |
| 2907 |
return client; |
| 2908 |
}; |
| 2909 |
var QueryClientProvider = ({ client, children }) => { |
| 2910 |
react.useEffect(() => { |
| 2911 |
client.mount(); |
| 2912 |
return () => { |
| 2913 |
client.unmount(); |
| 2914 |
}; |
| 2915 |
}, [client]); |
| 2916 |
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientContext.Provider, { |
| 2917 |
value: client, |
| 2918 |
children |
| 2919 |
}); |
| 2920 |
}; |
| 2921 |
|
| 2922 |
//#endregion |
| 2923 |
//#region node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js |
| 2924 |
var IsRestoringContext = react.createContext(false); |
| 2925 |
var useIsRestoring = () => react.useContext(IsRestoringContext); |
| 2926 |
var IsRestoringProvider = IsRestoringContext.Provider; |
| 2927 |
|
| 2928 |
//#endregion |
| 2929 |
//#region node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js |
| 2930 |
function createValue() { |
| 2931 |
let isReset = false; |
| 2932 |
return { |
| 2933 |
clearReset: () => { |
| 2934 |
isReset = false; |
| 2935 |
}, |
| 2936 |
reset: () => { |
| 2937 |
isReset = true; |
| 2938 |
}, |
| 2939 |
isReset: () => { |
| 2940 |
return isReset; |
| 2941 |
} |
| 2942 |
}; |
| 2943 |
} |
| 2944 |
var QueryErrorResetBoundaryContext = react.createContext(createValue()); |
| 2945 |
var useQueryErrorResetBoundary = () => react.useContext(QueryErrorResetBoundaryContext); |
| 2946 |
|
| 2947 |
//#endregion |
| 2948 |
//#region node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js |
| 2949 |
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => { |
| 2950 |
if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) { |
| 2951 |
if (!errorResetBoundary.isReset()) options.retryOnMount = false; |
| 2952 |
} |
| 2953 |
}; |
| 2954 |
var useClearResetErrorBoundary = (errorResetBoundary) => { |
| 2955 |
react.useEffect(() => { |
| 2956 |
errorResetBoundary.clearReset(); |
| 2957 |
}, [errorResetBoundary]); |
| 2958 |
}; |
| 2959 |
var getHasError = ({ result, errorResetBoundary, throwOnError, query, suspense }) => { |
| 2960 |
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query])); |
| 2961 |
}; |
| 2962 |
|
| 2963 |
//#endregion |
| 2964 |
//#region node_modules/@tanstack/react-query/build/modern/suspense.js |
| 2965 |
var ensureSuspenseTimers = (defaultedOptions) => { |
| 2966 |
if (defaultedOptions.suspense) { |
| 2967 |
const MIN_SUSPENSE_TIME_MS = 1e3; |
| 2968 |
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS); |
| 2969 |
const originalStaleTime = defaultedOptions.staleTime; |
| 2970 |
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime); |
| 2971 |
if (typeof defaultedOptions.gcTime === "number") defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, MIN_SUSPENSE_TIME_MS); |
| 2972 |
} |
| 2973 |
}; |
| 2974 |
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring; |
| 2975 |
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending; |
| 2976 |
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => { |
| 2977 |
errorResetBoundary.clearReset(); |
| 2978 |
}); |
| 2979 |
|
| 2980 |
//#endregion |
| 2981 |
//#region node_modules/@tanstack/react-query/build/modern/useBaseQuery.js |
| 2982 |
function useBaseQuery(options, Observer, queryClient) { |
| 2983 |
if (typeof options !== "object" || Array.isArray(options)) throw new Error("Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object"); |
| 2984 |
const isRestoring = useIsRestoring(); |
| 2985 |
const errorResetBoundary = useQueryErrorResetBoundary(); |
| 2986 |
const client = useQueryClient(queryClient); |
| 2987 |
const defaultedOptions = client.defaultQueryOptions(options); |
| 2988 |
client.getDefaultOptions().queries?._experimental_beforeQuery?.(defaultedOptions); |
| 2989 |
if (!defaultedOptions.queryFn) console.error(`[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`); |
| 2990 |
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic"; |
| 2991 |
ensureSuspenseTimers(defaultedOptions); |
| 2992 |
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary); |
| 2993 |
useClearResetErrorBoundary(errorResetBoundary); |
| 2994 |
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash); |
| 2995 |
const [observer] = react.useState(() => new Observer(client, defaultedOptions)); |
| 2996 |
const result = observer.getOptimisticResult(defaultedOptions); |
| 2997 |
const shouldSubscribe = !isRestoring && options.subscribed !== false; |
| 2998 |
react.useSyncExternalStore(react.useCallback((onStoreChange) => { |
| 2999 |
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop; |
| 3000 |
observer.updateResult(); |
| 3001 |
return unsubscribe; |
| 3002 |
}, [observer, shouldSubscribe]), () => observer.getCurrentResult(), () => observer.getCurrentResult()); |
| 3003 |
react.useEffect(() => { |
| 3004 |
observer.setOptions(defaultedOptions); |
| 3005 |
}, [defaultedOptions, observer]); |
| 3006 |
if (shouldSuspend(defaultedOptions, result)) throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary); |
| 3007 |
if (getHasError({ |
| 3008 |
result, |
| 3009 |
errorResetBoundary, |
| 3010 |
throwOnError: defaultedOptions.throwOnError, |
| 3011 |
query: client.getQueryCache().get(defaultedOptions.queryHash), |
| 3012 |
suspense: defaultedOptions.suspense |
| 3013 |
})) throw result.error; |
| 3014 |
client.getDefaultOptions().queries?._experimental_afterQuery?.(defaultedOptions, result); |
| 3015 |
if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) (isNewCacheEntry ? fetchOptimistic(defaultedOptions, observer, errorResetBoundary) : client.getQueryCache().get(defaultedOptions.queryHash)?.promise)?.catch(noop).finally(() => { |
| 3016 |
observer.updateResult(); |
| 3017 |
}); |
| 3018 |
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result; |
| 3019 |
} |
| 3020 |
|
| 3021 |
//#endregion |
| 3022 |
//#region node_modules/@tanstack/react-query/build/modern/useQuery.js |
| 3023 |
function useQuery(options, queryClient) { |
| 3024 |
return useBaseQuery(options, QueryObserver, queryClient); |
| 3025 |
} |
| 3026 |
|
| 3027 |
//#endregion |
| 3028 |
//#region node_modules/@tanstack/react-query/build/modern/useMutationState.js |
| 3029 |
function useIsMutating(filters, queryClient) { |
| 3030 |
const client = useQueryClient(queryClient); |
| 3031 |
return useMutationState({ filters: { |
| 3032 |
...filters, |
| 3033 |
status: "pending" |
| 3034 |
} }, client).length; |
| 3035 |
} |
| 3036 |
function getResult(mutationCache, options) { |
| 3037 |
return mutationCache.findAll(options.filters).map((mutation) => options.select ? options.select(mutation) : mutation.state); |
| 3038 |
} |
| 3039 |
function useMutationState(options = {}, queryClient) { |
| 3040 |
const mutationCache = useQueryClient(queryClient).getMutationCache(); |
| 3041 |
const optionsRef = react.useRef(options); |
| 3042 |
const result = react.useRef(null); |
| 3043 |
if (result.current === null) result.current = getResult(mutationCache, options); |
| 3044 |
react.useEffect(() => { |
| 3045 |
optionsRef.current = options; |
| 3046 |
}); |
| 3047 |
return react.useSyncExternalStore(react.useCallback((onStoreChange) => mutationCache.subscribe(() => { |
| 3048 |
const nextResult = replaceEqualDeep(result.current, getResult(mutationCache, optionsRef.current)); |
| 3049 |
if (result.current !== nextResult) { |
| 3050 |
result.current = nextResult; |
| 3051 |
notifyManager.schedule(onStoreChange); |
| 3052 |
} |
| 3053 |
}), [mutationCache]), () => result.current, () => result.current); |
| 3054 |
} |
| 3055 |
|
| 3056 |
//#endregion |
| 3057 |
//#region node_modules/@tanstack/react-query/build/modern/useMutation.js |
| 3058 |
function useMutation(options, queryClient) { |
| 3059 |
const client = useQueryClient(queryClient); |
| 3060 |
const [observer] = react.useState(() => new MutationObserver(client, options)); |
| 3061 |
react.useEffect(() => { |
| 3062 |
observer.setOptions(options); |
| 3063 |
}, [observer, options]); |
| 3064 |
const result = react.useSyncExternalStore(react.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult()); |
| 3065 |
const mutate = react.useCallback((variables, mutateOptions) => { |
| 3066 |
observer.mutate(variables, mutateOptions).catch(noop); |
| 3067 |
}, [observer]); |
| 3068 |
if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error; |
| 3069 |
return { |
| 3070 |
...result, |
| 3071 |
mutate, |
| 3072 |
mutateAsync: result.mutate |
| 3073 |
}; |
| 3074 |
} |
| 3075 |
|
| 3076 |
//#endregion |
| 3077 |
//#region node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js |
| 3078 |
function useInfiniteQuery(options, queryClient) { |
| 3079 |
return useBaseQuery(options, InfiniteQueryObserver, queryClient); |
| 3080 |
} |
| 3081 |
|
| 3082 |
//#endregion |
| 3083 |
//#region packages/packages/libs/query/src/index.ts |
| 3084 |
var src_exports = /* @__PURE__ */ __exportAll({ |
| 3085 |
QueryClient: () => QueryClient, |
| 3086 |
QueryClientProvider: () => QueryClientProvider, |
| 3087 |
createQueryClient: () => createQueryClient, |
| 3088 |
getQueryClient: () => getQueryClient, |
| 3089 |
useInfiniteQuery: () => useInfiniteQuery, |
| 3090 |
useIsMutating: () => useIsMutating, |
| 3091 |
useMutation: () => useMutation, |
| 3092 |
useQuery: () => useQuery, |
| 3093 |
useQueryClient: () => useQueryClient |
| 3094 |
}); |
| 3095 |
var queryClient; |
| 3096 |
function getQueryClient() { |
| 3097 |
if (!queryClient) throw new Error("Query client is not created yet."); |
| 3098 |
return queryClient; |
| 3099 |
} |
| 3100 |
function createQueryClient() { |
| 3101 |
if (queryClient) throw new Error("Query client is already created."); |
| 3102 |
queryClient = new QueryClient({ defaultOptions: { queries: { |
| 3103 |
refetchOnWindowFocus: false, |
| 3104 |
refetchOnReconnect: false |
| 3105 |
} } }); |
| 3106 |
return queryClient; |
| 3107 |
} |
| 3108 |
|
| 3109 |
//#endregion |
| 3110 |
//#region \0elementor-package-library-entry |
| 3111 |
(window.elementorV2 = window.elementorV2 || {}).query = src_exports; |
| 3112 |
|
| 3113 |
//#endregion |
| 3114 |
})(React); |
| 3115 |
window.elementorV2.query?.init?.(); |
| 3116 |
//# sourceMappingURL=query.js.map |