import { create } from 'zustand';
import type { VesselData } from '@data/mock/vessels';

interface VesselStore {
  vessels: VesselData[];
  suspects: VesselData[];
  selectedId: string | null;
  loaded: boolean;
  load: () => void;
  select: (id: string | null) => void;
}

export const useVesselStore = create<VesselStore>((set, get) => ({
  vessels: [],
  suspects: [],
  selectedId: null,
  loaded: false,

  load: () => {
    if (get().loaded) return;
    import('@data/mock/vessels').then(({ MOCK_VESSELS, MOCK_SUSPECTS }) => {
      set({ vessels: MOCK_VESSELS, suspects: MOCK_SUSPECTS, loaded: true });
    });
  },

  select: (id) => set({ selectedId: id }),
}));
