import { create } from 'zustand'
import type { BaseItemDto } from '../api/types'

/**
 * Tiny global store for the quick-look modal. Any PosterCard can call
 * `open(item)` on right-click / long-press, and a single QuickLookModal
 * mounted at the app root reads the current target. Avoids prop-drilling
 * a modal handler through every grid and row.
 */
interface QuickLookState {
  item: BaseItemDto | null
  open: (item: BaseItemDto) => void
  close: () => void
}

export const useQuickLookStore = create<QuickLookState>(set => ({
  item: null,
  open: (item) => set({ item }),
  close: () => set({ item: null }),
}))
