import { TagadaError } from '../../core/errors'; export interface GeoLocationData { ip_address?: string | null; city?: string | null; city_geoname_id?: number | null; region?: string | null; region_iso_code?: string | null; region_geoname_id?: number | null; postal_code?: string | null; country?: string | null; country_code?: string | null; country_geoname_id?: number | null; country_is_eu?: boolean | null; continent?: string | null; continent_code?: string | null; continent_geoname_id?: number | null; latitude?: number | null; longitude?: number | null; security?: { is_vpn?: boolean | null; } | null; timezone?: { name?: string | null; abbreviation?: string | null; gmt_offset?: number | null; current_time?: string | null; is_dst?: boolean | null; } | null; currency?: { currency_name?: string | null; currency_code?: string | null; } | null; connection?: { autonomous_system_number?: number | null; autonomous_system_organization?: string | null; connection_type?: string | null; isp_name?: string | null; organization_name?: string | null; } | null; flag?: { emoji?: string | null; unicode?: string | null; png?: string | null; svg?: string | null; } | null; as?: string | null; isp?: string | null; lat?: number | null; lon?: number | null; org?: string | null; query?: string | null; regionName?: string | null; status?: string | null; zip?: string | null; error?: string; } export interface UseGeoLocationOptions { /** * Whether to automatically fetch geolocation data on mount * @default true */ autoFetch?: boolean; /** * Custom IP address to fetch geolocation for * If not provided, will use the client's IP */ ip?: string; /** * Whether to refetch data when the hook mounts * @default false */ refetchOnMount?: boolean; } export interface UseGeoLocationReturn { /** * The geolocation data */ data: GeoLocationData | null; /** * Whether the request is currently loading */ isLoading: boolean; /** * Any error that occurred during the request */ error: TagadaError | null; /** * Function to manually fetch geolocation data */ fetchGeoData: (ip?: string) => Promise; /** * Function to clear the current data and error state */ clearData: () => void; /** * Whether the data is from localhost/development */ isLocalhost: boolean; /** * Whether the current IP is valid */ isValidIP: boolean; } /** * Hook to fetch and manage geolocation data - V2 Implementation * Compatible with V1 interface while using V2 provider architecture * * @example * ```tsx * function MyComponent() { * const { data, isLoading, error, fetchGeoData } = useGeoLocation(); * * if (isLoading) return
Loading location...
; * if (error) return
Error: {error}
; * * return ( *
*

Country: {data?.country}

*

City: {data?.city}

*

IP: {data?.ip_address}

*
* ); * } * ``` * * @example * ```tsx * function MyComponent() { * const { fetchGeoData } = useGeoLocation({ autoFetch: false }); * * const handleClick = () => { * fetchGeoData('8.8.8.8'); // Fetch for specific IP * }; * * return ; * } * ``` */ export declare function useGeoLocation(options?: UseGeoLocationOptions): UseGeoLocationReturn;