if (!Array.prototype.forEach) {
    Array.prototype.forEach = function(callback) {
        var _arr = this;
        var val, j;
        for (var i in _arr) {
            if (_arr.hasOwnProperty(i)) {
                j = parseInt(i);
                val = _arr[j];
                callback(val, j, _arr);
            }
        }
    }
}

if (!Array.prototype.map) {
    Array.prototype.map = function(callback) {
        var _arr = [];
        this.forEach(function(el, i, arr) {
            _arr.push(callback(el, i, arr));
        });
        return _arr;
    }
}

if (!Array.prototype.filter) {
    Array.prototype.filter = function(callback) {
        var _arr = [];
        this.forEach(function(el, i, arr) {
            if (callback(el, i, arr)) {
                _arr.push(el);
            }
        });
        return _arr;
    }
}

if (!Array.prototype.find) {
    Array.prototype.find = function(callback) {
        var _arr = this;
        var val, j;
        for (var i in _arr) {
            if (_arr.hasOwnProperty(i)) {
                j = parseInt(i);
                val = _arr[j];
                if (callback(val, j, _arr)) {
                    return val;
                }
            }
        }
        return null;
    }
}


if (!Array.prototype.findIndex) {
    Array.prototype.findIndex = function(callback) {
        var _arr = this;
        var val, j;
        for (var i in _arr) {
            if (_arr.hasOwnProperty(i)) {
                j = parseInt(i);
                val = _arr[j];
                if (callback(val, j, _arr)) {
                    return j;
                }
            }
        }
        return -1;
    }
}

if (!Array.prototype.reduce) {
    Array.prototype.reduce = function(callback) {
        var _arr = this,
            len = _arr.length,
            a = _arr[0],
            b = _arr[1];
        a = callback(a, b, 0, _arr);
        for (var i = 1; i < len - 2; i++) {
            if (_arr.hasOwnProperty(i)) {
                b = _arr[i + 1];
                a = callback(a, b, i, _arr);
            }
        }
        return a;
    }
}


if (!Array.prototype.reduceRight) {
    Array.prototype.reduceRight = function(callback) {
        var _arr = this,
            len = _arr.length,
            a = _arr[len - 1],
            b = _arr[len - 2];
        a = callback(a, b, 0, _arr);
        for (var i = len - 2; i > 0; i--) {
            if (_arr.hasOwnProperty(i)) {
                b = _arr[i - 1];
                a = callback(a, b, len - i - 1, _arr);
            }
        }
        return a;
    }
}

if (!Array.prototype.some) {
    Array.prototype.some = function(callback) {
        var _arr = this;
        var val, j;
        for (var i in _arr) {
            if (_arr.hasOwnProperty(i)) {
                j = parseInt(i);
                val = _arr[j];
                if (callback(val, j, _arr)) {
                    return true;
                }
            }
        }
        return false;
    }
}

if (!Array.prototype.every) {
    Array.prototype.every = function(callback) {
        var _arr = this;
        var val, j;
        for (var i in _arr) {
            if (_arr.hasOwnProperty(i)) {
                j = parseInt(i);
                val = _arr[j];
                if (!callback(val, j, _arr)) {
                    return false;
                }
            }
        }
        return true;
    }
}

if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(el) {
        var _arr = this;
        var val;
        for (var i in _arr) {
            val = _arr[i];
            if (_arr.hasOwnProperty(i) && val === el) {
                return parseInt(i);
            }
        }
        return -1;
    }
}


if (!Function.prototype.bind) {
    Function.prototype.bind = function() {
        var fn = this,
            slice = Array.prototype.slice,
            presetArgs = slice.call(arguments),
            context = presetArgs.shift();
        return function() {
            return fn.apply(context, presetArgs.concat(slice.call(arguments)));
        };
    };
}

if (typeof Object.assign != 'function') {
    Object.assign = function(target) {
        if (target === undefined || target === null) {
            throw new TypeError('Cannot convert undefined or null to object');
        }
        var output = Object(target);
        for (var index = 1; index < arguments.length; index++) {
            var source = arguments[index];
            if (source !== undefined && source !== null) {
                for (var nextKey in source) {
                    if (source.hasOwnProperty(nextKey)) {
                        output[nextKey] = source[nextKey];
                    }
                }
            }
        }
        return output;
    };

}

if (typeof Object.create !== 'function') {
    Object.create = function(o) {
        function F() {}
        F.prototype = o?o:Object;
        F.prototype.constructor = F;
        return new F();
    };
}


if (!Object.keys) {
    Object.keys = (function() {
        'use strict';
        var hasOwnProperty = Object.prototype.hasOwnProperty,
            hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
            dontEnums = [
                'toString',
                'toLocaleString',
                'valueOf',
                'hasOwnProperty',
                'isPrototypeOf',
                'propertyIsEnumerable',
                'constructor'
            ],
            dontEnumsLength = dontEnums.length;

        return function(obj) {
            if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
                throw new TypeError('Object.keys called on non-object');
            }

            var result = [],
                prop,
                i;

            for (prop in obj) {
                if (hasOwnProperty.call(obj, prop)) {
                    result.push(prop);
                }
            }

            if (hasDontEnumBug) {
                for (i = 0; i < dontEnumsLength; i++) {
                    if (hasOwnProperty.call(obj, dontEnums[i])) {
                        result.push(dontEnums[i]);
                    }
                }
            }
            return result;
        };
    }());
}


! function(window) {

    if (!window.console) {
        window.console = {};
    }
    var con = window.console;
    var prop,
        method;
    var dummy = function() {};
    var properties = ['memory'];
    var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEn' +
        'd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,time' +
        'line,timelineEnd,timeStamp,trace,warn').split(',');
    while (prop = properties.pop())
        if (!con[prop])
            con[prop] = {};
    while (method = methods.pop())
        if (!con[method])
            con[method] = dummy;


    Array.isArray || (Array.isArray = function(arr) {
        return Object.prototype.toString.call(arr) == '[object Array]';
    });

    Object.is || (Object.is = function is(x, y) {
        // SameValue algorithm
        if (x === y) {
            // Steps 1-5, 7-10 Steps 6.b-6.e: +0 != -0 Added the nonzero y check to make
            // Flow happy, but it is redundant
            return x !== 0 || y !== 0 || 1 / x === 1 / y;
        } else {
            // Step 6.a: NaN == NaN
            return x !== x && y !== y;
        }
    });
}(window);