import { TemplateResult, PropertyValues, nothing } from 'lit';
import { HttpRequest, type IHttpRequest } from '@api-client/core/models/HttpRequest.js';
import { type IRequestAuthorization, RequestAuthorization } from '@api-client/core/models/RequestAuthorization.js';
import { type IRequestConfig } from '@api-client/core/models/RequestConfig.js';
import type { IHttpAssertion } from '@api-client/core/models/http-flows/HttpAssertion.js';
import { type DeserializedPayload } from '@api-client/core/lib/transformers/PayloadSerializer.js';
import type { IHttpFlow } from '@api-client/core/models/http-flows/HttpFlows.js';
import type { IRequestUiMeta } from '@api-client/core/models/RequestUiMeta.js';
import type { AuthorizationType } from '@api-client/core/models/Authorization.js';
import type { IProperty } from '@api-client/core/models/Property.js';
import ApiElement from '../ApiElement.js';
import type { TabSelectionDetail } from '../../md/tabs/internals/Tabs.js';
import type { UiDialogClosingReason } from '../../md/dialog/internals/Dialog.js';
import '../../md/icons/ui-icon.js';
import '../../define/http/http-url-input.js';
import '../../define/http/http-url-params-form.js';
import '../../define/http/http-headers-form.js';
import '../../define/http/http-snippets.js';
import '../../define/http/http-body-editor.js';
import '../../define/http/http-assertions.js';
import '../../define/http/http-flows.js';
import '../../define/http/http-request-config.js';
import '../../md/dropdown-list/ui-dropdown-list.js';
import '../../md/list/ui-list.js';
import '../../md/list/ui-list-item.js';
import '../../md/button/ui-button.js';
import '../../md/tabs/ui-tabs.js';
import '../../md/tabs/ui-tab.js';
import '../../md/divider/ui-divider.js';
import '../../md/dialog/ui-dialog.js';
import '../../define/authorization/basic-authorization.js';
import '../../define/authorization/bearer-authorization.js';
import '../../define/authorization/ntlm-authorization.js';
import '../../define/authorization/apikey-authorization.js';
import '../../define/authorization/oauth2-authorization.js';
import '../../define/authorization/oidc-authorization.js';
import '../../define/authorization/cc-authorization.js';
export declare const HttpMethods: string[];
export declare const NonPayloadMethods: string[];
export type SelectedTab = 'parameters' | 'headers' | 'payload' | 'authorization' | 'code-snippets' | 'assertions' | 'config' | 'flows';
export interface SendDetails {
    /**
     * The request object to send.
     */
    request: IHttpRequest;
    /**
     * Optional authorization configuration.
     */
    authorization: IRequestAuthorization[] | undefined;
    /**
     * The request options.
     */
    config: IRequestConfig | undefined;
    /**
     * HTTP tests to perform.
     */
    assertions: IHttpAssertion[] | undefined;
}
/**
 * An element that renders an HTTP editor.
 *
 * @fires send - A custom event when the user requested to send the request. The detail object is the editor's request.
 * @fires abort - When the user requested to abort the ongoing request.
 * @fires authorizationchange - When authorization data change.
 * @fires uichange - When the UI model change.
 */
