"use strict";
// SPDX-FileCopyrightText: 2026 Catalan Lover <catalanlover@protonmail.com>
//
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppserviceAvatarCommand = void 0;
const matrix_protection_suite_1 = require("matrix-protection-suite");
const interface_manager_1 = require("@the-draupnir-project/interface-manager");
const matrix_basic_types_1 = require("@the-draupnir-project/matrix-basic-types");
const AppserviceBotInterfaceAdaptor_1 = require("./AppserviceBotInterfaceAdaptor");
const matrix_protection_suite_for_matrix_bot_sdk_1 = require("matrix-protection-suite-for-matrix-bot-sdk");
exports.AppserviceAvatarCommand = (0, interface_manager_1.describeCommand)({
    summary: "Sets the avatar of the main appservice admin bot.",
    parameters: [],
    rest: {
        name: "avatar url",
        acceptor: interface_manager_1.StringPresentationType,
    },
    async executor(context, _info, _keywords, avatarParts) {
        const avatarUrl = avatarParts.join(" ").trim();
        if (!avatarUrl) {
            return matrix_protection_suite_1.ActionError.Result("Avatar URL cannot be empty");
        }
        if (!(0, matrix_basic_types_1.isStringMediaURI)(avatarUrl)) {
            return matrix_protection_suite_1.ActionError.Result(`Invalid MXC URI format. Expected format: mxc://server/media-id, got: ${avatarUrl}`);
        }
        const setAvatarResult = await context.client
            .setAvatarUrl(avatarUrl)
            .then((_) => (0, matrix_protection_suite_1.Ok)(undefined), matrix_protection_suite_for_matrix_bot_sdk_1.resultifyBotSDKRequestError);
        if ((0, matrix_protection_suite_1.isError)(setAvatarResult)) {
            return setAvatarResult.elaborate(`Failed to set appservice bot avatar to ${avatarUrl}`);
        }
        return setAvatarResult;
    },
});
AppserviceBotInterfaceAdaptor_1.AppserviceBotInterfaceAdaptor.describeRenderer(exports.AppserviceAvatarCommand, {
    isAlwaysSupposedToUseDefaultRenderer: true,
});
//# sourceMappingURL=AvatarCommand.js.map