"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

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

var React = _interopRequireWildcard(require("react"));

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

var _logoUrl = require("../../logo-url");

var _excluded = ["type", "className", "alt"];

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

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 _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 _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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var TYPE = {
  BRAINLY: 'brainly',
  BRAINLY_INVERSE: 'brainly-inverse',
  BRAINLY_MOBILE: 'brainly-mobile',
  BRAINLY_MOBILE_INVERSE: 'brainly-mobile-inverse',
  EODEV: 'eodev',
  EODEV_INVERSE: 'eodev-inverse',
  EODEV_MOBILE: 'eodev-mobile',
  EODEV_MOBILE_INVERSE: 'eodev-mobile-inverse',
  NOSDEVOIRS: 'nosdevoirs',
  NOSDEVOIRS_INVERSE: 'nosdevoirs-inverse',
  NOSDEVOIRS_MOBILE: 'nosdevoirs-mobile',
  NOSDEVOIRS_MOBILE_INVERSE: 'nosdevoirs-mobile-inverse',
  ZNANIJA: 'znanija',
  ZNANIJA_INVERSE: 'znanija-inverse',
  ZNANIJA_MOBILE: 'znanija-mobile',
  ZNANIJA_MOBILE_INVERSE: 'znanija-mobile-inverse',
  ZNANIJA_PLUS: 'znanija-plus',
  ZNANIJA_PLUS_INVERSE: 'znanija-plus-inverse',
  ZNANIJA_PLUS_SMALL: 'znanija-plus-small',
  BRAINLY_PLUS: 'brainly-plus',
  BRAINLY_PLUS_INVERSE: 'brainly-plus-inverse',
  BRAINLY_TUTORING: 'brainly-tutoring',
  BRAINLY_TUTORING_INVERSE: 'brainly-tutoring-inverse',
  LOGO_TUTOR: 'logo-tutor',
  LOGO_MATH_SOLVER: 'logo-math-solver',
  LOGO_COMMUNITY_QA: 'logo-community-qa',
  LOGO_TEXTBOOK_DETECTIVE: 'logo-textbook-detective',
  BRAINLY_LOGOTYPE_TUTOR: 'brainly-logotype-tutor',
  BRAINLY_LOGOTYPE_MATH_SOLVER: 'brainly-logotype-math-solver',
  BRAINLY_LOGOTYPE_COMMUNITY_QA: 'brainly-logotype-community-qa',
  BRAINLY_LOGOTYPE_TEXTBOOK_DETECTIVE: 'brainly-logotype-textbook-detective'
};
exports.TYPE = TYPE;

function getDefaultAlt(type) {
  var replacers = [{
    regexp: /-mobile/g,
    newSubstr: ''
  }, {
    regexp: /-inverse/g,
    newSubstr: ''
  }, {
    regexp: /-small/g,
    newSubstr: ''
  }, {
    regexp: /-logotype-/g,
    newSubstr: ' '
  }, {
    regexp: /logo-/g,
    newSubstr: ''
  }, {
    regexp: /-/g,
    newSubstr: ' '
  }];
  return replacers.reduce(function (alt, _ref) {
    var regexp = _ref.regexp,
        newSubstr = _ref.newSubstr;
    return alt.replace(regexp, newSubstr);
  }, type);
}

var Logo = function Logo(_ref2) {
  var _ref2$type = _ref2.type,
      type = _ref2$type === void 0 ? TYPE.BRAINLY : _ref2$type,
      className = _ref2.className,
      alt = _ref2.alt,
      props = _objectWithoutProperties(_ref2, _excluded);

  var logoClass = (0, _classnames2.default)('sg-logo', _defineProperty({}, "sg-logo--".concat(type), type !== TYPE.BRAINLY), className);
  var logoPath = "".concat((0, _logoUrl.getLogoUrl)(type));
  var defaultAlt = getDefaultAlt(type);
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
    className: logoClass,
    "data-logotype": type
  }), /*#__PURE__*/React.createElement("img", {
    className: "sg-logo__image",
    src: logoPath,
    alt: alt !== null && alt !== void 0 ? alt : defaultAlt
  }));
};

var _default = Logo;
exports.default = _default;