"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntersectionsChartAxis = void 0;
var react_1 = __importStar(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var styles_1 = require("./styles");
var helpers_1 = require("../../helpers");
var IntersectionsChartAxis = function (_a) {
    var xScale = _a.xScale, yScale = _a.yScale, width = _a.width, height = _a.height;
    var styles = (0, styles_1.useStyles)();
    var ticksRef = (0, react_1.useRef)(null);
    var ticks = (0, react_1.useMemo)(function () {
        return yScale
            .nice()
            .ticks()
            .filter(function (tick) { return Number.isInteger(tick); });
    }, [yScale]);
    var ticksWidth = (0, react_1.useMemo)(function () { return (0, helpers_1.calculateTicksWidth)(ticks); }, [ticks]);
    return (react_1.default.createElement("g", null,
        xScale.domain().map(function (d, i) {
            var x = xScale(d) + xScale.bandwidth() / 2;
            return react_1.default.createElement("line", { key: "v-grid-".concat(i), className: styles.verticalGrid, x1: x, x2: x, y1: 0, y2: height });
        }),
        ticks.map(function (tick, i) {
            var y = yScale(tick);
            return react_1.default.createElement("line", { key: "h-grid-".concat(i), className: styles.horizontalGrid, x1: 0, x2: width, y1: y, y2: y });
        }),
        react_1.default.createElement("g", { ref: ticksRef }, ticks.map(function (tick, i) {
            var y = yScale(tick);
            return (react_1.default.createElement("g", { key: "x-tick-".concat(i), transform: "translate(0,".concat(y, ")") },
                react_1.default.createElement("line", { className: styles.axis, x1: -4, x2: 0, y1: 0, y2: 0 }),
                react_1.default.createElement("text", { className: styles.axisTickLabel, x: -8, y: 4 }, tick)));
        })),
        react_1.default.createElement("line", { className: styles.axis, x1: 0, x2: 0, y1: 0, y2: height }),
        react_1.default.createElement("line", { className: styles.axis, x1: 0, x2: width, y1: height, y2: height }),
        react_1.default.createElement("text", { className: styles.axisLabel, transform: "translate(".concat(-ticksWidth - 12, ",").concat(height / 2, ") rotate(-90)") }, ui_i18n_1.default.text('No. of unified profiles'))));
};
exports.IntersectionsChartAxis = IntersectionsChartAxis;
