// Runtime types - used by browser runtime and experiment generator

export type DeviceType = 'Mobile' | 'Tablet' | 'Desktop';

export type RuntimeUrlTargeting = {
  url: string;
  condition: string;
};

export type RuntimeCookieTargeting = {
  cookieName: string;
  cookieValues: string[];
};

export type RuntimeVariant = {
  weight: number;
  redirectUrl?: string;
  globalJavascript?: string;
  globalCSS?: string;
  changes?: Array<Record<string, unknown>>;
};

export type RuntimeExperimentConfig = {
  type: string;
  urlTargeting?: RuntimeUrlTargeting[];
  cookieTargeting?: RuntimeCookieTargeting[];
  deviceTargeting?: string[];
  variants: Record<string, RuntimeVariant>;
  deployed?: string | number;
};

export type RuntimeExperimentData = {
  websiteId?: string;
  ganMeasurementId?: string;
  serverContainerUrl?: string;
  experiments?: Record<string, RuntimeExperimentConfig>;
  eventGoals?: string[];
  variantsUrlSearch?: string;
};

export type RuntimeExperimentResult = {
  expVariantMap: Record<string, string>;
  experimentsToCount: Array<{ id: string } & Record<string, unknown>>;
  allExpVariantMap: Record<string, string>;
  isRedirected?: boolean;
};

export type RuntimeException = {
  message: string;
  code?: string;
  stack?: string;
  timestamp?: number;
  url?: string;
  method?: string;
};
