'use strict';

var _typeof = require('@babel/runtime/helpers/typeof');
require('core-js/modules/es.array.concat.js');
require('core-js/modules/es.array.includes.js');
require('core-js/modules/es.array.join.js');
require('core-js/modules/es.object.keys.js');
require('core-js/modules/es.object.to-string.js');
require('core-js/modules/es.object.values.js');
require('core-js/modules/es.string.includes.js');
require('core-js/modules/web.dom-collections.for-each.js');
var PropTypes = require('prop-types');
var colors = require('@carbon/colors');
var bundledIcons = require('../utils/bundledIcons.js');
var deprecate = require('../internal/deprecate.js');
var DateTimePickerV2WithoutTimeSpinner = require('../components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js');
var LayoutConstants = require('./LayoutConstants.js');
var SharedPropTypes = require('./SharedPropTypes.js');
var ChartPropTypes = require('./ChartPropTypes.js');

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

var _typeof__default = /*#__PURE__*/_interopDefault(_typeof);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

var CHART_COLORS = [colors.purple70, colors.cyan50, colors.teal70, colors.magenta70, colors.red50, colors.red90, colors.green60, colors.blue80, colors.magenta50, colors.teal50, colors.cyan90, colors.purple50];
var AttributePropTypes = PropTypes__default.default.shape({
  label: PropTypes__default.default.string,
  // optional for little cards
  /** the key to load the value from the values object */
  dataSourceId: PropTypes__default.default.string.isRequired,
  /** optional data filter to apply to each attribute */
  dataFilter: PropTypes__default.default.objectOf(PropTypes__default.default.any),
  secondaryValue: PropTypes__default.default.shape({
    /** the key to load the value from the values object */
    dataSourceId: PropTypes__default.default.string.isRequired,
    color: PropTypes__default.default.string,
    trend: PropTypes__default.default.oneOf(['up', 'down'])
  }),
  thresholds: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
    comparison: PropTypes__default.default.oneOf(['<', '>', '=', '<=', '>=']).isRequired,
    value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]).isRequired,
    color: PropTypes__default.default.string,
    icon: PropTypes__default.default.string
  })),
  precision: PropTypes__default.default.number,
  unit: PropTypes__default.default.string
});
var RowHeightPropTypes = PropTypes__default.default.shape({
  lg: PropTypes__default.default.number,
  md: PropTypes__default.default.number,
  sm: PropTypes__default.default.number,
  xs: PropTypes__default.default.number
});
var DashboardBreakpointsPropTypes = PropTypes__default.default.shape({
  lg: PropTypes__default.default.number,
  md: PropTypes__default.default.number,
  sm: PropTypes__default.default.number,
  xs: PropTypes__default.default.number
});
var DashboardColumnsPropTypes = PropTypes__default.default.shape({
  lg: PropTypes__default.default.number,
  md: PropTypes__default.default.number,
  sm: PropTypes__default.default.number,
  xs: PropTypes__default.default.number
});
var ValueContentPropTypes = {
  content: PropTypes__default.default.shape({
    attributes: PropTypes__default.default.arrayOf(AttributePropTypes).isRequired
  }),
  /** Value card expects its values passed as an object with key value pairs */
  values: PropTypes__default.default.oneOfType([PropTypes__default.default.object, PropTypes__default.default.arrayOf(PropTypes__default.default.object)]),
  /** DataState will override the cards default empty state and error string */
  dataState: PropTypes__default.default.shape({
    type: PropTypes__default.default.oneOf([LayoutConstants.CARD_DATA_STATE.NO_DATA, LayoutConstants.CARD_DATA_STATE.ERROR]).isRequired,
    icon: PropTypes__default.default.element,
    label: PropTypes__default.default.string.isRequired,
    description: PropTypes__default.default.string.isRequired,
    extraTooltipText: PropTypes__default.default.string,
    learnMoreElement: PropTypes__default.default.element,
    tooltipDirection: PropTypes__default.default.oneOf(['bottom', 'top', 'left', 'right'])
  }),
  cardVariables: PropTypes__default.default.objectOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.func, PropTypes__default.default.number, PropTypes__default.default.bool])),
  /**
   * Value Card's formatting can be updated at runtime, customFormatter is provided the default formatted value and
   * the original value and expects a value to be returned that will be rendered on the value card.
   * customerFormatter(defaultFormattedValue, originalValue)
   */
  /** @deprecated use `formatter` */
  customFormatter: PropTypes__default.default.func,
  /**
   * formatter(originalValue, ctx) => ReactNode|string
   * Called before default formatting. If it returns a non-nullish value, that is rendered.
   * ctx: { locale, attribute, secondary?: boolean, isNumberValueCompact, fontSize }
   */
  formatter: PropTypes__default.default.func,
  /** optional custom font size for the displayed value */
  fontSize: PropTypes__default.default.number,
  /** option to determine whether the number should be abbreviated (i.e. 10,000 = 10K) */
  isNumberValueCompact: PropTypes__default.default.bool,
  /** Callback fired when an attribute is clicked to take further action like opening a modal */
  onAttributeClick: PropTypes__default.default.func
};
var TableCardPropTypes = {
  tooltip: PropTypes__default.default.node,
  title: PropTypes__default.default.string,
  size: PropTypes__default.default.oneOf([LayoutConstants.CARD_SIZES.LARGE, LayoutConstants.CARD_SIZES.LARGEWIDE]),
  content: PropTypes__default.default.shape({
    columns: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      dataSourceId: PropTypes__default.default.string.isRequired,
      /** optional width in pixels, default is no enforced max width */
      width: PropTypes__default.default.number,
      label: PropTypes__default.default.string,
      priority: PropTypes__default.default.number,
      /** See the renderDataFunction for TablePropTypes */
      renderDataFunction: PropTypes__default.default.func,
      /** optional type. If "TIMESTAMP", it will format to 'L HH:mm' */
      type: PropTypes__default.default.string,
      /** optional custom link */
      linkTemplate: PropTypes__default.default.shape({
        href: PropTypes__default.default.string,
        target: PropTypes__default.default.string
      })
    })).isRequired,
    showHeader: PropTypes__default.default.bool,
    expandedRows: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      id: PropTypes__default.default.string,
      label: PropTypes__default.default.string,
      /** optional custom link */
      linkTemplate: PropTypes__default.default.shape({
        href: PropTypes__default.default.string,
        target: PropTypes__default.default.string
      }),
      /** optional type. If "TIMESTAMP", it will format to 'L HH:mm' */
      type: PropTypes__default.default.string
    })),
    thresholds: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      dataSourceId: PropTypes__default.default.string.isRequired,
      comparison: PropTypes__default.default.oneOf(['<', '>', '=', '<=', '>=']).isRequired,
      value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]).isRequired,
      severity: PropTypes__default.default.oneOf([1, 2, 3]),
      /** optional overrides for color and icon */
      color: PropTypes__default.default.string,
      /** Custom threshold icon name */
      icon: PropTypes__default.default.string,
      /** Custom threshold label text */
      label: PropTypes__default.default.string,
      /** Optionally shows threshold severity label text. Shows by default */
      showSeverityLabel: PropTypes__default.default.bool,
      /** Optionally changes threshold severity label text */
      severityLabel: PropTypes__default.default.string,
      /** Shows column when there is no data */
      showOnContent: PropTypes__default.default.bool
    })),
    sort: PropTypes__default.default.oneOf(['ASC', 'DESC']),
    emptyMessage: PropTypes__default.default.node
  }).isRequired,
  value: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
    id: PropTypes__default.default.string.isRequired,
    values: PropTypes__default.default.objectOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.bool, PropTypes__default.default.number, PropTypes__default.default.instanceOf(Date), PropTypes__default.default.object, PropTypes__default.default.node])).isRequired,
    actions: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      id: PropTypes__default.default.string.isRequired,
      label: PropTypes__default.default.string,
      icon: PropTypes__default.default.oneOfType([PropTypes__default.default.oneOf(bundledIcons.bundledIconNames), PropTypes__default.default.shape({
        width: PropTypes__default.default.string,
        height: PropTypes__default.default.string,
        viewBox: PropTypes__default.default.string.isRequired,
        svgData: SharedPropTypes.SvgPropType.isRequired
      })])
    }))
  })),
  i18n: PropTypes__default.default.shape({
    criticalLabel: PropTypes__default.default.string,
    moderateLabel: PropTypes__default.default.string,
    lowLabel: PropTypes__default.default.string,
    selectSeverityPlaceholder: PropTypes__default.default.string,
    searchPlaceholder: PropTypes__default.default.string,
    filterButtonAria: PropTypes__default.default.string,
    defaultFilterStringPlaceholdText: PropTypes__default.default.string,
    downloadIconDescription: PropTypes__default.default.string
  }),
  /** whether to use translated labels in cards */
  shouldUseTranslatedLabels: PropTypes__default.default.bool,
  cardVariables: PropTypes__default.default.objectOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.func, PropTypes__default.default.number, PropTypes__default.default.bool])),
  /** default date format pattern that follows the dayjs formatting patterns */
  defaultDateFormatPattern: PropTypes__default.default.string
};

