import type { ImmutableTree, JsonGroup } from "@react-awesome-query-builder/ui"; export type AlertQueryCombinator = "AND" | "OR"; export type AlertQueryOperator = | "equal" | "less" | "less_or_equal" | "greater" | "greater_or_equal"; export type AlertQueryFieldType = "number" | "boolean"; export type ContactAlertSeverity = "HEALTHY" | "WATCH" | "NEED_ACTION"; export enum AlertSharingType { PRIVATE = "PRIVATE", COMPANY = "COMPANY", } export interface AlertQueryField { key: string; label: string; type: AlertQueryFieldType; /** "dollar" = prefix "$", "percent" = suffix "%" */ unit?: "dollar" | "percent"; /** Allowed operators (defaults to all numeric operators). */ operators?: AlertQueryOperator[]; /** Lower bound for numeric value (inclusive). Enforced at input time. */ min?: number; /** Upper bound for numeric value (inclusive). Enforced at input time. */ max?: number; } export interface ContactAlertQueryBuilderProps { /** Current ImmutableTree state — fully controlled. */ value: ImmutableTree; onChange: (newTree: ImmutableTree) => void; fields?: AlertQueryField[]; className?: string; } export interface ContactAlertDialogProps { open: boolean; onOpenChange: (open: boolean) => void; mode?: "create" | "edit"; initialName?: string; initialSeverity?: ContactAlertSeverity; /** Initial query in JsonGroup format (array children1). Converted to ImmutableTree on open. */ initialQuery?: JsonGroup; /** Show "Share across company" checkbox for company admins. */ isCompanyAdmin?: boolean; initialShareAcrossCompany?: boolean; onSave: (data: { name: string; severity: ContactAlertSeverity; /** Backend-compatible ImmutableTree (filterSegment format). */ filterSegment: ImmutableTree; sharingType: AlertSharingType; }) => void; isLoading?: boolean; /** Fired when the underlying QB sanitizeTree throws while saving. */ onError?: (error: Error) => void; className?: string; }