'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 __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const LineChart = React__default.default.forwardRef(
  (props, ref) => {
    const {
      height = 154,
      showPointer = true,
      showLegend = true,
      showXaxis = false,
      chartProps
    } = props;
    const [width, setWidth] = React.useState(0);
    const wrapperRef = React.useRef(null);
    React.useEffect(() => {
      var _a;
      setWidth(((_a = wrapperRef.current) == null ? void 0 : _a.offsetWidth) || 0);
    }, []);
    return /* @__PURE__ */ React__default.default.createElement(index, { i18n: parrot.parrotI18n }, /* @__PURE__ */ React__default.default.createElement(
      styled.LineChartWrapper,
      {
        className: cs__default.default("metric-wrapper", !showXaxis && "hidden-xaxis"),
        ref: wrapperRef,
        style: { height: showLegend ? height + 30 : height }
      },
      /* @__PURE__ */ React__default.default.createElement(RenderChart, __spreadProps(__spreadValues({}, chartProps), { width })),
      showPointer && /* @__PURE__ */ React__default.default.createElement(Pointer, { uuid: chartProps.syncId, metricWidth: width })
    ));
  }
);
var LineChart$1 = LineChart;

exports.default = LineChart$1;