/** carbon charts legend truncation options */
var TruncationPropTypes = PropTypes__default.default.shape({
  /** truncation type */
  type: PropTypes__default.default.oneOf(['end_line', 'mid_line', 'front_line', 'none']),
  /** number of characters needed to enable truncation */
  threshold: PropTypes__default.default.number,
  /** number of characters needed to enable truncation */
  numCharacter: PropTypes__default.default.number
});

/** Optionally addes a zoom bar to the chart */
var ZoomBarPropTypes = PropTypes__default.default.shape({
  /** Determines which axis to put the zoomBar */
  axes: PropTypes__default.default.oneOf(['top']),
  // top is the only axes supported right now
  // axes: PropTypes.oneOf(['top', 'bottom', 'left', 'right']), // TODO: When the other axes are supported, swap to this proptype
  /** Determines whether the zoomBar is enabled */
  enabled: PropTypes__default.default.bool,
  /** Optional domain to zoom to by default. Can be a timestamp or date string */
  initialZoomDomain: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])),
  /** How the zoomBar will display. Graph view shows a graphical interpretation of the chart data.
   * Slider view is a simple slider with no graphical interpretation */
  view: PropTypes__default.default.oneOf(['graph_view', 'slider_view'])
});

/** This dataset only supports one data attribute at a time */
var BarChartDatasetPropType = {
  /** data attribute that will be displayed as bar height y-axis value */
  dataSourceId: PropTypes__default.default.string.isRequired,
  /** optional label of the bar in the legend */
  label: PropTypes__default.default.string,
  /** optional each attribute has a different color, or use an object to set a color by category value,
   * or an array if you don't care which category values maps to a particular color. NOTE: If using the
   * object option, the key must match the dataset label name */
  color: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.objectOf(PropTypes__default.default.string), PropTypes__default.default.arrayOf(PropTypes__default.default.string)])
};
var BarChartCardPropTypes = {
  /** card size */
  size: function size(props, propName, componentName) {
    var error;
    if (!Object.keys(LayoutConstants.CARD_SIZES).includes(props[propName])) {
      error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(LayoutConstants.CARD_SIZES).join(','), "."));
    }
    // If the size
    if (props[propName] === LayoutConstants.CARD_SIZES.SMALL || props[propName] === LayoutConstants.CARD_SIZES.SMALLWIDE || props[propName] === LayoutConstants.CARD_SIZES.SMALLFULL) {
      error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
    }
    return error;
  },
  content: PropTypes__default.default.shape({
    /** the layout of the bar chart (horizontal, vertical) */
    layout: PropTypes__default.default.oneOf(Object.values(LayoutConstants.BAR_CHART_LAYOUTS)),
    /** the type of bar chart (simple, grouped, stacked) */
    type: function type(props, propName, componentName) {
      var error;
      // Must be one of the BAR_CHART_TYPES
      if (!Object.values(LayoutConstants.BAR_CHART_TYPES).includes(props[propName])) {
        error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be `SIMPLE`, `GROUPED`, or `STACKED`."));
      } // GROUPED charts can't have timeDataSourceId
      else if (props[propName] === LayoutConstants.BAR_CHART_TYPES.GROUPED && props.timeDataSourceId) {
        error = new Error("`BarChartCard` of type `GROUPED` cannot use `timeDataSourceId` at this time.");
      } // STACKED charts with timeDataSourceId and categoryDataSourceId can't have datasource labels
      else if (props[propName] === LayoutConstants.BAR_CHART_TYPES.STACKED && props.timeDataSourceId && props.categoryDataSourceId) {
        var hasDataSourceLabel = false;
        props.series.forEach(function (datasource) {
          if (datasource.label) {
            hasDataSourceLabel = true;
          }
        });
        if (hasDataSourceLabel) {
          error = new Error("`BarChartCard` of type `STACKED` with `categoryDataSourceId` AND `timeDataSourceId` cannot use `label` within series. The legend labels will be created from the `categoryDataSourceId`.");
        }
      }
      return error;
    },
    /** x-axis display name */
    xLabel: PropTypes__default.default.string,
    /** y-axis display name */
    yLabel: PropTypes__default.default.string,
    /** the amount of decimals to show in a bar chart */
    decimalPrecision: PropTypes__default.default.number,
    /** defined dataset attributes */
    series: PropTypes__default.default.arrayOf(PropTypes__default.default.shape(BarChartDatasetPropType)).isRequired,
    /** for category type bar charts this is the x-axis value */
    categoryDataSourceId: function categoryDataSourceId(props, propName, componentName) {
      var error;
      if (props[propName] && props.type === LayoutConstants.BAR_CHART_TYPES.SIMPLE && props.timeDataSourceId) {
        error = new Error("`".concat(componentName, "` of type `SIMPLE` can not have `").concat(propName, "` AND `timeDataSourceId`."));
      } // all charts must have oneOf[categoryDataSourceId, timeDataSourceId]
      else if (!props[propName] && !props.timeDataSourceId) {
        error = new Error("`".concat(componentName, "` must have `").concat(propName, "` OR `timeDataSourceId`."));
      }
      return error;
    },
    /** for time based bar charts this is the x-axis value */
    timeDataSourceId: function timeDataSourceId(props, propName, componentName) {
      var error;
      if (props[propName] && props.type === LayoutConstants.BAR_CHART_TYPES.SIMPLE && props.categoryDataSourceId) {
        error = new Error("`".concat(componentName, "` of type `SIMPLE` can not have `").concat(propName, "` AND `categoryDataSourceId`."));
      }
      return error;
    },
    /** optional units to put in the legend for all datasets */
    unit: PropTypes__default.default.string,
    /** Optionally addes a zoom bar to the chart */
    zoomBar: ZoomBarPropTypes,
    /** carbon charts legend truncation options */
    truncation: TruncationPropTypes
  }).isRequired,
  /** array of data from the backend for instance [{quarter: '2020-Q1', city: 'Amsterdam', particles: 44700}, ...] */
  values: PropTypes__default.default.arrayOf(PropTypes__default.default.object),
  /** internationalization */
  i18n: PropTypes__default.default.shape({
    alertDetected: PropTypes__default.default.string,
    tooltipGroupLabel: PropTypes__default.default.string,
    tooltipTotalLabel: PropTypes__default.default.string,
    defaultFilterStringPlaceholdText: PropTypes__default.default.string
  }),
  /** optional domain to graph from. First value is the beginning of the range. Second value is the end of the range
   * can be date instance or timestamp */
  domainRange: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.object])),
  /** Show timestamp in browser local time or GMT */
  showTimeInGMT: PropTypes__default.default.bool,
  /** tooltip format pattern that follows the dayjs formatting patterns */
  tooltipDateFormatPattern: PropTypes__default.default.string,
  /** default date format pattern that follows the dayjs formatting patterns */
  defaultDateFormatPattern: PropTypes__default.default.string
};
var PieCardPropTypes = {
  /** Configuration content for the PieChart */
  content: PropTypes__default.default.shape({
    /** Object that maps the groupDataSourceId with a specific color, e.g. {'Group A': 'red', 'Group B': 'blue', ... } */
    colors: PropTypes__default.default.objectOf(PropTypes__default.default.string),
    /** Function to output custom HTML for the tooltip. Passed an array or object with the data,
     * and the default tooltip markup */
    customTooltip: PropTypes__default.default.func,
    /** Defaults to 'group' but can be overriden to be any string property of the objects in the values array */
    groupDataSourceId: PropTypes__default.default.string,
    /**
     * Function to format the labels. Input to the function is a wrapped data object containing additional
     * chart label info such as x & y positions etc */
    labelsFormatter: PropTypes__default.default.func,
    /** The alignment of the legend in relation to the chart, can be 'left', 'center', or 'right'. */
    legendAlignment: PropTypes__default.default.oneOf(['left', 'center', 'right']),
    /** The position of the legend in relation to the chart, can be 'bottom' or 'top'. */
    legendPosition: PropTypes__default.default.oneOf(['top', 'bottom']),
    /** carbon charts legend truncation options */
    truncation: TruncationPropTypes
  }),
  /** Used to overide the internal components and props for advanced customisation */
  overrides: PropTypes__default.default.shape({
    card: SharedPropTypes.OverridePropTypes,
    pieChart: SharedPropTypes.OverridePropTypes,
    table: SharedPropTypes.OverridePropTypes
  }),
  /**
   * array of data objects from the backend for instance [{group: 'Group A', value: 50}, {group: 'Group B', value: 50}, ...]
   * The group property can be called anything since it can be mapped via the groupDataSourceId but there must at least
   * be one property called value of type number. */
  values: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOfType([PropTypes__default.default.shape({
    /** the name of the slice */
    group: PropTypes__default.default.string.isRequired,
    /** the value of the slice */
    value: PropTypes__default.default.number.isRequired
  }), PropTypes__default.default.object]))
};
({
  content: PropTypes__default.default.shape({
    title: PropTypes__default.default.string,
    data: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      label: PropTypes__default.default.string.isRequired,
      value: PropTypes__default.default.number.isRequired,
      color: PropTypes__default.default.string
    }))
  }).isRequired
});
var ImageCardValuesPropType = PropTypes__default.default.shape({
  hotspots: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
    x: PropTypes__default.default.number,
    y: PropTypes__default.default.number,
    icon: PropTypes__default.default.string,
    color: PropTypes__default.default.string,
    height: PropTypes__default.default.number,
    width: PropTypes__default.default.number,
    content: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.node, PropTypes__default.default.shape({
      title: PropTypes__default.default.string,
      description: PropTypes__default.default.string,
      values: PropTypes__default.default.objectOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])),
      attributes: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
        dataSourceId: PropTypes__default.default.string,
        label: PropTypes__default.default.string,
        precision: PropTypes__default.default.number,
        thresholds: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
          comparison: PropTypes__default.default.oneOf(['>', '>=', '=', '<=', '<']),
          value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
          icon: PropTypes__default.default.string,
          color: PropTypes__default.default.string
        }))
      }))
    })])
  }))
});
var ImageCardPropTypes = {
  content: PropTypes__default.default.shape({
    id: PropTypes__default.default.string,
    src: PropTypes__default.default.string,
    zoomMax: PropTypes__default.default.number,
    /** value for object-fit property - contain, cover, fill */
    displayOption: PropTypes__default.default.string
  }).isRequired,
  values: ImageCardValuesPropType,
  /** the maximum supported file size in bytes */
  maxFileSizeInBytes: PropTypes__default.default.number,
  onUpload: PropTypes__default.default.func,
  onBrowseClick: PropTypes__default.default.func,
  accept: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
  /** callback that you can use to validate the image, if you return a message we will display it as an error */
  validateUploadedImage: PropTypes__default.default.func,
  size: function size(props, propName, componentName) {
    var error;
    if (!Object.keys(LayoutConstants.CARD_SIZES).includes(props[propName])) {
      error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(LayoutConstants.CARD_SIZES).join(','), "."));
    }
    // If the size
    if (props[propName] === LayoutConstants.CARD_SIZES.SMALL || props[propName] === LayoutConstants.CARD_SIZES.SMALLWIDE || props[propName] === LayoutConstants.CARD_SIZES.SMALLFULL || props[propName] === LayoutConstants.CARD_SIZES.LARGETHIN) {
      error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the lists will not render correctly. Minimum size is `MEDIUM`"));
    }
    return error;
  }
};
var GaugeCardPropTypes = {
  tooltip: PropTypes__default.default.element,
  content: PropTypes__default.default.shape({
    gauges: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      dataSourceId: PropTypes__default.default.string,
      units: PropTypes__default.default.string,
      minimumValue: PropTypes__default.default.number,
      maximumValue: PropTypes__default.default.number,
      renderValueFunction: PropTypes__default.default.func,
      color: PropTypes__default.default.string,
      backgroundColor: PropTypes__default.default.string,
      shape: PropTypes__default.default.oneOf(['half-circle', 'line', 'circle']),
      trend: PropTypes__default.default.shape({
        /** the key to load the trend value from the values object. */
        dataSourceId: PropTypes__default.default.string,
        color: PropTypes__default.default.string,
        trend: PropTypes__default.default.oneOf(['up', 'down'])
      }),
      thresholds: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
        comparison: PropTypes__default.default.oneOf(['<', '>', '=', '<=', '>=']),
        value: PropTypes__default.default.number,
        color: PropTypes__default.default.string,
        label: PropTypes__default.default.string
      }))
    }))
  }),
  values: PropTypes__default.default.shape({
    temperature: PropTypes__default.default.number,
    temperatureTrend: PropTypes__default.default.number
  })
};
var DashboardLayoutPropTypes = PropTypes__default.default.shape({
  i: PropTypes__default.default.string,
  x: PropTypes__default.default.number,
  y: PropTypes__default.default.number,
  w: PropTypes__default.default.number,
  h: PropTypes__default.default.number
});
var CardDimensionPropTypes = PropTypes__default.default.shape({
  w: PropTypes__default.default.number,
  h: PropTypes__default.default.number
});
var CardDimensionsPropTypes = PropTypes__default.default.shape({
  lg: CardDimensionPropTypes,
  md: CardDimensionPropTypes,
  sm: CardDimensionPropTypes,
  xs: CardDimensionPropTypes
});
var CardSizesToDimensionsPropTypes = PropTypes__default.default.shape({
  XSMALL: CardDimensionsPropTypes,
  SMALL: CardDimensionsPropTypes,
  TALL: CardDimensionsPropTypes,
  MEDIUM: CardDimensionsPropTypes,
  WIDE: CardDimensionsPropTypes,
  LARGE: CardDimensionsPropTypes,
  XLARGE: CardDimensionsPropTypes
});
var TimeRangeOptionsPropTypes = function TimeRangeOptionsPropTypes(props, propName, componentName) {
  var error;
  var timeRangeProp = props[propName];
  // if the
  if (props[propName]) {
    var timeRangeKeys = Object.keys(timeRangeProp);
    // only validate the options if they are populated and they are strings
    if (timeRangeKeys.length > 0 && typeof timeRangeProp[timeRangeKeys[0]] === 'string') {
      // throw error if timeRangeOptions does not include 'this' or 'last'
      var isError = timeRangeKeys.some(function (key) {
        return !key.includes('this') && !key.includes('last');
      });
      if (isError) {
        error = new Error("`".concat(componentName, "` prop `").concat(propName, "` key's should include `this` or `last` i.e. `{ thisWeek: 'This week', lastWeek: 'Last week'}`"));
      }
    } else if (timeRangeKeys.length > 0 && _typeof__default.default(timeRangeProp[timeRangeKeys[0]]) === 'object') {
      // throw error if timeRangeOptions does not label or offset fields
      var _isError = timeRangeKeys.some(function (key) {
        return !timeRangeProp[key].label || !timeRangeProp[key].offset;
      });
      if (_isError) {
        error = new Error("`".concat(componentName, "` prop `").concat(propName, "` each keyed object needs a label and offset."));
      }
    }
  }
  return error;
};
var ComboChartPropTypes = {
  content: PropTypes__default.default.shape({
    /** Which combination of charts should be rendered in the underlying <ComboChart> control */
    comboChartTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      type: PropTypes__default.default.oneOf(['scatter', 'line', 'simple-bar', 'stacked-bar', 'grouped-bar', 'area', 'stacked-area']),
      options: PropTypes__default.default.shape({
        points: PropTypes__default.default.shape({
          enabled: PropTypes__default.default.bool,
          radius: PropTypes__default.default.number,
          filled: PropTypes__default.default.bool,
          opacity: PropTypes__default.default.number
        })
      }),
      /* Name of the dataset/series the chart should follow */
      correspondingDatasets: PropTypes__default.default.arrayOf(PropTypes__default.default.string)
    })),
    /** the number of decimals to show in the legend and on the y-axis */
    decimalPrecision: PropTypes__default.default.number,
    /** Optionally hide zero. Useful when chart values are not close to zero, giving a better view of the meaningful data */
    includeZeroOnXaxis: PropTypes__default.default.bool,
    /** Optionally hide zero. Useful when chart values are not close to zero, giving a better view of the meaningful data */
    includeZeroOnYaxis: PropTypes__default.default.bool,
    /** Number of grid-line spaces to the left and right of the chart to add white space to. Defaults to 1 */
    addSpaceOnEdges: PropTypes__default.default.number,
    curve: PropTypes__default.default.string,
    legend: PropTypes__default.default.shape({
      alignment: PropTypes__default.default.oneOf(['center', 'left', 'right']),
      /** the clickability of legend items */
      clickable: PropTypes__default.default.boolean,
      enabled: PropTypes__default.default.boolean,
      order: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
      position: PropTypes__default.default.oneOf(['bottom', 'left', 'right', 'top']),
      truncation: PropTypes__default.default.shape({
        numCharater: PropTypes__default.default.number,
        threshold: PropTypes__default.default.number,
        types: PropTypes__default.default.string
      })
    }),
    timeDataSourceId: PropTypes__default.default.string,
    /** Dotted x-axis lines used for denoting data thresholds, etc */
    thresholds: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      fillColor: PropTypes__default.default.string,
      label: PropTypes__default.default.string,
      value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.object]),
      /** a function to format the threshold values */
      valueFormatter: PropTypes__default.default.func
    }))
  }),
  /** default date format pattern that follows the dayjs formatting patterns */
  defaultDateFormatPattern: PropTypes__default.default.string
};

