Liferay.Loader.define("layout-content-page-editor-web@2.0.136/page_editor/app/components/layout-data-items/Container", ['module', 'exports', 'require', 'frontend-js-react-web$classnames', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', '../../../prop-types/index', '../../selectors/selectLanguageId', '../../services/InfoItemService', '../../store/index', '../../utils/getFrontendTokenValue', '../../utils/getResponsiveConfig', '../../utils/loadBackgroundImage'], 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 _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

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

    var _index = require("../../../prop-types/index");

    var _selectLanguageId = _interopRequireDefault(require("../../selectors/selectLanguageId"));

    var _InfoItemService = _interopRequireDefault(require("../../services/InfoItemService"));

    var _index2 = require("../../store/index");

    var _getFrontendTokenValue = require("../../utils/getFrontendTokenValue");

    var _getResponsiveConfig = require("../../utils/getResponsiveConfig");

    var _loadBackgroundImage = _interopRequireDefault(require("../../utils/loadBackgroundImage"));

    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 };
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {
          return Object.getOwnPropertyDescriptor(object, sym).enumerable;
        });keys.push.apply(keys, symbols);
      }return keys;
    }

    function _objectSpread(target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          ownKeys(Object(source)).forEach(function (key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
          });
        }
      }return target;
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

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

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_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 Container = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
      var _classNames;

      var children = _ref.children,
          className = _ref.className,
          data = _ref.data,
          item = _ref.item,
          _ref$withinTopper = _ref.withinTopper,
          withinTopper = _ref$withinTopper === void 0 ? false : _ref$withinTopper;
      var selectedViewportSize = (0, _index2.useSelector)(function (state) {
        return state.selectedViewportSize;
      });
      var itemConfig = (0, _getResponsiveConfig.getResponsiveConfig)(item.config, selectedViewportSize);
      var _itemConfig$styles = itemConfig.styles,
          backgroundColor = _itemConfig$styles.backgroundColor,
          backgroundImage = _itemConfig$styles.backgroundImage,
          borderColor = _itemConfig$styles.borderColor,
          borderRadius = _itemConfig$styles.borderRadius,
          borderWidth = _itemConfig$styles.borderWidth,
          fontFamily = _itemConfig$styles.fontFamily,
          fontSize = _itemConfig$styles.fontSize,
          fontWeight = _itemConfig$styles.fontWeight,
          height = _itemConfig$styles.height,
          marginBottom = _itemConfig$styles.marginBottom,
          marginLeft = _itemConfig$styles.marginLeft,
          marginRight = _itemConfig$styles.marginRight,
          marginTop = _itemConfig$styles.marginTop,
          maxHeight = _itemConfig$styles.maxHeight,
          maxWidth = _itemConfig$styles.maxWidth,
          minHeight = _itemConfig$styles.minHeight,
          minWidth = _itemConfig$styles.minWidth,
          opacity = _itemConfig$styles.opacity,
          overflow = _itemConfig$styles.overflow,
          paddingBottom = _itemConfig$styles.paddingBottom,
          paddingLeft = _itemConfig$styles.paddingLeft,
          paddingRight = _itemConfig$styles.paddingRight,
          paddingTop = _itemConfig$styles.paddingTop,
          shadow = _itemConfig$styles.shadow,
          textAlign = _itemConfig$styles.textAlign,
          textColor = _itemConfig$styles.textColor,
          width = _itemConfig$styles.width;
      var widthType = itemConfig.widthType;
      var languageId = (0, _index2.useSelector)(_selectLanguageId.default);

      var _useState = (0, _react.useState)(''),
          _useState2 = _slicedToArray(_useState, 2),
          backgroundImageValue = _useState2[0],
          setBackgroundImageValue = _useState2[1];

      var _useState3 = (0, _react.useState)(null),
          _useState4 = _slicedToArray(_useState3, 2),
          link = _useState4[0],
          setLink = _useState4[1];

      (0, _react.useEffect)(function () {
        (0, _loadBackgroundImage.default)(backgroundImage).then(setBackgroundImageValue);
      }, [backgroundImage]);
      (0, _react.useEffect)(function () {
        if (!itemConfig.link) {
          return;
        }

        if (itemConfig.link.href) {
          setLink(itemConfig.link);
        } else if (itemConfig.link.fieldId) {
          _InfoItemService.default.getInfoItemFieldValue(_objectSpread(_objectSpread({}, itemConfig.link), {}, {
            languageId: languageId,
            onNetworkStatus: function onNetworkStatus() {}
          })).then(function (_ref2) {
            var fieldValue = _ref2.fieldValue;
            setLink({
              href: fieldValue,
              target: itemConfig.link.target
            });
          });
        }
      }, [itemConfig.link, languageId]);
      var style = {
        boxSizing: 'border-box'
      };
      style.backgroundColor = (0, _getFrontendTokenValue.getFrontendTokenValue)(backgroundColor);
      style.border = "solid ".concat(borderWidth, "px");
      style.borderColor = (0, _getFrontendTokenValue.getFrontendTokenValue)(borderColor);
      style.borderRadius = (0, _getFrontendTokenValue.getFrontendTokenValue)(borderRadius);
      style.color = (0, _getFrontendTokenValue.getFrontendTokenValue)(textColor);
      style.fontFamily = (0, _getFrontendTokenValue.getFrontendTokenValue)(fontFamily);
      style.fontSize = (0, _getFrontendTokenValue.getFrontendTokenValue)(fontSize);
      style.fontWeight = (0, _getFrontendTokenValue.getFrontendTokenValue)(fontWeight);
      style.height = height;
      style.maxHeight = maxHeight;
      style.minHeight = minHeight;
      style.opacity = opacity ? opacity / 100 : null;
      style.overflow = overflow;

      if (!withinTopper) {
        style.boxShadow = (0, _getFrontendTokenValue.getFrontendTokenValue)(shadow);
        style.maxWidth = maxWidth;
        style.minWidth = minWidth;
        style.width = width;
      }

      if (backgroundImageValue) {
        style.backgroundImage = "url(".concat(backgroundImageValue, ")");
        style.backgroundPosition = '50% 50%';
        style.backgroundRepeat = 'no-repeat';
        style.backgroundSize = 'cover';
      }

      var content = /*#__PURE__*/_react.default.createElement("div", _extends({}, link ? {} : data, {
        className: (0, _classnames.default)(className, "mb-".concat(marginBottom || 0), "mt-".concat(marginTop || 0), "pb-".concat(paddingBottom || 0), "pl-".concat(paddingLeft || 0), "pr-".concat(paddingRight || 0), "pt-".concat(paddingTop || 0), (_classNames = {
          container: widthType === 'fixed',
          empty: !item.children.length && !height
        }, _defineProperty(_classNames, "bg-".concat(backgroundColor), backgroundColor && !backgroundColor.startsWith('#')), _defineProperty(_classNames, "ml-".concat(marginLeft || 0), widthType !== 'fixed' && !withinTopper), _defineProperty(_classNames, "mr-".concat(marginRight || 0), widthType !== 'fixed' && !withinTopper), _defineProperty(_classNames, textAlign ? textAlign.startsWith('text-') ? textAlign : "text-".concat(textAlign) : '', textAlign), _classNames)),
        ref: ref,
        style: style
      }), children);

      return link ? /*#__PURE__*/_react.default.createElement("a", _extends({}, data, {
        href: link.href,
        style: {
          color: 'inherit',
          textDecoration: 'none'
        },
        target: link.target
      }), content) : content;
    });

    Container.displayName = 'Container';
    var _default = Container;
    exports.default = _default;
    //# sourceMappingURL=Container.js.map
  }
});
//# sourceMappingURL=Container.js.map