'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var parrot = require('@cloudtower/parrot');
var index = require('../ErrorBoundary/index.js');
var Pointer = require('./Pointer.js');
var RenderChart = require('./RenderChart.js');
var styled = require('./styled.js');
var cs = require('classnames');
var React = require('react');

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

var cs__default = /*#__PURE__*/_interopDefault(cs);
var React__default = /*#__PURE__*/_interopDefault(React);

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
const Metric = (props) => {
  const {
    height = 154,
    showPointer = true,
    showLegend = true,
    showXaxis = false,
    chartProps,
    "data-testid": dataTestId
  } = props;
  const [width, setWidth] = React.useState();
  const wrapperRef = React.useRef(null);
  React.useEffect(() => {
    var _a;
    setWidth((_a = wrapperRef.current) == null ? void 0 : _a.offsetWidth);
  }, []);
  return /* @__PURE__ */ React__default.default.createElement(index, { i18n: parrot.parrotI18n }, /* @__PURE__ */ React__default.default.createElement(
    styled.MetricWrapper,
    {
      "data-testid": dataTestId,
      className: cs__default.default("metric-wrapper", !showXaxis && "hidden-xaxis"),
      ref: wrapperRef,
      style: { height: showLegend ? height + 30 : height }
    },
    /* @__PURE__ */ React__default.default.createElement(RenderChart, __spreadValues({}, chartProps)),
    showPointer && /* @__PURE__ */ React__default.default.createElement(Pointer, { uuid: chartProps.syncId, metricWidth: width })
  ));
};
var Metric$1 = Metric;

exports.Pointer = Pointer;
exports.RenderChart = RenderChart;
exports.default = Metric$1;
