'use strict';

var index = require('../KitStoreProvider/index.js');
var _ = require('lodash');
var React = require('react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var ___default = /*#__PURE__*/_interopDefault(_);
var React__default = /*#__PURE__*/_interopDefault(React);

const Pointer = ({ uuid = "", metricWidth }) => {
  const pointers = index.useKitSelector(
    (state) => ___default.default.get(state, "chart.pointers")
  );
  if (!(pointers == null ? void 0 : pointers[uuid])) {
    return null;
  }
  const { left = 0, text } = pointers[uuid];
  let dis = -99999999;
  const threshold = 50;
  if (metricWidth) {
    if (left <= threshold) {
      dis = threshold;
    } else if (left >= metricWidth - threshold) {
      dis = metricWidth - threshold;
    } else {
      dis = left;
    }
  }
  return /* @__PURE__ */ React__default.default.createElement(
    "div",
    {
      style: {
        transform: `translate(${dis}px)`,
        position: "absolute",
        whiteSpace: "nowrap"
      }
    },
    /* @__PURE__ */ React__default.default.createElement("div", { className: "pointer-wrapper" }, text)
  );
};
var Pointer$1 = Pointer;

module.exports = Pointer$1;
