"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var application = require("tns-core-modules/application");
var SalesforceDMP = (function () {
    function SalesforceDMP() {
        this.kruxEventAggregator = com.krux.androidsdk.aggregator.KruxEventAggregator;
        if (SalesforceDMP.instance) {
            throw new Error("Error: Instance already created: Use Salesforce.getInstance() instead of new.");
        }
        SalesforceDMP.instance = this;
    }
    SalesforceDMP.getInstance = function () {
        return SalesforceDMP.instance;
    };
    SalesforceDMP.prototype.initialize = function (configId, debug) {
        var kruxSegmentsCallback = new com.krux.androidsdk.aggregator.KruxSegments({
            getSegments: function (_segments) {
            }
        });
        this.kruxEventAggregator.initialize(application.android.context, configId, kruxSegmentsCallback, debug);
    };
    SalesforceDMP.prototype.trackPageView = function (page, pageAttributes, userAttributes) {
        this.kruxEventAggregator.trackPageView(page, this.keyValuesToBundle(pageAttributes), this.keyValuesToBundle(userAttributes));
    };
    SalesforceDMP.prototype.fireEvent = function (event, eventAttributes) {
        this.kruxEventAggregator.fireEvent(event, this.keyValuesToBundle(eventAttributes));
    };
    SalesforceDMP.prototype.keyValuesToBundle = function (keyValues) {
        if (keyValues == null) {
            return null;
        }
        var bundle = new android.os.Bundle();
        for (var i = 0; i < Object.keys(keyValues).length; i++) {
            var key = Object.keys(keyValues)[i];
            bundle.putString(key, keyValues[key]);
        }
        return bundle;
    };
    SalesforceDMP.instance = new SalesforceDMP();
    return SalesforceDMP;
}());
exports.SalesforceDMP = SalesforceDMP;
//# sourceMappingURL=salesforce.android.js.map