"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _Accordion = _interopRequireDefault(require("@material-ui/core/Accordion"));

var _AccordionSummary = _interopRequireDefault(require("@material-ui/core/AccordionSummary"));

var _AccordionDetails = _interopRequireDefault(require("@material-ui/core/AccordionDetails"));

var _AccordionActions = _interopRequireDefault(require("@material-ui/core/AccordionActions"));

var _styles = require("@material-ui/core/styles");

var _classnames = _interopRequireDefault(require("classnames"));

var _expansionPanelProps = require("./expansionPanelProps");

var _Icon = _interopRequireDefault(require("./../DataDisplay/Icon"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    expansionPanelHeader: {
      minHeight: 0,
      backgroundColor: theme.palette.grey.light,
      height: theme.spacing(4),
      "&$headerPanelExpanded": {
        minHeight: 0,
        margin: 0
      },
      borderColor: theme.palette.grey.borders
    },
    expandIcon: {
      hight: theme.spacing(1),
      width: theme.spacing(1)
    },
    headerPanelExpanded: {}
  };
});

var ExpansionPanel = function ExpansionPanel(_ref) {
  var _expansionPanelProps$;

  var header = _ref.header,
      content = _ref.content,
      actions = _ref.actions,
      expansionPanelProps = _ref.expansionPanelProps,
      expansionPanelActionsProps = _ref.expansionPanelActionsProps;

  if ((0, _expansionPanelProps.isExpansionPanelProps)(expansionPanelProps) === false) {
    throw new TypeError("expansionPanelProps property is not of type ExpansionPanelProps");
  }

  if ((0, _expansionPanelProps.isExpansionPanelActionsProps)(expansionPanelActionsProps) === false) {
    throw new TypeError("expansionPanelActionsProps property is not of type ExpansionPanelActionsProps");
  }

  var classes = useStyles(); // Expansion panel props

  var disabled = expansionPanelProps == null ? void 0 : expansionPanelProps.get(_expansionPanelProps.ExpansionPanelProps.propNames.disabled);
  var defaultExpanded = (_expansionPanelProps$ = expansionPanelProps == null ? void 0 : expansionPanelProps.get(_expansionPanelProps.ExpansionPanelProps.propNames.defaultExpanded)) != null ? _expansionPanelProps$ : true;

  var _React$useState = _react.default.useState(defaultExpanded),
      _React$useState2 = _slicedToArray(_React$useState, 2),
      expanded = _React$useState2[0],
      setExpanded = _React$useState2[1];

  var internalOnChange = function internalOnChange(evt, isExpanded) {
    setExpanded(isExpanded);
  };

  var expansionPanelRootStyle = expansionPanelProps == null ? void 0 : expansionPanelProps.getStyle(_expansionPanelProps.ExpansionPanelProps.ruleNames.root);
  var panelSummaryRootStyle = expansionPanelProps == null ? void 0 : expansionPanelProps.getStyle(_expansionPanelProps.ExpansionPanelProps.ruleNames.summaryRoot);
  var panelSummaryExpandedStyle = expansionPanelProps == null ? void 0 : expansionPanelProps.getStyle(_expansionPanelProps.ExpansionPanelProps.ruleNames.summaryExpanded);
  var panelDetailsStyle = expansionPanelProps == null ? void 0 : expansionPanelProps.getStyle(_expansionPanelProps.ExpansionPanelProps.ruleNames.details);
  var panelActionsStyle = expansionPanelProps == null ? void 0 : expansionPanelProps.getStyle(_expansionPanelProps.ExpansionPanelProps.ruleNames.actions); // Expansion panel summary props
  // Expansion panel actions props

  var disableSpacing = expansionPanelActionsProps == null ? void 0 : expansionPanelActionsProps.get(_expansionPanelProps.ExpansionPanelActionsProps.propNames.disableSpacing);
  return /*#__PURE__*/_react.default.createElement(_Accordion.default, {
    defaultExpanded: defaultExpanded,
    disabled: disabled == null ? false : disabled,
    expanded: expanded,
    onChange: internalOnChange,
    classes: {
      root: expansionPanelRootStyle
    }
  }, /*#__PURE__*/_react.default.createElement(_AccordionSummary.default, {
    expandIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
      id: "chevron-down",
      className: classes.expandIcon
    }),
    classes: {
      root: (0, _classnames.default)(classes.expansionPanelHeader, panelSummaryRootStyle),
      expanded: (0, _classnames.default)(classes.headerPanelExpanded, panelSummaryExpandedStyle)
    }
  }, header), /*#__PURE__*/_react.default.createElement(_AccordionDetails.default, {
    classes: {
      root: panelDetailsStyle
    }
  }, content), actions != null ? /*#__PURE__*/_react.default.createElement(_AccordionActions.default, {
    classes: {
      root: panelActionsStyle
    },
    disableSpacing: disableSpacing == null ? false : disableSpacing
  }, actions) : null);
};

__signature__(ExpansionPanel, "useStyles{classes}\nuseState{[expanded, setExpanded](defaultExpanded)}", function () {
  return [useStyles];
});

__signature__(ExpansionPanel, "useStyles{classes}\nuseState{[expanded, setExpanded](defaultExpanded)}", function () {
  return [useStyles];
});

var _default = ExpansionPanel;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/ExpansionPanel.js");
  reactHotLoader.register(ExpansionPanel, "ExpansionPanel", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/ExpansionPanel.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/ExpansionPanel.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/ExpansionPanel.js");
  reactHotLoader.register(ExpansionPanel, "ExpansionPanel", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/ExpansionPanel.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/ExpansionPanel.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();