define("moneyformatter", ["clientkernelModulesApi", "moneyApi"],
    function(clientkernelModulesApi, moneyApi) {
        "use strict";

        function $iterator(o) {
            if (o instanceof Array) return function() {
                return {
                    cur: 0,
                    arr: o,
                    hasNext: function() {
                        return this.cur < this.arr.length;
                    },
                    next: function() {
                        return this.arr[this.cur++];
                    }
                };
            };
            return typeof(o.iterator) == 'function' ? $bind(o, o.iterator) : o.iterator;
        };;
        var $fid = 0;

        function $bind(o, m) {
            if (m == null) return null;
            if (m.__id__ == null) m.__id__ = $fid++;
            var f;
            if (o.hx__closures__ == null) o.hx__closures__ = {};
            else f = o.hx__closures__[m.__id__];
            if (f == null) {
                f = function() {
                    return f.method.apply(f.scope, arguments);
                };
                f.scope = o;
                f.method = m;
                o.hx__closures__[m.__id__] = f;
            }
            return f;
        };
        var $_;
        var $estr = function() {
            return _hcmn_.js_Boot.__string_rec(this, '');
        };
        if (typeof moneyformatter == 'undefined') {
            var moneyformatter = {};
        };
        moneyformatter.Activator = function() {};
        moneyformatter.Activator = ck_implements(moneyformatter.Activator, clientkernelModulesApi.IModuleActivator);
        moneyformatter.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        moneyformatter.Activator.__name__ = ["moneyformatter", "Activator"];
        moneyformatter.Activator.prototype.start = function(context) {
            var moneyFormatter = new moneyformatter.MoneyFormatter();
            context.registerService(moneyFormatter, moneyApi.IMoneyFormatterController, null);
            context.registerService(moneyFormatter, moneyApi.IMoneyFormatter, null);
        };
        moneyformatter.Activator.prototype.stop = function(context) {};
        moneyformatter.Activator.main = function() {
            null;
        };
        moneyformatter.Activator.prototype.__class__ = moneyformatter.Activator;
        moneyformatter.MoneyFormatter = function() {
            this.THOUSANDS_GROUP_SIZE = 3;
        };
        moneyformatter.MoneyFormatter = ck_implements(moneyformatter.MoneyFormatter, moneyApi.IMoneyFormatterController);
        moneyformatter.MoneyFormatter = ck_implements(moneyformatter.MoneyFormatter, moneyApi.IMoneyFormatter);
        moneyformatter.MoneyFormatter = ck_implements(moneyformatter.MoneyFormatter, clientkernelModulesApi.IService);
        moneyformatter.MoneyFormatter.__interfaces__ = [moneyApi.IMoneyFormatterController, moneyApi.IMoneyFormatter, clientkernelModulesApi.IService];
        moneyformatter.MoneyFormatter.__name__ = ["moneyformatter", "MoneyFormatter"];
        moneyformatter.MoneyFormatter.prototype.currencyFormat = null;
        moneyformatter.MoneyFormatter.prototype.THOUSANDS_GROUP_SIZE = null;
        moneyformatter.MoneyFormatter.prototype.setCurrencyFormat = function(currencyFormat) {
            this.currencyFormat = currencyFormat;
        };
        moneyformatter.MoneyFormatter.prototype.format = function(moneyString) {
            if (this.currencyFormat == null) return moneyString;
            if (moneyString == null || moneyString.length == 0) return null;
            var moneyFloat = parseFloat(moneyString);
            if (isNaN(moneyFloat) || moneyFloat < 0) return null;
            var moneyArray = moneyString.split(".");
            var integer = moneyArray[0];
            if (integer.length == 0) integer = "0";
            if (moneyArray.length == 1) moneyArray.push("00");
            var fraction = moneyArray[1];
            if (fraction.length == 0) fraction = "00";
            if (fraction.length == 1) fraction = fraction + "0";
            if (fraction.length != 2) return null;
            var result = "";
            if (this.currencyFormat.useThousandsSeparator && integer.length > this.THOUSANDS_GROUP_SIZE) {
                var currentThousandGroup = 1;
                var i = 0;
                while (true) {
                    result = result + integer.charAt(i);
                    i++;
                    if (i == integer.length) break;
                    if ((integer.length - i) % this.THOUSANDS_GROUP_SIZE == 0) {
                        if (this.currencyFormat.thousandsSeparator != "_") result = result + this.currencyFormat.thousandsSeparator;
                        else result = result + " ";
                    }
                }
            } else result = integer;
            if (this.currencyFormat.minorCurrencyLock && integer == "0") {
                var minorPaddingSpace;
                if (this.currencyFormat.minorSymbolPaddingSpace) minorPaddingSpace = " ";
                else minorPaddingSpace = "";
                while (fraction.charAt(0) == "0") fraction = _hcmn_.HxOverrides.substr(fraction, 1, null);
                if (this.currencyFormat.minorSymbolIsLeftAligned) result = this.currencyFormat.minorSymbol + minorPaddingSpace + fraction;
                else result = fraction + minorPaddingSpace + this.currencyFormat.minorSymbol;
            } else {
                var decimalSeparator;
                if (this.currencyFormat.decimalPrecision == 0) decimalSeparator = "";
                else decimalSeparator = this.currencyFormat.decimalSeparator;
                if (fraction.length > this.currencyFormat.decimalPrecision) fraction = fraction.substring(0, this.currencyFormat.decimalPrecision);
                result = result + decimalSeparator + fraction;
                var majorPaddingSpace;
                if (this.currencyFormat.majorSymbolPaddingSpace) majorPaddingSpace = " ";
                else majorPaddingSpace = "";
                if (this.currencyFormat.majorSymbolIsLeftAligned) result = this.currencyFormat.majorSymbol + majorPaddingSpace + result;
                else result = result + majorPaddingSpace + this.currencyFormat.majorSymbol;
            }
            return result;
        };
        moneyformatter.MoneyFormatter.prototype.isZero = function(moneyString) {
            return parseFloat(moneyString) == 0;
        };
        moneyformatter.MoneyFormatter.prototype.__class__ = moneyformatter.MoneyFormatter;
        return {
            exports: moneyformatter,
            activator: moneyformatter.Activator
        };
    });
//# sourceURL=moneyFormatter.js