// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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;
};
import { Transform } from 'class-transformer';
import { hexToBigInt } from '../../utils/hex-encoding';
/**
 * All of the token scheme types.
 */
var TokenSchemeType;
(function (TokenSchemeType) {
    /** A simple token scheme. */
    TokenSchemeType[TokenSchemeType["Simple"] = 0] = "Simple";
})(TokenSchemeType || (TokenSchemeType = {}));
/**
 * The base class for token schemes.
 */
var TokenScheme = /** @class */ (function () {
    /**
     * @param type The type of token scheme.
     */
    function TokenScheme(type) {
        this.type = type;
    }
    return TokenScheme;
}());
/**
 * A simple token scheme.
 */
var SimpleTokenScheme = /** @class */ (function (_super) {
    __extends(SimpleTokenScheme, _super);
    /**
     * @param mintedTokens The number of tokens that were minted.
     * @param meltedTokens The number of tokens that were melted.
     * @param maximumSupply The maximum supply of the token.
     */
    function SimpleTokenScheme(mintedTokens, meltedTokens, maximumSupply) {
        var _this = _super.call(this, TokenSchemeType.Simple) || this;
        if (typeof mintedTokens === 'bigint') {
            _this.mintedTokens = mintedTokens;
        }
        else if (mintedTokens) {
            _this.mintedTokens = hexToBigInt(mintedTokens);
        }
        else {
            _this.mintedTokens = BigInt(0);
        }
        if (typeof meltedTokens === 'bigint') {
            _this.meltedTokens = meltedTokens;
        }
        else if (meltedTokens) {
            _this.meltedTokens = hexToBigInt(meltedTokens);
        }
        else {
            _this.meltedTokens = BigInt(0);
        }
        if (typeof maximumSupply === 'bigint') {
            _this.maximumSupply = maximumSupply;
        }
        else if (maximumSupply) {
            _this.maximumSupply = hexToBigInt(maximumSupply);
        }
        else {
            _this.maximumSupply = BigInt(0);
        }
        return _this;
    }
    __decorate([
        Transform(function (value) { return hexToBigInt(value.value); })
    ], SimpleTokenScheme.prototype, "mintedTokens");
    __decorate([
        Transform(function (value) { return hexToBigInt(value.value); })
    ], SimpleTokenScheme.prototype, "meltedTokens");
    __decorate([
        Transform(function (value) { return hexToBigInt(value.value); })
    ], SimpleTokenScheme.prototype, "maximumSupply");
    return SimpleTokenScheme;
}(TokenScheme));
var TokenSchemeDiscriminator = {
    property: 'type',
    subTypes: [
        { value: SimpleTokenScheme, name: TokenSchemeType.Simple },
    ]
};
export { TokenSchemeDiscriminator, TokenScheme, TokenSchemeType, SimpleTokenScheme, };
//# sourceMappingURL=token-scheme.js.map