;
window.FineMark = window.FineMark || {};

$.extend(FineMark, {
    Manager: function () {
        var FP_VERSION = "3.2.0";
        var PPF_VERSION = "8.2.0";
        var FINE_MARK_VERSION = "1.0.0";

        var FINE_MARK_COOKIE_KEY = "fineMarkId";

        return {
            version: function () {
                console.log(
                        "FP VERSION: " + FP_VERSION + "; " +
                        "FINE MARK VERSION: " + FINE_MARK_VERSION + "; " +
                        "PPF_VERSION: " + PPF_VERSION
                );
            },

            init: function () {
                if (!FR.CookieInfor.getCookieByName(FINE_MARK_COOKIE_KEY)) {
                    // Initialize an agent at application startup.
                    // can using more custom components
                    var fpPromise = FingerprintJS.load();
                    // Get the visitor identifier when you need it.
                    fpPromise
                            .then(function (fp) {
                                return fp.get()
                            })
                            .then(function (result) {
                                // This is the visitor identifier:
                                // todo collect more components and create by server
                                var visitorId = result.visitorId;
                                // todo verify in v2
                                // save in cookie
                                FR.CookieInfor.addCookie(FINE_MARK_COOKIE_KEY, visitorId, 200);
                            });
                }
            }
        }

    }()
})
$(function () {
    FineMark.Manager.init();
});