import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectSpread from "@babel/runtime/helpers/objectSpread";

/**
 * Web Notification Component
 *
 */
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { registerElement, validateDOMAttributes // processChildren
} from '../../shared/component-helper'; // import './style/dnb-notification.css' // no good solution to import the style here

import Icon from '../../components/icon-primary/IconPrimary';
const renderProps = {// render_content: null
};
export const propTypes = {
  notification_amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  title_text: PropTypes.string,
  class: PropTypes.string,

  /** React props */
  className: PropTypes.string,
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]) // Web Component props
  // render_content: PropTypes.func

};
export const defaultProps = _objectSpread({
  notification_amount: 0,
  title_text: null,
  class: null,

  /** React props */
  className: null,
  children: null
}, renderProps);

var _ref =
/*#__PURE__*/
React.createElement("span", {
  className: "dnb-notification__icon"
}, React.createElement(Icon, {
  className: "dnb-notification__icon",
  icon: "bell"
}));

export default class Notification extends PureComponent {
  static enableWebComponent() {
    registerElement(Notification.tagName, Notification, defaultProps);
  } // static getContent(props) {
  //   if (typeof props.render_content === 'function') {
  //     return props.render_content(props)
  //   }
  //   return processChildren(props)
  // }


  render() {
    const {
      notification_amount,
      title_text,
      className,
      class: _className
    } = this.props; // const content = Notification.getContent(this.props)

    const params = {
      className: classnames('dnb-notification', className, _className, notification_amount > 0 ? 'dnb-notification--has-notification' : null)
    };
    const buttonParams = {
      title: title_text.replace(/{amount}/, notification_amount) // also used for code markup simulation

    };
    validateDOMAttributes(this.props, params);
    return React.createElement("div", params, React.createElement("button", _extends({
      className: "dnb-notification__button"
    }, buttonParams), React.createElement("span", {
      className: "dnb-notification__inner"
    }, _ref, notification_amount > 0 && React.createElement("span", {
      className: "dnb-notification__amount"
    }, React.createElement("span", {
      className: "dnb-notification__amount__inner"
    }, notification_amount)))));
  }

}

_defineProperty(Notification, "tagName", 'dnb-notification');

_defineProperty(Notification, "defaultProps", defaultProps);

Notification.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};