use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpAsciiPreview {
    pub offset: usize,
    pub byte_len: usize,
    pub preview: String,
    pub truncated: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpSaveTaggedCollectionHeaderProbe {
    pub profile_family: String,
    pub source_kind: String,
    pub semantic_family: String,
    pub metadata_tag_offset: usize,
    pub records_tag_offset: usize,
    pub close_tag_offset: usize,
    pub direct_collection_flag: u32,
    pub direct_collection_flag_hex: String,
    pub direct_record_stride: u32,
    pub direct_record_stride_hex: String,
    pub live_id_bound: u32,
    pub live_id_bound_hex: String,
    pub live_record_count: u32,
    pub live_record_count_hex: String,
    pub header_words: Vec<u32>,
    pub header_hex_words: Vec<String>,
    pub evidence: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpSaveUnclassifiedTaggedCollectionHeaderProbe {
    pub profile_family: String,
    pub source_kind: String,
    pub semantic_family: String,
    pub metadata_tag: u32,
    pub metadata_tag_hex: String,
    pub records_tag: u32,
    pub records_tag_hex: String,
    pub close_tag: u32,
    pub close_tag_hex: String,
    pub metadata_tag_offset: usize,
    pub records_tag_offset: usize,
    pub close_tag_offset: usize,
    pub records_span_len: usize,
    pub direct_collection_flag: u32,
    pub direct_collection_flag_hex: String,
    pub direct_record_stride: u32,
    pub direct_record_stride_hex: String,
    pub live_id_bound: u32,
    pub live_id_bound_hex: String,
    pub live_record_count: u32,
    pub live_record_count_hex: String,
    pub header_words: Vec<u32>,
    pub header_hex_words: Vec<String>,
    pub evidence: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpSaveTrainCollectionDirectoryEntryProbe {
    pub live_entry_id: u32,
    pub payload_relative_offset: u32,
    pub payload_relative_offset_hex: String,
    pub payload_absolute_offset: usize,
    pub previous_live_entry_id: u32,
    pub previous_live_entry_id_hex: String,
    pub next_live_entry_id: u32,
    pub next_live_entry_id_hex: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpSaveTrainCollectionDirectoryProbe {
    pub profile_family: String,
    pub source_kind: String,
    pub semantic_family: String,
    pub metadata_tag_offset: usize,
    pub records_tag_offset: usize,
    pub close_tag_offset: usize,
    pub directory_root_dword_index: usize,
    pub directory_entry_dword_count: usize,
    pub live_record_count: u32,
    pub live_id_bound: u32,
    #[serde(default)]
    pub chain_head_live_entry_id: Option<u32>,
    #[serde(default)]
    pub chain_tail_live_entry_id: Option<u32>,
    pub entries: Vec<SmpSaveTrainCollectionDirectoryEntryProbe>,
    pub evidence: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SmpSaveRegionProfileEntryProbe {
    pub entry_index: usize,
    pub row_relative_offset: usize,
    pub name: String,
    pub trailing_weight_f32: f32,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SmpSaveRegionProfileCollectionProbe {
    pub direct_collection_flag: u32,
    pub entry_stride: u32,
    pub live_id_bound: u32,
    pub live_record_count: u32,
    pub entry_start_relative_offset: usize,
    pub trailing_padding_len: usize,
    #[serde(default)]
    pub entries: Vec<SmpSaveRegionProfileEntryProbe>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SmpSaveDwordCandidate {
    pub label: String,
    pub relative_offset: usize,
    pub relative_offset_hex: String,
    pub raw_u32: u32,
    pub raw_u32_hex: String,
    pub value_i32: i32,
    pub value_f32: f32,
}
