"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.FiltersPanel = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _designSystem = require("@wix/design-system");
var _react = _interopRequireWildcard(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _useBuildAccordionItems = require("../../hooks/useBuildAccordionItems");
var _FiltersPanelFooter = require("./FiltersPanelFooter");
var _FilterRenderingContext = require("../FilterRenderingContext");
var _FiltersPanelState = require("./FiltersPanelState");
var _react2 = require("@wix/bex-core/react");
var _useRafRender = require("../../hooks/useRafRender");
var _PatternsSidePanel = require("../SidePanel/PatternsSidePanel");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/FiltersPanel/FiltersPanel.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function _FiltersPanel(props) {
  const {
    state,
    children,
    ...rest
  } = props;
  const {
    toolbar,
    totalInlineFilters: {
      value: totalInlineFilters
    }
  } = state;
  const accordionItems = (0, _useBuildAccordionItems.useBuildAccordionItems)(state);
  const entered = (0, _useRafRender.useRafRender)();
  const {
    translate: t
  } = (0, _react2.useWixPatternsContainer)();
  const [filtersPanelState] = (0, _react.useState)(() => new _FiltersPanelState.FiltersPanelState({
    toolbar
  }));
  const [filterRenderingContext] = (0, _react.useState)(() => ({
    location: 'panel'
  }));
  const [wsrDefaults] = (0, _react.useState)(() => ({
    input: {
      size: 'small'
    },
    button: {
      size: 'small'
    }
  }));
  if (!entered) {
    return null;
  }
  let child = /*#__PURE__*/_react.default.createElement(_PatternsSidePanel.PatternsSidePanel, (0, _extends2.default)({
    dataHook: "filters-side-panel",
    onClose: filtersPanelState.onCloseButtonClick,
    width: "100%",
    closeButtonProps: {
      ariaLabel: t('cairo.filtersPanel.header.closeButton.ariaLabel')
    }
  }, rest, {
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 60,
      columnNumber: 5
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.SidePanel.Header, {
    title: state.panelTitle.value ?? (totalInlineFilters != null ? t('cairo.filtersPanel.header', {
      num: totalInlineFilters
    }) : undefined),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 69,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement("div", {
    "data-hook": "filters-panel-scroll-container",
    style: {
      overflowY: 'auto'
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 80,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Accordion, {
    dataHook: "filters-panel-accordion",
    skin: "light",
    hideShadow: true,
    multiple: true,
    items: accordionItems,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 84,
      columnNumber: 9
    }
  })), /*#__PURE__*/_react.default.createElement(_designSystem.SidePanel.Footer, {
    noPadding: true,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 92,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_FiltersPanelFooter.FiltersPanelFooter, {
    state: toolbar,
    onClearButtonClicked: state.onClearButtonClicked,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 93,
      columnNumber: 9
    }
  })), children);
  child = /*#__PURE__*/_react.default.createElement(_FilterRenderingContext.FilterRenderingContextProvider, {
    value: filterRenderingContext,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 103,
      columnNumber: 5
    }
  }, child);
  child = /*#__PURE__*/_react.default.createElement(_designSystem.WixStyleReactDefaultsOverrideProvider, {
    value: wsrDefaults,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 109,
      columnNumber: 5
    }
  }, child);
  return child;
}
const FiltersPanel = exports.FiltersPanel = (0, _mobxReactLite.observer)(_FiltersPanel);
//# sourceMappingURL=FiltersPanel.js.map