use super::super::entries::build_periodic_company_service_entries;
use super::super::near_city_acquisition::build_near_city_acquisition_trace_inputs;
use super::super::notes::{
    build_linked_transit_trace_inputs, build_periodic_company_service_notes,
};
use super::super::peer_site::build_peer_site_trace_inputs;
use super::linked_transit_fields::build_linked_transit_report_fields;
use super::near_city_fields::build_near_city_report_fields;
use super::peer_site_fields::build_peer_site_report_fields;
use crate::inspect::smp::services::*;

pub(in crate::inspect::smp) fn build_periodic_company_service_trace_report(
    analysis: &SmpSaveCompanyChairmanAnalysisReport,
) -> SmpPeriodicCompanyServiceTraceReport {
    let profile_family = analysis.profile_family.clone();
    let selected_company_id = analysis.selected_company_id;
    let region_record_body_present = analysis.region_record_triplets.is_some();
    let placed_structure_record_body_present = analysis.placed_structure_record_triplets.is_some();
    let infrastructure_asset_side_buffer_present =
        analysis.placed_structure_dynamic_side_buffer.is_some();
    let world_issue_37_present = analysis.world_issue_37.is_some();
    let world_finance_neighborhood_present = analysis.world_finance_neighborhood.is_some();

    let peer_site = build_peer_site_trace_inputs(analysis);
    let near_city = build_near_city_acquisition_trace_inputs(analysis);
    let linked_transit = build_linked_transit_trace_inputs();

    let peer_site_fields = build_peer_site_report_fields(&peer_site);
    let near_city_fields = build_near_city_report_fields(&near_city);
    let linked_transit_fields = build_linked_transit_report_fields(&linked_transit);

    let companies = build_periodic_company_service_entries(analysis);
    let notes = build_periodic_company_service_notes(&peer_site, &near_city);

    SmpPeriodicCompanyServiceTraceReport {
        profile_family,
        selected_company_id,
        world_issue_37_present,
        world_finance_neighborhood_present,
        region_record_body_present,
        placed_structure_record_body_present,
        infrastructure_asset_side_buffer_present,
        peer_site_selector_candidate_owner_strip: peer_site_fields
            .peer_site_selector_candidate_owner_strip,
        peer_site_selector_candidate_persisted_tag_hex: peer_site_fields
            .peer_site_selector_candidate_persisted_tag_hex,
        peer_site_selector_candidate_selector_lane: peer_site_fields
            .peer_site_selector_candidate_selector_lane,
        peer_site_selector_candidate_secondary_payload_lane: peer_site_fields
            .peer_site_selector_candidate_secondary_payload_lane,
        peer_site_selector_candidate_post_secondary_byte_status: peer_site_fields
            .peer_site_selector_candidate_post_secondary_byte_status,
        peer_site_selector_candidate_class_identity_status: peer_site_fields
            .peer_site_selector_candidate_class_identity_status,
        peer_site_selector_candidate_helper_linkage: peer_site_fields
            .peer_site_selector_candidate_helper_linkage,
        peer_site_selector_candidate_saved_payload_summaries: peer_site_fields
            .peer_site_selector_candidate_saved_payload_summaries,
        peer_site_selector_candidate_saved_payload_delta_summaries: peer_site_fields
            .peer_site_selector_candidate_saved_payload_delta_summaries,
        peer_site_selector_candidate_saved_footer_padding_summaries: peer_site_fields
            .peer_site_selector_candidate_saved_footer_padding_summaries,
        peer_site_selector_candidate_saved_companion_byte_summaries: peer_site_fields
            .peer_site_selector_candidate_saved_companion_byte_summaries,
        peer_site_selector_candidate_saved_policy_trailing_word_summaries: peer_site_fields
            .peer_site_selector_candidate_saved_policy_trailing_word_summaries,
        peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries:
            peer_site_fields.peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries,
        peer_site_selector_candidate_saved_nonzero_companion_building_family_overlap_summaries:
            peer_site_fields
                .peer_site_selector_candidate_saved_nonzero_companion_building_family_overlap_summaries,
        peer_site_selector_candidate_saved_nonzero_companion_building_family_residue_summaries:
            peer_site_fields
                .peer_site_selector_candidate_saved_nonzero_companion_building_family_residue_summaries,
        peer_site_persisted_selector_bundle_fields: peer_site_fields
            .peer_site_persisted_selector_bundle_fields,
        peer_site_rebuilt_transient_followon_fields: peer_site_fields
            .peer_site_rebuilt_transient_followon_fields,
        peer_site_shellless_minimum_persisted_identity_status: peer_site_fields
            .peer_site_shellless_minimum_persisted_identity_status,
        peer_site_shellless_minimum_persisted_identity_inputs: peer_site_fields
            .peer_site_shellless_minimum_persisted_identity_inputs,
        peer_site_restore_input_fields: peer_site_fields.peer_site_restore_input_fields,
        peer_site_runtime_input_fields: peer_site_fields.peer_site_runtime_input_fields,
        peer_site_runtime_reconstruction_status: peer_site_fields
            .peer_site_runtime_reconstruction_status,
        peer_site_runtime_reconstruction_steps: peer_site_fields
            .peer_site_runtime_reconstruction_steps,
        near_city_acquisition_region_input_fields: near_city_fields
            .near_city_acquisition_region_input_fields,
        near_city_acquisition_peer_input_fields: near_city_fields
            .near_city_acquisition_peer_input_fields,
        near_city_acquisition_company_input_fields: near_city_fields
            .near_city_acquisition_company_input_fields,
        near_city_acquisition_shellless_readiness_status: near_city_fields
            .near_city_acquisition_shellless_readiness_status,
        near_city_acquisition_runtime_backed_input_families: near_city_fields
            .near_city_acquisition_runtime_backed_input_families,
        near_city_acquisition_site_owner_company_projection_status: near_city_fields
            .near_city_acquisition_site_owner_company_projection_status,
        near_city_acquisition_site_self_id_projection_status: near_city_fields
            .near_city_acquisition_site_self_id_projection_status,
        near_city_acquisition_site_cached_tri_lane_projection_status: near_city_fields
            .near_city_acquisition_site_cached_tri_lane_projection_status,
        near_city_acquisition_tri_lane_live_service_status: near_city_fields
            .near_city_acquisition_tri_lane_live_service_status,
        near_city_acquisition_candidate_subtype_projection_status: near_city_fields
            .near_city_acquisition_candidate_subtype_projection_status,
        near_city_acquisition_backing_record_projection_status: near_city_fields
            .near_city_acquisition_backing_record_projection_status,
        near_city_acquisition_nontransport_persisted_source_status: near_city_fields
            .near_city_acquisition_nontransport_persisted_source_status,
        near_city_acquisition_nontransport_persisted_source_candidates: near_city_fields
            .near_city_acquisition_nontransport_persisted_source_candidates,
        near_city_acquisition_tri_lane_save_shape_family_status: near_city_fields
            .near_city_acquisition_tri_lane_save_shape_family_status,
        near_city_acquisition_tri_lane_save_shape_family_candidates: near_city_fields
            .near_city_acquisition_tri_lane_save_shape_family_candidates,
        near_city_acquisition_tri_lane_live_owner_families: near_city_fields
            .near_city_acquisition_tri_lane_live_owner_families,
        near_city_acquisition_tri_lane_candidate_gate_fields: near_city_fields
            .near_city_acquisition_tri_lane_candidate_gate_fields,
        near_city_acquisition_tri_lane_runtime_writer_roles: near_city_fields
            .near_city_acquisition_tri_lane_runtime_writer_roles,
        near_city_acquisition_tri_lane_direct_caller_families: near_city_fields
            .near_city_acquisition_tri_lane_direct_caller_families,
        near_city_acquisition_tri_lane_formula_input_lanes: near_city_fields
            .near_city_acquisition_tri_lane_formula_input_lanes,
        near_city_acquisition_projection_hypotheses: near_city_fields
            .near_city_acquisition_projection_hypotheses,
        near_city_acquisition_remaining_owner_gaps: near_city_fields
            .near_city_acquisition_remaining_owner_gaps,
        near_city_acquisition_region_lane_statuses: near_city_fields
            .near_city_acquisition_region_lane_statuses,
        atlas_candidate_consumers: linked_transit_fields.atlas_candidate_consumers,
        known_bridge_helpers: linked_transit_fields.known_bridge_helpers,
        next_owner_questions: linked_transit_fields.next_owner_questions,
        linked_transit_shellless_readiness_status: linked_transit_fields
            .linked_transit_shellless_readiness_status,
        linked_transit_minimum_persisted_identity_inputs: linked_transit_fields
            .linked_transit_minimum_persisted_identity_inputs,
        linked_transit_live_rebuilt_cache_lanes: linked_transit_fields
            .linked_transit_live_rebuilt_cache_lanes,
        linked_transit_runtime_backed_input_families: linked_transit_fields
            .linked_transit_runtime_backed_input_families,
        linked_transit_remaining_owner_gaps: linked_transit_fields
            .linked_transit_remaining_owner_gaps,
        companies,
        notes,
    }
}
