"use strict";

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

require("kit_logger");

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

var _mqttClient = _interopRequireDefault(require("mqtt-client"));

var _constants = require("./constants");

var _message = _interopRequireDefault(require("./message"));

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

var Logger = logger("mqtt");

var Notifier =
/*#__PURE__*/
function () {
  function Notifier(userInfo, renderVideo, renderPlatform) {
    _classCallCheck(this, Notifier);

    this.userInfo = userInfo;
    this.messageCache = {
      totalCount: 0,
      messages: []
    }; // 当前消息缓存

    this._subscribers = {}; //订阅器缓存

    this._siteConfig = {
      site_code: this.userInfo.site,
      TcpIP: '',
      TcpPort: _constants.DEFAULT_TCP_PORT,
      TimeOut: '',
      KeepAlive: '',
      IsSSL: true,
      mqtt_path: _constants.DEFAULT_MQTT_PATH
    };
    this._config = {
      mqtt_path: '/mqtt',
      nginxStart: 'false',
      mqtt_mess: {
        IsSSL: false
      }
    };
    this.MQTTCount = 0;
    this.MQTTClient = null;
    this.MQTTOptions = {};
    this.IsNeedReconnect = true;
    this.currentPageIndex = 1;
    this.currentPageSize = 10;
    this.start = this.start.bind(this);
    this.stop = this.stop.bind(this);
    this.subscribe = this.subscribe.bind(this);
    this.unsubscribe = this.unsubscribe.bind(this);
    this.confirmRead = this.confirmRead.bind(this);
    this.loadMore = this.loadMore.bind(this);
    this.hasMore = this.hasMore.bind(this);
    this.renderVideo = renderVideo;
    this.renderVideoElement = null;
    this.renderPlatform = renderPlatform;
    this.renderPlatformElement = null;
  } // 对外接口


  _createClass(Notifier, [{
    key: "start",
    value: function start() {
      var _this = this;

      return regeneratorRuntime.async(function start$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              window.cc = this.messageCache;
              this.getMqttSiteCode().then(function () {
                _this.loadHisMessages(_this.currentPageIndex, _this.currentPageSize);

                _this.connectMQTTServer();
              });

            case 2:
            case "end":
              return _context.stop();
          }
        }
      }, null, this);
    }
  }, {
    key: "stop",
    value: function stop() {
      this.disconnectMQTTServer();
    }
  }, {
    key: "subscribe",
    value: function subscribe(type, handler) {
      if (!(type in this._subscribers)) {
        this._subscribers[type] = [];
      }

      this._subscribers[type].push(handler);
    }
  }, {
    key: "unsubscribe",
    value: function unsubscribe(type, handler) {
      if (!(type in this._subscribers)) {
        logger.info('无效事件无法删除');
      }

      if (!handler) {
        delete this._subscribers[type];
      } else {
        var idx = this._subscribers[type].findIndex(function (ele) {
          return ele === handler;
        });

        if (idx === -1) {
          logger.info('无效事件无法删除');
          return;
        }

        this._subscribers[type].splice(idx, 1);

        if (this._subscribers[type].length === 0) {
          delete this._subscribers[type];
        }
      }
    }
  }, {
    key: "publish",
    value: function publish(type, payload) {
      if (!(type in this._subscribers) || this._subscribers[type].length === 0) {
        return;
      }

      this._subscribers[type].forEach(function (handler) {
        try {
          handler(payload);
        } catch (e) {
          logger.warn('订阅器委托错误' + e.message);
        }
      });
    }
  }, {
    key: "confirmRead",
    value: function confirmRead() {
      var isAll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      var hisIDs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

      if (this.messageCache && this.messageCache.totalCount === 0 && this.messageCache.messages.length === 0) {
        return;
      }

      if (isAll) hisIDs = this.messageCache.messages.map(function (item) {
        return item.id;
      });
      var self = this;
      Http.postInformationStatus({
        userID: this.userInfo.OID,
        hisID: hisIDs.join(','),
        isAll: isAll ? 1 : ''
      }).then(function (res) {
        if (res.statusCode !== _constants.ERR_OK) {
          Logger.info(res.errMsg);
          return;
        }

        if (isAll) {
          self.messageCache.totalCount = 0;
          self.messageCache.messages = [];
          self.currentPageIndex = 1;
        } else {
          hisIDs.forEach(function (id) {
            var index = self.messageCache.messages.findIndex(function (item) {
              return item.id == id;
            });

            if (index > -1) {
              self.messageCache.messages.splice(index, 1);
              self.messageCache.totalCount--;
            }
          });
        }

        self.publish(_constants.NEW_MESSAGE, self.messageCache);
      })["catch"](function (err) {
        logger.error('postInformationStatus调用失败' + err);
      });
    }
  }, {
    key: "hasMore",
    value: function hasMore() {
      if (!this.messageCache) return false;
      if (!this.messageCache.totalCount) return false;
      return this.messageCache.totalCount > this.messageCache.messages.length;
    }
  }, {
    key: "loadMore",
    value: function loadMore(callback) {
      if (!this.hasMore()) return Promise.resolve([]);
      this.currentPageIndex += 1;
      return this.loadHisMessages(this.currentPageIndex, this.currentPageSize);
    } // mqtt

  }, {
    key: "connectMQTTServer",
    value: function connectMQTTServer() {
      var hostname, port, clientId, timeout, keepAlive, cleanSession, ssl, userName, password, path;
      return regeneratorRuntime.async(function connectMQTTServer$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              hostname = this._siteConfig.TcpIP;
              port = this._siteConfig.TcpPort;
              clientId = 'client-' + this.generatedId();
              timeout = _constants.DEFAULT_TIMEOUT;
              keepAlive = _constants.DEFAULT_KEEPLIVE;
              cleanSession = true;
              ssl = this._siteConfig.IsSSL;
              userName = _constants.USERNAME;
              password = _constants.PASSWORD;
              path = this._siteConfig.mqtt_path;
              this.MQTTCount = 0;

              if (hostname) {
                this.MQTTClient = new _mqttClient["default"].Client(hostname, port, path, clientId);
                this.MQTTOptions = {
                  invocationContext: {
                    host: hostname,
                    port: port,
                    path: path,
                    clientId: clientId
                  },
                  timeout: timeout,
                  keepAliveInterval: keepAlive,
                  cleanSession: cleanSession,
                  useSSL: ssl,
                  userName: userName,
                  password: password,
                  onSuccess: this.onMQTTConnect.bind(this),
                  onFailure: function onFailure(e) {
                    console.log(e);
                  }
                };
                this.MQTTClient.connect(this.MQTTOptions);
                this.MQTTClient.onConnectionLost = this.onMQTTConnectionLost.bind(this);
                this.MQTTClient.onMessageArrived = this.onMessageArrived.bind(this);
              }

            case 12:
            case "end":
              return _context2.stop();
          }
        }
      }, null, this);
    }
  }, {
    key: "disconnectMQTTServer",
    value: function disconnectMQTTServer() {
      if (this.MQTTClient) {
        this.IsNeedReconnect = false;
        this.MQTTClient.disconnect();
        this.MQTTClient = null;
      }
    }
  }, {
    key: "getSiteCode",
    value: function getSiteCode() {
      return this._siteConfig.site_code;
    }
  }, {
    key: "getUserInfo",
    value: function getUserInfo() {
      return this.userInfo;
    }
  }, {
    key: "getSiteConfig",
    value: function getSiteConfig() {
      return this._siteConfig;
    }
  }, {
    key: "onMQTTConnect",
    value: function onMQTTConnect() {
      var site = this.getSiteCode(); //信息化主题

      this.MQTTClient.subscribe(site + _constants.REQUEST_SERVICE.EIMTopic); //节水主题

      this.MQTTClient.subscribe(site + _constants.REQUEST_SERVICE.SaveWaTopic); //系统主题

      this.MQTTClient.subscribe(site + _constants.REQUEST_SERVICE.SystemTopic); //工单主题

      this.MQTTClient.subscribe(site + _constants.REQUEST_SERVICE.WorkerOrderTopic); //报警主题

      this.MQTTClient.subscribe(site + _constants.REQUEST_SERVICE.ScadaTopic); //用户主题

      this.MQTTClient.subscribe(site + "".concat(_constants.REQUEST_SERVICE.UserTopic).concat(this.userInfo.OID));
    }
  }, {
    key: "onMQTTConnectionLost",
    value: function onMQTTConnectionLost(responseObject) {
      var self = this;

      if (this.IsNeedReconnect) {
        this.MQTTClient.connect(self.MQTTOptions);
        this.MQTTtester = setInterval(function () {
          if (self.MQTTClient.isConnected) {
            clearInterval(self.MQTTtester);
          } else {
            self.MQTTClient.connect(self.MQTTOptions);
          }
        }, 1000);
      }
    }
  }, {
    key: "onMessageArrived",
    value: function onMessageArrived(buffer) {
      try {
        var parseMessage = JSON.parse(buffer.payloadString);
        var userInfo = this.getUserInfo();
        var infoType = this.getMessageType(parseMessage.infoType);
        var state = null;

        if (_lodash["default"].isEmpty(parseMessage.tousers) || userInfo.OID == parseMessage.tousers || parseMessage.tousers.includes(userInfo.OID + ',') || parseMessage.tousers.includes(',' + userInfo.OID)) {
          if (document.visibilityState === "visible" || document.visibilityState === "hidden") {
            this.renderWindowsInfo(buffer);
          }

          var messContent = parseMessage.content;
          var timeH = (new Date() - new Date(parseMessage.createTime)) / 1000 / 60;
          var timeMss = Math.abs(timeH) > 1440 ? parseMessage.createTime.split('.')[0] : Math.abs(timeH) > 60 ? (timeH / 60).toFixed(0) + '小时前' : Math.abs(timeH) > 1 ? timeH.toFixed(0) + '分钟前' : '刚刚';
          var _messString = {
            id: parseMessage.ID,
            infoContent: messContent,
            infoLevel: parseMessage.level,
            time: "".concat(timeMss),
            infoType: infoType,
            dateTime: parseMessage.createTime,
            webConfig: parseMessage.web_config,
            webPath: parseMessage.web_path,
            messType: parseMessage.MessType
          };

          if (parseMessage.tousers === "") {
            _messString.messType = "公告";
            var content = messContent.replace(/\\n/g, ',');
            state = new window.SpeechSynthesisUtterance("您有新的公告：" + content.substring(0, content.lastIndexOf(',')).replace('：', ',') + " 时间：" + timeMss);
          } else {
            var _content = messContent.replace(/\\n/g, ',');

            state = new window.SpeechSynthesisUtterance("您有新的消息：" + _content.substring(0, _content.lastIndexOf(',')).replace('：', ',') + " 时间：" + timeMss);
          }

          if (this.getParseVesion()) {
            _messString.infoContent = this.parseMessageToJSON(infoType, _messString);
          } else {
            _messString.infoContent = JSON.parse(JSON.stringify(_messString.infoContent || '{}'));
          }

          var message = (0, _message["default"])(_messString);
          this.messageCache.totalCount += 1;
          this.messageCache.messages.push(message);
          this.publish(_constants.NEW_MESSAGE, this.messageCache);

          if (_messString.infoLevel === _constants.PLATFORM_LEVEL && _messString.infoType === _constants.MESSAGE_TYPE.SCADA_TYPE) {
            this.parseScadaMessage(Object.assign(message, {
              messContent: messContent
            }));
            this.renderPopPlatform(Object.assign(message, {
              messContent: messContent
            }));
          } else if (_messString.infoLevel === _constants.VIDEO_LEVEL) {
            this.renderPopVideo(Object.assign(message, {
              messContent: messContent
            }));
            state.lang = "zh";
            state.rate = 1;
            window.speechSynthesis.speak(state);
          } else if (message.infoLevel === _constants.PLATFORM_LEVEL) {
            console.log(_messString);
          } else {
            state.lang = "zh";
            state.rate = 1;
            window.speechSynthesis.speak(state);
          }
        }
      } catch (e) {
        Logger.error('收到消息处理异常:' + e.message);
      }
    }
  }, {
    key: "renderWindowsInfo",
    value: function renderWindowsInfo(message) {
      function notifyMessage(message) {
        var parseMessage = JSON.parse(message.payloadString);
        var content = "";

        for (var i = 0; i < parseMessage.content.split('\\n').length; i++) {
          content += "".concat(parseMessage.content.split('\\n')[i], " ");
        }

        ;
        var messageBody = {
          title: "",
          content: content
        };

        if (parseMessage.tousers === "") {
          messageBody.title = "新公告：";
        } else {
          messageBody.title = "新通知：";
        }

        if (!("Notification" in window)) {
          message.warn("This browser does not support desktop notification");
        } else if (Notification.permission === "granted") {
          var notification = new Notification(messageBody.title, {
            body: "".concat(messageBody.content),
            icon: "https://panda-water.com/web4/assets/images/icon/熊猫新1.png"
          });

          notification.onclick = function () {
            notification.close();
          };
        } else if (Notification.permission !== 'denied') {
          Notification.requestPermission(function (permission) {
            if (permission === "granted") {
              var _notification = new Notification(messageBody.title, {
                body: "".concat(messageBody.content),
                icon: "https://panda-water.com/web4/assets/images/icon/熊猫新1.png"
              });

              _notification.onclick = function () {
                _notification.close();
              };
            }
          });
        }
      }

      notifyMessage(message);
    }
  }, {
    key: "renderPopPlatform",
    value: function renderPopPlatform(message) {
      this.renderPlatformElement = this.renderPlatform && this.renderPlatform(message);
    }
  }, {
    key: "renderPopVideo",
    value: function renderPopVideo(message) {
      this.renderVideoElement = this.renderVideo && this.renderVideo(message);
    }
  }, {
    key: "destoryPlatform",
    value: function destoryPlatform() {
      this.renderPlatformElement = null;
    }
  }, {
    key: "destoryVideo",
    value: function destoryVideo() {
      this.renderVideoElement = null;
    } // 工具类

  }, {
    key: "loadHisMessages",
    value: function loadHisMessages(pageIndex, pageSize) {
      var _this2 = this;

      var self;
      return regeneratorRuntime.async(function loadHisMessages$(_context3) {
        while (1) {
          switch (_context3.prev = _context3.next) {
            case 0:
              self = this;
              return _context3.abrupt("return", Http.getInformationInfo({
                userID: self.getUserInfo().OID,
                pageIndex: pageIndex,
                pageSize: pageSize,
                'request.preventCache': Date.now()
              }).then(function (res) {
                if (res) {
                  var result = {
                    totalCount: res.totalRcdNum,
                    messages: res.getMe.map(_this2.parseHisToMessage.bind(_this2))
                  };
                  self.messageCache.totalCount = result.totalCount;
                  (result.messages || []).forEach(function (message) {
                    var index = self.messageCache.messages.findIndex(function (item) {
                      return item.id == message.id;
                    });
                    index === -1 && self.messageCache.messages.push(message);
                  });

                  if (self.messageCache.totalCount > self.messageCache.messages.length && res.getMe.length === 0) {
                    // 服务端返回总数还有，但是查不到数据了，前端修正服务端返回的总数
                    self.messageCache.totalCount = self.messageCache.messages.length;
                  }

                  self.publish(_constants.NEW_MESSAGE, self.messageCache);
                  return Promise.resolve(result);
                }
              }));

            case 2:
            case "end":
              return _context3.stop();
          }
        }
      }, null, this);
    }
  }, {
    key: "getMqttSiteCode",
    value: function getMqttSiteCode() {
      var self;
      return regeneratorRuntime.async(function getMqttSiteCode$(_context4) {
        while (1) {
          switch (_context4.prev = _context4.next) {
            case 0:
              self = this;
              return _context4.abrupt("return", Http.getMqttSiteCode({
                'request.preventCache': Date.now()
              }).then(function (res) {
                if (res && res.say.statusCode === _constants.ERR_OK) {
                  if (Array.isArray(res.getMe) && res.getMe.length > 0) {
                    if (res.getMe[0]) {
                      self._siteConfig.IsSSL = res.getMe[0].IsSSL ? res.getMe[0].IsSSL : false;
                      self._siteConfig.site_code = res.getMe[0].SiteCode || self._siteConfig.site_code;
                      self._siteConfig.TcpIP = res.getMe[0].TcpIP;
                      self._siteConfig.TcpPort = res.getMe[0].TcpPort ? parseInt(res.getMe[0].TcpPort) : 8083;
                      self._siteConfig.MessageLevel = res.getMe[0].MessageLevel ? res.getMe[0].MessageLevel : _constants.DEFAULT_PARSE_LEVEL;
                    }

                    if (res.getMe[0].NginxStart) {
                      self._siteConfig.TcpIP = window.location.hostname;
                      self._siteConfig.TcpPort = parseInt(window.location.port);
                      self._siteConfig.mqtt_path = '/ws/';
                    } else {
                      self._siteConfig.TcpIP = _constants.DEFAULT_TCP_IP;
                      self._siteConfig.TcpPort = _constants.DEFAULT_TCP_PORT;
                      self._siteConfig.IsSSL = true;
                    }
                  }
                } else {
                  logger.info('获取mqtt服务器参数失败');
                }
              }));

            case 2:
            case "end":
              return _context4.stop();
          }
        }
      }, null, this);
    }
  }, {
    key: "generatedId",
    value: function generatedId() {
      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
            v = c == 'x' ? r : r & 0x3 | 0x8;
        return v.toString(16);
      }).toUpperCase();
    }
  }, {
    key: "getMessageType",
    value: function getMessageType(messageType) {
      var infoType = _constants.MESSAGE_TYPE.UNKNOWN;

      switch (messageType) {
        case _constants.MESSAGE_TEXT_TYPE.PROJECT_FLOW:
          infoType = _constants.MESSAGE_TYPE.CASE_TYPE;
          break;

        case _constants.MESSAGE_TEXT_TYPE.SYS_MESSAGE:
        case _constants.MESSAGE_TEXT_TYPE.SYS_NOTICE:
          infoType = _constants.MESSAGE_TYPE.SYS_TYPE;
          break;

        case _constants.MESSAGE_TEXT_TYPE.SAWATER:
          infoType = _constants.MESSAGE_TYPE.SAVE_WA_TYPE;
          break;

        case _constants.MESSAGE_TEXT_TYPE.EMTT:
          infoType = _constants.MESSAGE_TYPE.EIMT_TYPE;
          break;

        case _constants.MESSAGE_TEXT_TYPE.MESSAGE_ALERT:
          infoType = _constants.MESSAGE_TYPE.MESSAGE_ALERT;
          break;

        case _constants.MESSAGE_TEXT_TYPE.SCADA_ALARM:
        case '':
          infoType = _constants.MESSAGE_TYPE.SCADA_TYPE;

        default:
          break;
      }

      return infoType;
    }
  }, {
    key: "parseHisToMessage",
    value: function parseHisToMessage(hisMessage) {
      var timeH = (new Date() - new Date(hisMessage.HisCreateTime)) / 1000 / 60;
      var timeMss = Math.abs(timeH) > 1440 ? hisMessage.HisCreateTime.split('.')[0] : Math.abs(timeH) > 60 ? (timeH / 60).toFixed(0) + '小时前' : Math.abs(timeH) > 1 ? timeH.toFixed(0) + '分钟前' : '刚刚';
      var message = {
        id: hisMessage.HisID,
        infoContent: hisMessage.InfoContent,
        time: "".concat(timeMss),
        infoType: this.getMessageType(hisMessage.InfoType),
        dateTime: hisMessage.HisCreateTime,
        infoLevel: hisMessage.InfoLevel,
        webConfig: hisMessage.web_config,
        webPath: hisMessage.web_path,
        messType: hisMessage.MessType
      };

      if (this.getParseVesion()) {
        message.infoContent = this.parseMessageToJSON(message.infoType, message);
      } else {
        message.infoContent = JSON.parse(JSON.stringify(message.infoContent || '{}'));
      }

      return (0, _message["default"])(message);
    }
  }, {
    key: "getParseVesion",
    value: function getParseVesion() {
      var siteConfig = this.getSiteConfig();
      return !siteConfig.MessageLevel || siteConfig.MessageLevel !== '2.0';
    }
  }, {
    key: "parseMessageToJSON",
    value: function parseMessageToJSON(messageType, messageContent) {
      var messageBody = messageContent;

      try {
        switch (messageType) {
          case _constants.MESSAGE_TYPE.SCADA_TYPE:
            messageBody = this.parseMessageAlarm(messageContent);
            break;

          case _constants.MESSAGE_TYPE.CASE_TYPE:
            messageBody = this.parseMessageCase(messageContent);
            break;

          case _constants.MESSAGE_TYPE.SYS_TYPE:
            messageBody = this.parseMessageNotice(messageContent);
            break;

          case _constants.MESSAGE_TYPE.SAVE_WA_TYPE:
            break;

          case _constants.MESSAGE_TYPE.EIMT_TYPE:
            break;

          case _constants.MESSAGE_TYPE.UNKNOWN:
            break;

          default:
            break;
        }
      } catch (e) {
        logger.info('1.0消息通知解析消息内容出错:' + e.message, '消息对象:', messString);
      } finally {}

      return messageBody;
    }
  }, {
    key: "parseMessageCase",
    value: function parseMessageCase(messString) {
      var attr = messString.infoContent.split('\\n');
      var caseContent = {
        caseType: attr[0].split('】')[0].split('【')[1],
        flowName: attr[0].split('】')[1],
        nodeName: attr[1],
        content: attr[2],
        time: messString.dateTime
      };
      return caseContent;
    }
  }, {
    key: "parseMessageAlarm",
    value: function parseMessageAlarm(messString) {
      var attr = messString.infoContent.split('\\n');
      var alarmContent = {
        alarmType: attr[0].split('】')[0].split('【')[1],
        deviceCode: '',
        alarmDevice: attr[0].split('】')[1],
        alarmContent: attr[1],
        alarmThreshold: attr[2].includes(' / ') ? attr[2].split('/')[1].trim(' ') : '',
        alarmValue: attr[2].includes(' / ') ? attr[2].split('/')[0].trim(' ') : attr[2].includes('：') ? attr[2].split('：')[1] : '',
        time: messString.dateTime
      };
      return alarmContent;
    }
  }, {
    key: "parseMessageNotice",
    value: function parseMessageNotice(messString) {
      var attr = messString.infoContent.split('\\n');
      var noticeContent = {
        noticeType: attr[0].split('】')[0].split('【')[1],
        noticeTitle: attr[0].split('】')[1],
        noticeContent: attr[1],
        time: messString.dateTime
      };
      return noticeContent;
    }
  }, {
    key: "parseScadaMessage",
    value: function parseScadaMessage(message) {
      var data = message.messContent.split('\\n');
      var last = data[2];
      var alarmType = data[0].split('】')[0].split('【')[1];
      var sensor = data[1];
      var station = data[0].split('】')[1];
      var lastValue = last;

      if (last.includes(' / ')) {
        lastValue = "";
        var alaVal = last.split(' / ');
        var newVal = 0,
            setVal = 0,
            unit = "";

        if (alaVal[0].includes(' ')) {
          newVal = alaVal[0].split(' ')[0] * 1;
          setVal = alaVal[1].split(' ')[0] * 1;
          unit = alaVal[0].split(' ')[1];
        } else {
          newVal = alaVal[0] * 1;
          setVal = alaVal[1] * 1;
        }

        lastValue = Math.abs(setVal - newVal).toFixed(2) + unit;
      } else {
        lastValue = ",报警实时值" + lastValue;
      }

      var msg = "紧急报警:" + station + "," + alarmType + "," + sensor + lastValue + ",请注意!!!";

      for (var i = 0; i < 3; i++) {
        msg += msg;
      }

      var state = new window.SpeechSynthesisUtterance(msg);
      state.lang = "zh";
      state.rate = 1;
      window.speechSynthesis.cancel();
      window.speechSynthesis.speak(state);
    }
  }]);

  return Notifier;
}();

var _default = Notifier;
exports["default"] = _default;