package kz.konturai.parser.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;
import java.util.Map;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class MarketingAnalysisResponseV2 {

    private String reportTitle;
    private Sections sections;
    private List<String> sources;

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class Sections {
        private MarketOverview marketOverview;
        private TargetAudience targetAudience;
        private CompetitiveEnvironment competitiveEnvironment;
        private DemandAndBehavior demandAndBehavior;
        private CustomerJourney customerJourney;
        private AcquisitionChannels acquisitionChannels;
        private MarketingEconomics marketingEconomics;
        private Bottlenecks bottlenecks;
        private Recommendations recommendations;
    }

    @Setter
    @Getter
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    @AllArgsConstructor
    @NoArgsConstructor
    public static class MarketOverview {
        private String title;
        private MarketOverviewMetrics metrics;
        private MonthlyOnlineIndex monthlyOnlineIndex;
        private Map<String, Integer> geography;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class MarketOverviewMetrics {
        private String onlineDemandIndex;
        private String onlinePotential;
        private String demandGrowthRateYoy;
        private String seasonalityCoefficientSpring;
        private String seasonalityRange;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class MonthlyOnlineIndex {
        private Double january;
        private Double february;
        private Double march;
        private Double april;
        private Double may;
        private Double june;
        private Double july;
        private Double august;
        private Double september;
        private Double october;
        private Double november;
        private Double december;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class TargetAudience {
        private String title;
        private TargetAudienceMetrics metrics;
        @com.fasterxml.jackson.annotation.JsonProperty("income_by_age")
        private Map<String, Integer> incomeByAge;
        private List<AudienceSegment> segments;
        private Map<String, String> ageStructure;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class TargetAudienceMetrics {
        private String totalAudienceSize;
        private String leadingSegmentShare;
        private String aboveAverageIncomeShare;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class AudienceSegment {
        private String name;
        private String share;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class CompetitiveEnvironment {
        private String title;
        private CompetitiveEnvironmentMetrics metrics;
        private List<CompetitorRow> competitors;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class CompetitiveEnvironmentMetrics {
        private String leaderMarketShare;
        private String competitionLevel;
        private String adPressure;
        private String marketLeaderName;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class CompetitorRow {
        private String name;
        private String website;
        private Integer visibilityScore;
        private List<String> keyStrengths;
        private String priceSegment;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class DemandAndBehavior {
        private String title;
        private DemandAndBehaviorMetrics metrics;
        private Map<String, String> searchQueryTypes;
        private Map<String, String> decisionFactors;
        private Map<String, String> reasonsForRefusal;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class DemandAndBehaviorMetrics {
        private String searchVolumeGrowth;
        private String interactionsBeforePurchase;
        private String repeatRefusalProbability;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class CustomerJourney {
        private String title;
        private FunnelMetrics funnelMetrics;
        private ConversionRates conversionRates;
        private FunnelBottlenecks funnelBottlenecks;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class FunnelMetrics {
        private String adTraffic;
        private String siteVisitors;
        private Integer leads;
        private Integer bookings;
        private Integer payments;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class ConversionRates {
        private String leadToBooking;
        private String bookingToPayment;
        private String leadToPaymentTotal;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class FunnelBottlenecks {
        private String leadToBooking;
        private String bookingToPayment;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class AcquisitionChannels {
        private String title;
        private AcquisitionChannelsMetrics metrics;
        private Map<String, String> channelShares;
        private Map<String, ChannelEfficiency> channelEfficiency;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class AcquisitionChannelsMetrics {
        private String searchTrafficShare;
        private String averageLeadCost;
        private String growthPotential;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class ChannelEfficiency {
        private String cost;
        private String status;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class MarketingEconomics {
        private String title;
        private MarketingEconomicsMetrics metrics;
        private FinancialPerformance financialPerformance;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class MarketingEconomicsMetrics {
        private String customerAcquisitionCostCac;
        private String repeatSalesConversion;
        private String roi;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class FinancialPerformance {
        private MonthYearValue marketingExpenses;
        private MonthYearValue clients;
        private MonthYearValue cac;
        private MonthYearValue revenueFromClient;
        private MonthYearValue profitFromClient;

    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class MonthYearValue {
        private String month;
        private String year;

    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class Bottlenecks {
        private String title;
        private Map<String, String> statistics;
        private BottlenecksDetails details;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class BottlenecksDetails {
        private List<String> landing;
        private List<String> leadManagement;
        private List<String> retention;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class Recommendations {
        private String title;
        private List<CorePillar> corePillars;
        private String conclusion;
    }

    @Setter
    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
    public static class CorePillar {
        private String strategy;
        private String action;
    }
}
