import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import 'core-js/modules/es.symbol.js';
import 'core-js/modules/es.array.concat.js';
import 'core-js/modules/es.array.filter.js';
import 'core-js/modules/es.object.get-own-property-descriptor.js';
import 'core-js/modules/es.object.get-own-property-descriptors.js';
import 'core-js/modules/es.object.keys.js';
import 'core-js/modules/es.object.to-string.js';
import 'core-js/modules/web.dom-collections.for-each.js';
import { CARD_TYPES } from '../constants/LayoutConstants.js';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var getChartOptions = function getChartOptions(type, hasData, content) {
  var _content$status, _content$status2, _content$status3;
  var basicOptionsObject = {
    color: content.color,
    animations: false,
    accessibility: true,
    toolbar: {
      enabled: false
    },
    legend: {
      position: content.legendPosition,
      enabled: hasData,
      truncation: content.truncation
    }
  };
  return type === CARD_TYPES.METER_CHART ? _objectSpread(_objectSpread({}, basicOptionsObject), {}, {
    containerResizable: true,
    meter: {
      peak: content.peak,
      proportional: {
        total: content.meterTotal,
        unit: content.meterUnit,
        totalFormatter: content.totalFormatter
      },
      status: {
        ranges: [].concat(_toConsumableArray(content !== null && content !== void 0 && (_content$status = content.status) !== null && _content$status !== void 0 && _content$status.success ? [{
          range: content.status.success,
          status: 'success'
        }] : []), _toConsumableArray(content !== null && content !== void 0 && (_content$status2 = content.status) !== null && _content$status2 !== void 0 && _content$status2.warning ? [{
          range: content.status.warning,
          status: 'warning'
        }] : []), _toConsumableArray(content !== null && content !== void 0 && (_content$status3 = content.status) !== null && _content$status3 !== void 0 && _content$status3.danger ? [{
          range: content.status.danger,
          status: 'danger'
        }] : []))
      }
    }
  }) : type === CARD_TYPES.SPARKLINE_CHART ? _objectSpread(_objectSpread({}, basicOptionsObject), {}, {
    grid: {
      x: {
        enabled: false
      },
      y: {
        enabled: false
      }
    },
    axes: {
      bottom: {
        visible: false,
        title: content.xLabel,
        mapsTo: content.xProperty,
        thresholds: content.xThresholds,
        scaleType: 'time'
      },
      left: {
        visible: false,
        title: content.yLabel,
        mapsTo: content.yProperty,
        thresholds: content.yThresholds,
        scaleType: 'linear'
      }
    },
    points: {
      enabled: false
    },
    legend: {
      enabled: false
    }
  }) : type === CARD_TYPES.STACKED_AREA_CHART ? _objectSpread(_objectSpread({}, basicOptionsObject), {}, {
    axes: {
      left: {
        stacked: true,
        title: content.yLabel,
        mapsTo: content.yProperty,
        thresholds: content.yThresholds,
        scaleType: 'linear'
      },
      bottom: {
        title: content.xLabel,
        mapsTo: content.xProperty,
        thresholds: content.xThresholds,
        scaleType: 'time'
      }
    },
    curve: content.curve
  }) : content;
};

export { getChartOptions };
