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Delivr using Terser v5.39.0.\n * Original file: /npm/mailpit-api@1.7.2/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n  for (var name in all)\n    __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n  if (from && typeof from === \"object\" || typeof from === \"function\") {\n    for (let key of __getOwnPropNames(from))\n      if (!__hasOwnProp.call(to, key) && key !== except)\n        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n  }\n  return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n  // If the importer is in node compatibility mode or this is not an ESM\n  // file that has been converted to a CommonJS file using a Babel-\n  // compatible transform (i.e. \"__esModule\" has not been set), then set\n  // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n  isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n  mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n  MailpitClient: () => MailpitClient\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_axios = __toESM(require(\"axios\"));\nvar import_ws = __toESM(require(\"partysocket/ws\"));\nvar import_ws2 = __toESM(require(\"ws\"));\nvar MailpitClient = class {\n  axiosInstance;\n  baseURL;\n  wsURL;\n  webSocket = null;\n  eventListeners = /* @__PURE__ */ new Map();\n  /**\n   * Creates an instance of {@link MailpitClient}.\n   * @param baseURL - The base URL of the Mailpit API.\n   * @param auth - Optional authentication credentials.\n   * @param auth.username - The username for basic authentication.\n   * @param auth.password - The password for basic authentication.\n   * @example No Auth\n   * ```typescript\n   * const mailpit = new MailpitClient(\"http://localhost:8025\");\n   * ```\n   * @example Basic Auth\n   * ```typescript\n   * const mailpit = new MailpitClient(\"http://localhost:8025\", {\n   *   username: \"admin\",\n   *   password: \"supersecret\"\n   * });\n   * ```\n   */\n  constructor(baseURL, auth) {\n    if (!baseURL || !/^https?:\\/\\//.test(baseURL)) {\n      throw new Error(\n        \"The value of the 'baseURL' parameter must start with http:// or https://\"\n      );\n    }\n    this.baseURL = baseURL;\n    this.wsURL = `${baseURL.replace(/^http/, \"ws\")}/api/events`;\n    this.axiosInstance = import_axios.default.create({\n      baseURL,\n      auth,\n      validateStatus: function(status) {\n        return status === 200;\n      }\n    });\n  }\n  async handleRequest(request, options = { fullResponse: false }) {\n    try {\n      const response = await request();\n      return options.fullResponse ? response : response.data;\n    } catch (error) {\n      if ((0, import_axios.isAxiosError)(error)) {\n        const url = error.config?.url || \"UNKNOWN URL\";\n        const method = error.config?.method?.toUpperCase() || \"UNKNOWN METHOD\";\n        if (error.response) {\n          throw new Error(\n            `Mailpit API Error: ${error.response.status.toString()} ${error.response.statusText} at ${method} ${url}: ${JSON.stringify(error.response.data)}`\n          );\n        } else if (error.request) {\n          throw new Error(\n            `Mailpit API Error: No response received from server at ${method} ${url}`\n          );\n        } else {\n          throw new Error(\n            `Mailpit API Error: ${error.toString()} at ${method} ${url}`\n          );\n        }\n      } else {\n        throw new Error(`Unexpected Error: ${error}`);\n      }\n    }\n  }\n  /**\n   * Retrieves information about the Mailpit instance.\n   *\n   * @returns Basic runtime information, message totals and latest release version.\n   * @example\n   * ```typescript\n   * const info = await mailpit.getInfo();\n   * ```\n   */\n  async getInfo() {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\"/api/v1/info\")\n    );\n  }\n  /**\n   * Retrieves the configuration of the Mailpit web UI.\n   * @remarks Intended for web UI only!\n   * @returns Configuration settings\n   * @example\n   * ```typescript\n   * const config = await mailpit.getConfiguration();\n   * ```\n   */\n  async getConfiguration() {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\"/api/v1/webui\")\n    );\n  }\n  /**\n   * Retrieves a summary of a specific message and marks it as read.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @returns Message summary\n   * @example\n   * ```typescript\n   * const message = await mailpit.getMessageSummary();\n   * ```\n   */\n  async getMessageSummary(id = \"latest\") {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}`\n      )\n    );\n  }\n  /**\n   * Retrieves the headers of a specific message.\n   * @remarks Header keys are returned alphabetically.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @returns Message headers\n   * @example\n   * ```typescript\n   * const headers = await mailpit.getMessageHeaders();\n   * ```\n   */\n  async getMessageHeaders(id = \"latest\") {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}/headers`\n      )\n    );\n  }\n  /**\n   * Retrieves a specific attachment from a message.\n   * @param id - Message database ID or \"latest\"\n   * @param partID - The attachment part ID\n   * @returns Attachment as binary data and the content type\n   * @example\n   * ```typescript\n   * const message = await mailpit.getMessageSummary();\n   * if (message.Attachments.length) {\n   *  const attachment = await mailpit.getMessageAttachment(message.ID, message.Attachments[0].PartID);\n   *  // Do something with the attachment data\n   * }\n   * ```\n   */\n  async getMessageAttachment(id, partID) {\n    const response = await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}/part/${partID}`,\n        { responseType: \"arraybuffer\" }\n      ),\n      { fullResponse: true }\n    );\n    return {\n      data: response.data,\n      contentType: response.headers[\"content-type\"]\n    };\n  }\n  /**\n   * Generates a cropped 180x120 JPEG thumbnail of an image attachment from a message.\n   * Only image attachments are supported.\n   * @remarks\n   * If the image is smaller than 180x120 then the image is padded.\n   * If the attachment is not an image then a blank image is returned.\n   * @param id - Message database ID or \"latest\"\n   * @param partID - The attachment part ID\n   * @returns Image attachment thumbnail as binary data and the content type\n   * @example\n   * ```typescript\n   * const message = await mailpit.getMessageSummary();\n   * if (message.Attachments.length) {\n   *  const thumbnail = await mailpit.getAttachmentThumbnail(message.ID, message.Attachments[0].PartID);\n   *  // Do something with the thumbnail data\n   * }\n   * ```\n   */\n  async getAttachmentThumbnail(id, partID) {\n    const response = await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}/part/${partID}/thumb`,\n        {\n          responseType: \"arraybuffer\"\n        }\n      ),\n      { fullResponse: true }\n    );\n    return {\n      data: response.data,\n      contentType: response.headers[\"content-type\"]\n    };\n  }\n  /**\n   * Retrieves the full email message source as plain text.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @returns Plain text message source\n   * @example\n   * ```typescript\n   * const messageSource = await mailpit.getMessageSource();\n   * ```\n   */\n  async getMessageSource(id = \"latest\") {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(`/api/v1/message/${id}/raw`)\n    );\n  }\n  /**\n   * Release a message via a pre-configured external SMTP server.\n   * @remarks This is only enabled if message relaying has been configured.\n   * @param id - The message database ID. Use `latest` to return the latest message.\n   * @param relayTo - Array of email addresses to relay the message to\n   * @returns Plain text \"ok\" response\n   * @example\n   * ```typescript\n   * const message = await mailpit.releaseMessage(\"latest\", [\"user1@example.test\", \"user2@example.test\"]);\n   * ```\n   */\n  async releaseMessage(id, relayTo) {\n    return await this.handleRequest(\n      () => this.axiosInstance.post(`/api/v1/message/${id}/release`, relayTo)\n    );\n  }\n  /**\n   * Sends a message\n   * @param sendReqest - The request containing the message details.\n   * @returns Response containing database messsage ID\n   * @example\n   * ```typescript\n   * await mailpit.sendMessage(\n   *  From: { Email: \"user@example.test\", Name: \"First LastName\" },\n   *  To: [{ Email: \"rec@example.test\", Name: \"Recipient Name\"}, {Email: \"another@example.test\"}],\n   *  Subject: \"Test Email\",\n   * );\n   * ```\n   */\n  async sendMessage(sendReqest) {\n    return await this.handleRequest(\n      () => this.axiosInstance.post(\n        `/api/v1/send`,\n        sendReqest\n      )\n    );\n  }\n  /**\n   * Retrieves a list of message summaries ordered from newest to oldest.\n   * @remarks Only contains the number of attachments and a snippet of the message body.\n   * @see {@link MailpitClient.getMessageSummary | getMessageSummary()} for more attachment and body details for a specific message.\n   * @param start - The pagination offset. Defaults to `0`.\n   * @param limit - The number of messages to retrieve. Defaults to `50`.\n   * @returns A list of message summaries\n   * @example\n   * ```typescript\n   * const messages = await.listMessages();\n   * ```\n   */\n  async listMessages(start = 0, limit = 50) {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/messages`,\n        { params: { start, limit } }\n      )\n    );\n  }\n  /**\n   * Set the read status of messages.\n   * @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is  set then all messages are updated.\n   * @param readStatus - The request containing the message database IDs/search string and the read status.\n   * @param readStatus.Read - The read status to set. Defaults to `false`.\n   * @param readStatus.IDs - The optional IDs of the messages to update.\n   * @param readStatus.Search - The optional search string to filter messages.\n   * @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.\n   * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}\n   * @returns Plain text \"ok\" response\n   * @example\n   * ```typescript\n   * // Set all messages as unread\n   * await mailpit.setReadStatus();\n   *\n   * // Set all messages as read\n   * await mailpit.setReadStatus({ Read: true });\n   *\n   * // Set specific messages as read using IDs\n   * await mailpit.setReadStatus({ IDs: [\"1\", \"2\", \"3\"], Read: true });\n   *\n   * // Set specific messages as read using search\n   * await mailpit.setReadStatus({ Search: \"from:example.test\", Read: true });\n   *\n   * // Set specific messages as read using after: search with time zone\n   * await mailpit.setReadStatus({ Search: \"after:2025-04-30\", Read: true }, { tz: \"America/Chicago\" });\n   * ```\n   */\n  async setReadStatus(readStatus, params) {\n    return await this.handleRequest(\n      () => this.axiosInstance.put(`/api/v1/messages`, readStatus, {\n        params\n      })\n    );\n  }\n  /**\n   * Delete individual or all messages.\n   * @remarks If no `IDs` are provided then all messages are deleted.\n   * @param deleteRequest - The request containing the message database IDs to delete.\n   * @returns Plain text \"ok\" response\n   * @example\n   * ```typescript\n   * // Delete all messages\n   * await mailpit.deleteMessages();\n   *\n   * // Delete specific messages\n   * await mailpit.deleteMessages({ IDs: [\"1\", \"2\", \"3\"] });\n   * ```\n   */\n  async deleteMessages(deleteRequest) {\n    return await this.handleRequest(\n      () => this.axiosInstance.delete(`/api/v1/messages`, {\n        data: deleteRequest\n      })\n    );\n  }\n  /**\n   * Retrieve messages matching a search, sorted by received date (descending).\n   * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}\n   * @remarks Only contains the number of attachments and a snippet of the message body.\n   * @see {@link MailpitClient.getMessageSummary | getMessageSummary()} for more attachment and body details for a specific message.\n   * @param search - The search request containing the query and optional parameters.\n   * @returns A list of message summaries matching the search criteria.\n   * @example\n   * ```typescript\n   * // Search for messages from a the domain example.test\n   * const messages = await mailpit.searchMessages({query: \"from:example.test\"});\n   * ```\n   */\n  async searchMessages(search) {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(`/api/v1/search`, {\n        params: search\n      })\n    );\n  }\n  /**\n   * Delete all messages matching a search.\n   * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}\n   * @param search - The search request containing the query.\n   * @returns Plain text \"ok\" response\n   * @example\n   * ```typescript\n   * // Delete all messages from the domain example.test\n   * await mailpit.deleteMessagesBySearch({query: \"from:example.test\"});\n   * ```\n   */\n  async deleteMessagesBySearch(search) {\n    return await this.handleRequest(\n      () => this.axiosInstance.delete(`/api/v1/search`, { params: search })\n    );\n  }\n  /**\n   * Performs an HTML check on a specific message.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @returns The summary of the message HTML checker\n   * @example\n   * ```typescript\n   * const htmlCheck = await mailpit.htmlCheck();\n   * ```\n   */\n  async htmlCheck(id = \"latest\") {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}/html-check`\n      )\n    );\n  }\n  /**\n   * Performs a link check on a specific message.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @param follow - Whether to follow links. Defaults to `false`.\n   * @returns The summary of the message Link checker.\n   * @example\n   * ```typescript\n   * const linkCheck = await mailpit.linkCheck();\n   * ```\n   */\n  async linkCheck(id = \"latest\", follow = false) {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}/link-check`,\n        { params: { follow } }\n      )\n    );\n  }\n  /**\n   * Performs a SpamAssassin check (if enabled) on a specific message.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @returns The SpamAssassin summary (if enabled)\n   * @example\n   * ```typescript\n   * const spamAssassinCheck = await mailpit.spamAssassinCheck();\n   * ```\n   */\n  async spamAssassinCheck(id = \"latest\") {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\n        `/api/v1/message/${id}/sa-check`\n      )\n    );\n  }\n  /**\n   * Retrieves a list of all the unique tags.\n   * @returns All unique message tags\n   * @example\n   * ```typescript\n   * const tags = await mailpit.getTags();\n   * ```\n   */\n  async getTags() {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(`/api/v1/tags`)\n    );\n  }\n  /**\n   * Sets and removes tag(s) on message(s). This will overwrite any existing tags for selected message database IDs.\n   * @param request - The request containing the message IDs and tags. To remove all tags from a message, pass an empty `Tags` array or exclude `Tags` entirely.\n   * @remarks\n   * Tags are limited to the following characters: `a-z`, `A-Z`, `0-9`, `-`, `.`, `spaces`, and `_`, and must be a minimum of 1 character.\n   * Other characters are silently stripped from the tag.\n   * @returns Plain text \"ok\" response\n   * @example\n   * ```typescript\n   * // Set tags on message(s)\n   * await mailpit.setTags({ IDs: [\"1\", \"2\", \"3\"], Tags: [\"tag1\", \"tag2\"] });\n   * // Remove tags from message(s)\n   * await mailpit.setTags({ IDs: [\"1\", \"2\", \"3\"]});\n   * ```\n   */\n  async setTags(request) {\n    return await this.handleRequest(\n      () => this.axiosInstance.put(`/api/v1/tags`, request)\n    );\n  }\n  /**\n   * Renames an existing tag.\n   * @param tag - The current name of the tag.\n   * @param newTagName - A new name for the tag.\n   * @remarks\n   * Tags are limited to the following characters: `a-z`, `A-Z`, `0-9`, `-`, `.`, `spaces`, and `_`, and must be a minimum of 1 character.\n   * Other characters are silently stripped from the tag.\n   * @returns Plain text \"ok\" response\n   * @example\n   * ```typescript\n   * await mailpit.renameTag(\"Old Tag Name\", \"New Tag Name\");\n   * ```\n   */\n  async renameTag(tag, newTagName) {\n    const encodedTag = encodeURIComponent(tag);\n    return await this.handleRequest(\n      () => this.axiosInstance.put(`/api/v1/tags/${encodedTag}`, {\n        Name: newTagName\n      })\n    );\n  }\n  /**\n   * Deletes a tag from all messages.\n   * @param tag - The name of the tag to delete.\n   * @remarks This does NOT delete any messages\n   * @returns Plain text \"ok\" response\n   * ```typescript\n   * await mailpit.deleteTag(\"Tag 1\");\n   * ```\n   */\n  async deleteTag(tag) {\n    const encodedTag = encodeURIComponent(tag);\n    return await this.handleRequest(\n      () => this.axiosInstance.delete(`/api/v1/tags/${encodedTag}`)\n    );\n  }\n  /**\n   * Retrieves the current Chaos triggers configuration (if enabled).\n   * @remarks This will return an error if Chaos is not enabled at runtime.\n   * @returns The Chaos triggers configuration\n   * @example\n   * ```typescript\n   * const triggers = await mailpit.getChaosTriggers();\n   * ```\n   */\n  async getChaosTriggers() {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(\"/api/v1/chaos\")\n    );\n  }\n  /**\n   * Sets and/or resets the Chaos triggers configuration (if enabled).\n   * @param triggers - The request containing the chaos triggers. Omitted triggers will reset to the default `0%` probabibility.\n   * @remarks This will return an error if Chaos is not enabled at runtime.\n   * @returns The updated Chaos triggers configuration\n   *  @example\n   * ```typescript\n   * // Reset all triggers to `0%` probability\n   * const triggers = await mailpit.setChaosTriggers();\n   * // Set `Sender` and reset `Authentication` and `Recipient` triggers\n   * const triggers = await mailpit.setChaosTriggers({ Sender: { ErrorCode: 451, Probability: 5 } });\n   * ```\n   */\n  async setChaosTriggers(triggers = {}) {\n    return await this.handleRequest(\n      () => this.axiosInstance.put(\n        \"/api/v1/chaos\",\n        triggers\n      )\n    );\n  }\n  /**\n   * Renders the HTML part of a specific message which can be used for UI integration testing.\n   * @remarks\n   * Attached inline images are modified to link to the API provided they exist.\n   * If the message does not contain an HTML part then a 404 error is returned.\n   *\n   *\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @param embed - Whether this route is to be embedded in an iframe. Defaults to `undefined`. Set to `1` to embed.\n   * The `embed` parameter will add `target=\"_blank\"` and `rel=\"noreferrer noopener\"` to all links.\n   * In addition, a small script will be added to the end of the document to post (postMessage()) the height of the document back to the parent window for optional iframe height resizing.\n   * Note that this will also transform the message into a full HTML document (if it isn't already), so this option is useful for viewing but not programmatic testing.\n   * @returns Rendered HTML\n   * @example\n   * ```typescript\n   * const html = await mailpit.renderMessageHTML();\n   * ```\n   */\n  async renderMessageHTML(id = \"latest\", embed) {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(`/view/${id}.html`, { params: { embed } })\n    );\n  }\n  /**\n   * Renders just the message's text part which can be used for UI integration testing.\n   * @param id - The message database ID. Defaults to `latest` to return the latest message.\n   * @returns Plain text\n   * @example\n   * ```typescript\n   * const html = await mailpit.renderMessageText();\n   * ```\n   */\n  async renderMessageText(id = \"latest\") {\n    return await this.handleRequest(\n      () => this.axiosInstance.get(`/view/${id}.txt`)\n    );\n  }\n  /**\n   * @internal\n   * Connects to the WebSocket endpoint for receiving real-time events.\n   */\n  connectWebSocket() {\n    if (this.webSocket && (this.webSocket.readyState === import_ws.default.OPEN || this.webSocket.readyState === import_ws.default.CONNECTING)) {\n      return;\n    }\n    const wsOptions = {};\n    if (this.axiosInstance.defaults.auth) {\n      wsOptions.headers = {\n        Authorization: `Basic ${Buffer.from(`${this.axiosInstance.defaults.auth.username}:${this.axiosInstance.defaults.auth.password}`).toString(\"base64\")}`\n      };\n    }\n    class AuthenticatedWebSocket extends import_ws2.default {\n      constructor(address, options) {\n        super(address, { ...wsOptions, ...options });\n      }\n    }\n    this.webSocket = new import_ws.default(this.wsURL, void 0, {\n      WebSocket: AuthenticatedWebSocket\n    });\n    this.webSocket.addEventListener(\"message\", (event) => {\n      let message;\n      try {\n        message = JSON.parse(event.data);\n      } catch {\n        return;\n      }\n      this.handleWebSocketMessage(message);\n    });\n  }\n  /**\n   * @internal\n   * Adds a listener to the event listeners map.\n   * @param eventType - The type of event to listen for\n   * @param listener - The listener function to add\n   */\n  addListener(eventType, listener) {\n    if (!this.eventListeners.has(eventType)) {\n      this.eventListeners.set(eventType, /* @__PURE__ */ new Set());\n    }\n    this.eventListeners.get(eventType)?.add(listener);\n  }\n  /**\n   * @internal\n   * Removes a listener from the event listeners map.\n   * @param eventType - The type of event to remove the listener from\n   * @param listener - The listener function to remove\n   */\n  removeListener(eventType, listener) {\n    const listeners = this.eventListeners.get(eventType);\n    if (listeners) {\n      listeners.delete(listener);\n      if (listeners.size === 0) {\n        this.eventListeners.delete(eventType);\n      }\n    }\n  }\n  /**\n   * @internal\n   * Dispatches a message to listeners of a specific event type.\n   * @param eventType - The event type to dispatch to\n   * @param message - The event message\n   */\n  dispatchToListeners(eventType, message) {\n    const listeners = this.eventListeners.get(eventType);\n    if (listeners) {\n      listeners.forEach((listener) => {\n        listener(message);\n      });\n    }\n  }\n  /**\n   * @internal\n   * Handles incoming WebSocket messages and dispatches them to registered listeners.\n   * @param message - The event message\n   */\n  handleWebSocketMessage(message) {\n    this.dispatchToListeners(message.Type, message);\n    this.dispatchToListeners(\"*\", message);\n  }\n  /**\n   * Disconnects from the real-time event stream.\n   * @example\n   * ```typescript\n   * mailpit.disconnect();\n   * ```\n   */\n  disconnect() {\n    if (this.webSocket) {\n      const ws = this.webSocket;\n      this.webSocket = null;\n      ws.close(1e3, \"Client disconnect\");\n    }\n  }\n  /**\n   * Registers a listener for real-time events of a specific type.\n   * @remarks\n   * Automatically connects to the event stream if not already connected.\n   * @param eventType - The type of event to listen for.\n   * Specific event types include: \"new\" (new messages), \"stats\", \"update\", \"delete\", \"prune\", \"truncate\", and \"error\".\n   * Use \"*\" to listen for all event types (Useful if processing all events uniformly (e.g., logging, debugging, metrics)).\n   * @param listener - The callback function to invoke when an event is received\n   * @returns A function to unregister the listener\n   * @example Listen for event type \"new\" messages (recommended)\n   * ```typescript\n   * const unsubscribe = mailpit.onEvent(\"new\", (event) => {\n   *   // event.Data is typed as MailpitMessageSummary with full type safety\n   *   console.log(\"New message:\", event.Data.Subject);\n   * });\n   *\n   * // Other code...\n   *\n   * // Unsubscribe listener when no longer needed\n   * unsubscribe();\n   * ```\n   * @example Listen for all events uniformly (for logging/debugging)\n   * ```typescript\n   * const unsubscribe = mailpit.onEvent(\"*\", (event) => {\n   *   // Generic processing for all event types\n   *   console.log(`Event ${event.Type} received`);\n   * });\n   *\n   * // Other code...\n   *\n   * // Unsubscribe listener when no longer needed\n   * unsubscribe();\n   * ```\n   */\n  onEvent(eventType, listener) {\n    if (!this.webSocket || this.webSocket.readyState === import_ws.default.CLOSED) {\n      this.connectWebSocket();\n    }\n    this.addListener(eventType, listener);\n    return () => {\n      this.removeListener(eventType, listener);\n    };\n  }\n  /**\n   * Waits for the next event of a specific type.\n   * @remarks\n   * Automatically connects to the event stream if not already connected.\n   * Primarily intended for testing scenarios where you need to wait for a single specific event.\n   * The promise will reject if the timeout is reached before an event is received.\n   * @param eventType - The type of event to wait for.\n   * Specific event types include: \"new\" (new messages), \"stats\", \"update\", \"delete\", \"prune\", \"truncate\", and \"error\".\n   * @param timeout - Timeout in milliseconds (default: 5000ms). Pass `Infinity` to disable timeout.\n   * @returns A promise that resolves with the event when received, or rejects on timeout\n   * @example Basic usage\n   * ```typescript\n   * // Create the promise before triggering the event\n   * const eventPromise = mailpit.waitForEvent(\"new\");\n   *\n   * // Do something that triggers an email to send\n   * await mailpit.sendMessage({\n   *   From: { Email: \"test@example.com\" },\n   *   To: [{ Email: \"recipient@example.com\" }],\n   *   Subject: \"Test\",\n   * });\n   *\n   * // Wait for the event confirming the message was received\n   * const event = await eventPromise;\n   * // event.Data is fully typed as MailpitMessageSummary\n   * console.log(\"Message received:\", event.Data.Subject);\n   * ```\n   */\n  waitForEvent(eventType, timeout = 5e3) {\n    if (!this.webSocket || this.webSocket.readyState === import_ws.default.CLOSED) {\n      this.connectWebSocket();\n    }\n    return new Promise((resolve, reject) => {\n      let timer = null;\n      const cleanup = () => {\n        if (timer) {\n          clearTimeout(timer);\n        }\n        this.removeListener(eventType, listener);\n      };\n      const listener = (event) => {\n        cleanup();\n        resolve(event);\n      };\n      this.addListener(eventType, listener);\n      if (isFinite(timeout)) {\n        timer = setTimeout(() => {\n          cleanup();\n          reject(new Error(`Timeout waiting for event of type \"${eventType}\"`));\n        }, timeout);\n      }\n    });\n  }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n  MailpitClient\n});\n"]}