/** These props all comes from the Button component */
var MapControlPropType = PropTypes__default.default.shape({
  /** optionally used by the consumer, ignored by the Mapcard */
  id: PropTypes__default.default.string,
  /** the icon to be displayed by the button */
  icon: SharedPropTypes.ButtonIconPropType,
  /** the icon text description */
  iconDescription: PropTypes__default.default.string,
  /** defaults to 'ghost', use 'icon-selection' for toggle buttons  */
  kind: PropTypes__default.default.oneOf(['ghost', 'icon-selection']),
  /** the callback for when a control is clicked */
  onClick: PropTypes__default.default.func,
  /** toggle selected styling for buttons of kind=icon-selection */
  selected: PropTypes__default.default.bool
});
var MapCardPropTypes = {
  /** true makes the legend full bleed at the bottom of the map */
  isLegendFullWidth: PropTypes__default.default.bool,
  /** true if the settings panel should be showing */
  isSettingPanelOpen: PropTypes__default.default.bool,
  /** list of layered map control buttons that are expanded horizontally */
  layeredControls: PropTypes__default.default.arrayOf(MapControlPropType),
  /** reference to the container element that holds the 3rd party map */
  mapContainerRef: PropTypes__default.default.object.isRequired,
  /** list of map control buttons */
  mapControls: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOfType([MapControlPropType, PropTypes__default.default.shape({
    group: PropTypes__default.default.arrayOf(MapControlPropType),
    visibleItemsCount: PropTypes__default.default.number,
    hasScroll: PropTypes__default.default.bool
  })])),
  /** callback when user zooms in */
  onZoomIn: PropTypes__default.default.func.isRequired,
  /** callback when user zooms out */
  onZoomOut: PropTypes__default.default.func.isRequired,
  /** an element or component containing the settingspanel (side bar content) */
  settingsContent: PropTypes__default.default.elementType,
  /** list of text - color pairs for the legend. Each pair is an array where pos 0 is the text and pos 1 the color */
  stops: PropTypes__default.default.array,
  /** the ref used needed by a drag and drop library like react-dnd. Is added to the map container element. */
  dropRef: PropTypes__default.default.oneOfType([PropTypes__default.default.shape({}), PropTypes__default.default.func])
};
var MeterChartCardPropTypes = {
  content: ChartPropTypes.MeterChartPropTypes.content,
  values: ChartPropTypes.MeterChartPropTypes.data,
  size: function size(props, propName, componentName) {
    var error;
    if (!Object.keys(LayoutConstants.CARD_SIZES).includes(props[propName])) {
      error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(LayoutConstants.CARD_SIZES).join(','), "."));
    }
    // If the size
    if (props[propName] === LayoutConstants.CARD_SIZES.SMALL || props[propName] === LayoutConstants.CARD_SIZES.SMALLWIDE || props[propName] === LayoutConstants.CARD_SIZES.SMALLFULL || props[propName] === LayoutConstants.CARD_SIZES.MEDIUMTHIN) {
      error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
    }
    return error;
  }
};
var SparklineChartCardPropTypes = {
  content: ChartPropTypes.SparklineChartPropTypes.content,
  values: ChartPropTypes.SparklineChartPropTypes.data,
  size: function size(props, propName, componentName) {
    var error;
    if (!Object.keys(LayoutConstants.CARD_SIZES).includes(props[propName])) {
      error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(LayoutConstants.CARD_SIZES).join(','), "."));
    }
    // If the size
    if (props[propName] === LayoutConstants.CARD_SIZES.SMALL || props[propName] === LayoutConstants.CARD_SIZES.SMALLWIDE || props[propName] === LayoutConstants.CARD_SIZES.SMALLFULL || props[propName] === LayoutConstants.CARD_SIZES.MEDIUMTHIN) {
      error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
    }
    return error;
  }
};
var StackedAreaChartCardPropTypes = {
  content: ChartPropTypes.StackedAreaChartPropTypes.content,
  values: ChartPropTypes.StackedAreaChartPropTypes.data,
  size: function size(props, propName, componentName) {
    var error;
    if (!Object.keys(LayoutConstants.CARD_SIZES).includes(props[propName])) {
      error = new Error("`".concat(componentName, "` prop `").concat(propName, "` must be one of ").concat(Object.keys(LayoutConstants.CARD_SIZES).join(','), "."));
    }
    // If the size
    if (props[propName] === LayoutConstants.CARD_SIZES.SMALL || props[propName] === LayoutConstants.CARD_SIZES.SMALLWIDE || props[propName] === LayoutConstants.CARD_SIZES.SMALLFULL || props[propName] === LayoutConstants.CARD_SIZES.MEDIUMTHIN) {
      error = new Error("Deprecation notice: `".concat(componentName, "` prop `").concat(propName, "` cannot be `").concat(props[propName], "` as the charts will not render correctly. Minimum size is `MEDIUM`"));
    }
    return error;
  }
};
var DATE_PICKER_OPTIONS = {
  ICON_ONLY: 'iconOnly',
  FULL: 'full'
};
var CardPropTypes = {
  title: PropTypes__default.default.string,
  subtitle: PropTypes__default.default.string,
  hasTitleWrap: PropTypes__default.default.bool,
  id: PropTypes__default.default.string,
  isLoading: PropTypes__default.default.bool,
  isEmpty: PropTypes__default.default.bool,
  isEditable: PropTypes__default.default.bool,
  /** goes full screen if expanded */
  isExpanded: PropTypes__default.default.bool,
  /** True if the card can be resizable in the DashboardGrid by dragging the borders */
  isResizable: PropTypes__default.default.bool,
  /**
   * Define the icon render to be rendered.
   * Can be a React component class
   */
  renderExpandIcon: PropTypes__default.default.oneOfType([PropTypes__default.default.func, PropTypes__default.default.object]),
  /** should hide the header */
  hideHeader: PropTypes__default.default.bool,
  /** should hide only the card title but keep the toolbar visible. Also disables card content padding. */
  hideTitle: PropTypes__default.default.bool,
  /** sets the CardWrapper CSS overflow to visible */
  showOverflow: deprecate(PropTypes__default.default.bool, '\nThe prop `showOverflow` for Card has been deprecated. It was previously needed for a custom positioned tooltip in the ValueCard, but the ValueCard now uses the default positioning of the tooltip. The `iot--card--wrapper--overflowing` class has been removed. For automated testing, you can target `data-testid="Card"` instead.'),
  size: PropTypes__default.default.oneOf(Object.values(LayoutConstants.LEGACY_CARD_SIZES)),
  layout: PropTypes__default.default.oneOf(Object.values(LayoutConstants.CARD_LAYOUTS)),
  breakpoint: PropTypes__default.default.oneOf(Object.values(LayoutConstants.DASHBOARD_SIZES)),
  /** setting to none will remove internal padding from sides and bottom of card. */
  padding: PropTypes__default.default.oneOf(['default', 'none']),
  /** Optional selected range to pass at the card level */
  timeRange: PropTypes__default.default.oneOfType([PropTypes__default.default.string, DateTimePickerV2WithoutTimeSpinner.DateTimePickerDefaultValuePropTypes]),
  /** Generates the available time range selection options. Each option should include 'this' or 'last'.
   * i.e. { thisWeek: 'This week', lastWeek: 'Last week'}
   */
  timeRangeOptions: TimeRangeOptionsPropTypes,
  availableActions: PropTypes__default.default.shape({
    edit: PropTypes__default.default.bool,
    clone: PropTypes__default.default.bool,
    delete: PropTypes__default.default.bool,
    expand: PropTypes__default.default.bool,
    range: PropTypes__default.default.oneOfType([PropTypes__default.default.bool,
    // previous simple range selector
    /** Use the new datepicker */
    PropTypes__default.default.oneOf(Object.values(DATE_PICKER_OPTIONS)) // these are the new'iconOnly' will only show icon, 'full' shows whole field
    ]),
    settings: PropTypes__default.default.bool,
    extra: PropTypes__default.default.bool
  }),
  /** All the labels that need translation */
  i18n: PropTypes__default.default.shape({
    noDataLabel: PropTypes__default.default.string,
    noDataShortLabel: PropTypes__default.default.string,
    errorLoadingDataLabel: PropTypes__default.default.string,
    errorLoadingDataShortLabel: PropTypes__default.default.string,
    // card labels
    rollingPeriodLabel: PropTypes__default.default.string,
    last24HoursLabel: PropTypes__default.default.string,
    last7DaysLabel: PropTypes__default.default.string,
    lastMonthLabel: PropTypes__default.default.string,
    lastQuarterLabel: PropTypes__default.default.string,
    lastYearLabel: PropTypes__default.default.string,
    periodToDateLabel: PropTypes__default.default.string,
    thisWeekLabel: PropTypes__default.default.string,
    thisMonthLabel: PropTypes__default.default.string,
    thisQuarterLabel: PropTypes__default.default.string,
    thisYearLabel: PropTypes__default.default.string,
    hourlyLabel: PropTypes__default.default.string,
    dailyLabel: PropTypes__default.default.string,
    weeklyLabel: PropTypes__default.default.string,
    monthlyLabel: PropTypes__default.default.string,
    /** If no time range is selected we should show this string as the default */
    defaultLabel: PropTypes__default.default.node,
    // card actions
    selectTimeRangeLabel: PropTypes__default.default.string,
    editCardLabel: PropTypes__default.default.string,
    cloneCardLabel: PropTypes__default.default.string,
    deleteCardLabel: PropTypes__default.default.string,
    expandLabel: PropTypes__default.default.string,
    closeLabel: PropTypes__default.default.string,
    loadingDataLabel: PropTypes__default.default.string,
    overflowMenuDescription: PropTypes__default.default.string,
    toLabel: PropTypes__default.default.string,
    titleTooltipIconDescription: PropTypes__default.default.string
  }),
  /** Adds an info icon after the title that when clicked shows a tooltip with this content.
   * Cannot be used together with the titleTextTooltip prop
   */
  tooltip: PropTypes__default.default.element,
  /** Adds tooltip to the title (no info icon) that when clicked shows a tooltip with this content.
   * Cannot be used together with the tooltip prop or the or the hasTitleWrap prop.
   */
  titleTextTooltip: PropTypes__default.default.element,
  toolbar: PropTypes__default.default.element,
  /** Row height in pixels for each layout */
  rowHeight: RowHeightPropTypes,
  /** media query pixel measurement that determines which particular dashboard layout should be used */
  dashboardBreakpoints: DashboardBreakpointsPropTypes,
  /** map of number of columns to a given dashboard layout */
  dashboardColumns: DashboardColumnsPropTypes,
  /** array of configurable sizes to dimensions */
  cardDimensions: CardSizesToDimensionsPropTypes,
  /** HTML classes that should be applied to the content container */
  contentClassName: PropTypes__default.default.string,
  /** optional function that should return an icon react element based on a icon name, it is called back with the icon name and then an object containing additional icon properties to add to the rendered icon */
  renderIconByName: PropTypes__default.default.func,
  /** Event handlers needed for Dashboard Grid - isEditable */
  onMouseDown: PropTypes__default.default.func,
  onMouseUp: PropTypes__default.default.func,
  onTouchEnd: PropTypes__default.default.func,
  onTouchStart: PropTypes__default.default.func,
  onScroll: PropTypes__default.default.func,
  /** Optional event handlers */
  onFocus: PropTypes__default.default.func,
  onBlur: PropTypes__default.default.func,
  /** Optionally adds tab index to card container */
  tabIndex: PropTypes__default.default.number,
  /** For testing */
  testID: deprecate(PropTypes__default.default.string, "The 'testID' prop has been deprecated. Please use 'testId' instead."),
  testId: PropTypes__default.default.string,
  /** the locale of the card, needed for number and date formatting */
  locale: PropTypes__default.default.string,
  /** IANA timezone string to set as default timezone for dayjs */
  timeZone: PropTypes__default.default.string,
  /** a way to pass down dashboard grid resize handles, only used by other card types */
  resizeHandles: PropTypes__default.default.array,
  /** Optional callback function that is passed an onChange function and the original cardConfig object.
   * This allows additional information to be passed to be used in the Card Editor for this type.
   * You need to return an array of child objects with a header: {title, tooltip: {tooltipText: PropTypes.string}} and content element to render
   * We recommend doing this dynamically with the CardEditor onRenderCardEditForm property rather than hard-coding it in the Card JSON
   * * */
  renderEditContent: PropTypes__default.default.func,
  footerContent: PropTypes__default.default.elementType,
  dateTimeMask: PropTypes__default.default.string,
  extraActions: PropTypes__default.default.shape({
    id: PropTypes__default.default.string.isRequired,
    icon: PropTypes__default.default.oneOfType([PropTypes__default.default.func, PropTypes__default.default.object]),
    callback: PropTypes__default.default.func,
    disabled: PropTypes__default.default.bool,
    children: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      id: PropTypes__default.default.string.isRequired,
      itemText: PropTypes__default.default.string.isRequired,
      callback: PropTypes__default.default.func.isRequired,
      disabled: PropTypes__default.default.bool,
      hidden: PropTypes__default.default.bool
    })),
    content: PropTypes__default.default.node
  }),
  overrides: PropTypes__default.default.shape({
    errorMessage: SharedPropTypes.OverridePropTypes
  }),
  /** If set to true it will render outside of the current DOM in a portal, otherwise render as a child */
  renderDateDropdownInPortal: PropTypes__default.default.bool,
  extraHeaderContent: PropTypes__default.default.element,
  /** CSS gradient value to apply as the card background. */
  backgroundGradient: PropTypes__default.default.string,
  /** Theme for the card. Can be 'light' or 'dark' */
  theme: PropTypes__default.default.oneOf(['light', 'dark'])
};

