import { ButtonWidget, CalendarWidget, CommunityListWidget, CustomWidget, GetWidgetImageUploadLeaseResponse, GetWidgetsResponse, ImageWidget, PostFlairWidget, TextAreaWidget, UpdateCommunityListWidgetResponse, } from '@devvit/protos/types/devvit/plugin/redditapi/widgets/widgets_msg.js';
import { RedditAPI } from './RedditAPI.js';
export class Widgets extends RedditAPI {
    async AddButtonWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'button',
            ...request,
        }, metadata);
        return ButtonWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async AddImageWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'image',
            ...request,
        }, metadata);
        return ImageWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async AddCalendarWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'calendar',
            ...request,
        }, metadata);
        return CalendarWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async AddTextAreaWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'textarea',
            ...request,
        }, metadata);
        return TextAreaWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async AddCommunityListWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'community-list',
            ...request,
        }, metadata);
        return CommunityListWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async AddPostFlairWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'post-flair',
            ...request,
        }, metadata);
        return PostFlairWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async AddCustomWidget(request, metadata) {
        const response = await this._fetch('AddWidget', {
            kind: 'custom',
            ...request,
        }, metadata);
        return CustomWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async DeleteWidget(request, metadata) {
        await this._fetch('DeleteWidget', request, metadata);
        return {};
    }
    async UpdateButtonWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'button',
            ...request,
        }, metadata);
        return ButtonWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdateImageWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'image',
            ...request,
        }, metadata);
        return ImageWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdateCalendarWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'calendar',
            ...request,
        }, metadata);
        return CalendarWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdateTextAreaWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'textarea',
            ...request,
        }, metadata);
        return TextAreaWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdateCommunityListWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'community-list',
            ...request,
        }, metadata);
        return UpdateCommunityListWidgetResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdatePostFlairWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'post-flair',
            ...request,
        }, metadata);
        return PostFlairWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdateCustomWidget(request, metadata) {
        const response = await this._fetch('UpdateWidget', {
            kind: 'custom',
            ...request,
        }, metadata);
        return CustomWidget.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async OrderWidgets(request, metadata) {
        await this._fetch('ReorderWidgets', request, metadata);
        return {};
    }
    async GetWidgetImageUploadLease(request, metadata) {
        const response = await this._fetch('UploadImageForWidget', request, metadata);
        return GetWidgetImageUploadLeaseResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async GetWidgets(request, metadata) {
        const response = await this._fetch('GetWidgets', request, metadata);
        return GetWidgetsResponse.fromJSON(this._decodeAndValidateResponseJSON(response, [/^widget_/]));
    }
}
