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AAU,kBAAoB,EAAc,oBAMhD,OAJI,IACF,GAAW,mBAAqB,GAG3B,EAAS,IAAI,MAAM,GAC5B,CAEA,EAAS,KAAM,EAAe,EAAe,EAC/C,GAEJ,EAEA,OAAO,QAAU","file":"/npm/sandbox-resolver@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/sandbox-resolver@1.0.0/index.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 EPMSource = require(\"./epm\");\nvar NPMSource = require(\"./npm\");\nvar GlobalNPMSource = require(\"./globalnpm\");\nvar FSSource = require(\"./fs\");\nvar whilst = require(\"async/whilst\");\nvar contract = require(\"sandbox-contract\");\nvar expect = require(\"truffle-expect\");\nvar provision = require(\"truffle-provisioner\");\n\nfunction Resolver(options) {\n  expect.options(options, [\"working_directory\", \"contracts_build_directory\"]);\n\n  this.options = options;\n\n  this.sources = [\n    new EPMSource(options.working_directory, options.contracts_build_directory),\n    new NPMSource(options.working_directory),\n    new GlobalNPMSource(),\n    new FSSource(options.working_directory, options.contracts_build_directory)\n  ];\n}\n\n// This function might be doing too much. If so, too bad (for now).\nResolver.prototype.require = function(import_path, search_path) {\n  var self = this;\n\n  for (let i = 0; i < self.sources.length; i++) {\n    var source = self.sources[i];\n    var result = source.require(import_path, search_path);\n    if (result) {\n      var abstraction = contract(result);\n      provision(abstraction, self.options);\n      return abstraction;\n    }\n  }\n  throw new Error(\n    \"Could not find artifacts for \" + import_path + \" from any sources\"\n  );\n};\n\nResolver.prototype.resolve = function(import_path, imported_from, callback) {\n  var self = this;\n\n  if (typeof imported_from === \"function\") {\n    callback = imported_from;\n    imported_from = null;\n  }\n\n  var resolved_body = null;\n  var resolved_path = null;\n  var current_index = -1;\n  var current_source;\n\n  whilst(\n    function() {\n      return !resolved_body && current_index < self.sources.length - 1;\n    },\n    function(next) {\n      current_index += 1;\n      current_source = self.sources[current_index];\n\n      current_source.resolve(import_path, imported_from, function(\n        err,\n        body,\n        file_path\n      ) {\n        if (!err && body) {\n          resolved_body = body;\n          resolved_path = file_path;\n        }\n        next(err);\n      });\n    },\n    function(err) {\n      if (err) return callback(err);\n\n      if (!resolved_body) {\n        var message = \"Could not find \" + import_path + \" from any sources\";\n\n        if (imported_from) {\n          message += \"; imported from \" + imported_from;\n        }\n\n        return callback(new Error(message));\n      }\n\n      callback(null, resolved_body, resolved_path, current_source);\n    }\n  );\n};\n\nmodule.exports = Resolver;\n"]}