// Berth Status Enum
export enum BerthStatus {
  Available = 'Available',
  Waitlist = 'Waitlist',
  Reserved = 'Reserved',
  Sold = 'Sold'
}

// Berth Area Enum
export enum BerthArea {
  A = 'A',
  B = 'B',
  C = 'C',
  D = 'D',
  E = 'E'
}

// Side Pontoon Options
export enum SidePontoon {
  No = 'No',
  QuaySB = 'Quay SB',
  QuayPT = 'Quay PT',
  QuaySBYesPT = 'Quay SB, Yes PT',
  QuayPTYesSB = 'Quay PT, Yes SB',
  YesSB = 'Yes SB',
  YesPT = 'Yes PT'
}

// Mooring Type Options
export enum MooringType {
  SidePierMed = 'Side Pier / Med Mooring',
  DoubleMed = '2x Med Mooring',
  SidePierFinger = 'Side Pier / Finger',
  FingerMed = 'Finger / Med Mooring',
  DoubleFinger = '2x Finger'
}

// Cleat Type Options
export enum CleatType {
  A3 = 'A3',
  A5 = 'A5'
}

// Cleat Capacity Options
export enum CleatCapacity {
  TwentyToTwentyFour = '20-24 ton break load',
  TenToFourteen = '10-14 ton break load'
}

// Bollard Type Options
export enum BollardType {
  TypeA = 'Bull bollard type A',
  TypeB = 'Bull bollard type B'
}

// Bollard Capacity Options
export enum BollardCapacity {
  Twenty = '20 ton break load',
  Forty = '40 ton break load'
}

// Access Options
export enum Access {
  CarThreeTonToVessel = 'Car (3t) to Vessel',
  CarToVessel = 'Car to Vessel',
  CarToQuaiCartToVessel = 'Car to Quai, Cart to Vessel',
  CartToVessel = 'Cart to Vessel',
  CarThreeAndHalfTonToVessel = 'Car (3.5t) to Vessel'
}

// Interested Party with status info
export interface InterestedParty extends Interest {
  linkId?: number; // ID of the link record if needed
}

export interface Berth {
  Id: number;
  "Mooring Number": string; // e.g., 'A5'
  Area: string; // Area enum values: A, B, C, D, E
  Status: string; // BerthStatus enum values
  "Nominal Boat Size": number; // in feet (imperial)
  "Nominal Boat Size (Metric)": number; // formula field - read only
  "Water Depth": number; // in feet
  "Water Depth (Metric)": number; // formula field - read only
  Length: number; // in feet
  "Length (Metric)": number; // formula field - read only
  Width: number; // in feet
  "Width (Metric)": number; // formula field - read only
  Draft: number; // in feet (was previously "Depth")
  "Draft (Metric)": number; // formula field - read only
  "Side Pontoon": string; // SidePontoon enum values
  "Power Capacity": number;
  Voltage: number;
  "Mooring Type": string; // MooringType enum values
  "Cleat Type": string; // CleatType enum values
  "Cleat Capacity": string; // CleatCapacity enum values
  "Bollard Type": string; // BollardType enum values
  "Bollard Capacity": string; // BollardCapacity enum values
  "Bow Facing": string;
  Access: string; // Access enum values
  Price: number;
  "Interested Parties"?: InterestedParty[];
  "Created At"?: string;
  "Updated At"?: string;
}

export interface BerthsResponse {
  list: Berth[];
}

export interface EOIDocument {
  mimetype: string;
  size: number;
  title: string;
  url: string;
  icon: string;
}

export type InterestSalesProcessLevel =
  | "General Qualified Interest"
  | "Specific Qualified Interest"
  | "LOI and NDA Sent"
  | "Signed LOI and NDA"
  | "Made Reservation"
  | "Contract Negotiation"
  | "Contract Negotiations Finalized"
  | "Contract Signed";

export const InterestSalesProcessLevelFlow = [
  "General Qualified Interest",
  "Specific Qualified Interest",
  "LOI and NDA Sent",
  "Signed LOI and NDA",
  "Made Reservation",
  "Contract Negotiation",
  "Contract Negotiations Finalized",
  "Contract Signed",
];

export type InterestLeadCategory = "General" | "Friends and Family";

export const InterestLeadCategoryFlow = ["General", "Friends and Family"];

export type ContactMethodPreferred = "Email" | "Phone";

export const ContactMethodPreferredFlow = ["Email", "Phone"];

export type EOIStatus = "Awaiting Further Details" | "Waiting for Signatures" | "Signed";