export default class RequestEditor extends ApiElement {
    /**
     * A promise set when reading payload from the `request` object.
     * It is resolved after the payload is read anf the `payload` property is set.
     */
    protected readingPayloadPromise: Promise<void>;
    /**
     * A promise set when the payload is being written to the `request` object.
     * It is resolved after the `payload` is set on the request as a serializable object.
     */
    protected writingPayloadPromise: Promise<void>;
    /**
     * A flag used to determine when the payload is being read for the synchronous code.
     */
    accessor readingPayload: boolean;
    /**
     * The base request object.
     */
    accessor request: IHttpRequest;
    /**
     * The request payload.
     * It can be just a string or an object with the payload data depending on the content type.
     */
    accessor payload: DeserializedPayload | undefined;
    /**
     * The current content type value.
     */
    accessor contentType: string | undefined;
    accessor authorization: IRequestAuthorization[] | undefined;
    accessor assertions: IHttpAssertion[] | undefined;
    accessor flows: IHttpFlow[] | undefined;
    /**
     * Redirect URL for the OAuth2 authorization.
     * If can be also set by dispatching `oauth2-redirect-url-changed`
     * with `value` property on the `detail` object.
     */
    accessor oauth2RedirectUri: string | undefined;
    /**
     * When set the editor is in read only mode.
     */
    accessor readOnly: boolean;
    /**
     * A value to be passed to the OAuth 2 `authorizationUri` property in case
     * if current configuration has no value.
     * This is to be used as a default value.
     */
    accessor oauth2AuthorizationUri: string | undefined;
    /**
     * A value to be passed to the OAuth 2 `accessTokenUri` property in case
     * if current configuration has no value.
     * This is to be used as a default value.
     */
    accessor oauth2AccessTokenUri: string | undefined;
    /**
     * When set it ignores all `content-*` headers when the request method is `GET`.
     * When not set or `false` it renders a warning message.
     */
    accessor ignoreContentOnGet: boolean;
    /**
     * When set the `content-` headers warning dialog is rendered.
     */
    accessor contentHeadersDialogOpened: boolean;
    /**
     * To be set when the request is being transported.
     */
    accessor loading: boolean;
    /**
     * An index of currently opened tab.
     * @attribute
     */
    accessor selectedTab: SelectedTab;
    /**
     * Optional instance of the `RequestUiMeta` to store the UI state.
     */
    accessor ui: IRequestUiMeta | undefined;
    /**
     * HTTP request configuration for the transport.
     */
    accessor config: IRequestConfig;
    /**
     * @returns True when the request cannot have the payload on the message.
     */
    get isPayload(): boolean;
    protected _awaitingOAuth2authorization: boolean;
    /**
     * This is set by the internal logic. When `ignoreContentOnGet` is set and the headers have `content-` headers
     * a dialog is rendered when trying to send the request. When the user chooses to ignore the warning this
     * flag makes sure that `send()` does not check headers.
     *
     * @todo(pawel): This should be done in the request logic module plugin.
     * Plugins can stop request indefinitely or cancel it.
     */
    ignoreValidationOnGet: boolean;
    protected accessor snippets: IHttpRequest | undefined;
    constructor();
    connectedCallback(): void;
    disconnectedCallback(): void;
    firstUpdated(changedProperties: PropertyValues<this>): void;
    protected willUpdate(changedProperties: PropertyValues<this>): void;
    protected setupContentType(request?: IHttpRequest): void;
    protected readPayload(): Promise<void>;
    /**
     * Validates state of the URL.
     * @return True if the URL has a structure that looks like
     * an URL which means scheme + something
     */
    validateUrl(): boolean;
    /**
     * Checks if current request requires calling `authorize()` on the OAuth2 method.
     *
     * @return This returns `true` only for valid OAuth 2 method that has no access token.
     */
    requiresAuthorization(): boolean;
    /**
     * Validates headers for `Content-*` entries against current method.
     * @param request The request object
     * @return True if headers are invalid.
     */
    validateContentHeaders(request: IHttpRequest): boolean;
    /**
     * Serializes the current values to the `IHttpRequest`
     */
    serialize(): Promise<IHttpRequest>;
    /**
     * Dispatches the send request event to the HTTP request engine.
     */
    send(): Promise<void>;
    protected notifySend(request: IHttpRequest): void;
    /**
     * If the request does not exist it creates one.
     * @returns The request object.
     */
    protected getRequest(): IHttpRequest;
    /**
     * Aborts the request
     */
    abort(): void;
    protected handleInternalSend(e: Event): void;
    protected handleVerbSelection(e: CustomEvent): void;
    /**
     * @param verb The HTTP verb (operation, method)
     */
    selectVerb(verb: string): void;
    /**
     * The handler for the URL editor change event
     */
    protected handlerUrlChange(e: Event): void;
    /**
     * Commits the change in the URL.
     * @param value The new URL value
     */
    selectUrl(value: string): void;
    protected handleTabSelect(e: CustomEvent<TabSelectionDetail>): void;
    protected handleParamsChange(e: Event): void;
    /**
     * The handler for the headers change event from the headers editor.
     */
    handleHeadersChange(e: Event): void;
    selectHeaders(model: IProperty[]): void;
    /**
     * The handler for the body editor change event
     */
    protected handleBody(e: Event): void;
    protected updatePayload(value: DeserializedPayload, mime?: string): Promise<void>;
    /**
     * When `mime` is set it creates the `payloadOptions` property with the mime.
     * @param request The request to set the mime type
     * @param mime the mime type value
     */
    protected setPayloadMimeOption(request: IHttpRequest | HttpRequest, mime?: string): void;
    protected handleFlows(e: Event): void;
    selectFlows(flows?: IHttpFlow[]): void;
    protected handleAssertions(e: Event): void;
    selectAssertions(assertions?: IHttpAssertion[]): void;
    protected handleConfig(e: Event): void;
    selectRequestConfig(config: IRequestConfig): void;
    /**
     * Called to notify listeners about a particular property change
     *
     * @param type The property that changed. The resulting event type is
     *             the combination of this value and the `change` suffix.
     * @param value The value of the changed property
     */
    protected notifyPropertyChanged(type: string, value: unknown): void;
    protected handleContentWarningClose(e: CustomEvent<UiDialogClosingReason>): void;
    /**
     * When a request change this recomputes the values for code snippets.
     * These are different from the actual values in the request as
     * they contain authorization values applied to it.
     */
    protected computeSnippetsRequest(): Promise<void>;
    /**
     * Adds a new authorization object to the request for the given type.
     *
     * @returns The created instance of the authorization.
     */
    addAuthorization(type: AuthorizationType): RequestAuthorization;
    /**
     * Updates authorization schema on the editor.
     * @param schema The new schema to replace the old one
     * @param isValid Whether the schema is valid.
     */
    updateAuthorization(schema: IRequestAuthorization, isValid: boolean): void;
    /**
     * Removes authorization schema from the editor.
     * @param type The authorization type to remove.
     */
    removeAuthorization(type: string): void;
    protected handleAuthAdd(e: CustomEvent): void;
    protected handleAuthChange(e: Event): void;
    protected handleAuthDelete(e: Event): void;
    protected render(): TemplateResult;
    /**
     * @returns The template for the top line with method selector, URL, and options.
     */
    protected renderUrlEditorArea(): TemplateResult;
    protected renderUrlMeta(): TemplateResult;
    /**
     * @returns The template for the HTTP method selector
     */
    protected renderHttpMethodSelector(): TemplateResult;
    /**
     * @returns The templates for each supported HTTP methods
     */
    protected renderHttpVerbOptions(): TemplateResult[];
    /**
     * @returns The template for the HTTP URL editor
     */
    protected renderUrlEditor(): TemplateResult;
    /**
     * @returns The template for the "send" or "abort" buttons.
     */
    protected renderSendButton(): TemplateResult | string;
    /**
     * @returns The template for the request editor tabs
     */
    protected renderTabs(): TemplateResult;
    /**
     * @returns The template for the current editor
     */
    protected renderCurrentEditor(): TemplateResult;
    protected renderParameters(visible: boolean): TemplateResult;
    /**
     * @param visible Whether the panel should not be hidden
     * @returns The template for the headers editor
     */
    protected renderHeaders(visible: boolean): TemplateResult;
    /**
     * @param visible Whether the panel should not be hidden
     * @returns The template for the body editor
     */
    protected renderBody(visible: boolean): TemplateResult;
    /**
     * @param visible Whether the panel should not be hidden
     * @returns The template for the authorization editor
     */
    protected renderAuthorization(visible: boolean): TemplateResult | string;
    protected renderAuthorizationActions(current?: IRequestAuthorization[]): TemplateResult;
    protected renderAuthorizationOptions(available: string[]): TemplateResult;
    protected renderAuthorizationList(authorization?: IRequestAuthorization[]): TemplateResult[];
    protected renderEmptyAuthorization(): TemplateResult;
    protected renderBasicAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderBearerAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderNtlmAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderOauthAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderOidcAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderCCAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderApiKeyAuthorization(auth: IRequestAuthorization): TemplateResult;
    protected renderHttpFlows(visible: boolean): TemplateResult | string;
    protected renderAssertions(visible: boolean): TemplateResult | string;
    protected renderRequestConfig(visible: boolean): TemplateResult | typeof nothing;
    /**
     * @param visible Whether the panel should be rendered
     * @returns The template for the Code snippets
     */
    protected renderSnippets(visible: boolean): TemplateResult | string;
    /**
     * @returns The template for the invalid content headers dialog
     */
    protected renderHeadersDialog(): TemplateResult | string;
}
//# sourceMappingURL=RequestEditor.d.ts.map