/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@automattic/yara@2.6.3/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var util=require("util"),yara=require("./build/Release/yara");function _parseMetadata(e){for(var r=0;r<e.metas.length;r++){var a=e.metas[r].split(":"),t={type:parseInt(a.shift()),id:a.shift(),value:a.join(":")};t.type==yara.MetaType.Integer?t.value=parseInt(t.value):t.type==yara.MetaType.Boolean&&(t.value="true"==t.value),e.metas[r]=t}return e}function _expandConstantObject(e){var r=[];for(var a in e)r.push([a,e[a]]);for(var t=0;t<r.length;t++)e[r[t][1]]=r[t][0]}function CompileRulesError(e){this.name="CompileRulesError",this.message=e}function Scanner(e){this.yara=new yara.ScannerWrap}_expandConstantObject(yara.ErrorCode),util.inherits(CompileRulesError,Error),Scanner.prototype.getRules=function(){var e=this.yara.getRules();return e.rules.forEach((function(e){_parseMetadata(e)})),e},Scanner.prototype.reconfigureVariables=function(e){return this.yara.reconfigureVariables(e)},Scanner.prototype.configure=function(e,r){return this.yara.configure(e,(function(e,a){if(a)for(var t=0;t<a.length;t++){var n=a[t].split(":");a[t]={index:parseInt(n[0]),line:parseInt(n[1]),message:n[2]}}if(e){if(e.errors){var i=[];e.errors.forEach((function(e){var r=e.split(":");i.push({index:parseInt(r[0]),line:parseInt(r[1]),message:r[2]})})),(e=new CompileRulesError(e.message)).errors=i}r(e,a)}else r(null,a)}))},Scanner.prototype.configureAsync=util.promisify(Scanner.prototype.configure),Scanner.prototype.scan=function(e,r){return e.buffer&&(e.offset||(e.offset=0),e.length||(e.length=e.buffer.length-e.offset)),this.yara.scan(e,(function(e,a){e?r(e):(a.rules.forEach((function(e){e=_parseMetadata(e);for(var r=0;r<e.matches.length;r++){var a=e.matches[r].split(":"),t={offset:parseInt(a[0]),length:parseInt(a[1]),id:a[2]};r<e.datas.length&&(t.bytes=e.datas[r]),e.matches[r]=t}delete e.datas})),r(null,a))}))},Scanner.prototype.scanAsync=util.promisify(Scanner.prototype.scan),exports.CompileRulesError=CompileRulesError,exports.Scanner=Scanner,exports.MetaType=yara.MetaType,exports.ScanFlag=yara.ScanFlag,exports.VariableType=yara.VariableType,exports.createScanner=function(e){return new Scanner(e||{})},exports.initialize=function(e){return yara.initialize(e)},exports.initializeAsync=util.promisify(exports.initialize),exports.libyaraVersion=function(){return yara.libyaraVersion()};
//# sourceMappingURL=/sm/68a79618681174c1c9a3db5b3a3c5129aea51c5861bb2557b8452a471981b6db.map