exports.AttributePropTypes = AttributePropTypes;
exports.BarChartCardPropTypes = BarChartCardPropTypes;
exports.CHART_COLORS = CHART_COLORS;
exports.CardDimensionPropTypes = CardDimensionPropTypes;
exports.CardDimensionsPropTypes = CardDimensionsPropTypes;
exports.CardPropTypes = CardPropTypes;
exports.CardSizesToDimensionsPropTypes = CardSizesToDimensionsPropTypes;
exports.ComboChartPropTypes = ComboChartPropTypes;
exports.DATE_PICKER_OPTIONS = DATE_PICKER_OPTIONS;
exports.DashboardBreakpointsPropTypes = DashboardBreakpointsPropTypes;
exports.DashboardColumnsPropTypes = DashboardColumnsPropTypes;
exports.DashboardLayoutPropTypes = DashboardLayoutPropTypes;
exports.GaugeCardPropTypes = GaugeCardPropTypes;
exports.ImageCardPropTypes = ImageCardPropTypes;
exports.ImageCardValuesPropType = ImageCardValuesPropType;
exports.MapCardPropTypes = MapCardPropTypes;
exports.MapControlPropType = MapControlPropType;
exports.MeterChartCardPropTypes = MeterChartCardPropTypes;
exports.PieCardPropTypes = PieCardPropTypes;
exports.RowHeightPropTypes = RowHeightPropTypes;
exports.SparklineChartCardPropTypes = SparklineChartCardPropTypes;
exports.StackedAreaChartCardPropTypes = StackedAreaChartCardPropTypes;
exports.TableCardPropTypes = TableCardPropTypes;
exports.TimeRangeOptionsPropTypes = TimeRangeOptionsPropTypes;
exports.TruncationPropTypes = TruncationPropTypes;
exports.ValueContentPropTypes = ValueContentPropTypes;
exports.ZoomBarPropTypes = ZoomBarPropTypes;
