// Plant Blockchain Types

import { GrowingEnvironment, GrowthMetrics } from '../environment/types';

export interface PlantLocation {
  latitude: number;
  longitude: number;
  address?: string;
  city?: string;
  country?: string;
}

export interface PlantOwner {
  id: string;
  name: string;
  email: string;
  walletAddress?: string;
}

export interface PlantData {
  id: string;
  commonName: string;
  scientificName?: string;
  species?: string;
  genus?: string;
  family?: string;

  // Lineage tracking
  parentPlantId?: string; // Original plant this came from
  propagationType?: 'seed' | 'clone' | 'cutting' | 'division' | 'grafting' | 'original';
  generation: number; // How many generations from the original

  // Plant lifecycle
  plantedDate: string;
  harvestedDate?: string;
  status: 'sprouted' | 'growing' | 'mature' | 'flowering' | 'fruiting' | 'dormant' | 'deceased';

  // Location and ownership
  location: PlantLocation;
  owner: PlantOwner;

  // Plant network
  childPlants: string[]; // IDs of clones and seeds from this plant

  // Environmental data
  environment?: GrowingEnvironment;
  growthMetrics?: GrowthMetrics;

  // Additional metadata
  notes?: string;
  images?: string[];
  plantsNetId?: string; // ID from plants.net API

  // Timestamps
  registeredAt: string;
  updatedAt: string;
}

export interface BlockData {
  index: number;
  timestamp: string;
  plant: PlantData;
  previousHash: string;
  hash: string;
  nonce: number;
}

export interface PlantLineage {
  plantId: string;
  ancestors: PlantData[];
  descendants: PlantData[];
  siblings: PlantData[]; // Other plants from the same parent
  generation: number;
}

export interface NearbyPlant {
  plant: PlantData;
  distance: number; // in kilometers
  owner: PlantOwner;
}

export interface PlantNetwork {
  totalPlants: number;
  totalOwners: number;
  species: { [key: string]: number };
  globalDistribution: { [country: string]: number };
}
