"use strict";

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

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

var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));

var _textProps = _interopRequireWildcard(require("../../textProps"));

var _TooltippedTypography = _interopRequireDefault(require("../TooltippedElements/TooltippedTypography"));

var _lodash = _interopRequireDefault(require("lodash"));

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

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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 () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

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

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 {
    italicText: {
      fontStyle: "italic"
    }
  };
});

var Address = function Address(_ref) {
  var address = _ref.address,
      textProps = _ref.textProps;
  var classes = useStyles();

  if ((0, _textProps.isTextProps)(textProps) === false) {
    throw new TypeError("textProps property is not of type TextProps");
  }

  var cityRegionPostalCode = "".concat(address.city, ", ").concat(address.regionCode, ", ").concat(address.postalCode);
  var contactPerson = address.firstName && address.lastName ? "".concat(address.firstName, " ").concat(address.lastName) : address.firstName || address.lastName;
  var addressInfo = [address.addressName, contactPerson, address.line1, address.line2, cityRegionPostalCode, address.country, address.notes, address.email, address.phoneNumber];
  var addressNoteIndex = 6;
  var customStyles = textProps == null ? void 0 : textProps.get(_textProps.default.propNames.classes);
  return /*#__PURE__*/_react.default.createElement(_Grid.default, {
    container: true,
    direction: "column"
  }, addressInfo.map(function (elem, index) {
    return !_lodash.default.isEmpty(elem) ? /*#__PURE__*/_react.default.createElement(_TooltippedTypography.default, {
      key: index,
      noWrap: true,
      className: (0, _classnames.default)(customStyles, index === addressNoteIndex ? classes.italicText : null),
      children: elem,
      titleValue: elem
    }) : null;
  }));
};

__signature__(Address, "useStyles{classes}", function () {
  return [useStyles];
});

__signature__(Address, "useStyles{classes}", function () {
  return [useStyles];
});

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

;

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