{"ast":null,"code":"function RetryOperation(timeouts, options) {\n // Compatibility for the old (timeouts, retryForever) signature\n if (typeof options === 'boolean') {\n options = {\n forever: options\n };\n }\n this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));\n this._timeouts = timeouts;\n this._options = options || {};\n this._maxRetryTime = options && options.maxRetryTime || Infinity;\n this._fn = null;\n this._errors = [];\n this._attempts = 1;\n this._operationTimeout = null;\n this._operationTimeoutCb = null;\n this._timeout = null;\n this._operationStart = null;\n this._timer = null;\n if (this._options.forever) {\n this._cachedTimeouts = this._timeouts.slice(0);\n }\n}\nmodule.exports = RetryOperation;\nRetryOperation.prototype.reset = function () {\n this._attempts = 1;\n this._timeouts = this._originalTimeouts.slice(0);\n};\nRetryOperation.prototype.stop = function () {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this._timeouts = [];\n this._cachedTimeouts = null;\n};\nRetryOperation.prototype.retry = function (err) {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n if (!err) {\n return false;\n }\n var currentTime = new Date().getTime();\n if (err && currentTime - this._operationStart >= this._maxRetryTime) {\n this._errors.push(err);\n this._errors.unshift(new Error('RetryOperation timeout occurred'));\n return false;\n }\n this._errors.push(err);\n var timeout = this._timeouts.shift();\n if (timeout === undefined) {\n if (this._cachedTimeouts) {\n // retry forever, only keep last error\n this._errors.splice(0, this._errors.length - 1);\n timeout = this._cachedTimeouts.slice(-1);\n } else {\n return false;\n }\n }\n var self = this;\n this._timer = setTimeout(function () {\n self._attempts++;\n if (self._operationTimeoutCb) {\n self._timeout = setTimeout(function () {\n self._operationTimeoutCb(self._attempts);\n }, self._operationTimeout);\n if (self._options.unref) {\n self._timeout.unref();\n }\n }\n self._fn(self._attempts);\n }, timeout);\n if (this._options.unref) {\n this._timer.unref();\n }\n return true;\n};\nRetryOperation.prototype.attempt = function (fn, timeoutOps) {\n this._fn = fn;\n if (timeoutOps) {\n if (timeoutOps.timeout) {\n this._operationTimeout = timeoutOps.timeout;\n }\n if (timeoutOps.cb) {\n this._operationTimeoutCb = timeoutOps.cb;\n }\n }\n var self = this;\n if (this._operationTimeoutCb) {\n this._timeout = setTimeout(function () {\n self._operationTimeoutCb();\n }, self._operationTimeout);\n }\n this._operationStart = new Date().getTime();\n this._fn(this._attempts);\n};\nRetryOperation.prototype.try = function (fn) {\n console.log('Using RetryOperation.try() is deprecated');\n this.attempt(fn);\n};\nRetryOperation.prototype.start = function (fn) {\n console.log('Using RetryOperation.start() is deprecated');\n this.attempt(fn);\n};\nRetryOperation.prototype.start = RetryOperation.prototype.try;\nRetryOperation.prototype.errors = function () {\n return this._errors;\n};\nRetryOperation.prototype.attempts = function () {\n return this._attempts;\n};\nRetryOperation.prototype.mainError = function () {\n if (this._errors.length === 0) {\n return null;\n }\n var counts = {};\n var mainError = null;\n var mainErrorCount = 0;\n for (var i = 0; i < this._errors.length; i++) {\n var error = this._errors[i];\n var message = error.message;\n var count = (counts[message] || 0) + 1;\n counts[message] = count;\n if (count >= mainErrorCount) {\n mainError = error;\n mainErrorCount = count;\n }\n }\n return mainError;\n};","map":{"version":3,"names":["RetryOperation","timeouts","options","forever","_originalTimeouts","JSON","parse","stringify","_timeouts","_options","_maxRetryTime","maxRetryTime","Infinity","_fn","_errors","_attempts","_operationTimeout","_operationTimeoutCb","_timeout","_operationStart","_timer","_cachedTimeouts","slice","module","exports","prototype","reset","stop","clearTimeout","retry","err","currentTime","Date","getTime","push","unshift","Error","timeout","shift","undefined","splice","length","self","setTimeout","unref","attempt","fn","timeoutOps","cb","try","console","log","start","errors","attempts","mainError","counts","mainErrorCount","i","error","message","count"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@langchain/core/node_modules/retry/lib/retry_operation.js"],"sourcesContent":["function RetryOperation(timeouts, options) {\n // Compatibility for the old (timeouts, retryForever) signature\n if (typeof options === 'boolean') {\n options = { forever: options };\n }\n\n this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));\n this._timeouts = timeouts;\n this._options = options || {};\n this._maxRetryTime = options && options.maxRetryTime || Infinity;\n this._fn = null;\n this._errors = [];\n this._attempts = 1;\n this._operationTimeout = null;\n this._operationTimeoutCb = null;\n this._timeout = null;\n this._operationStart = null;\n this._timer = null;\n\n if (this._options.forever) {\n this._cachedTimeouts = this._timeouts.slice(0);\n }\n}\nmodule.exports = RetryOperation;\n\nRetryOperation.prototype.reset = function() {\n this._attempts = 1;\n this._timeouts = this._originalTimeouts.slice(0);\n}\n\nRetryOperation.prototype.stop = function() {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n if (this._timer) {\n clearTimeout(this._timer);\n }\n\n this._timeouts = [];\n this._cachedTimeouts = null;\n};\n\nRetryOperation.prototype.retry = function(err) {\n if (this._timeout) {\n clearTimeout(this._timeout);\n }\n\n if (!err) {\n return false;\n }\n var currentTime = new Date().getTime();\n if (err && currentTime - this._operationStart >= this._maxRetryTime) {\n this._errors.push(err);\n this._errors.unshift(new Error('RetryOperation timeout occurred'));\n return false;\n }\n\n this._errors.push(err);\n\n var timeout = this._timeouts.shift();\n if (timeout === undefined) {\n if (this._cachedTimeouts) {\n // retry forever, only keep last error\n this._errors.splice(0, this._errors.length - 1);\n timeout = this._cachedTimeouts.slice(-1);\n } else {\n return false;\n }\n }\n\n var self = this;\n this._timer = setTimeout(function() {\n self._attempts++;\n\n if (self._operationTimeoutCb) {\n self._timeout = setTimeout(function() {\n self._operationTimeoutCb(self._attempts);\n }, self._operationTimeout);\n\n if (self._options.unref) {\n self._timeout.unref();\n }\n }\n\n self._fn(self._attempts);\n }, timeout);\n\n if (this._options.unref) {\n this._timer.unref();\n }\n\n return true;\n};\n\nRetryOperation.prototype.attempt = function(fn, timeoutOps) {\n this._fn = fn;\n\n if (timeoutOps) {\n if (timeoutOps.timeout) {\n this._operationTimeout = timeoutOps.timeout;\n }\n if (timeoutOps.cb) {\n this._operationTimeoutCb = timeoutOps.cb;\n }\n }\n\n var self = this;\n if (this._operationTimeoutCb) {\n this._timeout = setTimeout(function() {\n self._operationTimeoutCb();\n }, self._operationTimeout);\n }\n\n this._operationStart = new Date().getTime();\n\n this._fn(this._attempts);\n};\n\nRetryOperation.prototype.try = function(fn) {\n console.log('Using RetryOperation.try() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = function(fn) {\n console.log('Using RetryOperation.start() is deprecated');\n this.attempt(fn);\n};\n\nRetryOperation.prototype.start = RetryOperation.prototype.try;\n\nRetryOperation.prototype.errors = function() {\n return this._errors;\n};\n\nRetryOperation.prototype.attempts = function() {\n return this._attempts;\n};\n\nRetryOperation.prototype.mainError = function() {\n if (this._errors.length === 0) {\n return null;\n }\n\n var counts = {};\n var mainError = null;\n var mainErrorCount = 0;\n\n for (var i = 0; i < this._errors.length; i++) {\n var error = this._errors[i];\n var message = error.message;\n var count = (counts[message] || 0) + 1;\n\n counts[message] = count;\n\n if (count >= mainErrorCount) {\n mainError = error;\n mainErrorCount = count;\n }\n }\n\n return mainError;\n};\n"],"mappings":"AAAA,SAASA,cAAcA,CAACC,QAAQ,EAAEC,OAAO,EAAE;EACzC;EACA,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;IAChCA,OAAO,GAAG;MAAEC,OAAO,EAAED;IAAQ,CAAC;EAChC;EAEA,IAAI,CAACE,iBAAiB,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACN,QAAQ,CAAC,CAAC;EAC7D,IAAI,CAACO,SAAS,GAAGP,QAAQ;EACzB,IAAI,CAACQ,QAAQ,GAAGP,OAAO,IAAI,CAAC,CAAC;EAC7B,IAAI,CAACQ,aAAa,GAAGR,OAAO,IAAIA,OAAO,CAACS,YAAY,IAAIC,QAAQ;EAChE,IAAI,CAACC,GAAG,GAAG,IAAI;EACf,IAAI,CAACC,OAAO,GAAG,EAAE;EACjB,IAAI,CAACC,SAAS,GAAG,CAAC;EAClB,IAAI,CAACC,iBAAiB,GAAG,IAAI;EAC7B,IAAI,CAACC,mBAAmB,G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