import type { SessionToken } from "./cookies/d8a_cookies.ts"; export type ConsentValue = "granted" | "denied"; export type ConsentKey = "ad_storage" | "analytics_storage" | "ad_user_data" | "ad_personalization"; export type ConsentState = Partial> & Record; export type RuntimeEvent = { name: string; params: Record; }; export type BrowserContext = { dl: string; dt: string; dr: string; dh: string; ul: string; sr: string; }; export type PropertyConfig = Record & { server_container_url?: string; send_page_view?: boolean; }; export type RuntimeState = { jsDate: Date | null; pageLoadMs: number | null; propertyIds: string[]; propertyConfigs: Record; primaryPropertyId: string; consent: ConsentState; consentDefault: ConsentState; consentUpdate: ConsentState; consentGtag: ConsentState; consentDefaultGtag: ConsentState; consentUpdateGtag: ConsentState; userId: string | null; set: Record; linker: LinkerConfig; incomingDl: IncomingDlPayload | null; events: RuntimeEvent[]; __onEvent: null | ((name: string, params: Record) => void); __onConfig: null | ((propertyId: string, patchCfg: Record) => void); __onSet: null | ((args: SetCommandArgs) => void); hitCounter: number; sessionEngagementMs: number; sessionEngaged: boolean; anonCid: string | null; cookieAttrsSig: Record | null; sharedSessionTokens: SessionToken[] | null; sharedSessionValue: string | null; emInstalled: boolean; emSiteSearchFired: boolean; __lastEffectiveAnalyticsStorage: ConsentValue | undefined; __consentPingInitScheduled?: boolean; __consentPingInitDone?: boolean; }; export type D8aTagData = Record & { __d8aInstallResults?: Record; __d8aInstallResultsByDataLayer?: Record; }; export type WindowLike = { d8aDataLayerName?: unknown; d8aGlobalName?: unknown; d8aGtagDataLayerName?: unknown; document: { cookie: string; title?: string; hidden?: boolean; visibilityState?: string; referrer?: string; currentScript?: unknown; hasFocus?: () => boolean; addEventListener?: (type: string, listener: (...args: unknown[]) => void, options?: boolean | { capture?: boolean; passive?: boolean; once?: boolean; }) => void; removeEventListener?: (type: string, listener: (...args: unknown[]) => void, options?: boolean | { capture?: boolean; passive?: boolean; once?: boolean; }) => void; }; location?: { href?: string; hostname?: string; protocol?: string; search?: string; pathname?: string; }; history?: { replaceState?: (data: unknown, unused: string, url?: string) => void; }; navigator?: { language?: string; userAgent?: string; userLanguage?: string; userAgentData?: unknown; sendBeacon?: null | ((url: string | URL, data?: SendBeaconData) => boolean); }; screen?: { width?: number; height?: number; }; addEventListener?: (type: string, listener: (...args: unknown[]) => void, options?: boolean | { capture?: boolean; passive?: boolean; once?: boolean; }) => void; removeEventListener?: (type: string, listener: (...args: unknown[]) => void, options?: boolean | { capture?: boolean; passive?: boolean; once?: boolean; }) => void; setTimeout: (handler: (...args: unknown[]) => void, timeout?: number) => number; clearTimeout: (id: number) => void; d8a_tag_data?: D8aTagData; hasFocus?: () => boolean; }; export type LinkerUrlPosition = "query" | "fragment"; export type LinkerConfig = { domains: string[]; accept_incoming?: boolean; decorate_forms?: boolean; url_position?: LinkerUrlPosition; }; export type IncomingDlPayload = { ts: number; cookies: Record; }; export type SetCommandArgs = { type: "object"; obj: Record; } | { type: "field"; field: string; value: unknown; }; export type WindowLikeTransport = { navigator?: { sendBeacon?: null | ((url: string | URL, data?: SendBeaconData) => boolean); }; fetch?: (url: string, opts?: unknown) => Promise<{ status?: number; }>; }; export type SendBeaconData = string | Blob | FormData | URLSearchParams | ArrayBuffer | null | undefined;