import * as tslib_1 from "tslib";
import { NgModule, InjectionToken, Inject, Optional } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ChartComponent } from './chart.component';
import { Chart } from 'chart.js';
import { replaceDefaultColors } from './color.helpers';
import { EChartComponent } from './echart.component';
export var CHART_DEFAULT_COLORS = new InjectionToken('ezy-chart-default-colours');
var ChartsModule = /** @class */ (function () {
    function ChartsModule(defaultColors) {
        if (defaultColors) {
            replaceDefaultColors(defaultColors);
        }
    }
    ChartsModule = tslib_1.__decorate([
        NgModule({
            declarations: [ChartComponent, EChartComponent],
            imports: [CommonModule],
            exports: [ChartComponent, EChartComponent]
        }),
        tslib_1.__param(0, Optional()),
        tslib_1.__param(0, Inject(CHART_DEFAULT_COLORS)),
        tslib_1.__metadata("design:paramtypes", [Array])
    ], ChartsModule);
    return ChartsModule;
}());
export { ChartsModule };
export { ChartComponent, EChartComponent };
Chart.pluginService.register({
    afterEvent: function (chartInstance, chartEvent) {
        var legend = chartInstance.legend;
        var canvas = chartInstance.canvas;
        var x = chartEvent.x;
        var y = chartEvent.y;
        var cursorStyle = 'default';
        if (x <= legend.right && x >= legend.left && y <= legend.bottom && y >= legend.top) {
            for (var _i = 0, _a = legend.legendHitBoxes; _i < _a.length; _i++) {
                var box = _a[_i];
                if (x <= box.left + box.width && x >= box.left && y <= box.top + box.height && y >= box.top) {
                    cursorStyle = 'pointer';
                    break;
                }
            }
        }
        if (canvas) {
            canvas.style.cursor = cursorStyle;
        }
    }
});
//# sourceMappingURL=charts.module.js.map