package dto

import responsedto "wucher/internal/transport/http/dto/response"

type FMReportAttributes struct {
	ID                    string                             `json:"id,omitempty" example:"019d6772-471c-7b70-b42a-d94020ef61e4"`
	ReportCode            *string                            `json:"report_code" example:"EC-135-1"`
	TakeoverID            string                             `json:"takeover_id,omitempty" example:"019e8713-aa19-7fb7-a510-a0332dc69697"`
	FlightID              string                             `json:"flight_id,omitempty" example:"019d6774-98e8-7fba-9ef4-3795c0da8a13"`
	FlightInspectionID    string                             `json:"flight_inspection_id,omitempty" example:"019d6772-471c-7b70-b42a-d94020ef61e4"`
	Engine1GpcN1          *string                            `json:"engine1_gpc_n1" example:"GPC/N1 63.2"`
	Engine1PtcN2          *string                            `json:"engine1_ptc_n2" example:"PTC/N2 61.8"`
	Engine2GpcN1          *string                            `json:"engine2_gpc_n1" example:"GPC/N1 62.9"`
	Engine2PtcN2          *string                            `json:"engine2_ptc_n2" example:"PTC/N2 61.5"`
	CompletedAt           string                             `json:"completed_at,omitempty" example:"2026-04-20T10:15:00Z"`
	CompletedBy           string                             `json:"completed_by,omitempty" example:"019d61db-53c6-7280-87ec-e65f205c6d3b"`
	PilotName             *string                            `json:"pilot_name,omitempty" example:"John Doe"`
	HelicopterIdentifier  *string                            `json:"helicopter_identifier,omitempty" example:"OE-TEST"`
	Flight                *responsedto.FlightResource        `json:"flight,omitempty"`
	Missions              []responsedto.MissionResource      `json:"missions,omitempty"`
	FlightInspection      *FlightInspectionResource          `json:"flight_inspection,omitempty"`
	AfterFlightInspection *AfterFlightInspectionResource     `json:"after_flight_inspection,omitempty"`
	FleetStatus           *responsedto.FleetStatusResource   `json:"fleet_status,omitempty"`
	HelicopterUsage       *HelicopterUsageResource           `json:"helicopter_usage,omitempty"`
	UsageBreakdown        *FMReportUsageBreakdown            `json:"usage_breakdown,omitempty"`
	TakeoverFiles         []responsedto.TakeoverFileResource `json:"takeover_files,omitempty"`
	FMReportAttachments   *FMReportAttachments               `json:"fm_report_attachments,omitempty"`
	CreatedAt             string                             `json:"created_at,omitempty" example:"2026-04-20T08:00:00Z"`
	UpdatedAt             string                             `json:"updated_at,omitempty" example:"2026-04-20T08:00:00Z"`
}

type FMReportAirframeValues struct {
	Hours  float64 `json:"hours" example:"1523.5"`
	Cycles float64 `json:"cycles" example:"320"`
}

type FMReportEngineValues struct {
	Hours   float64 `json:"hours" example:"1523.5"`
	GpcNgN1 float64 `json:"gpc_ng_n1" example:"63.2"`
	PtcNfN2 float64 `json:"ptc_nf_n2" example:"61.8"`
	Ccc     float64 `json:"ccc" example:"44"`
}

// FMReportCountersValues are the "Landings, Complaints & Sign-off" counters.
type FMReportCountersValues struct {
	Landings         float64 `json:"landings" example:"120"`
	FlightReports    float64 `json:"flight_reports" example:"80"`
	HookReleases     float64 `json:"hook_releases" example:"10"`
	RotorBrakeCycles float64 `json:"rotor_brake_cycles" example:"8"`
}

// FMReportUsageSnapshot is one row of the breakdown table (all columns for a single
// prev/today/total bucket). An absent engine (single-engine aircraft) stays zero-valued.
type FMReportUsageSnapshot struct {
	Airframe FMReportAirframeValues `json:"airframe"`
	Engine1  FMReportEngineValues   `json:"engine_1"`
	Engine2  FMReportEngineValues   `json:"engine_2"`
	Counters FMReportCountersValues `json:"counters"`
}

// FMReportUsageBreakdown is the prev/today/total table shown on the FM report page,
// grouped by row: prev = total - today (the prior-day cumulative), today = this flight's
// contribution, total = the cumulative to date.
type FMReportUsageBreakdown struct {
	Prev  FMReportUsageSnapshot `json:"prev"`
	Today FMReportUsageSnapshot `json:"today"`
	Total FMReportUsageSnapshot `json:"total"`
}

type FMReportAttachments struct {
	AdditionalFMReport []FMReportAttachmentItem `json:"additional_fm_report,omitempty"`
	Briefing           []FMReportAttachmentItem `json:"briefing,omitempty"`
	WeightBalance      []FMReportAttachmentItem `json:"weight_balance,omitempty"`
	OFP                []FMReportAttachmentItem `json:"ofp,omitempty"`
}

type FMReportAttachmentItem struct {
	ID          string  `json:"id"`
	FileID      string  `json:"file_id"`
	DownloadURL *string `json:"download_url,omitempty"`
}

type FMReportResource struct {
	Type       string             `json:"type" example:"fm_report"`
	ID         string             `json:"id,omitempty" example:"019d6772-471c-7b70-b42a-d94020ef61e4"`
	Attributes FMReportAttributes `json:"attributes"`
}

type FMReportResponse struct {
	Data FMReportResource `json:"data"`
}

type FMReportListResponse struct {
	Data []FMReportResource `json:"data"`
	Meta struct {
		PageNumber int   `json:"page_number" example:"1"`
		PageSize   int   `json:"page_size" example:"20"`
		Total      int64 `json:"total" example:"1"`
	} `json:"meta"`
}
