{"version":3,"file":"query.cjs","names":["Removable","replaceData","noop","resolveQueryValue","skipToken","timeUntilStale","ensureQueryFn","infiniteQueryBehavior","createRetryer","CancelledError","canFetch"],"sources":["../../src/query.ts"],"sourcesContent":["import {\n  ensureQueryFn,\n  noop,\n  replaceData,\n  resolveQueryValue,\n  skipToken,\n  timeUntilStale,\n} from './utils'\nimport { notifyManager } from './notifyManager'\nimport { CancelledError, canFetch, createRetryer } from './retryer'\nimport { Removable } from './removable'\nimport { infiniteQueryBehavior } from './infiniteQueryBehavior'\nimport type { QueryCache } from './queryCache'\nimport type { QueryClient } from './queryClient'\nimport type {\n  CancelOptions,\n  DefaultError,\n  FetchStatus,\n  InitialDataFunction,\n  OmitKeyof,\n  QueryFunctionContext,\n  QueryKey,\n  QueryMeta,\n  QueryOptions,\n  QueryStatus,\n  SetDataOptions,\n  StaleTime,\n} from './types'\nimport type { QueryObserver } from './queryObserver'\nimport type { Retryer } from './retryer'\n\n// TYPES\n\ninterface QueryConfig<\n  TQueryFnData,\n  TError,\n  TData,\n  TQueryKey extends QueryKey = QueryKey,\n> {\n  client: QueryClient\n  queryKey: TQueryKey\n  queryHash: string\n  options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>\n  defaultOptions?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>\n  state?: QueryState<TData, TError>\n}\n\n/**\n * The raw state stored on a `Query` instance. This is the underlying state\n * that observer results (e.g. `QueryObserverResult`) are derived from.\n */\nexport interface QueryState<TData = unknown, TError = DefaultError> {\n  /**\n   * The last successfully resolved data for the query.\n   */\n  data: TData | undefined\n  /**\n   * The number of times the query has successfully resolved.\n   */\n  dataUpdateCount: number\n  /**\n   * The timestamp for when the query most recently returned the `status` as `\"success\"`.\n   */\n  dataUpdatedAt: number\n  /**\n   * The error object for the query, if the last attempt resulted in an error.\n   * - Defaults to `null`.\n   */\n  error: TError | null\n  /**\n   * The sum of all errors, incremented every time the query resolves with an error.\n   */\n  errorUpdateCount: number\n  /**\n   * The timestamp for when the query most recently returned the `status` as `\"error\"`.\n   */\n  errorUpdatedAt: number\n  /**\n   * The failure count for the current fetch.\n   * - Incremented every time the fetch fails.\n   * - Reset to `0` when the fetch succeeds.\n   */\n  fetchFailureCount: number\n  /**\n   * The reason the current fetch failed, as reported by the retryer.\n   * - Reset to `null` when the fetch succeeds.\n   */\n  fetchFailureReason: TError | null\n  /**\n   * Metadata passed to the currently in-flight (or most recent) fetch, e.g. the\n   * `fetchMore` direction for infinite queries.\n   */\n  fetchMeta: FetchMeta | null\n  /**\n   * Whether the query has been marked as invalidated via `invalidate()`.\n   * - Reset to `false` whenever the query resolves successfully.\n   */\n  isInvalidated: boolean\n  /**\n   * The status of the query.\n   * - `pending` if there's no cached data and no attempt was finished yet.\n   * - `error` if the last attempt resulted in an error.\n   * - `success` if the query has data.\n   */\n  status: QueryStatus\n  /**\n   * The fetch status of the query.\n   * - `fetching`: the `queryFn` is currently executing.\n   * - `paused`: a fetch wanted to run but has been paused (see network mode).\n   * - `idle`: the query is not fetching.\n   */\n  fetchStatus: FetchStatus\n}\n\n/**\n * The context passed to a {@link QueryBehavior}'s `onFetch`, which can replace `fetchFn` to change\n * how the query fetches (e.g. to fetch pages for an infinite query).\n */\nexport interface FetchContext<\n  TQueryFnData,\n  TError,\n  TData,\n  TQueryKey extends QueryKey = QueryKey,\n> {\n  /**\n   * The function that runs the fetch. By default it calls `queryFn`; `onFetch` can replace it.\n   */\n  fetchFn: () => unknown | Promise<unknown>\n  /**\n   * The options of this fetch.\n   */\n  fetchOptions?: FetchOptions\n  /**\n   * The `AbortSignal` that aborts when the fetch is cancelled.\n   */\n  signal: AbortSignal\n  /**\n   * The options of the query.\n   */\n  options: QueryOptions<TQueryFnData, TError, TData, any>\n  /**\n   * The `QueryClient` the query belongs to.\n   */\n  client: QueryClient\n  /**\n   * The key of the query.\n   */\n  queryKey: TQueryKey\n  /**\n   * The state of the query when the fetch starts.\n   */\n  state: QueryState<TData, TError>\n}\n\n/**\n * Customizes how a query fetches, e.g. the behavior that fetches the pages of an infinite query.\n */\nexport interface QueryBehavior<\n  TQueryFnData = unknown,\n  TError = DefaultError,\n  TData = TQueryFnData,\n  TQueryKey extends QueryKey = QueryKey,\n> {\n  /**\n   * Called before each fetch of the query, e.g. to replace `fetchFn` in the context.\n   */\n  onFetch: (\n    context: FetchContext<TQueryFnData, TError, TData, TQueryKey>,\n    query: Query,\n  ) => void\n}\n\n/**\n * The direction an infinite query fetches in: `'forward'` for the next page, `'backward'` for the\n * previous one.\n */\nexport type FetchDirection = 'forward' | 'backward'\n\n/**\n * Metadata for a fetch, e.g. the direction when an infinite query fetches more pages.\n */\nexport interface FetchMeta {\n  /**\n   * Set when an infinite query fetches another page, with the direction to fetch in.\n   */\n  fetchMore?: { direction: FetchDirection }\n}\n\n/**\n * Options for a single fetch of a query.\n */\nexport interface FetchOptions<TData = unknown> {\n  /**\n   * If `true`, an in-flight fetch is cancelled before starting a new one, when the query already\n   * has data. Otherwise, the in-flight fetch is reused.\n   */\n  cancelRefetch?: boolean\n  /**\n   * Metadata of the fetch, stored in the query's `fetchMeta` state.\n   */\n  meta?: FetchMeta\n  /**\n   * A promise to use for the first attempt instead of calling `fetchFn`, e.g. a pending promise\n   * restored by `hydrate`.\n   */\n  initialPromise?: Promise<TData>\n}\n\ninterface FailedAction<TError> {\n  type: 'failed'\n  failureCount: number\n  error: TError\n}\n\ninterface FetchAction {\n  type: 'fetch'\n  meta?: FetchMeta\n}\n\ninterface SuccessAction<TData> {\n  data: TData | undefined\n  type: 'success'\n  dataUpdatedAt?: number\n  manual?: boolean\n}\n\ninterface ErrorAction<TError> {\n  type: 'error'\n  error: TError\n}\n\ninterface InvalidateAction {\n  type: 'invalidate'\n}\n\ninterface PauseAction {\n  type: 'pause'\n}\n\ninterface ContinueAction {\n  type: 'continue'\n}\n\ninterface SetStateAction<TData, TError> {\n  type: 'setState'\n  state: Partial<QueryState<TData, TError>>\n}\n\n/**\n * The actions a query dispatches to update its state, e.g. when it starts fetching, fails, or\n * succeeds.\n */\nexport type Action<TData, TError> =\n  | ContinueAction\n  | ErrorAction<TError>\n  | FailedAction<TError>\n  | FetchAction\n  | InvalidateAction\n  | PauseAction\n  | SetStateAction<TData, TError>\n  | SuccessAction<TData>\n\n// CLASS\n\n/**\n * Represents a single cached query. A `Query` holds the query's key, options,\n * state (data/error/status), and the observers currently subscribed to it.\n *\n * Instances are created and managed internally by `QueryCache`; application\n * code typically interacts with queries indirectly through `QueryClient` or\n * a framework hook like `useQuery`. Direct access to a `Query` instance is\n * possible via `queryCache.find()`/`findAll()` for inspecting cache state.\n * @example\n * ```ts\n * const queryCache = queryClient.getQueryCache()\n * const query = queryCache.find({ queryKey: ['posts'] })\n *\n * if (query) {\n *   console.log(query.state.dataUpdatedAt)\n * }\n * ```\n */\nexport class Query<\n  TQueryFnData = unknown,\n  TError = DefaultError,\n  TData = TQueryFnData,\n  TQueryKey extends QueryKey = QueryKey,\n> extends Removable {\n  queryKey: TQueryKey\n  queryHash: string\n  options!: QueryOptions<TQueryFnData, TError, TData, TQueryKey>\n  state: QueryState<TData, TError>\n  #queryType?: 'infinite'\n\n  #initialState: QueryState<TData, TError>\n  #revertState?: QueryState<TData, TError>\n  #cache: QueryCache\n  #client: QueryClient\n  #retryer?: Retryer<TData>\n  observers: Array<QueryObserver<any, any, any, any, any>>\n  #defaultOptions?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>\n  #abortSignalConsumed: boolean\n\n  constructor(config: QueryConfig<TQueryFnData, TError, TData, TQueryKey>) {\n    super()\n\n    this.#abortSignalConsumed = false\n    this.#defaultOptions = config.defaultOptions\n    this.setOptions(config.options)\n    this.observers = []\n    this.#client = config.client\n    this.#cache = this.#client.getQueryCache()\n    this.queryKey = config.queryKey\n    this.queryHash = config.queryHash\n    this.#initialState = getDefaultState(this.options)\n    this.state = config.state ?? this.#initialState\n    this.scheduleGc()\n  }\n  /**\n   * The `meta` object passed in the query's options, if any.\n   * @returns The query's `meta`, or `undefined` if none was set.\n   */\n  get meta(): QueryMeta | undefined {\n    return this.options.meta\n  }\n\n  /**\n   * `'infinite'` for an infinite query, otherwise `undefined`.\n   * @internal\n   * @returns The type of the query, set from the `_type` option (e.g. `'infinite'`).\n   */\n  get queryType() {\n    return this.#queryType\n  }\n\n  /**\n   * The promise for the currently in-flight fetch, if the query is fetching.\n   * `undefined` when the query is not fetching.\n   * @returns The promise of the in-flight fetch, or `undefined`.\n   */\n  get promise(): Promise<TData> | undefined {\n    return this.#retryer?.promise\n  }\n\n  /**\n   * Replaces the query's options and applies their `gcTime`. If the query has no data yet, it gets\n   * the `initialData` from the new options, if any.\n   * @internal\n   * @param options - The new query options, merged on top of the query's default options.\n   */\n  setOptions(\n    options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n  ): void {\n    this.options = { ...this.#defaultOptions, ...options }\n\n    if (options?._type) {\n      this.#queryType = options._type\n    }\n\n    this.updateGcTime(this.options.gcTime)\n\n    // oxlint-disable-next-line typescript/no-unnecessary-condition\n    if (this.state && this.state.data === undefined) {\n      const defaultState = getDefaultState(this.options)\n      if (defaultState.data !== undefined) {\n        this.setState(\n          successState(defaultState.data, defaultState.dataUpdatedAt),\n        )\n        this.#initialState = defaultState\n      }\n    }\n  }\n\n  protected override optionalRemove() {\n    if (!this.observers.length && this.state.fetchStatus === 'idle') {\n      this.#cache.remove(this)\n    }\n  }\n\n  /**\n   * Writes new data to the query and marks it as successfully fetched.\n   * @internal\n   * @param newData - The data to write. Structural sharing with the current data is applied.\n   * @param options - Set `updatedAt` to override the timestamp, and `manual` to mark the write as\n   * manual (e.g. from `queryClient.setQueryData`).\n   * @returns The data that was written.\n   */\n  setData(\n    newData: TData,\n    options?: SetDataOptions & { manual: boolean },\n  ): TData {\n    const data = replaceData(this.state.data, newData, this.options)\n\n    // Set data and mark it as cached\n    this.#dispatch({\n      data,\n      type: 'success',\n      dataUpdatedAt: options?.updatedAt,\n      manual: options?.manual,\n    })\n\n    return data\n  }\n\n  /**\n   * Merges the given partial state directly into this query's state, notifying observers. Used\n   * by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a\n   * user manually trigger a loading/error state or edit the cached data.\n   * @param state - The partial state to merge into the query's state.\n   */\n  setState(state: Partial<QueryState<TData, TError>>): void {\n    this.#dispatch({ type: 'setState', state })\n  }\n\n  /**\n   * Cancels the query's currently in-flight fetch, if any.\n   * - Returns a promise that resolves once the cancellation has settled.\n   * - If no fetch is in progress, resolves immediately.\n   * @param options - Set `revert` to restore the state from before the fetch started, and `silent`\n   * to suppress the cancellation error when a new fetch replaces the cancelled one.\n   * @returns A promise that resolves once the cancellation has settled.\n   * @example\n   * ```ts\n   * await query.cancel()\n   * ```\n   */\n  cancel(options?: CancelOptions): Promise<void> {\n    const promise = this.#retryer?.promise\n    this.#retryer?.cancel(options)\n    return promise ? promise.then(noop).catch(noop) : Promise.resolve()\n  }\n\n  /**\n   * Clears the query's garbage collection timeout and silently cancels any\n   * in-flight fetch. Called by `QueryCache` when the query is removed from\n   * the cache.\n   * @see {@link Query#cancel}\n   */\n  override destroy(): void {\n    super.destroy()\n\n    this.cancel({ silent: true })\n  }\n\n  /**\n   * The state the query was created with.\n   * @internal\n   * @returns The state the query had when it was first created, used by {@link Query#reset}.\n   */\n  get resetState(): QueryState<TData, TError> {\n    return this.#initialState\n  }\n\n  /**\n   * Resets the query back to its initial state (the state it had when it was\n   * first created, e.g. any `initialData`), destroying it first to cancel any\n   * in-flight fetch.\n   */\n  reset(): void {\n    this.destroy()\n    this.setState(this.resetState)\n  }\n\n  /**\n   * Returns `true` if the query has at least one observer for which `enabled`\n   * does not resolve to `false`.\n   * @returns `true` if the query has an enabled observer.\n   */\n  isActive(): boolean {\n    return this.observers.some(\n      (observer) => resolveQueryValue(observer.options.enabled, this) !== false,\n    )\n  }\n\n  /**\n   * Returns `true` if the query is disabled, meaning it will not fetch\n   * automatically.\n   * - If the query has observers, it is disabled when none of them are active\n   *   (see `isActive`).\n   * - If the query has no observers, it is disabled when its `queryFn` is\n   *   `skipToken` or it has never been fetched.\n   * @returns `true` if the query is disabled.\n   */\n  isDisabled(): boolean {\n    if (this.getObserversCount() > 0) {\n      return !this.isActive()\n    }\n    // if a query has no observers, it should still be considered disabled if it never attempted a fetch\n    return this.options.queryFn === skipToken || !this.isFetched()\n  }\n\n  /**\n   * Returns `true` if the query has been fetched, i.e. it has resolved with\n   * either data or an error at least once.\n   * @returns `true` if the query has been fetched.\n   */\n  isFetched() {\n    return this.state.dataUpdateCount + this.state.errorUpdateCount > 0\n  }\n\n  /**\n   * Returns `true` if the query has at least one observer configured with\n   * `staleTime: 'static'`, meaning it is treated as never stale.\n   * @returns `true` if the query is static.\n   */\n  isStatic(): boolean {\n    if (this.getObserversCount() > 0) {\n      return this.observers.some(\n        (observer) =>\n          resolveQueryValue(observer.options.staleTime, this) === 'static',\n      )\n    }\n\n    return false\n  }\n\n  /**\n   * Returns `true` if the query is stale.\n   * - If the query has observers, defers to whether any observer's current\n   *   result reports `isStale` (which accounts for each observer's own\n   *   `staleTime` and `enabled` state).\n   * - If the query has no observers, it is considered stale when it has no\n   *   data or has been invalidated.\n   * @returns `true` if the query is stale.\n   * @see {@link Query#isStaleByTime}\n   * @example\n   * ```ts\n   * if (query.isStale()) {\n   *   // refetch or otherwise treat the cached data as outdated\n   * }\n   * ```\n   */\n  isStale(): boolean {\n    // check observers first, their `isStale` has the source of truth\n    // calculated with `isStaleByTime` and it takes `enabled` into account\n    if (this.getObserversCount() > 0) {\n      return this.observers.some(\n        (observer) => observer.getCurrentResult().isStale,\n      )\n    }\n\n    return this.state.data === undefined || this.state.isInvalidated\n  }\n\n  /**\n   * Returns `true` if the query's data is stale relative to the given\n   * `staleTime` (defaults to `0`).\n   * - A query with no data is always stale.\n   * - `staleTime: 'static'` is never stale.\n   * - An invalidated query is always stale.\n   * - Otherwise, staleness is based on elapsed time since `dataUpdatedAt`.\n   * @param staleTime - The time, in milliseconds, after which data is considered stale, or\n   * `'static'` to never treat existing data as stale. A query without data is stale either way.\n   * @returns `true` if the query's data is stale.\n   * @see {@link Query#isStale}\n   * @example\n   * ```ts\n   * const isStale = query.isStaleByTime(1000 * 60)\n   * ```\n   */\n  isStaleByTime(staleTime: StaleTime = 0): boolean {\n    // no data is always stale\n    if (this.state.data === undefined) {\n      return true\n    }\n    // static is never stale\n    if (staleTime === 'static') {\n      return false\n    }\n    // if the query is invalidated, it is stale\n    if (this.state.isInvalidated) {\n      return true\n    }\n\n    return !timeUntilStale(this.state.dataUpdatedAt, staleTime)\n  }\n\n  /**\n   * Refetches the query when the window regains focus, if an observer wants that, and continues a\n   * paused fetch.\n   * @internal\n   */\n  onFocus(): void {\n    const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus())\n\n    observer?.refetch({ cancelRefetch: false })\n\n    // Continue fetch if currently paused\n    this.#retryer?.continue()\n  }\n\n  /**\n   * Refetches the query when the app reconnects, if an observer wants that, and continues a paused\n   * fetch.\n   * @internal\n   */\n  onOnline(): void {\n    const observer = this.observers.find((x) => x.shouldFetchOnReconnect())\n\n    observer?.refetch({ cancelRefetch: false })\n\n    // Continue fetch if currently paused\n    this.#retryer?.continue()\n  }\n\n  /**\n   * Subscribes an observer to the query and stops its garbage collection.\n   * @internal\n   * @param observer - The observer to add. Adding an observer that is already subscribed does\n   * nothing.\n   */\n  addObserver(observer: QueryObserver<any, any, any, any, any>): void {\n    if (!this.observers.includes(observer)) {\n      this.observers.push(observer)\n\n      // Stop the query from being garbage collected\n      this.clearGcTimeout()\n\n      this.#cache.notify({ type: 'observerAdded', query: this, observer })\n    }\n  }\n\n  /**\n   * Unsubscribes an observer from the query.\n   * @internal\n   * @param observer - The observer to remove. When the last observer is removed, the in-flight\n   * fetch is cancelled if its abort signal was consumed (otherwise only its retries are stopped),\n   * and garbage collection is scheduled.\n   */\n  removeObserver(observer: QueryObserver<any, any, any, any, any>): void {\n    const index = this.observers.indexOf(observer)\n    if (index !== -1) {\n      this.observers.splice(index, 1)\n\n      if (!this.observers.length) {\n        // If the transport layer does not support cancellation\n        // we'll let the query continue so the result can be cached\n        if (this.#retryer) {\n          if (\n            this.#abortSignalConsumed ||\n            (this.state.fetchStatus === 'paused' &&\n              this.state.status === 'pending')\n          ) {\n            this.#retryer.cancel({ revert: true })\n          } else {\n            this.#retryer.cancelRetry()\n          }\n        }\n\n        this.scheduleGc()\n      }\n\n      this.#cache.notify({ type: 'observerRemoved', query: this, observer })\n    }\n  }\n\n  /**\n   * Returns the number of observers currently subscribed to this query.\n   * @returns The number of observers.\n   * @example\n   * ```ts\n   * if (query.getObserversCount() === 0) {\n   *   // no component is currently watching this query\n   * }\n   * ```\n   */\n  getObserversCount(): number {\n    return this.observers.length\n  }\n\n  /**\n   * Marks the query as invalidated, unless it is already invalidated. This\n   * updates `state.isInvalidated` and notifies observers, but does not by\n   * itself trigger a refetch.\n   * @example\n   * ```ts\n   * query.invalidate()\n   * ```\n   */\n  invalidate(): void {\n    if (!this.state.isInvalidated) {\n      this.#dispatch({ type: 'invalidate' })\n    }\n  }\n\n  /**\n   * Fetches the query, i.e. runs its `queryFn` (through any configured\n   * retryer/behavior) and updates the query's state with the result.\n   * - If a fetch is already in flight, returns its promise instead of\n   *   starting a new one, unless `fetchOptions.cancelRefetch` is set and the\n   *   query already has data, in which case the current fetch is silently\n   *   cancelled first.\n   * - If `options` is passed, it replaces the query's current options\n   *   before fetching.\n   * @param options - Query options that replace the query's current options before fetching. They\n   * are not applied when an in-flight fetch is reused.\n   * @param fetchOptions - Set `cancelRefetch` to cancel an in-flight fetch first (only if the query\n   * already has data), and `meta` to pass extra information to the query's behavior.\n   * @returns A promise that resolves with the fetched data, or rejects with the fetch error. If the\n   * fetch is cancelled with `revert` while the query has data, it resolves with the restored data\n   * instead.\n   */\n  async fetch(\n    options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n    fetchOptions?: FetchOptions<TQueryFnData>,\n  ): Promise<TData> {\n    if (\n      this.state.fetchStatus !== 'idle' &&\n      // If the promise in the retryer is already rejected, we have to definitely\n      // re-start the fetch; there is a chance that the query is still in a\n      // pending state when that happens\n      this.#retryer?.status() !== 'rejected'\n    ) {\n      if (this.state.data !== undefined && fetchOptions?.cancelRefetch) {\n        // Silently cancel current fetch if the user wants to cancel refetch\n        this.cancel({ silent: true })\n      } else if (this.#retryer) {\n        // make sure that retries that were potentially cancelled due to unmounts can continue\n        this.#retryer.continueRetry()\n        // Return current promise if we are already fetching\n        return this.#retryer.promise\n      }\n    }\n\n    // Update config if passed, otherwise the config from the last execution is used\n    if (options) {\n      this.setOptions(options)\n    }\n\n    // Use the options from the first observer with a query function if no function is found.\n    // This can happen when the query is hydrated or created with setQueryData.\n    if (!this.options.queryFn) {\n      const observer = this.observers.find((x) => x.options.queryFn)\n      if (observer) {\n        this.setOptions(observer.options)\n      }\n    }\n\n    if (process.env.NODE_ENV !== 'production') {\n      if (!Array.isArray(this.options.queryKey)) {\n        console.error(\n          `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`,\n        )\n      }\n    }\n\n    const abortController = new AbortController()\n\n    // Adds an enumerable signal property to the object that\n    // which sets abortSignalConsumed to true when the signal\n    // is read.\n    const addSignalProperty = (object: unknown) => {\n      Object.defineProperty(object, 'signal', {\n        enumerable: true,\n        get: () => {\n          this.#abortSignalConsumed = true\n          return abortController.signal\n        },\n      })\n    }\n\n    // Create fetch function\n    const fetchFn = () => {\n      const queryFn = ensureQueryFn(this.options, fetchOptions)\n\n      // Create query function context\n      const createQueryFnContext = (): QueryFunctionContext<TQueryKey> => {\n        const queryFnContext: OmitKeyof<\n          QueryFunctionContext<TQueryKey>,\n          'signal'\n        > = {\n          client: this.#client,\n          queryKey: this.queryKey,\n          meta: this.meta,\n        }\n        addSignalProperty(queryFnContext)\n        return queryFnContext as QueryFunctionContext<TQueryKey>\n      }\n\n      const queryFnContext = createQueryFnContext()\n\n      this.#abortSignalConsumed = false\n      if (this.options.persister) {\n        return this.options.persister(\n          queryFn,\n          queryFnContext,\n          this as unknown as Query,\n        )\n      }\n\n      return queryFn(queryFnContext)\n    }\n\n    // Trigger behavior hook\n    const createFetchContext = (): FetchContext<\n      TQueryFnData,\n      TError,\n      TData,\n      TQueryKey\n    > => {\n      const context: OmitKeyof<\n        FetchContext<TQueryFnData, TError, TData, TQueryKey>,\n        'signal'\n      > = {\n        fetchOptions,\n        options: this.options,\n        queryKey: this.queryKey,\n        client: this.#client,\n        state: this.state,\n        fetchFn,\n      }\n\n      addSignalProperty(context)\n      return context as FetchContext<TQueryFnData, TError, TData, TQueryKey>\n    }\n\n    const context = createFetchContext()\n\n    const behavior =\n      this.#queryType === 'infinite'\n        ? (infiniteQueryBehavior(\n            (this.options as { pages?: number }).pages,\n          ) as QueryBehavior<TQueryFnData, TError, TData, TQueryKey>)\n        : this.options.behavior\n    behavior?.onFetch(context, this as unknown as Query)\n\n    // Store state in case the current fetch needs to be reverted\n    this.#revertState = this.state\n\n    // Set to fetching state if not already in it\n    if (\n      this.state.fetchStatus === 'idle' ||\n      this.state.fetchMeta !== context.fetchOptions?.meta\n    ) {\n      this.#dispatch({ type: 'fetch', meta: context.fetchOptions?.meta })\n    }\n\n    // Try to fetch the data\n    const retryer = (this.#retryer = createRetryer({\n      initialPromise: fetchOptions?.initialPromise as\n        | Promise<TData>\n        | undefined,\n      fn: context.fetchFn as () => Promise<TData>,\n      onCancel: (error) => {\n        if (error instanceof CancelledError && error.revert) {\n          this.setState({\n            ...this.#revertState,\n            fetchStatus: 'idle' as const,\n          })\n        }\n        abortController.abort()\n      },\n      onFail: (failureCount, error) => {\n        this.#dispatch({ type: 'failed', failureCount, error })\n      },\n      onPause: () => {\n        this.#dispatch({ type: 'pause' })\n      },\n      onContinue: () => {\n        this.#dispatch({ type: 'continue' })\n      },\n      retry: context.options.retry,\n      retryDelay: context.options.retryDelay,\n      networkMode: context.options.networkMode,\n      canRun: () => true,\n    }))\n\n    try {\n      const data = await retryer.start()\n      // this is more of a runtime guard\n      if (data === undefined) {\n        if (process.env.NODE_ENV !== 'production') {\n          console.error(\n            `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`,\n          )\n        }\n        throw new Error(`${this.queryHash} data is undefined`)\n      }\n\n      this.setData(data)\n\n      // Notify cache callback\n      this.#cache.config.onSuccess?.(data, this as Query<any, any, any, any>)\n      this.#cache.config.onSettled?.(\n        data,\n        this.state.error as any,\n        this as Query<any, any, any, any>,\n      )\n      return data\n    } catch (error) {\n      if (error instanceof CancelledError) {\n        if (error.silent) {\n          // silent cancellation implies a new fetch is going to be started,\n          // so we piggyback onto that promise\n          return this.#retryer.promise\n        } else if (error.revert) {\n          // transform error into reverted state data\n          // if the initial fetch was cancelled, we have no data, so we have\n          // to get reject with a CancelledError\n          if (this.state.data === undefined) {\n            throw error\n          }\n          return this.state.data\n        }\n      }\n      this.#dispatch({\n        type: 'error',\n        error: error as TError,\n      })\n\n      // Notify cache callback\n      this.#cache.config.onError?.(\n        error as any,\n        this as Query<any, any, any, any>,\n      )\n      this.#cache.config.onSettled?.(\n        this.state.data,\n        error as any,\n        this as Query<any, any, any, any>,\n      )\n\n      throw error // rethrow the error for further handling\n    } finally {\n      // The settled retryer's promise would otherwise pin this fetch's raw\n      // result (a second copy after structural sharing) for the query's lifetime\n      if (this.#retryer === retryer) {\n        this.#retryer = undefined\n      }\n      // Schedule query gc after fetching\n      this.scheduleGc()\n    }\n  }\n\n  #dispatch(action: Action<TData, TError>): void {\n    const reducer = (\n      state: QueryState<TData, TError>,\n    ): QueryState<TData, TError> => {\n      switch (action.type) {\n        case 'failed':\n          return {\n            ...state,\n            fetchFailureCount: action.failureCount,\n            fetchFailureReason: action.error,\n          }\n        case 'pause':\n          return {\n            ...state,\n            fetchStatus: 'paused',\n          }\n        case 'continue':\n          return {\n            ...state,\n            fetchStatus: 'fetching',\n          }\n        case 'fetch':\n          return {\n            ...state,\n            ...fetchState(state.data, this.options),\n            fetchMeta: action.meta ?? null,\n          }\n        case 'success':\n          const newState = {\n            ...state,\n            ...successState(action.data, action.dataUpdatedAt),\n            dataUpdateCount: state.dataUpdateCount + 1,\n            ...(!action.manual && {\n              fetchStatus: 'idle' as const,\n              fetchFailureCount: 0,\n              fetchFailureReason: null,\n            }),\n          }\n          // If fetching ends successfully, we don't need revertState as a fallback anymore.\n          // For manual updates, capture the state to revert to it in case of a cancellation.\n          this.#revertState = action.manual ? newState : undefined\n\n          return newState\n        case 'error':\n          const error = action.error\n          return {\n            ...state,\n            error,\n            errorUpdateCount: state.errorUpdateCount + 1,\n            errorUpdatedAt: Date.now(),\n            fetchFailureCount: state.fetchFailureCount + 1,\n            fetchFailureReason: error,\n            fetchStatus: 'idle',\n            status: 'error',\n            // flag existing data as invalidated if we get a background error\n            // note that \"no data\" always means stale so we can set unconditionally here\n            isInvalidated: true,\n          }\n        case 'invalidate':\n          return {\n            ...state,\n            isInvalidated: true,\n          }\n        case 'setState':\n          return {\n            ...state,\n            ...action.state,\n          }\n      }\n    }\n\n    this.state = reducer(this.state)\n\n    notifyManager.batch(() => {\n      // Keep the current iteration stable if an observer unsubscribes\n      // synchronously while it is being notified.\n      this.observers.slice().forEach((observer) => {\n        observer.onQueryUpdate()\n      })\n\n      this.#cache.notify({ query: this, type: 'updated', action })\n    })\n  }\n}\n\n/**\n * Returns the state changes applied when a query starts fetching.\n * @param data - The query's current data. If it is `undefined`, the query is also reset to\n * `'pending'` with no error.\n * @param options - The query options, whose `networkMode` decides whether the query is `'fetching'`\n * or `'paused'`.\n * @returns The partial query state for a starting fetch.\n */\nexport function fetchState<\n  TQueryFnData,\n  TError,\n  TData,\n  TQueryKey extends QueryKey,\n>(\n  data: TData | undefined,\n  options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n) {\n  return {\n    fetchFailureCount: 0,\n    fetchFailureReason: null,\n    fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',\n    ...(data === undefined &&\n      ({\n        error: null,\n        status: 'pending',\n      } as const)),\n  } as const\n}\n\n/**\n * Returns the state changes applied when a query receives data.\n * @param data - The new data.\n * @param dataUpdatedAt - The timestamp the data is recorded with. Defaults to the current time.\n * @returns The partial query state for a successful update.\n */\nfunction successState<TData>(data: TData | undefined, dataUpdatedAt?: number) {\n  return {\n    data,\n    dataUpdatedAt: dataUpdatedAt ?? Date.now(),\n    error: null,\n    isInvalidated: false,\n    status: 'success' as const,\n  }\n}\n\n/**\n * Returns the initial state of a query, based on its `initialData` and `initialDataUpdatedAt`\n * options.\n * @param options - The query options.\n * @returns The initial query state: `'success'` if `initialData` is set, otherwise `'pending'`.\n */\nfunction getDefaultState<\n  TQueryFnData,\n  TError,\n  TData,\n  TQueryKey extends QueryKey,\n>(\n  options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): QueryState<TData, TError> {\n  const data =\n    typeof options.initialData === 'function'\n      ? (options.initialData as InitialDataFunction<TData>)()\n      : options.initialData\n\n  const hasData = data !== undefined\n\n  const initialDataUpdatedAt = hasData\n    ? typeof options.initialDataUpdatedAt === 'function'\n      ? options.initialDataUpdatedAt()\n      : options.initialDataUpdatedAt\n    : 0\n\n  return {\n    data,\n    dataUpdateCount: 0,\n    dataUpdatedAt: hasData ? (initialDataUpdatedAt ?? Date.now()) : 0,\n    error: null,\n    errorUpdateCount: 0,\n    errorUpdatedAt: 0,\n    fetchFailureCount: 0,\n    fetchFailureReason: null,\n    fetchMeta: null,\n    isInvalidated: false,\n    status: hasData ? 'success' : 'pending',\n    fetchStatus: 'idle',\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0RA,IAAa,QAAb,cAKUA,kBAAAA,UAAU;CAKlB;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA,YAAY,QAA6D;EACvE,MAAM;EAEN,KAAK,uBAAuB;EAC5B,KAAK,kBAAkB,OAAO;EAC9B,KAAK,WAAW,OAAO,OAAO;EAC9B,KAAK,YAAY,CAAC;EAClB,KAAK,UAAU,OAAO;EACtB,KAAK,SAAS,KAAK,QAAQ,cAAc;EACzC,KAAK,WA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