import { MCurrencyType } from '../money/money';
export var MCurrencySymbolPosition;
(function (MCurrencySymbolPosition) {
    MCurrencySymbolPosition["Before"] = "before";
    MCurrencySymbolPosition["After"] = "after";
})(MCurrencySymbolPosition || (MCurrencySymbolPosition = {}));
var MCurrency = /** @class */ (function () {
    function MCurrency(type, localizedSymbol, symbolPosition) {
        this.type = type;
        this.localizedSymbol = localizedSymbol;
        this.symbolPosition = symbolPosition;
    }
    return MCurrency;
}());
export { MCurrency };
var MDecimalFormat = /** @class */ (function () {
    function MDecimalFormat(thousandSeparator, decimalMark) {
        this.thousandSeparator = thousandSeparator;
        this.decimalMark = decimalMark;
    }
    return MDecimalFormat;
}());
export { MDecimalFormat };
var L10n = /** @class */ (function () {
    function L10n(options) {
        this.currency = (options || {}).curCurrency || MCurrencyType.CAD;
    }
    Object.defineProperty(L10n.prototype, "currentCurrency", {
        get: function () {
            return this.currency;
        },
        set: function (value) {
            this.currency = value;
        },
        enumerable: false,
        configurable: true
    });
    L10n.prototype.getCurrencyDetail = function (locale) {
        var currency = this.currentCurrency;
        var currencyTemplate = new Intl.NumberFormat(locale, { maximumSignificantDigits: 1, style: 'currency', currency: MCurrencyType[currency] }).format(0);
        var localizedSymbol = currencyTemplate.replace('0', '').trim();
        return new MCurrency(currency, localizedSymbol, currencyTemplate.split(localizedSymbol)[0] === '' ? MCurrencySymbolPosition.Before : MCurrencySymbolPosition.After);
    };
    L10n.prototype.getDecimalFormat = function (locale) {
        // TODO : Make this code more generic when the need arise.
        switch (locale) {
            case 'en-CA':
                return new MDecimalFormat(',', '.');
            case 'fr-CA':
                return new MDecimalFormat(' ', ',');
            default:
                throw new Error('l10n: Unhandled locale type.  Please specify a decimal format for this locale.');
        }
    };
    return L10n;
}());
export { L10n };
var L10nPlugin = {
    install: function (v, options) {
        v.prototype.$log.debug('$l10n', 'plugin.install');
        (v.prototype).$l10n = new L10n(options);
    }
};
export default L10nPlugin;
//# sourceMappingURL=l10n.js.map