export const EOIStatusFlow = ["Awaiting Further Details", "Waiting for Signatures", "Signed"];

export type BerthInfoSentStatus = "Pending" | "Yes";

export const BerthInfoSentStatusFlow = ["Pending", "Yes"];

export type ContractSentStatus = "Pending" | "Yes";

export const ContractSentStatusFlow = ["Pending", "Yes"];

export type Deposit10PercentStatus = "Awaiting Further Details" | "Pending" | "Received";

export const Deposit10PercentStatusFlow = ["Awaiting Further Details", "Pending", "Received"];

export type ContractStatus = "Pending" | "40% Received" | "Complete";

export const ContractStatusFlow = ["Pending", "40% Received", "Complete"];

export interface Interest {
  Id: number;
  "Full Name": string;
  "Yacht Name": string;
  Length: string;
  Address: string;
  "Email Address": string;
  Berths_id: number;
  Berth: Berth;
  "Sales Process Level": InterestSalesProcessLevel;
  "Phone Number": string;
  "Extra Comments": string;
  "Berth Size Desired": string;
  "LOI-NDA Document": string;
  "Berth Recommendations": number;
  "Date Added": string;
  Width: string;
  Depth: string;
  "Created At": string;
  "Request More Information": string;
  Source: string;
  "Place of Residence": string;
  "Contact Method Preferred": ContactMethodPreferred;
  "Request Form Sent": string;
  "Berth Number": string;
  "EOI Time Sent": string;
  "EOI Document": EOIDocument[];
  "Lead Category": string;
  "Request More Info - To Sales": string;
  "EOI Send to Sales": string;
  "Time LOI Sent": string;
  Berths: number;
  "EOI Status": EOIStatus;
  "Berth Info Sent Status": BerthInfoSentStatus;
  "Contract Sent Status": ContractSentStatus;
  "Deposit 10% Status": Deposit10PercentStatus;
  "Contract Status": ContractStatus;
  // EOI Link fields
  "EOI Client Link"?: string;
  "EOI David Link"?: string;
  "EOI Oscar Link"?: string;
  // New signature link fields
  "Signature Link Client"?: string;
  "Signature Link CC"?: string;
  "Signature Link Developer"?: string;
  // Embedded signature link fields
  "EmbeddedSignatureLinkClient"?: string;
  "EmbeddedSignatureLinkCC"?: string;
  "EmbeddedSignatureLinkDeveloper"?: string;
  // Documenso document ID for generated documents
  "documensoID"?: string;
}

export interface InterestsResponse {
  list: Interest[];
}

// Expense tracking types
export interface ExpenseReceipt {
  id: string;
  url: string;
  signedUrl: string;
  title: string;
  mimetype: string;
  size: number;
  width: number;
  height: number;
  thumbnails: {
    tiny: { signedUrl: string };
    small: { signedUrl: string };
    card_cover: { signedUrl: string };
  };
}

export type ExpenseCategory = "Food/Drinks" | "Shop" | "Online" | "Other";
export type PaymentMethod = "Cash" | "Card";

export interface Expense {
  Id: number;
  "Establishment Name": string;
  Price: string; // Format: "45.99" (numeric value only)
  currency: string; // ISO currency code: "EUR", "USD", "GBP", etc.
  "Payment Method": PaymentMethod;
  Category: ExpenseCategory;
  Payer: string;
  Time: string; // Format: "YYYY-MM-DD HH:mm:ss"
  Contents: string; // Long text description
  Receipt: ExpenseReceipt[];
  Paid: boolean;
  CreatedAt: string;
  UpdatedAt: string;
  
  // Computed properties (added by API)
  PriceNumber?: number; // Parsed price as number for calculations
  CurrencySymbol?: string; // Display symbol: "€", "$", "£"
  PriceUSD?: number; // Converted USD amount
  ConversionRate?: number; // Exchange rate used (from currency to USD)
  ConversionDate?: string; // When rate was fetched
  DisplayPrice?: string; // "€45.99 ($48.12)" or just "€45.99" if USD
  DisplayPriceUSD?: string; // "$48.12" formatted USD amount
  FormattedDate?: string; // Formatted date string
  FormattedTime?: string; // Formatted time string
  FormattedDateTime?: string; // Formatted date-time string
}

export interface ExpenseFilters {
  startDate?: string;
  endDate?: string;
  payer?: string;
  category?: ExpenseCategory;
}

export interface ExpensesResponse {
  list: Expense[];
  PageInfo: PageInfo;
}
