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2B,EAAO,kBAehD,EAEA,EAAW,UAAU,UAAY,SAAS,GACxC,GAAyB,MAArB,KAAK,OAAO,GACd,OAAO,KAAK,OAAO,GAAM,aAG7B,EAEA,EAAW,UAAU,aAAe,SAAS,GAC3C,GAAyB,MAArB,KAAK,OAAO,GACd,OAAO,KAAK,OAAO,GAAM,gBAG7B,EAEA,EAAW,UAAU,aAAe,SAAS,GAC3C,GAAyB,MAArB,KAAK,OAAO,GACd,OAAO,KAAK,OAAO,GAAM,iBAG7B,EAEA,EAAW,UAAU,qBAAuB,SAAS,GAEnD,GADA,KAAK,SAAW,KAAK,YAAY,GACZ,MAAjB,KAAK,SACP,OAAO,cAAc,iBAAiB,KAAM,KAAK,SAAS,MAG9D,EAEA,EAAW,UAAU,YAAc,WAIjC,YAHgC,IAA5B,KAAK,MAAM,cACb,KAAK,KAAK,yEAEL,KAAK,MAAM,YACpB,EAEA,EAAW,UAAU,MAAQ,SAAS,EAAM,EAAK,GAC/C,OAAO,KAAK,MAAM,MAAM,EAAM,EAAK,EACrC,EAEA,EAAW,UAAU,WAAa,SAAS,EAAM,EAAK,EAAO,GAC3D,IAAI,EAGmB,EAUvB,OAZA,EAAQ,KAAK,MAAM,MAAM,EAAM,EAAK,GAAO,GACvC,GACF,EAAM,MAAe,EAIlB,KAHM,SAAS,GACd,OAAO,EAAS,KAAK,EAAO,KAAM,EACpC,IACe,MAAE,SAAU,GAC3B,OAAO,SAAS,GACd,OAAO,EAAS,KAAK,EAAO,EAAO,KACrC,CACD,CAJkB,CAIhB,OAEE,CACT,EAEO,CAER,CAjlBY,GAmlBb,OAAO,QAAU","file":"/npm/rivescript-hf@1.18.2/lib/rivescript.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/rivescript-hf@1.18.2/lib/rivescript.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar Brain, JSObjectHandler, Parser, RSVP, RiveScript, VERSION, inherit_utils, readDir, sorting, utils;\n\nVERSION = \"1.17.2\";\n\nParser = require(\"./parser\");\n\nBrain = require(\"./brain\");\n\nutils = require(\"./utils\");\n\nsorting = require(\"./sorting\");\n\ninherit_utils = require(\"./inheritance\");\n\nJSObjectHandler = require(\"./lang/javascript\");\n\nRSVP = require(\"rsvp\");\n\nreadDir = require(\"fs-readdir-recursive\");\n\nRiveScript = (function() {\n  function RiveScript(opts) {\n    var key, ref, value;\n    if (opts == null) {\n      opts = {};\n    }\n    this._debug = opts.debug ? opts.debug : false;\n    this._strict = opts.strict ? opts.strict : true;\n    this._depth = opts.depth ? parseInt(opts.depth) : 50;\n    this._utf8 = opts.utf8 ? opts.utf8 : false;\n    this._forceCase = opts.forceCase ? opts.forceCase : false;\n    this._onDebug = opts.onDebug ? opts.onDebug : null;\n    this._concat = opts.concat ? opts.concat : null;\n    this.unicodePunctuation = new RegExp(/[.,!?;:]/g);\n    this.errors = {\n      replyNotMatched: \"ERR: No Reply Matched\",\n      replyNotFound: \"ERR: No Reply Found\",\n      objectNotFound: \"[ERR: Object Not Found]\",\n      deepRecursion: \"ERR: Deep Recursion Detected\"\n    };\n    if (typeof opts.errors === \"object\") {\n      ref = opts.errors;\n      for (key in ref) {\n        value = ref[key];\n        if (opts.errors.hasOwnProperty(key)) {\n          this.errors[key] = value;\n        }\n      }\n    }\n    this._node = {};\n    this._runtime = this.runtime();\n    this.parser = new Parser(this);\n    this.brain = new Brain(this);\n    this._pending = [];\n    this._loadCount = 0;\n    this._global = {};\n    this._var = {};\n    this._sub = {};\n    this._submax = 1;\n    this._person = {};\n    this._personmax = 1;\n    this._array = {};\n    this._users = {};\n    this._freeze = {};\n    this._includes = {};\n    this._inherits = {};\n    this._handlers = {};\n    this._objlangs = {};\n    this._topics = {};\n    this._thats = {};\n    this._sorted = {};\n    if (typeof opts === \"object\") {\n      if (opts.debug) {\n        this._debug = true;\n      }\n      if (opts.strict) {\n        this._strict = true;\n      }\n      if (opts.depth) {\n        this._depth = parseInt(opts.depth);\n      }\n      if (opts.utf8) {\n        this._utf8 = true;\n      }\n    }\n    this._handlers.javascript = new JSObjectHandler(this);\n    this.say(\"RiveScript Interpreter v\" + VERSION + \" Initialized.\");\n    this.say(\"Runtime Environment: \" + this._runtime);\n  }\n\n  RiveScript.prototype.version = function() {\n    return VERSION;\n  };\n\n  RiveScript.prototype.Promise = RSVP.Promise;\n\n  RiveScript.prototype.runtime = function() {\n    if (process.browser) {\n      return \"web\";\n    }\n    this._node.fs = require(\"fs\");\n    return \"node\";\n  };\n\n  RiveScript.prototype.say = function(message) {\n    if (this._debug !== true) {\n      return;\n    }\n    if (this._onDebug) {\n      return this._onDebug(message);\n    } else {\n      return console.log(message);\n    }\n  };\n\n  RiveScript.prototype.warn = function(message, filename, lineno) {\n    if ((filename != null) && (lineno != null)) {\n      message += \" at \" + filename + \" line \" + lineno;\n    }\n    if (this._onDebug) {\n      return this._onDebug(\"[WARNING] \" + message);\n    } else if (console) {\n      if (console.error) {\n        return console.error(message);\n      } else {\n        return console.log(\"[WARNING] \" + message);\n      }\n    } else if (window) {\n      return window.alert(message);\n    }\n  };\n\n  RiveScript.prototype.loadFile = function(path, onSuccess, onError) {\n    var file, i, len, loadCount;\n    if (typeof path === \"string\") {\n      path = [path];\n    }\n    loadCount = this._loadCount++;\n    this._pending[loadCount] = {};\n    for (i = 0, len = path.length; i < len; i++) {\n      file = path[i];\n      this.say(\"Request to load file: \" + file);\n      this._pending[loadCount][file] = 1;\n      if (this._runtime === \"web\") {\n        this._ajaxLoadFile(loadCount, file, onSuccess, onError);\n      } else {\n        this._nodeLoadFile(loadCount, file, onSuccess, onError);\n      }\n    }\n    return loadCount;\n  };\n\n  RiveScript.prototype._ajaxLoadFile = function(loadCount, file, onSuccess, onError) {\n    return $.ajax({\n      url: file,\n      dataType: \"text\",\n      success: (function(_this) {\n        return function(data, textStatus, xhr) {\n          _this.say(\"Loading file \" + file + \" complete.\");\n          _this.parse(file, data, onError);\n          delete _this._pending[loadCount][file];\n          if (Object.keys(_this._pending[loadCount]).length === 0) {\n            if (typeof onSuccess === \"function\") {\n              return onSuccess.call(void 0, loadCount);\n            }\n          }\n        };\n      })(this),\n      error: (function(_this) {\n        return function(xhr, textStatus, errorThrown) {\n          _this.say(\"Ajax error! \" + textStatus + \"; \" + errorThrown);\n          if (typeof onError === \"function\") {\n            return onError.call(void 0, textStatus, loadCount);\n          }\n        };\n      })(this)\n    });\n  };\n\n  RiveScript.prototype._nodeLoadFile = function(loadCount, file, onSuccess, onError) {\n    return this._node.fs.readFile(file, (function(_this) {\n      return function(err, data) {\n        if (err) {\n          if (typeof onError === \"function\") {\n            onError.call(void 0, err, loadCount);\n          } else {\n            _this.warn(err);\n          }\n          return;\n        }\n        _this.parse(file, \"\" + data, onError);\n        delete _this._pending[loadCount][file];\n        if (Object.keys(_this._pending[loadCount]).length === 0) {\n          if (typeof onSuccess === \"function\") {\n            return onSuccess.call(void 0, loadCount);\n          }\n        }\n      };\n    })(this));\n  };\n\n  RiveScript.prototype.loadDirectory = function(path, onSuccess, onError) {\n    var loadCount, toLoad;\n    if (this._runtime === \"web\") {\n      this.warn(\"loadDirectory can't be used on the web!\");\n      return;\n    }\n    loadCount = this._loadCount++;\n    this._pending[loadCount] = {};\n    toLoad = [];\n    if (onError == null) {\n      onError = function() {};\n    }\n    return this._node.fs.stat(path, (function(_this) {\n      return function(err, stats) {\n        var file, files, i, j, len, len1, results;\n        if (err) {\n          return onError.call(void 0, err, loadCount);\n        }\n        if (!stats.isDirectory()) {\n          return onError.call(void 0, path + \" is not a directory\", loadCount);\n        }\n        _this.say(\"Loading batch \" + loadCount + \" from directory \" + path);\n        files = readDir(path);\n        for (i = 0, len = files.length; i < len; i++) {\n          file = files[i];\n          if (file.match(/\\.(rive|rs)$/i)) {\n            _this._pending[loadCount][path + \"/\" + file] = 1;\n            toLoad.push(path + \"/\" + file);\n          }\n        }\n        results = [];\n        for (j = 0, len1 = toLoad.length; j < len1; j++) {\n          file = toLoad[j];\n          _this.say(\"Parsing file \" + file + \" from directory\");\n          results.push(_this._nodeLoadFile(loadCount, file, onSuccess, onError));\n        }\n        return results;\n      };\n    })(this));\n  };\n\n  RiveScript.prototype.stream = function(code, onError) {\n    this.say(\"Streaming code.\");\n    return this.parse(\"stream()\", code, onError);\n  };\n\n  RiveScript.prototype.parse = function(filename, code, onError) {\n    var ast, data, i, internal, j, len, len1, name, object, ref, ref1, ref2, ref3, results, topic, trigger, type, value, vars;\n    this.say(\"Parsing code!\");\n    ast = this.parser.parse(filename, code, onError);\n    ref = ast.begin;\n    for (type in ref) {\n      vars = ref[type];\n      if (!ast.begin.hasOwnProperty(type)) {\n        continue;\n      }\n      internal = \"_\" + type;\n      for (name in vars) {\n        value = vars[name];\n        if (type === 'sub' || type === 'person') {\n          this[internal + \"max\"] = Math.max(this[internal + \"max\"], name.split(\" \").length);\n        }\n        if (!vars.hasOwnProperty(name)) {\n          continue;\n        }\n        if (value === \"<undef>\") {\n          delete this[internal][name];\n        } else {\n          this[internal][name] = value;\n        }\n      }\n      if (this._global.debug != null) {\n        this._debug = this._global.debug === \"true\" ? true : false;\n      }\n      if (this._global.depth != null) {\n        this._depth = parseInt(this._global.depth) || 50;\n      }\n    }\n    ref1 = ast.topics;\n    for (topic in ref1) {\n      data = ref1[topic];\n      if (!ast.topics.hasOwnProperty(topic)) {\n        continue;\n      }\n      if (this._includes[topic] == null) {\n        this._includes[topic] = {};\n      }\n      if (this._inherits[topic] == null) {\n        this._inherits[topic] = {};\n      }\n      utils.extend(this._includes[topic], data.includes);\n      utils.extend(this._inherits[topic], data.inherits);\n      if (this._topics[topic] == null) {\n        this._topics[topic] = [];\n      }\n      ref2 = data.triggers;\n      for (i = 0, len = ref2.length; i < len; i++) {\n        trigger = ref2[i];\n        this._topics[topic].push(trigger);\n        if (trigger.previous != null) {\n          if (this._thats[topic] == null) {\n            this._thats[topic] = {};\n          }\n          if (this._thats[topic][trigger.trigger] == null) {\n            this._thats[topic][trigger.trigger] = {};\n          }\n          this._thats[topic][trigger.trigger][trigger.previous] = trigger;\n        }\n      }\n    }\n    ref3 = ast.objects;\n    results = [];\n    for (j = 0, len1 = ref3.length; j < len1; j++) {\n      object = ref3[j];\n      if (this._handlers[object.language]) {\n        this._objlangs[object.name] = object.language;\n        results.push(this._handlers[object.language].load(object.name, object.code));\n      } else {\n        results.push(void 0);\n      }\n    }\n    return results;\n  };\n\n  RiveScript.prototype.sortReplies = function() {\n    var allTriggers, thatTriggers, topic;\n    this._sorted.topics = {};\n    this._sorted.thats = {};\n    this.say(\"Sorting triggers...\");\n    for (topic in this._topics) {\n      if (!this._topics.hasOwnProperty(topic)) {\n        continue;\n      }\n      this.say(\"Analyzing topic \" + topic + \"...\");\n      allTriggers = inherit_utils.getTopicTriggers(this, topic);\n      this._sorted.topics[topic] = sorting.sortTriggerSet(allTriggers, true);\n      thatTriggers = inherit_utils.getTopicTriggers(this, topic, true);\n      this._sorted.thats[topic] = sorting.sortTriggerSet(thatTriggers, false);\n    }\n    this._sorted.sub = sorting.sortList(Object.keys(this._sub));\n    return this._sorted.person = sorting.sortList(Object.keys(this._person));\n  };\n\n  RiveScript.prototype.deparse = function() {\n    var key, result;\n    result = {\n      begin: {\n        global: utils.clone(this._global),\n        \"var\": utils.clone(this._var),\n        sub: utils.clone(this._sub),\n        person: utils.clone(this._person),\n        array: utils.clone(this._array),\n        triggers: []\n      },\n      topics: utils.clone(this._topics),\n      inherits: utils.clone(this._inherits),\n      includes: utils.clone(this._includes),\n      objects: {}\n    };\n    for (key in this._handlers) {\n      result.objects[key] = {\n        _objects: utils.clone(this._handlers[key]._objects)\n      };\n    }\n    if (result.topics.__begin__ != null) {\n      result.begin.triggers = result.topics.__begin__;\n      delete result.topics.__begin__;\n    }\n    if (this._debug) {\n      result.begin.global.debug = this._debug;\n    }\n    if (this._depth !== 50) {\n      result.begin.global.depth = this._depth;\n    }\n    return result;\n  };\n\n  RiveScript.prototype.stringify = function(deparsed) {\n    return this.parser.stringify(deparsed);\n  };\n\n  RiveScript.prototype.write = function(filename, deparsed) {\n    if (this._runtime === \"web\") {\n      this.warn(\"write() can't be used on the web!\");\n      return;\n    }\n    return this._node.fs.writeFile(filename, this.stringify(deparsed), function(err) {\n      if (err) {\n        return this.warn(\"Error writing to file \" + filename + \": \" + err);\n      }\n    });\n  };\n\n  RiveScript.prototype.setHandler = function(lang, obj) {\n    if (obj === void 0) {\n      return delete this._handlers[lang];\n    } else {\n      return this._handlers[lang] = obj;\n    }\n  };\n\n  RiveScript.prototype.setSubroutine = function(name, code) {\n    if (this._handlers.javascript) {\n      this._objlangs[name] = \"javascript\";\n      return this._handlers.javascript.load(name, code);\n    }\n  };\n\n  RiveScript.prototype.setGlobal = function(name, value) {\n    if (value === void 0) {\n      return delete this._global[name];\n    } else {\n      return this._global[name] = value;\n    }\n  };\n\n  RiveScript.prototype.setVariable = function(name, value) {\n    if (value === void 0) {\n      return delete this._var[name];\n    } else {\n      return this._var[name] = value;\n    }\n  };\n\n  RiveScript.prototype.setSubstitution = function(name, value) {\n    if (value === void 0) {\n      return delete this._sub[name];\n    } else {\n      this._submax = Math.max(name.split(' ').length, this._submax);\n      return this._sub[name] = value;\n    }\n  };\n\n  RiveScript.prototype.setPerson = function(name, value) {\n    if (value === void 0) {\n      return delete this._person[name];\n    } else {\n      this._personmax = Math.max(name.split(' ').length, this._personmax);\n      return this._person[name] = value;\n    }\n  };\n\n  RiveScript.prototype.setUservar = function(user, name, value) {\n    if (!this._users[user]) {\n      this._users[user] = {\n        topic: \"random\"\n      };\n    }\n    if (value === void 0) {\n      return delete this._users[user][name];\n    } else {\n      if (name === \"topic\" && this._forceCase) {\n        value = value.toLowerCase();\n      }\n      return this._users[user][name] = value;\n    }\n  };\n\n  RiveScript.prototype.setUservars = function(user, data) {\n    var key, results;\n    if (!this._users[user]) {\n      this._users[user] = {\n        topic: \"random\"\n      };\n    }\n    results = [];\n    for (key in data) {\n      if (!data.hasOwnProperty(key)) {\n        continue;\n      }\n      if (key === \"topic\" && this._forceCase) {\n        data[key] = data[key].toLowerCase();\n      }\n      if (data[key] === void 0) {\n        results.push(delete this._users[user][key]);\n      } else {\n        results.push(this._users[user][key] = data[key]);\n      }\n    }\n    return results;\n  };\n\n  RiveScript.prototype.getVariable = function(name) {\n    if (typeof this._var[name] !== \"undefined\") {\n      return this._var[name];\n    } else {\n      return \"undefined\";\n    }\n  };\n\n  RiveScript.prototype.getUservar = function(user, name) {\n    if (!this._users[user]) {\n      return \"undefined\";\n    }\n    if (typeof this._users[user][name] !== \"undefined\") {\n      return this._users[user][name];\n    } else {\n      return \"undefined\";\n    }\n  };\n\n  RiveScript.prototype.getUservars = function(user) {\n    if (user === void 0) {\n      return utils.clone(this._users);\n    } else {\n      if (this._users[user] != null) {\n        return utils.clone(this._users[user]);\n      }\n      return void 0;\n    }\n  };\n\n  RiveScript.prototype.clearUservars = function(user) {\n    if (user === void 0) {\n      return this._users = {};\n    } else {\n      return delete this._users[user];\n    }\n  };\n\n  RiveScript.prototype.freezeUservars = function(user) {\n    if (this._users[user] != null) {\n      return this._freeze[user] = utils.clone(this._users[user]);\n    } else {\n      return this.warn(\"Can't freeze vars for user \" + user + \": not found!\");\n    }\n  };\n\n  RiveScript.prototype.thawUservars = function(user, action) {\n    if (action == null) {\n      action = \"thaw\";\n    }\n    if (typeof action !== \"string\") {\n      action = \"thaw\";\n    }\n    if (this._freeze[user] == null) {\n      this.warn(\"Can't thaw user vars: \" + user + \" wasn't frozen!\");\n      return;\n    }\n    if (action === \"thaw\") {\n      this.clearUservars(user);\n      this._users[user] = utils.clone(this._freeze[user]);\n      return delete this._freeze[user];\n    } else if (action === \"discard\") {\n      return delete this._freeze[user];\n    } else if (action === \"keep\") {\n      this.clearUservars(user);\n      return this._users[user] = utils.clone(this._freeze[user]);\n    } else {\n      return this.warn(\"Unsupported thaw action!\");\n    }\n  };\n\n  RiveScript.prototype.lastMatch = function(user) {\n    if (this._users[user] != null) {\n      return this._users[user].__lastmatch__;\n    }\n    return void 0;\n  };\n\n  RiveScript.prototype.initialMatch = function(user) {\n    if (this._users[user] != null) {\n      return this._users[user].__initialmatch__;\n    }\n    return void 0;\n  };\n\n  RiveScript.prototype.lastTriggers = function(user) {\n    if (this._users[user] != null) {\n      return this._users[user].__last_triggers__;\n    }\n    return void 0;\n  };\n\n  RiveScript.prototype.getUserTopicTriggers = function(user) {\n    this.userVars = this.getUservars(user);\n    if (this.userVars != null) {\n      return inherit_utils.getTopicTriggers(this, this.userVars.topic);\n    }\n    return void 0;\n  };\n\n  RiveScript.prototype.currentUser = function() {\n    if (this.brain._currentUser === void 0) {\n      this.warn(\"currentUser() is intended to be called from within a JS object macro!\");\n    }\n    return this.brain._currentUser;\n  };\n\n  RiveScript.prototype.reply = function(user, msg, scope) {\n    return this.brain.reply(user, msg, scope);\n  };\n\n  RiveScript.prototype.replyAsync = function(user, msg, scope, callback) {\n    var reply;\n    reply = this.brain.reply(user, msg, scope, true);\n    if (callback) {\n      reply.then((function(_this) {\n        return function(result) {\n          return callback.call(_this, null, result);\n        };\n      })(this))[\"catch\"]((function(_this) {\n        return function(error) {\n          return callback.call(_this, error, null);\n        };\n      })(this));\n    }\n    return reply;\n  };\n\n  return RiveScript;\n\n})();\n\nmodule.exports = RiveScript;\n"]}