import { create } from 'zustand';

export interface WeatherSnapshot {
  stationName: string;
  capturedAt: string;
  wind: {
    speed: number;
    direction: number;
    directionLabel: string;
    speed_1k: number;
    speed_3k: number;
  };
  wave: {
    height: number;
    maxHeight: number;
    period: number;
    direction: string;
  };
  temperature: {
    current: number;
    feelsLike: number;
  };
  pressure: number;
  visibility: number;
  salinity: number;
  astronomy?: {
    sunrise: string;
    sunset: string;
    moonrise: string;
    moonset: string;
    moonPhase: string;
    tidalRange: number;
  };
  alert?: string;
  forecast?: Array<{
    time: string;
    icon: string;
    temperature: number;
    windSpeed: number;
  }>;
}

interface WeatherSnapshotStore {
  snapshot: WeatherSnapshot | null;
  setSnapshot: (data: WeatherSnapshot) => void;
  clearSnapshot: () => void;
}

export const useWeatherSnapshotStore = create<WeatherSnapshotStore>((set) => ({
  snapshot: null,
  setSnapshot: (data) => set({ snapshot: data }),
  clearSnapshot: () => set({ snapshot: null }),
}));
