Liferay.Loader.define("dynamic-data-mapping-form-report-web@1.0.20/js/components/sidebar/Sidebar.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/icon', '@frontend-taglib-clay$clayui/layout', '@frontend-taglib-clay$clayui/loading-indicator', 'frontend-js-react-web$react', '../../hooks/useRequest.es', '../list/List.es', '../summary/Summary.es', './SidebarContext.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports["default"] = void 0;

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _layout = _interopRequireDefault(require("@frontend-taglib-clay$clayui/layout"));

    var _loadingIndicator = _interopRequireDefault(require("@frontend-taglib-clay$clayui/loading-indicator"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _useRequest2 = _interopRequireDefault(require("../../hooks/useRequest.es"));

    var _List = _interopRequireDefault(require("../list/List.es"));

    var _Summary = _interopRequireDefault(require("../summary/Summary.es"));

    var _SidebarContext = require("./SidebarContext.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { "default": obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj["default"] = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

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

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var SidebarContent = function SidebarContent() {
      var _useContext = (0, _react.useContext)(_SidebarContext.SidebarContext),
          field = _useContext.field,
          formReportRecordsFieldValuesURL = _useContext.formReportRecordsFieldValuesURL,
          portletNamespace = _useContext.portletNamespace,
          _useContext$summary = _useContext.summary,
          summary = _useContext$summary === void 0 ? {} : _useContext$summary,
          toggleSidebar = _useContext.toggleSidebar,
          totalEntries = _useContext.totalEntries,
          type = _useContext.type;

      var _URL = new URL(formReportRecordsFieldValuesURL),
          origin = _URL.origin;

      var path = formReportRecordsFieldValuesURL.replace(origin, '');
      var endpoint = "".concat(path, "&").concat(portletNamespace, "fieldName=").concat(field.name);

      var _useRequest = (0, _useRequest2["default"])(endpoint),
          isLoading = _useRequest.isLoading,
          _useRequest$response = _useRequest.response,
          data = _useRequest$response === void 0 ? [] : _useRequest$response;

      var icon = field.icon,
          label = field.label;
      return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("nav", {
        className: "component-tbar tbar"
      }, _react["default"].createElement(_layout["default"].ContainerFluid, null, _react["default"].createElement("ul", {
        className: "tbar-nav"
      }, _react["default"].createElement("li", {
        className: "tbar-item"
      }, _react["default"].createElement("div", {
        className: "icon"
      }, _react["default"].createElement(_icon["default"], {
        symbol: icon
      }))), _react["default"].createElement("li", {
        className: "tbar-item tbar-item-expand"
      }, _react["default"].createElement("div", {
        className: "tbar-section"
      }, _react["default"].createElement("div", {
        className: "field-info"
      }, _react["default"].createElement("p", {
        className: "title"
      }, label), _react["default"].createElement("p", {
        className: "description"
      }, totalEntries, ' ', Liferay.Language.get('entries').toLowerCase())))), _react["default"].createElement("li", {
        className: "tbar-item"
      }, _react["default"].createElement(_button["default"], {
        className: "close-sidebar",
        displayType: "secondary",
        monospaced: true,
        onClick: function onClick() {
          return toggleSidebar();
        }
      }, _react["default"].createElement(_icon["default"], {
        className: "close-button",
        symbol: 'times-small'
      })))))), _react["default"].createElement("div", {
        className: "sidebar-body"
      }, isLoading && _react["default"].createElement("div", {
        className: "align-items-center d-flex loading-wrapper"
      }, _react["default"].createElement(_loadingIndicator["default"], null)), !!Object.entries(summary).length && _react["default"].createElement(_Summary["default"], {
        summary: summary
      }), _react["default"].createElement(_List["default"], {
        data: data,
        type: type
      })));
    };

    var _default = function _default() {
      var _useContext2 = (0, _react.useContext)(_SidebarContext.SidebarContext),
          field = _useContext2.field,
          isOpen = _useContext2.isOpen,
          portletNamespace = _useContext2.portletNamespace;

      return _react["default"].createElement(_react["default"].Fragment, null, isOpen && _react["default"].createElement("div", {
        className: "sidebar-backdrop"
      }), _react["default"].createElement("div", {
        className: 'sidebar-container sidebar-reports' + (isOpen ? ' open' : ''),
        id: "".concat(portletNamespace, "-sidebar-reports")
      }, _react["default"].createElement("div", {
        className: "sidebar sidebar-light"
      }, field && _react["default"].createElement(SidebarContent, null))));
    };

    exports["default"] = _default;
    //# sourceMappingURL=Sidebar.es.js.map
  }
});
//# sourceMappingURL=Sidebar.es.js.map