{"version":3,"file":"ChatEventClient.mjs","sources":["../../../../../src/models/clients/ChatEventClient.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { MessageRequest, MessageResponse } from \"@yext/chat-core\";\nimport { ChatClient } from \"./ChatClient\";\n\n/**\n * An event-driven client for processing user message and provide responses\n * by emitting and listening to events.\n *\n * @public\n */\nexport interface ChatEventClient {\n  /**\n   * Initializes the client, using credentials and data in the provided message to setup a chat session.\n   *\n   * @param messageResponse - The message response that initiated the handoff to the chat client.\n   */\n  init(messageResponse: MessageResponse): Promise<any>;\n\n  /**\n   * Registers an event listener for a specified event.\n   * Supported events are:\n   * - `message`: A new message has been received.\n   * - `typing`: The agent is typing.\n   * - `close`: The chat session has been closed.\n   *\n   * @param eventName - The name of the event to listen to.\n   * @param cb - The callback function to be executed when the event is triggered.\n   */\n  on(eventName: \"message\" | \"typing\" | \"close\", cb: (data: any) => void): void;\n\n  /**\n   * Emits an event with the specified name and data, triggering all registered listeners for that event.\n   *\n   * @param eventName - The name of the event to emit.\n   * @param data  - The data to be passed to the event listeners.\n   */\n  emit(eventName: string, data: any): void;\n\n  /**\n   * Processes a message request. The response should be emitted as a message event.\n   *\n   * @param request - The message request to process.\n   */\n  processMessage(request: MessageRequest): Promise<void>;\n\n  /**\n   * Provide the current chat session.\n   */\n  getSession(): any;\n\n  /**\n   * Reset the current chat session.\n   */\n  resetSession(): void;\n\n  /**\n   * Reinitialize the session using existing session data.\n   */\n  reinitializeSession(credentials: any): Promise<void>;\n}\n\nexport function isChatEventClient(\n  client: ChatClient\n): client is ChatEventClient {\n  return (client as ChatEventClient).init !== undefined;\n}\n"],"names":[],"mappings":"AAAA;AA8DM,SAAU,iBAAiB,CAC/B,MAAkB,EAAA;AAElB,IAAA,OAAQ,MAA0B,CAAC,IAAI,KAAK,SAAS,CAAC;AACxD;;;;"}