define('application/widgets/login/password', [
    'rofl/widgets/input/password'
], function (
    PasswordInput
) {
    'use strict';
    var DEFAULT_MAX_LENGTH = 4;
    return PasswordInput.extend({
        /**
         * Initializes the component.
         *
         * @param {Object} opts - The options object.
         */
        init: function init (opts) {
            opts = opts || {};
            this._maxLength = opts.maxLength || DEFAULT_MAX_LENGTH;
            init.base.call(this, opts);
        },
        /**
         * Repeat function.
         *
         * @param {string} str - String to repeat.
         * @param {number} count - Number of times to repeat.
         * @returns {string} Returns repeated string.
         * @private
         */
        _repeat: function (str, count) {
            var array = [], i;
            for (i = 0; i < count;) {
                array[i++] = str;
            }
            return array.join('');
        },
        /**
         * Masks a string value.
         *
         * @param {string} value - The value to mask.
         * @returns {string} - The masked string.
         * @private
         */
        _maskValue: function (value) {
            var result = '',
                count = value.length;
            if (this._maxLength > count > 0) {
                result = this._repeat(this._maskCharacter, count - 1) + value.charAt(count - 1);
            } else {
                result = this._repeat(this._maskCharacter, (count));
            }
            return result;
        },
        /**
         * Clears the input field value.
         */
        clearInputField: function () {
            this.setValue('');
        }
    });
});