import type {Cell} from "../../utils/cellStore.ts";
import type {LogRecord} from "./useLogs.ts";

/**
 * Zustand store definition for managing user preferences related to logging.
 *
 * Includes flags for toggling relative timestamps and automatic scroll behavior.
 */
export type LoggingSettings = {
  /** Whether to display log timestamps as relative (e.g., "2m 15s ago") instead of absolute. */
  showRelativeTime: boolean;
  /** Updates the `showRelativeTime` setting. */
  setShowRelativeTime: (showRelativeTime: boolean) => void;
};

/**
 * Props for any component that renders a single log message entry.
 *
 * @param recordCell - A reactive `Cell` containing a single `LogRecord`.
 * @param onUpdate - Optional callback triggered when the log entry updates.
 */
export type MessageComponentProps = {
  recordCell: Cell<LogRecord>,
  onUpdate?: () => void,
};

/**
 * Key used for the experiment filter predicate in the filter map, to exclude experiment logs from the developer logs.
 */
export const EXPERIMENT_FILTER_KEY = "experiment_filter";
export const EXPERIMENT_LOGGER_NAME = "experiment";
