/** * @license * Copyright 2023 Nuraly, Laabidi Aymen * SPDX-License-Identifier: MIT */ import type { ChatbotPlugin } from '../core/types.js'; import { ChatPluginBase } from './chat-plugin.js'; /** * Interface for flight information */ export interface FlightInfo { origin: string; destination: string; departureTime: string; arrivalTime: string; departureDate: string; arrivalDate: string; terminal?: string; gate?: string; arrivalTerminal?: string; arrivalGate?: string; duration: string; flightNumber?: string; airline?: string; status?: string; updated?: string; source?: string; } /** * Flight Card Plugin - transforms flight information into visual cards * * This plugin detects flight information in messages and renders them as styled cards. * Developers can customize the card template by extending this class. * * @example Basic usage * ```typescript * const flightPlugin = new FlightCardPlugin(); * controller.registerPlugin(flightPlugin); * ``` * * @example Custom template * ```typescript * class MyFlightCardPlugin extends FlightCardPlugin { * protected renderFlightCard(flight: FlightInfo): string { * return `
...
`; * } * } * ``` * * @example JSON format in message * ```json * { * "type": "flight", * "origin": "JED", * "destination": "TUN", * "departureTime": "11:40 PM", * "arrivalTime": "2:35 AM", * "departureDate": "mar. 14 oct.", * "arrivalDate": "mer. 15 oct.", * "duration": "4h 55min", * "terminal": "N", * "arrivalTerminal": "M" * } * ``` */ export declare class FlightCardPlugin extends ChatPluginBase implements ChatbotPlugin { readonly id = "flight-card"; readonly name = "Flight Card Plugin"; readonly version = "1.0.0"; readonly htmlTags: { name: string; open: string; close: string; }[]; /** * CSS class prefix for styling */ protected cssPrefix: string; /** * Render a skeleton placeholder while the flight data is loading */ renderHtmlBlockPlaceholder?(name: string): string; onInit(): void; /** * Process received messages and convert flight data to cards */ afterReceive(text: string): Promise; /** * Render a completed [FLIGHT]...[/FLIGHT] block when tokenized by the Provider/Service */ renderHtmlBlock(name: string, content: string): string; /** * Check if data object contains flight information */ protected isFlightData(data: any): boolean; /** * Render flight information as a card * Override this method to customize the card appearance */ protected renderFlightCard(flight: FlightInfo): string; /** * Get city name from airport code * Override this to provide custom city mappings */ protected getCityName(airportCode: string): string; /** * Escape HTML to prevent XSS */ protected escapeHtml(text: string): string; /** * Inject default styles for the flight card * Override this method to provide custom styles */ protected getStyles(): string; } //# sourceMappingURL=flight-card-plugin.d.ts.map