import type {
  FeatureFilters,
  FeatureMeta,
  MapFlyToOptions,
  POICategoryGroup,
  ViewState,
} from '../../../types';
import type { TravelTimeInitial } from '../../../hooks/useTravelTime';
import type { OverlayId } from '../../../lib/overlays';
import type { BasemapId } from '../../../lib/basemaps';
import type { Page } from '../../ui/Header';
import type { PointerEvent } from 'react';

export interface ExportState {
  onExport: (options?: { postcodes?: string[] }) => void;
  exporting: boolean;
}

export type ExportNotice = {
  kind: 'success' | 'error';
  message: string;
};

export interface MapPageProps {
  features: FeatureMeta[];
  poiCategoryGroups: POICategoryGroup[];
  initialFilters: FeatureFilters;
  initialViewState: ViewState;
  /** Offer the "check your area" GPS prompt (fresh demo visit, no URL view). */
  offerDemoLocation?: boolean;
  initialPOICategories: Set<string>;
  initialOverlays?: Set<OverlayId>;
  initialCrimeTypes?: Set<string>;
  initialBasemap?: BasemapId;
  initialColorOpacity?: number;
  initialTab: 'properties' | 'area';
  initialLoading: boolean;
  theme: 'light' | 'dark';
  pendingInfoFeature: string | null;
  onClearPendingInfoFeature: () => void;
  onNavigateTo: (page: Page, hash?: string, infoFeature?: string) => void;
  onExportStateChange?: (state: ExportState) => void;
  onDashboardParamsChange?: (params: string) => void;
  onDashboardReadyChange?: (ready: boolean) => void;
  screenshotMode?: boolean;
  ogMode?: boolean;
  isMobile?: boolean;
  initialTravelTime?: TravelTimeInitial;
  initialPostcode?: string;
  shareCode?: string;
  user?: { id: string; subscription: string; isAdmin?: boolean; canSeeListings?: boolean } | null;
  onLoginClick: () => void;
  onRegisterClick: () => void;
  onCheckoutLoginClick?: (returnPath?: string) => void;
  onCheckoutRegisterClick?: (returnPath?: string) => void;
  deferTutorial?: boolean;
  onSaveSearch?: (name: string, paramsOverride?: string) => Promise<void>;
  savingSearch?: boolean;
  editingSearch?: { id: string; name: string } | null;
  onCancelEdit?: () => void;
  onUpdateEdit?: (params: string) => Promise<void>;
  onUpdateEditInPlace?: (params: string) => Promise<void>;
}

export type MapFlyTo = (lat: number, lng: number, zoom: number, options?: MapFlyToOptions) => void;

export interface PaneResizeHandlers {
  onPointerDown: (event: PointerEvent) => void;
  onPointerMove: (event: PointerEvent) => void;
  onPointerUp: () => void;
}
