"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spread = (this && this.__spread) || function () {
    for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
    return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var d3 = require("d3");
var _ = require("lodash");
// window['_events']={};
var events = {};
if (_.has(window, '_events')) {
    events = window['_events'];
}
else {
    window['_events'] = {};
    events = window['_events'];
}
var default_1 = /** @class */ (function () {
    function default_1() {
    }
    default_1.on = function (type, fn) {
        var evt = type.toLowerCase();
        if (_.has(events, evt)) {
            return;
        }
        events[evt] = d3.dispatch(evt);
        events[evt].on(evt, fn);
    };
    default_1.call = function (type) {
        var _a;
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        var evt = type.toLowerCase();
        if (_.has(events, evt)) {
            (_a = events[evt]).call.apply(_a, __spread([evt, null], args));
            return;
        }
        else {
        }
    };
    return default_1;
}());
exports.default = default_1;
