/** * Appointment Availability Detector (INT-013) * * Detects appointment/booking systems on government and service portals, * checks for available slots, and monitors for openings. * * Supports 40+ languages globally with system-specific terminology. * * Key features: * - Detects appointment systems (cita previa, Termin, rendez-vous, etc.) * - Identifies booking URLs and calendar widgets * - Extracts available time slots from page content * - Classifies slot availability (available, limited, unavailable, unknown) * - Provides monitoring suggestions for slot openings * * Extensible to any scheduling/booking systems beyond government portals. */ import { type LanguageDetectionResult } from './language-aware-extraction.js'; /** * Appointment system type classification */ export type AppointmentSystemType = 'government' | 'healthcare' | 'consular' | 'immigration' | 'registration' | 'tax' | 'banking' | 'utility' | 'general' | 'unknown'; /** * Slot availability status */ export type SlotAvailability = 'available' | 'limited' | 'unavailable' | 'requires_login' | 'external_redirect' | 'unknown'; /** * Detected time slot */ export interface TimeSlot { /** Date in ISO format (YYYY-MM-DD) */ date?: string; /** Time in HH:MM format */ time?: string; /** Full datetime if available */ datetime?: string; /** Location/office name */ location?: string; /** Service type */ service?: string; /** Raw text describing the slot */ rawText: string; /** Confidence in slot detection (0-1) */ confidence: number; } /** * Booking system information */ export interface BookingSystem { /** System name (e.g., "cita previa", "Termin") */ name: string; /** System type */ type: AppointmentSystemType; /** Booking URL */ url?: string; /** Alternative URLs (backup links) */ alternativeUrls?: string[]; /** Whether login is required */ requiresLogin: boolean; /** Supported languages */ languages?: string[]; /** Contact for assistance */ contactInfo?: string; } /** * Result of appointment availability detection */ export interface AppointmentAvailabilityResult { /** Whether an appointment system was detected */ detected: boolean; /** Overall availability status */ availability: SlotAvailability; /** Detected booking system(s) */ systems: BookingSystem[]; /** Available time slots (if detectable) */ slots: TimeSlot[]; /** Earliest available date */ earliestAvailable?: string; /** Latest available date shown */ latestAvailable?: string; /** Number of available slots (if countable) */ slotCount?: number; /** Offices/locations with availability */ locationsWithSlots?: string[]; /** Offices/locations without availability */ locationsWithoutSlots?: string[]; /** Wait time estimate */ estimatedWaitTime?: string; /** Monitoring suggestions */ monitoringSuggestions: MonitoringSuggestion[]; /** Detected page language */ language: string; /** Language detection details */ languageDetection?: LanguageDetectionResult; /** Detection confidence (0-1) */ confidence: number; /** Warnings during detection */ warnings: string[]; /** Source URL if provided */ sourceUrl?: string; /** Raw text (optional) */ rawText?: string; } /** * Suggestion for monitoring slot availability */ export interface MonitoringSuggestion { /** Suggested check frequency in minutes */ checkIntervalMinutes: number; /** Best times to check */ bestCheckTimes?: string[]; /** Reason for suggestion */ reason: string; /** Priority level */ priority: 'high' | 'medium' | 'low'; } /** * Options for availability detection */ export interface AvailabilityDetectionOptions { /** Page language (auto-detected if not provided) */ language?: string; /** Source URL for context */ url?: string; /** Include raw text in result */ includeRawText?: boolean; /** Specific service type to look for */ serviceType?: string; /** Specific location to filter */ location?: string; } /** * Detects appointment systems and availability on web pages */ export declare class AppointmentAvailabilityDetector { /** * Detect appointment availability from HTML content */ detect(html: string, options?: AvailabilityDetectionOptions): AppointmentAvailabilityResult; /** * Detect booking systems from content */ private detectSystems; /** * Check if a keyword represents a named system */ private isNamedSystem; /** * Classify a booking URL into a system */ private classifySystem; /** * Extract system name from URL or content */ private extractSystemName; /** * Classify system type from URL and content */ private classifyType; /** * Check if URL appears to be a booking page */ private isBookingUrl; /** * Detect if login is required */ private detectLoginRequired; /** * Detect overall availability status */ private detectAvailability; /** * Extract time slots from text */ private extractTimeSlots; /** * Normalize date string to YYYY-MM-DD format for proper sorting */ private normalizeDateString; /** * Extract location information */ private extractLocations; /** * Generate monitoring suggestions */ private generateMonitoringSuggestions; /** * Calculate overall confidence score */ private calculateConfidence; } /** * Create a new detector instance */ export declare function createAvailabilityDetector(): AppointmentAvailabilityDetector; /** * Detect appointment availability from HTML */ export declare function detectAppointmentAvailability(html: string, options?: AvailabilityDetectionOptions): AppointmentAvailabilityResult; /** * Check if a page has an appointment system */ export declare function hasAppointmentSystem(html: string, language?: string): boolean; /** * Get availability status from a page */ export declare function getAvailabilityStatus(html: string, language?: string): SlotAvailability; //# sourceMappingURL=appointment-availability-detector.d.ts.map