import { b as QueryType, v as Query } from "./index-l2pJm30F.js";
import { a as Trigger, c as Triggers, o as TriggerOptions, s as TriggerType, t as FormattedResults } from "./index-D9P9itFa-C0Jtggx-.js";
import { FunctionComponent } from "react";
import { CookieSerializeOptions } from "cookie";

//#region ../../node_modules/@stefanprobst/rehype-extract-toc/src/index.d.ts
interface TocEntry {
  value: string;
  depth: number;
  id?: string;
  children?: Array<TocEntry>;
}
type Toc = Array<TocEntry>;
declare module "vfile" {
  interface DataMap {
    toc: Toc;
  }
}
//#endregion
//#region private/universal/types/util.d.ts
interface QueryItemBase {
  /**
   * The query that should be executed on the server.
   *
   * We are tracking queries as strings instead of objects because we are performing a
   * lot of comparisons and deduplication across the framework, so tracking them as
   * strings is more efficient than stringifying them again for every comparison.
   * Especially because we only need the raw object once at the end, when actually
   * executing the queries.
   */
  query: string;
  database?: string;
  result?: FormattedResults<unknown>[number];
  error?: unknown;
  /**
   * The ID of a particular connection to the database, through which the query should be
   * streamed. Allows for ensuring transport order between multiple writes.
   */
  stream?: string;
}
interface QueryItemRead extends QueryItemBase {
  type: 'read';
  paginationDetails?: {
    countForQueryAtIndex: PaginationInstruction['queryIndex'];
    direction: PaginationInstruction['direction'];
  };
  /** Whether the query is addressing multiple models at once. */
  multiModel?: boolean;
}
interface QueryItemWrite extends QueryItemBase {
  type: 'write';
  hookHash: string;
}
type PaginationInstruction = {
  leafIndex: number;
  hookHash: number;
  queryIndex: number;
  direction: 'before' | 'after';
  cursor: string;
  targetModel?: string;
};
type GeoLocation = {
  country: string | null;
  region: string | null;
  city: string | null;
  latitude: number | null;
  longitude: number | null;
  timeZone: string | null;
};
interface UserAgent {
  browser: string | null;
  browserVersion: string | null;
  deviceType: 'desktop' | 'mobile' | 'tablet' | null;
  os: string | null;
  osVersion: string | null;
}
type PageFetchingOptions = {
  /**
   * This property is used by `useMutation` on the client and allows for processing
   * queries on the edge, after which the edge then makes the results of the queries
   * available to the client using the defined checksum.
   */
  queries?: QueryItemWrite[];
  /**
   * A list of files that are referenced from the queries.
   */
  files?: Map<string, Blob>;
  /**
   * The page to render instead of the requested one in the case that an error has
   * occurred with the provided queries. This is useful if a new page was requested, but
   * the old page should be re-rendered if an error has occurred.
   */
  errorFallback?: string;
  /**
   * By default, the URL in the address bar of the browser will be updated after every
   * page transition. If this is not desired, you can disable it by setting this property
   * to `false`.
   */
  updateAddressBar?: boolean;
};
interface CustomNavigator {
  userAgent: UniversalContext['userAgent'];
  geoLocation: UniversalContext['geoLocation'];
  languages: UniversalContext['languages'];
}
//#endregion
//#region private/universal/utils/index.d.ts
type SetExistingCookie<T$1> = (value: T$1, options?: CookieOptions) => void;
type SetCookie<T$1> = (name: string, ...rest: Parameters<SetExistingCookie<T$1>>) => void;
interface CookieOptions {
  /**
   * Allows for making cookies accessible to the client, instead of allowing only the
   * server to read and modify them.
   */
  client?: true;
  /**
   * Allows for restricting the cookie to a specific URL path of the app.
   *
   * @default '/'
   */
  path?: string;
}
/**
 * Generates a function that can be used to set new cookies.
 *
 * @param serverContext - A server context object.
 *
 * @returns The function that can be used for setting cookies.
 */
//#endregion
//#region private/server/types/index.d.ts
type WaitUntil = (promise: Promise<unknown>) => void;
type TableOfContents = Toc;
interface PageMetadata {
  title?: Set<string>;
  themeColor?: string;
  colorScheme?: 'light' | 'dark';
  description?: string;
  icon?: string;
  openGraph?: {
    title?: string;
    description?: string;
    siteName?: string;
    images?: {
      url: string;
      width: number;
      height: number;
    }[];
  };
  x?: {
    title?: string;
    description?: string;
    card?: string;
    site?: string;
    creator?: string;
    images?: string[];
  };
  htmlClassName?: string;
  bodyClassName?: string;
}
interface TriggerOptions$1<TType extends QueryType = QueryType, TSchema = unknown> extends TriggerOptions<TType, TSchema> {
  /**
   * A list of cookies that are stored on the client.
   */
  cookies: ServerContext['cookies'];
  /**
   * Used for setting new cookies that should be stored on the client, updating existing
   * ones, or deleting existing ones.
   */
  setCookie: SetCookie<string | null>;
  /**
   * Details about the client that is accessing the application.
   */
  navigator: CustomNavigator;
  /**
   * The URL of the page for which the trigger is being executed.
   */
  location: URL;
  /**
   * Indicates whether the incoming query stems from a headless source, meaning the
   * application's browser client or REST API.
   *
   * In such cases, it is advised to validate the authority of the incoming query within
   * triggers, by performing permission validation.
   */
  headless: boolean;
}
type Trigger$1<TStage extends TriggerType, TType extends QueryType, TSchema extends (TStage extends 'before' | 'during' | 'after' ? never : unknown) = never, TOptions extends object = TriggerOptions$1<TType>> = Trigger<TStage, TType, TSchema, TOptions>;
type Triggers$1<TType extends QueryType = QueryType, TSchema = unknown> = Triggers<TType, TSchema, TriggerOptions$1<TType, TSchema>>;
//#endregion
//#region private/server/worker/tree.d.ts
interface Collected {
  queries: (QueryItemRead | QueryItemWrite)[];
  redirect?: string;
  metadata: PageMetadata;
  cookies?: Record<string, {
    value: string | null;
  } & CookieSerializeOptions>;
}
//#endregion
//#region private/server/context.d.ts
/** This context can only be consumed by server components. */
type ServerContext<TParams extends Record<string, unknown> | Array<string> = Record<string, string | Array<string> | null>> = Omit<UniversalContext<TParams>, 'collected'> & {
  cookies: Record<string, string | null>;
  collected: Collected;
  currentLeafIndex: number | null;
  waitUntil: WaitUntil;
  flushSession?: (/** A list of write queries that should be executed. */
  queries: Array<Query>, /** The ID of a particular database connection to stream the queries through. */
  queryStream?: string) => Promise<{
    results?: Collected['queries'];
  }>;
};
//#endregion
//#region private/universal/context.d.ts
/** This context can be consumed by client and server components. */
type UniversalContext<TParams extends Record<string, unknown> | Array<string> = Record<string, string | Array<string> | null>> = {
  url: string;
  params: TParams extends Array<string> ? { [K in TParams[number]]: string } : TParams;
  userAgent: UserAgent;
  geoLocation: GeoLocation;
  addressBarInSync: boolean;
  languages: string[];
  collected: {
    queries: QueryItemWrite[];
  };
};
//#endregion
export { Triggers$1 as a, PageFetchingOptions as c, TriggerOptions$1 as i, TableOfContents as n, SetExistingCookie as o, Trigger$1 as r, CustomNavigator as s, PageMetadata as t };