use crate::inspect::smp::services::*;

pub(super) struct PeerSiteTraceInputs {
    pub(super) peer_site_selector_candidate_owner_strip: String,
    pub(super) peer_site_selector_candidate_persisted_tag_hex: String,
    pub(super) peer_site_selector_candidate_selector_lane: String,
    pub(super) peer_site_selector_candidate_secondary_payload_lane: String,
    pub(super) peer_site_selector_candidate_post_secondary_byte_status: String,
    pub(super) peer_site_selector_candidate_class_identity_status: String,
    pub(super) peer_site_selector_candidate_helper_linkage: Vec<String>,
    pub(super) peer_site_selector_candidate_saved_payload_summaries:
        Vec<SmpSavePlacedStructureProfilePayloadSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_payload_delta_summaries:
        Vec<SmpSavePlacedStructureProfilePayloadDeltaSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_footer_padding_summaries:
        Vec<SmpSavePlacedStructureProfileFooterPaddingSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_companion_byte_summaries:
        Vec<SmpSavePlacedStructureProfileCompanionByteSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_policy_trailing_word_summaries:
        Vec<SmpSavePlacedStructurePolicyTrailingWordSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries:
        Vec<SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_nonzero_companion_building_family_overlap_summaries:
        Vec<SmpSavePlacedStructureNonzeroCompanionBuildingFamilyOverlapSummaryEntry>,
    pub(super) peer_site_selector_candidate_saved_nonzero_companion_building_family_residue_summaries:
        Vec<SmpSavePlacedStructureNonzeroCompanionBuildingFamilyResidueSummaryEntry>,
    pub(super) peer_site_persisted_selector_bundle_fields: Vec<String>,
    pub(super) peer_site_rebuilt_transient_followon_fields: Vec<String>,
    pub(super) peer_site_shellless_minimum_persisted_identity_status: String,
    pub(super) peer_site_shellless_minimum_persisted_identity_inputs: Vec<String>,
    pub(super) peer_site_restore_input_fields: Vec<String>,
    pub(super) peer_site_runtime_input_fields: Vec<String>,
    pub(super) peer_site_runtime_reconstruction_status: String,
    pub(super) peer_site_runtime_reconstruction_steps: Vec<String>,
}

