// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { LogError } from "../../../../core/decorator/LogErrorDecorator";
import { GetSecurityDetailsRequest, GetSecurityHoldersRequest, GetTotalSecurityHoldersRequest } from "../../request";
import ValidatedRequest from "../../../../core/validation/ValidatedArgs";
import { GetSecurityQuery } from "../../../../app/usecase/query/security/get/GetSecurityQuery";
import { BaseSecurityInPort } from "../BaseSecurityInPort";
import { GetSecurityHoldersQuery } from "../../../../app/usecase/query/security/security/getSecurityHolders/GetSecurityHoldersQuery";
import { GetTotalSecurityHoldersQuery } from "../../../../app/usecase/query/security/security/getTotalSecurityHolders/GetTotalSecurityHoldersQuery";
export class SecurityInPortInfo extends BaseSecurityInPort {
    async getInfo(request) {
        const { securityId } = request;
        ValidatedRequest.handleValidation("GetSecurityDetailsRequest", request);
        const res = await this.queryBus.execute(new GetSecurityQuery(securityId));
        const security = {
            name: res.security.name,
            symbol: res.security.symbol,
            isin: res.security.isin,
            type: res.security.type,
            decimals: res.security.decimals,
            isWhiteList: res.security.isWhiteList,
            isControllable: res.security.isControllable,
            isMultiPartition: res.security.isMultiPartition,
            totalSupply: res.security.totalSupply?.toString(),
            maxSupply: res.security.maxSupply?.toString(),
            diamondAddress: res.security.diamondAddress?.toString(),
            evmDiamondAddress: res.security.evmDiamondAddress?.toString(),
            paused: res.security.paused,
            regulation: res.security.regulation,
            isCountryControlListWhiteList: res.security.isCountryControlListWhiteList,
            countries: res.security.countries,
            info: res.security.info,
        };
        return security;
    }
    async getSecurityHolders(request) {
        const { securityId, start, end } = request;
        ValidatedRequest.handleValidation(GetSecurityHoldersRequest.name, request);
        return (await this.queryBus.execute(new GetSecurityHoldersQuery(securityId, start, end))).payload;
    }
    async getTotalSecurityHolders(request) {
        const { securityId } = request;
        ValidatedRequest.handleValidation(GetTotalSecurityHoldersRequest.name, request);
        return (await this.queryBus.execute(new GetTotalSecurityHoldersQuery(securityId))).payload;
    }
}
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetSecurityDetailsRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortInfo.prototype, "getInfo", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetSecurityHoldersRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortInfo.prototype, "getSecurityHolders", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetTotalSecurityHoldersRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortInfo.prototype, "getTotalSecurityHolders", null);
