import 'core-js/modules/es.symbol.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 _defineProperty from '@babel/runtime/helpers/defineProperty';
import React__default, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { CARD_TYPES } from '../../../constants/LayoutConstants.js';
import DataSeriesFormSettings from './CardEditFormItems/DataSeriesFormItems/DataSeriesFormSettings.js';
import ValueCardFormSettings from './CardEditFormItems/ValueCardFormItems/ValueCardFormSettings.js';
import ImageCardFormSettings from './CardEditFormItems/ImageCardFormItems/ImageCardFormSettings.js';
import BarChartCardFormSettings from './CardEditFormItems/BarChartCardFormItems/BarChartCardFormSettings.js';
import TableCardFormSettings from './CardEditFormItems/TableCardFormItems/TableCardFormSettings.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 propTypes = {
  /** an object where the keys are available dimensions and the values are the values available for those dimensions
   *  ex: { manufacturer: ['Rentech', 'GHI Industries'], deviceid: ['73000', '73001', '73002'] }
   */
  availableDimensions: PropTypes.shape({}),
  /** card data value */
  cardConfig: PropTypes.shape({
    id: PropTypes.string,
    title: PropTypes.string,
    size: PropTypes.string,
    type: PropTypes.string,
    content: PropTypes.shape({
      series: PropTypes.arrayOf(PropTypes.shape({
        label: PropTypes.string,
        dataSourceId: PropTypes.string,
        color: PropTypes.string
      })),
      xLabel: PropTypes.string,
      yLabel: PropTypes.string,
      unit: PropTypes.string,
      includeZeroOnXaxis: PropTypes.bool,
      includeZeroOnYaxis: PropTypes.bool,
      timeDataSourceId: PropTypes.string,
      showLegend: PropTypes.bool
    }),
    renderEditSettings: PropTypes.func,
    interval: PropTypes.string
  }),
  /** Callback function when form data changes */
  onChange: PropTypes.func.isRequired,
  i18n: PropTypes.shape({
    xAxisLabel: PropTypes.string,
    yAxisLabel: PropTypes.string,
    unitLabel: PropTypes.string,
    decimalPrecisionLabel: PropTypes.string,
    precisionLabel: PropTypes.string,
    showLegendLabel: PropTypes.string,
    fontSize: PropTypes.string
  })
};
var defaultProps = {
  availableDimensions: {},
  cardConfig: {},
  i18n: {
    xAxisLabel: 'X-axis label',
    yAxisLabel: 'Y-axis label',
    unitLabel: 'Unit',
    decimalPrecisionLabel: 'Decimal precision',
    precisionLabel: 'Precision',
    showLegendLabel: 'Show legend',
    fontSize: 'Font size'
  }
};
var CardEditFormSettings = function CardEditFormSettings(_ref) {
  var cardConfig = _ref.cardConfig,
    onChange = _ref.onChange,
    i18n = _ref.i18n,
    availableDimensions = _ref.availableDimensions;
  var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
  var type = cardConfig.type,
    renderEditSettings = cardConfig.renderEditSettings;
  var handleTranslation = useCallback(function (idToTranslate) {
    var openMenuText = mergedI18n.openMenuText,
      closeMenuText = mergedI18n.closeMenuText;
    switch (idToTranslate) {
      default:
        return '';
      case 'open.menu':
        return openMenuText || 'Open menu';
      case 'close.menu':
        return closeMenuText || 'Close menu';
    }
  }, [mergedI18n]);
  switch (type) {
    case CARD_TYPES.VALUE:
      return /*#__PURE__*/React__default.createElement(ValueCardFormSettings, {
        cardConfig: cardConfig,
        i18n: mergedI18n,
        onChange: onChange,
        translateWithId: handleTranslation
      });
    case CARD_TYPES.TIMESERIES:
      return /*#__PURE__*/React__default.createElement(DataSeriesFormSettings, {
        cardConfig: cardConfig,
        i18n: mergedI18n,
        onChange: onChange
      });
    case CARD_TYPES.BAR:
      return /*#__PURE__*/React__default.createElement(BarChartCardFormSettings, {
        cardConfig: cardConfig,
        i18n: mergedI18n,
        onChange: onChange
      });
    case CARD_TYPES.IMAGE:
      return /*#__PURE__*/React__default.createElement(ImageCardFormSettings, {
        cardConfig: cardConfig,
        i18n: mergedI18n,
        onChange: onChange,
        translateWithId: handleTranslation
      });
    case CARD_TYPES.TABLE:
      return /*#__PURE__*/React__default.createElement(TableCardFormSettings, {
        availableDimensions: availableDimensions,
        cardConfig: cardConfig,
        i18n: mergedI18n,
        onChange: onChange,
        translateWithId: handleTranslation
      });
    default:
      return renderEditSettings ? renderEditSettings(onChange, cardConfig) : null;
  }
};
CardEditFormSettings.propTypes = propTypes;
CardEditFormSettings.defaultProps = defaultProps;
CardEditFormSettings.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "CardEditFormSettings",
  "props": {
    "availableDimensions": {
      "defaultValue": {
        "value": "{}",
        "computed": false
      },
      "description": "an object where the keys are available dimensions and the values are the values available for those dimensions\n ex: { manufacturer: ['Rentech', 'GHI Industries'], deviceid: ['73000', '73001', '73002'] }",
      "type": {
        "name": "shape",
        "value": {}
      },
      "required": false
    },
    "cardConfig": {
      "defaultValue": {
        "value": "{}",
        "computed": false
      },
      "description": "card data value",
      "type": {
        "name": "shape",
        "value": {
          "id": {
            "name": "string",
            "required": false
          },
          "title": {
            "name": "string",
            "required": false
          },
          "size": {
            "name": "string",
            "required": false
          },
          "type": {
            "name": "string",
            "required": false
          },
          "content": {
            "name": "shape",
            "value": {
              "series": {
                "name": "arrayOf",
                "value": {
                  "name": "shape",
                  "value": {
                    "label": {
                      "name": "string",
                      "required": false
                    },
                    "dataSourceId": {
                      "name": "string",
                      "required": false
                    },
                    "color": {
                      "name": "string",
                      "required": false
                    }
                  }
                },
                "required": false
              },
              "xLabel": {
                "name": "string",
                "required": false
              },
              "yLabel": {
                "name": "string",
                "required": false
              },
              "unit": {
                "name": "string",
                "required": false
              },
              "includeZeroOnXaxis": {
                "name": "bool",
                "required": false
              },
              "includeZeroOnYaxis": {
                "name": "bool",
                "required": false
              },
              "timeDataSourceId": {
                "name": "string",
                "required": false
              },
              "showLegend": {
                "name": "bool",
                "required": false
              }
            },
            "required": false
          },
          "renderEditSettings": {
            "name": "func",
            "required": false
          },
          "interval": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "i18n": {
      "defaultValue": {
        "value": "{\n  xAxisLabel: 'X-axis label',\n  yAxisLabel: 'Y-axis label',\n  unitLabel: 'Unit',\n  decimalPrecisionLabel: 'Decimal precision',\n  precisionLabel: 'Precision',\n  showLegendLabel: 'Show legend',\n  fontSize: 'Font size',\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "xAxisLabel": {
            "name": "string",
            "required": false
          },
          "yAxisLabel": {
            "name": "string",
            "required": false
          },
          "unitLabel": {
            "name": "string",
            "required": false
          },
          "decimalPrecisionLabel": {
            "name": "string",
            "required": false
          },
          "precisionLabel": {
            "name": "string",
            "required": false
          },
          "showLegendLabel": {
            "name": "string",
            "required": false
          },
          "fontSize": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "onChange": {
      "description": "Callback function when form data changes",
      "type": {
        "name": "func"
      },
      "required": true
    }
  }
};
var CardEditFormSettings$1 = CardEditFormSettings;

export { CardEditFormSettings$1 as default };