pub(super) fn build_peer_site_trace_inputs(
    analysis: &SmpSaveCompanyChairmanAnalysisReport,
) -> PeerSiteTraceInputs {
    let peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries =
        summarize_peer_site_selector_candidate_saved_nonzero_companion_name_pairs(analysis);

    PeerSiteTraceInputs {
        peer_site_selector_candidate_owner_strip:
            "0x0045c150 -> 0x0045c310 -> 0x0045c36e -> 0x00456100 -> 0x00455b70"
                .to_string(),
        peer_site_selector_candidate_persisted_tag_hex: "0x5dc1".to_string(),
        peer_site_selector_candidate_selector_lane: "[owner+0x23e]".to_string(),
        peer_site_selector_candidate_secondary_payload_lane: "[owner+0x242]".to_string(),
        peer_site_selector_candidate_post_secondary_byte_status:
            "unresolved 0x5dc1 post-secondary discriminator byte after the repeated secondary payload string"
                .to_string(),
        peer_site_selector_candidate_class_identity_status:
            "grounded_direct_local_helper_strip".to_string(),
        peer_site_selector_candidate_helper_linkage: vec![
            "0x0040ceab -> 0x0045c150".to_string(),
            "0x0040d1a1 -> 0x0045c310".to_string(),
            "0x0040cd70 seeds [site+0x3cc/+0x3d0] from 0x62b2fc / 0x62b268".to_string(),
            "0x0040d1e1 -> 0x0045c3c0 consumes the same owner family's [site+0x246] child lane"
                .to_string(),
        ],
        peer_site_selector_candidate_saved_payload_summaries:
            summarize_peer_site_selector_candidate_saved_payloads(analysis),
        peer_site_selector_candidate_saved_payload_delta_summaries:
            summarize_peer_site_selector_candidate_saved_payload_deltas(analysis),
        peer_site_selector_candidate_saved_footer_padding_summaries:
            summarize_peer_site_selector_candidate_saved_footer_padding(analysis),
        peer_site_selector_candidate_saved_companion_byte_summaries:
            summarize_peer_site_selector_candidate_saved_companion_bytes(analysis),
        peer_site_selector_candidate_saved_policy_trailing_word_summaries:
            summarize_peer_site_selector_candidate_saved_policy_trailing_words(analysis),
        peer_site_selector_candidate_saved_nonzero_companion_building_family_overlap_summaries:
            summarize_peer_site_selector_candidate_saved_nonzero_companion_building_family_overlaps(
                &peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries,
            ),
        peer_site_selector_candidate_saved_nonzero_companion_building_family_residue_summaries:
            summarize_peer_site_selector_candidate_saved_nonzero_companion_building_family_residues(
                &peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries,
            ),
        peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries,
        peer_site_persisted_selector_bundle_fields: vec![
            "0x5dc1 payload lane [owner+0x23e] restored by 0x0045c150 and later fed into 0x0045c36e"
                .to_string(),
            "0x5dc1 payload lane [owner+0x242] restored by 0x0045c150 as the repeated secondary payload string"
                .to_string(),
            "0x5dc1 post-secondary one-byte residue after the repeated secondary payload string"
                .to_string(),
            "broader saved child/runtime selector bundle [owner+0x246/+0x24e/+0x252] emitted by 0x0040c980 -> 0x0045b560"
                .to_string(),
        ],
        peer_site_rebuilt_transient_followon_fields: vec![
            "[owner+0x246] primary transient handle rebuilt from payload strings by 0x0045c310"
                .to_string(),
            "[owner+0x24a] ambient transient rebuilt through 0x0045b210 after 0x0045b5f0 refreshes the current derived position scalar"
                .to_string(),
            "transient roots [owner+0x24e/+0x256/+0x25a/+0x25e] cleared by 0x0045c150 before 0x0045b5f0 / 0x0045b6f0 rebuild follow-on variant state"
                .to_string(),
            "larger animation/light/random-sound variant family rooted in [owner+0x23e] rebuilt through 0x0045b6f0 / 0x0045b760 / 0x0045baf0"
                .to_string(),
        ],
        peer_site_shellless_minimum_persisted_identity_status:
            "name_pair_and_post_secondary_byte_minimum_identity_subset_child_runtime_bundle_rebuild_followon"
                .to_string(),
        peer_site_shellless_minimum_persisted_identity_inputs: vec![
            "[site+0x3cc] cached source placed-structure id".to_string(),
            "[site+0x3d0] cached companion candidate/profile id".to_string(),
            "0x5dc1 payload lane [owner+0x23e]".to_string(),
            "0x5dc1 payload lane [owner+0x242]".to_string(),
            "0x5dc1 post-secondary one-byte residue".to_string(),
        ],
        peer_site_restore_input_fields: vec![
            "[site+0x3cc] saved placed-structure id feeding 0x62b2fc".to_string(),
            "[site+0x3d0] saved companion-region id from [placed+0x173] feeding 0x62b268"
                .to_string(),
            "0x5dc1 payload lane [owner+0x23e] feeding 0x0045c36e selector arg 1".to_string(),
            "0x5dc1 payload lane [owner+0x242] carrying the restored secondary payload string"
                .to_string(),
            "0x5dc1 post-secondary one-byte residue after the repeated secondary payload string"
                .to_string(),
        ],
        peer_site_runtime_input_fields: vec![
            "[site+0x04] live backing-record selector consumed by 0x0047efe0 / 0x0047fd50"
                .to_string(),
            "[site+0x2a8] linked peer-site id consumed by 0x0040d1f0".to_string(),
            "[peer+0x08] route-entry anchor id consumed by 0x0047dda0".to_string(),
        ],
        peer_site_runtime_reconstruction_status:
            "restore_subset_and_bring_up_reconstruct_runtime_subset".to_string(),
        peer_site_runtime_reconstruction_steps: vec![
            "[site+0x04] restored from 0x0045c150 -> 0x0045c310 -> 0x0045c36e -> 0x00456100 -> 0x00455b70 -> 0x0052edf0"
                .to_string(),
            "[site+0x2a8] rewritten by 0x0040f6d0 after 0x00481390 returns the linked peer id"
                .to_string(),
            "[peer+0x08] refreshed during 0x00444690 -> 0x004133b0 -> 0x0040ee10 -> 0x0040edf6 -> 0x00480710"
                .to_string(),
            "world-cell owner and linked-site chains [cell+0xd4]/[cell+0xd6] republished during 0x00480710 via 0x0042bbf0/0x0042bbb0 and 0x0042c9f0/0x0042c9a0"
                .to_string(),
        ],
    }
}
