"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = moneyRangeRender;
var _errorRender = _interopRequireDefault(require("./errorRender"));
var _defaultRender = _interopRequireDefault(require("./defaultRender"));
var _formatter = _interopRequireDefault(require("../formatter"));
function moneyRangeRender(cellData) {
  if (!cellData) {
    return '';
  }
  if (Object.prototype.toString.call(cellData) === '[object Object]') {
    if (!cellData.hasOwnProperty('lower') || !cellData.hasOwnProperty('upper')) {
      return (0, _errorRender["default"])();
    }
    var lower;
    var upper;
    try {
      lower = _formatter["default"].money(cellData.lower || '0', ',', 2);
      upper = _formatter["default"].money(cellData.upper || '0', ',', 2);
    } catch (e) {
      return (0, _errorRender["default"])();
    }
    return (0, _defaultRender["default"])(lower + " " + (cellData.currency || '') + " ~ " + upper + " " + (cellData.currency || ''));
  }
  return (0, _errorRender["default"])();
}
;