import type { RawValueExpectation, ValueExpectation } from "../../expect/types";
import type { ResolvedTargetBase } from "../../types";

export interface PingStats {
  alive: boolean;
  avgLatencyMs: null | number;
  maxLatencyMs: null | number;
  minLatencyMs: null | number;
  packetLoss: number;
  received: number;
  transmitted: number;
}

export interface PingTargetConfig {
  count?: number;
  host: string;
  packetSize?: number;
}

export interface RawIcmpExpectConfig {
  alive?: boolean;
  avgLatencyMs?: RawValueExpectation;
  durationMs?: RawValueExpectation;
  maxLatencyMs?: RawValueExpectation;
  packetLossPercent?: RawValueExpectation;
}

export interface ResolvedIcmpExpectConfig {
  alive: boolean;
  avgLatencyMs?: ValueExpectation;
  durationMs?: ValueExpectation;
  maxLatencyMs?: ValueExpectation;
  packetLossPercent?: ValueExpectation;
}

export interface ResolvedPingConfig {
  count: number;
  host: string;
  packetSize: number;
}

export interface ResolvedPingTarget extends ResolvedTargetBase {
  expect?: ResolvedIcmpExpectConfig;
  group: string;
  icmp: ResolvedPingConfig;
  intervalMs: number;
  name: null | string;
  rawExpect?: RawIcmpExpectConfig;
  timeoutMs: number;
  type: "icmp";
}
