import { z } from 'zod'; /** * Where the request came from, as far as the edge could tell. * * `region` is the human name (`Stockholm County`), not a code — codes differ per * country and a person reads the name. `timezone` is an IANA name, which is what a * UI hands to `Intl.DateTimeFormat` to show the visitor's local time. */ export declare const clientGeo: z.ZodObject<{ country: z.ZodNullable; region: z.ZodNullable; city: z.ZodNullable; timezone: z.ZodNullable; continent: z.ZodNullable; }, z.core.$strip>; export type ClientGeo = z.infer; export declare const EMPTY_GEO: ClientGeo; /** * What kind of thing sent the request. Coarse on purpose: the question a person * asks is "were they on a phone?", and a finer answer than this would be a guess * dressed as a fact — user agents lie, and iPadOS reports itself as a Mac. */ export declare const clientDeviceKind: z.ZodEnum<{ bot: "bot"; desktop: "desktop"; mobile: "mobile"; tablet: "tablet"; unknown: "unknown"; }>; export type ClientDeviceKind = z.infer; /** The browser and operating system, parsed out of the `User-Agent` into names a person reads. */ export declare const clientDevice: z.ZodObject<{ browser: z.ZodNullable; browserVersion: z.ZodNullable; os: z.ZodNullable; osVersion: z.ZodNullable; kind: z.ZodEnum<{ bot: "bot"; desktop: "desktop"; mobile: "mobile"; tablet: "tablet"; unknown: "unknown"; }>; }, z.core.$strip>; export type ClientDevice = z.infer; export declare const clientContext: z.ZodObject<{ userAgent: z.ZodNullable; language: z.ZodNullable; device: z.ZodObject<{ browser: z.ZodNullable; browserVersion: z.ZodNullable; os: z.ZodNullable; osVersion: z.ZodNullable; kind: z.ZodEnum<{ bot: "bot"; desktop: "desktop"; mobile: "mobile"; tablet: "tablet"; unknown: "unknown"; }>; }, z.core.$strip>; geo: z.ZodObject<{ country: z.ZodNullable; region: z.ZodNullable; city: z.ZodNullable; timezone: z.ZodNullable; continent: z.ZodNullable; }, z.core.$strip>; }, z.core.$strip>; export type ClientContext = z.infer; /** * Turn a `User-Agent` into names a person reads. * * Hand-rolled and small on purpose. A full UA database is a dependency that * changes weekly and answers questions nobody here asks (which Nokia model?); this * answers the four a support agent does — which browser, which OS, phone or not, * human or not — and stores the raw string beside them so a wrong answer can be * re-read later. Absent or unrecognised input is `unknown`, never a throw: a request * with a strange UA is still a request. */ export declare function parseUserAgent(userAgent: string | null | undefined): ClientDevice; /** The subset of the web-standard `Headers` this needs — so a test hands in a plain object. */ export interface HeadersLike { get(name: string): string | null; } /** * The first language tag of `Accept-Language`, or null. The header is a weighted * list (`sv-SE,sv;q=0.9,en;q=0.8`) and browsers put the preferred one first, so the * head is the answer; weights are not re-sorted, because no browser sends them out * of order and a hand-written header that does is not worth a parser. */ export declare function preferredLanguage(acceptLanguage: string | null | undefined): string | null; /** * Build a `ClientContext` from a request's headers and whatever geo the host knows. * * This is the runtime-neutral half: the headers are the same on every host, and the * geo is what differs — so a host with none (the node dev server) passes nothing and * gets `EMPTY_GEO`, and one with some (`cloudflareClientContext`) passes what it * normalised. A partial geo is filled out to the full shape so a row always has * every column — and a field that is present but `undefined` counts as absent, since * `Partial` admits it and a spread would carry it through to a schema that does not. */ export declare function clientContextOf(headers: HeadersLike, geo?: Partial): ClientContext; //# sourceMappingURL=client-context.d.ts.map