import { WebClient, ChatPostMessageArguments, ChatPostMessageResponse, FilesUploadV2Arguments, FilesInfoResponse, FilesInfoArguments, FilesGetUploadURLExternalArguments, FilesGetUploadURLExternalResponse, FilesCompleteUploadExternalArguments, FilesCompleteUploadExternalResponse } from '@slack/web-api';
import { IncomingWebhook, IncomingWebhookSendArguments, IncomingWebhookResult } from '@slack/webhook';
import { SlackWebClientOptions, FilesUploadV2Options, FilesUploadV2Response, SlackIncomingWebhookOptions } from './types.js';
import '@wdio/reporter';
import './constants.js';
import '@wdio/types';

/**
 * Copyright (c) moroo
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

/**
 * A client wrapper for Slack's WebClient API that simplifies common operations.
 *
 * This class provides methods for posting messages, uploading files, and interacting
 * with Slack's API in a more convenient way.
 *
 * @example
 * ```typescript
 * const slackWebClient = new SlackWebClient({
 *   token: 'xoxb-your-token-here'
 * });
 *
 * // Post a message
 * await slackWebClient.postMessage({
 *   channel: 'C12345',
 *   text: 'Hello from WebdriverIO!'
 * });
 *
 * // Upload a file
 * await slackWebClient.upload({
 *   channel_id: 'C12345',
 *   file: '/path/to/report.html',
 *   title: 'Test Report'
 * });
 * ```
 */
declare class SlackWebClient {
    private _token;
    private _client;
    /**
     * Creates an instance of the Slack Web Client.
     *
     * @param {SlackWebClientOptions | undefined} options - The options for configuring the Slack client, excluding 'type' and 'channel'.
     */
    constructor(options: SlackWebClientOptions);
    /**
     * Gets the authentication token for the Slack API.
     * @returns The current token value or undefined if not set.
     */
    get token(): string | undefined;
    /**
     * Gets the Slack WebClient instance.
     * @returns {WebClient} The Slack WebClient instance used for API interactions.
     */
    get client(): WebClient;
    /**
     * Posts a message to a Slack channel.
     *
     * @param payload - The arguments for posting a message to Slack
     * @returns A promise that resolves to the chat post message response
     * @throws Will throw and log an error if the message posting fails
     */
    postMessage(payload: ChatPostMessageArguments): Promise<ChatPostMessageResponse>;
    /**
     * Uploads files to Slack using the files.uploadV2 API endpoint.
     *
     * @param payload - The file upload parameters conforming to FilesUploadV2Arguments
     * @param options - Optional configuration for the upload process
     * @param options.waitForUpload - Whether to wait for file processing completion (default: true)
     * @param options.timeout - Maximum time in milliseconds to wait for upload completion (default: 30000)
     * @param options.interval - Polling interval in milliseconds when checking upload status (default: 1000)
     *
     * @returns Promise resolving to the Slack API response (FilesUploadV2Response)
     *
     * @throws Will throw and log any errors encountered during the upload process
     *
     * @example
     * const result = await slackClient.uploadV2({
     *   channel_id: "C12345",
     *   file: someFileBuffer,
     *   filename: "report.pdf",
     *   token: "xoxb-token"
     * });
     */
    uploadV2(payload: FilesUploadV2Arguments, options?: FilesUploadV2Options): Promise<FilesUploadV2Response>;
    /**
     * Waits for a file to be processed and uploaded on Slack.
     * This method repeatedly checks the file info until the file's mimetype is available,
     * indicating that the file has been successfully processed.
     *
     * @param fileId - The ID of the file to check
     * @param timeout - Maximum time in milliseconds to wait for the file upload (default: 30000)
     * @param interval - Time in milliseconds between each check (default: 1000)
     * @returns A Promise that resolves to the FilesInfoResponse once the file is processed
     * @throws {TimeoutError} If the file is not processed within the specified timeout
     * @throws {Error} If any error occurs during the file info retrieval
     */
    waitForUpload(fileId: string, token?: string, timeout?: number, interval?: number): Promise<FilesInfoResponse>;
    /**
     * Retrieves information about a file.
     *
     * @param options - Arguments for retrieving file information
     * @returns A promise that resolves to the file information response
     *
     * @example
     * ```typescript
     * const fileInfo = await client.filesInfo({
     *   file: "F123456789"
     * });
     * ```
     */
    filesInfo(options: FilesInfoArguments): Promise<FilesInfoResponse>;
    /**
     * Retrieves an external upload URL for files.
     *
     * @param options - The arguments for the external upload URL request
     * @returns A promise that resolves to a FilesGetUploadURLExternalResponse
     * @throws Will throw and log any errors that occur during the request
     */
    getUploadURLExternal(options: FilesGetUploadURLExternalArguments): Promise<FilesGetUploadURLExternalResponse>;
    /**
     * Completes an external file upload process.
     * Calls the Slack API's files.completeUploadExternal method.
     *
     * @param options - Arguments required for completing an external upload
     * @returns A promise resolving to the response from the Slack API
     * @throws Will throw and log any errors that occur during the API call
     */
    completeUploadExternal(options: FilesCompleteUploadExternalArguments): Promise<FilesCompleteUploadExternalResponse>;
}
/**
 * A class that provides an interface for sending messages to Slack via webhooks.
 *
 * This class wraps the Slack IncomingWebhook functionality and provides a simplified
 * interface for sending messages to a Slack channel.
 *
 * @example
 * ```typescript
 * const slackWebhookClient = new SlackWebhookClient({
 *   webhook: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
 *   username: 'WebdriverIO Reporter'
 * });
 *
 * await slackWebhookClient.send('Test message');
 * ```
 */
declare class SlackWebhookClient {
    private _url;
    private _webhook;
    /**
     * Creates an instance of the Slack IncomingWebhook.
     * @param {SlackIncomingWebhookOptions} options - Configuration options for the Slack webhook.
     */
    constructor(options: SlackIncomingWebhookOptions);
    /**
     * Gets the URL for the Slack webhook.
     * @returns The URL string for the Slack webhook.
     */
    get url(): string;
    /**
     * Gets the Slack IncomingWebhook instance.
     *
     * @returns {IncomingWebhook} The configured Slack webhook client
     */
    get webhook(): IncomingWebhook;
    /**
     * Sends a payload to Slack via webhook.
     *
     * @param payload - The content to send to Slack. Can be either a string or an IncomingWebhookSendArguments object.
     * @returns A Promise that resolves with the IncomingWebhookResult from Slack.
     * @throws Will re-throw any error that occurs during the send operation after logging it.
     */
    send(payload: string | IncomingWebhookSendArguments): Promise<IncomingWebhookResult>;
}

export { SlackWebClient, SlackWebhookClient };
