"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 _Icon = _interopRequireDefault(require("./../DataDisplay/Icon"));

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

var _useViewState3 = _interopRequireDefault(require("../../../hooks/useViewState"));

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 {
    summaryRoot: {
      height: theme.spacing(8),
      backgroundColor: theme.palette.primary.lighter,
      flexDirection: "row-reverse",
      borderRadius: 0,
      "&:hover": {
        backgroundColor: theme.palette.hoverprimary.lighter
      },
      "&:focus": {
        borderRadius: 0
      }
    },
    resetPadding: {
      padding: "0 !important"
    },
    panelExpanded: {},
    summaryContent: {
      marginLeft: theme.spacing(1),
      "&$panelExpanded": {
        marginLeft: theme.spacing(1)
      }
    },
    panelRoot: {
      "&$panelExpanded": {
        margin: "0",
        "&:before": {
          opacity: "1"
        }
      },
      "&:before": {
        backgroundColor: theme.palette.secondary.light
      }
    },
    summaryExpandIconRoot: {
      color: theme.palette.grey.darker,
      minWidth: "auto"
    }
  };
});

var SectionExpansionPanel = function SectionExpansionPanel(_ref) {
  var _panelState$isExpande;

  var header = _ref.header,
      content = _ref.content,
      actions = _ref.actions,
      expansionPanelId = _ref.expansionPanelId,
      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 _useViewState = (0, _useViewState3.default)(expansionPanelId),
      _useViewState2 = _slicedToArray(_useViewState, 2),
      panelState = _useViewState2[0],
      updateViewState = _useViewState2[1];

  var defaultExpanded = (_panelState$isExpande = panelState["isExpanded"]) != null ? _panelState$isExpande : 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);
    updateViewState("isExpanded", isExpanded);
  }; // Expansion panel summary props


  var defaultSummaryStyles = {
    edge: false,
    size: "small",
    classes: {
      root: classes.summaryExpandIconRoot,
      sizeSmall: classes.resetPadding
    }
  }; // 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: (0, _classnames.default)(classes.panelRoot),
      expanded: (0, _classnames.default)(classes.panelExpanded)
    }
  }, /*#__PURE__*/_react.default.createElement(_AccordionSummary.default, {
    expandIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
      id: "dropdown-chevron-down"
    }),
    IconButtonProps: defaultSummaryStyles,
    classes: {
      root: (0, _classnames.default)(classes.summaryRoot),
      expanded: (0, _classnames.default)(classes.panelExpanded),
      content: (0, _classnames.default)(classes.summaryContent),
      expandIcon: (0, _classnames.default)(classes.summaryExpandIconRoot)
    }
  }, header), /*#__PURE__*/_react.default.createElement(_AccordionDetails.default, {
    classes: {
      root: (0, _classnames.default)(classes.resetPadding)
    }
  }, content), actions != null ? /*#__PURE__*/_react.default.createElement(_AccordionActions.default, {
    disableSpacing: disableSpacing == null ? false : disableSpacing
  }, actions) : null);
};

__signature__(SectionExpansionPanel, "useStyles{classes}\nuseViewState{[panelState, updateViewState]}\nuseState{[expanded, setExpanded](defaultExpanded)}", function () {
  return [useStyles, _useViewState3.default];
});

__signature__(SectionExpansionPanel, "useStyles{classes}\nuseViewState{[panelState, updateViewState]}\nuseState{[expanded, setExpanded](defaultExpanded)}", function () {
  return [useStyles, _useViewState3.default];
});

var _default = SectionExpansionPanel;
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/SectionExpansionPanel.js");
  reactHotLoader.register(SectionExpansionPanel, "SectionExpansionPanel", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.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/SectionExpansionPanel.js");
  reactHotLoader.register(SectionExpansionPanel, "SectionExpansionPanel", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js");
})();

;

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