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,YAAc,EAAK,MAAM,YACzB,UAAY,EAAK,MAAM,YAZlB,IAeX,KAKA,MAAM,cAAc,MAAO,CAAC,UAAW,wBAAyB,MAAQ,KAAK,WAAW,WACrF,EAGP,IAGF,OAAO,QAAU","file":"/npm/react-notification-system-umd@0.2.15/dist/NotificationSystem.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-notification-system-umd@0.2.15/dist/NotificationSystem.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var React = require('react');\nvar createReactClass = require('create-react-class');\nvar PropTypes = require('prop-types');\nvar merge = require('object-assign');\nvar NotificationContainer = require('./NotificationContainer');\nvar Constants = require('./constants');\nvar Styles = require('./styles');\n\nvar NotificationSystem = createReactClass({\n\n  uid: 3400,\n\n  _isMounted: false,\n\n  _getStyles: {\n    overrideStyle: {},\n\n    overrideWidth: null,\n\n    setOverrideStyle: function(style) {\n      this.overrideStyle = style;\n    },\n\n    wrapper: function() {\n      if (!this.overrideStyle) return {};\n      return merge({}, Styles.Wrapper, this.overrideStyle.Wrapper);\n    },\n\n    container: function(position) {\n      var override = this.overrideStyle.Containers || {};\n      if (!this.overrideStyle) return {};\n\n      this.overrideWidth = Styles.Containers.DefaultStyle.width;\n\n      if (override.DefaultStyle && override.DefaultStyle.width) {\n        this.overrideWidth = override.DefaultStyle.width;\n      }\n\n      if (override[position] && override[position].width) {\n        this.overrideWidth = override[position].width;\n      }\n\n      return merge({}, Styles.Containers.DefaultStyle, Styles.Containers[position], override.DefaultStyle, override[position]);\n    },\n\n    elements: {\n      notification: 'NotificationItem',\n      title: 'Title',\n      messageWrapper: 'MessageWrapper',\n      dismiss: 'Dismiss',\n      action: 'Action',\n      actionWrapper: 'ActionWrapper'\n    },\n\n    byElement: function(element) {\n      var self = this;\n      return function(level) {\n        var _element = self.elements[element];\n        var override = self.overrideStyle[_element] || {};\n        if (!self.overrideStyle) return {};\n        return merge({}, Styles[_element].DefaultStyle, Styles[_element][level], override.DefaultStyle, override[level]);\n      };\n    }\n  },\n\n  _didNotificationRemoved: function(uid) {\n    var notification;\n    var notifications = this.state.notifications.filter(function(toCheck) {\n      if (toCheck.uid === uid) {\n        notification = toCheck;\n        return false;\n      }\n      return true;\n    });\n\n    if (this._isMounted) {\n      this.setState({ notifications: notifications });\n    }\n\n    if (notification && notification.onRemove) {\n      notification.onRemove(notification);\n    }\n  },\n\n  getInitialState: function() {\n    return {\n      notifications: []\n    };\n  },\n\n  propTypes: {\n    style: PropTypes.oneOfType([\n      PropTypes.bool,\n      PropTypes.object\n    ]),\n    noAnimation: PropTypes.bool,\n    allowHTML: PropTypes.bool\n  },\n\n  getDefaultProps: function() {\n    return {\n      style: {},\n      noAnimation: false,\n      allowHTML: false\n    };\n  },\n\n  addNotification: function(notification) {\n    var _notification = merge({}, Constants.notification, notification);\n    var notifications = this.state.notifications;\n    var i;\n\n    if (!_notification.level) {\n      throw new Error('notification level is required.');\n    }\n\n    if (Object.keys(Constants.levels).indexOf(_notification.level) === -1) {\n      throw new Error('\\'' + _notification.level + '\\' is not a valid level.');\n    }\n\n    if (isNaN(_notification.autoDismiss)) {\n      throw new Error('\\'autoDismiss\\' must be a number.');\n    }\n\n    if (Object.keys(Constants.positions).indexOf(_notification.position) === -1) {\n      throw new Error('\\'' + _notification.position + '\\' is not a valid position.');\n    }\n\n    // Some preparations\n    _notification.position = _notification.position.toLowerCase();\n    _notification.level = _notification.level.toLowerCase();\n    _notification.autoDismiss = parseInt(_notification.autoDismiss, 10);\n\n    _notification.uid = _notification.uid || this.uid;\n    _notification.ref = 'notification-' + _notification.uid;\n    this.uid += 1;\n\n    // do not add if the notification already exists based on supplied uid\n    for (i = 0; i < notifications.length; i++) {\n      if (notifications[i].uid === _notification.uid) {\n        return false;\n      }\n    }\n\n    notifications.push(_notification);\n\n    if (typeof _notification.onAdd === 'function') {\n      notification.onAdd(_notification);\n    }\n\n    this.setState({\n      notifications: notifications\n    });\n\n    return _notification;\n  },\n\n  getNotificationRef: function(notification) {\n    var self = this;\n    var foundNotification = null;\n\n    Object.keys(this.refs).forEach(function(container) {\n      if (container.indexOf('container') > -1) {\n        Object.keys(self.refs[container].refs).forEach(function(_notification) {\n          var uid = notification.uid ? notification.uid : notification;\n          if (_notification === 'notification-' + uid) {\n            // NOTE: Stop iterating further and return the found notification.\n            // Since UIDs are uniques and there won't be another notification found.\n            foundNotification = self.refs[container].refs[_notification];\n            return;\n          }\n        });\n      }\n    });\n\n    return foundNotification;\n  },\n\n  removeNotification: function(notification) {\n    var foundNotification = this.getNotificationRef(notification);\n    return foundNotification && foundNotification._hideNotification();\n  },\n\n  editNotification: function(notification, newNotification) {\n    var foundNotification = null;\n    // NOTE: Find state notification to update by using\n    // `setState` and forcing React to re-render the component.\n    var uid = notification.uid ? notification.uid : notification;\n\n    var newNotifications = this.state.notifications.filter(function(stateNotification) {\n      if (uid === stateNotification.uid) {\n        foundNotification = stateNotification;\n        return false;\n      }\n\n      return true;\n    });\n\n\n    if (!foundNotification) {\n      return;\n    }\n\n    newNotifications.push(\n      merge(\n        {},\n        foundNotification,\n        newNotification\n      )\n    );\n\n    this.setState({\n      notifications: newNotifications\n    });\n  },\n\n  clearNotifications: function() {\n    var self = this;\n    Object.keys(this.refs).forEach(function(container) {\n      if (container.indexOf('container') > -1) {\n        Object.keys(self.refs[container].refs).forEach(function(_notification) {\n          self.refs[container].refs[_notification]._hideNotification();\n        });\n      }\n    });\n  },\n\n  componentDidMount: function() {\n    this._getStyles.setOverrideStyle(this.props.style);\n    this._isMounted = true;\n  },\n\n  componentWillUnmount: function() {\n    this._isMounted = false;\n  },\n\n  render: function() {\n    var self = this;\n    var containers = null;\n    var notifications = this.state.notifications;\n\n    if (notifications.length) {\n      containers = Object.keys(Constants.positions).map(function(position) {\n        var _notifications = notifications.filter(function(notification) {\n          return position === notification.position;\n        });\n\n        if (!_notifications.length) {\n          return null;\n        }\n\n        return (\n          React.createElement(NotificationContainer, {\n            ref:  'container-' + position, \n            key:  position, \n            position:  position, \n            notifications:  _notifications, \n            getStyles:  self._getStyles, \n            onRemove:  self._didNotificationRemoved, \n            noAnimation:  self.props.noAnimation, \n            allowHTML:  self.props.allowHTML}\n          )\n        );\n      });\n    }\n\n\n    return (\n      React.createElement(\"div\", {className: \"notifications-wrapper\", style:  this._getStyles.wrapper() }, \n         containers \n      )\n    );\n  }\n});\n\nmodule.exports = NotificationSystem;\n"]}