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":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/broccoli-filter@1.3.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","'use strict';\n\nvar fs = require('fs');\nvar path = require('path');\nvar mkdirp = require('mkdirp');\nvar Promise = require('rsvp').Promise;\nvar Plugin = require('broccoli-plugin');\nvar helpers = require('broccoli-kitchen-sink-helpers');\nvar walkSync = require('walk-sync');\nvar mapSeries = require('promise-map-series');\nvar symlinkOrCopySync = require('symlink-or-copy').sync;\nvar copyDereferenceSync = require('copy-dereference').sync;\nvar Cache = require('./lib/cache');\nvar debugGenerator = require('debug');\nvar keyForFile = require('./lib/key-for-file');\n\nmodule.exports = Filter;\n\nFilter.prototype = Object.create(Plugin.prototype);\nFilter.prototype.constructor = Filter;\nfunction Filter(inputTree, options) {\n  if (!this || !(this instanceof Filter) ||\n      Object.getPrototypeOf(this) === Filter.prototype) {\n    throw new TypeError('Filter is an abstract class and must be sub-classed');\n  }\n\n  var name = 'broccoli-filter:' + (this.constructor.name);\n  if (this.description) {\n    name += ' > [' + this.description + ']';\n  }\n\n  this._debug = debugGenerator(name);\n\n  Plugin.call(this, [inputTree]);\n\n  if (options) {\n    if (options.extensions != null)\n      this.extensions = options.extensions;\n    if (options.targetExtension != null)\n      this.targetExtension = options.targetExtension;\n    // For encodings, `null` (buffers) is distinct from the default (UTF-8)\n    if (options.inputEncoding !== undefined)\n      this.inputEncoding = options.inputEncoding;\n    if (options.outputEncoding !== undefined)\n      this.outputEncoding = options.outputEncoding;\n  }\n\n  this._cache = new Cache();\n  this._canProcessCache = Object.create(null);\n  this._destFilePathCache = Object.create(null);\n}\n\nFilter.prototype.build = function build() {\n  var self = this;\n  var srcDir = this.inputPaths[0];\n  var destDir = this.outputPath;\n  var paths = walkSync(srcDir);\n\n  this._cache.deleteExcept(paths).forEach(function(key) {\n    fs.unlinkSync(this.cachePath + '/' + key);\n  }, this);\n\n  return mapSeries(paths, function rebuildEntry(relativePath) {\n    var destPath = destDir + '/' + relativePath;\n    if (relativePath.slice(-1) === '/') {\n      mkdirp.sync(destPath);\n    } else {\n      if (self.canProcessFile(relativePath)) {\n        return self.processAndCacheFile(srcDir, destDir, relativePath);\n      } else {\n        var srcPath = srcDir + '/' + relativePath;\n        symlinkOrCopySync(srcPath, destPath);\n      }\n    }\n  });\n};\n\nFilter.prototype.canProcessFile =\n    function canProcessFile(relativePath) {\n  return !!this.getDestFilePath(relativePath);\n};\n\nFilter.prototype.getDestFilePath = function getDestFilePath(relativePath) {\n  if (this.extensions == null) return relativePath;\n\n  for (var i = 0, ii = this.extensions.length; i < ii; ++i) {\n    var ext = this.extensions[i];\n    if (relativePath.slice(-ext.length - 1) === '.' + ext) {\n      if (this.targetExtension != null) {\n        relativePath =\n            relativePath.slice(0, -ext.length) + this.targetExtension;\n      }\n      return relativePath;\n    }\n  }\n  return null;\n}\n\nFilter.prototype.processAndCacheFile =\n    function processAndCacheFile(srcDir, destDir, relativePath) {\n  var self = this;\n  var cacheEntry = this._cache.get(relativePath);\n  var outputRelativeFile = self.getDestFilePath(relativePath);\n\n  if (cacheEntry) {\n    var hashResult = hash(srcDir, cacheEntry.inputFile);\n\n    if (cacheEntry.hash.hash === hashResult.hash) {\n      this._debug('cache hit: %s', relativePath);\n\n      return symlinkOrCopyFromCache(cacheEntry, destDir, outputRelativeFile);\n    } else {\n      this._debug('cache miss: %s \\n  - previous: %o \\n  - next:     %o ', relativePath, cacheEntry.hash.key, hashResult.key);\n    }\n\n  } else {\n    this._debug('cache prime: %s', relativePath);\n  }\n\n  return Promise.resolve().\n      then(function asyncProcessFile() {\n        return self.processFile(srcDir, destDir, relativePath);\n      }).\n      then(copyToCache,\n      // TODO(@caitp): error wrapper is for API compat, but is not particularly\n      // useful.\n      // istanbul ignore next\n      function asyncProcessFileErrorWrapper(e) {\n        if (typeof e !== 'object' || e === null) e = new Error('' + e);\n        e.file = relativePath;\n        e.treeDir = srcDir;\n        throw e;\n      })\n\n  function copyToCache() {\n    var entry = {\n      hash: hash(srcDir, relativePath),\n      inputFile: relativePath,\n      outputFile: destDir + '/' + outputRelativeFile,\n      cacheFile: self.cachePath + '/' + outputRelativeFile\n    };\n\n    if (fs.existsSync(entry.cacheFile)) {\n      fs.unlinkSync(entry.cacheFile);\n    } else {\n      mkdirp.sync(path.dirname(entry.cacheFile));\n    }\n\n    copyDereferenceSync(entry.outputFile, entry.cacheFile);\n\n    return self._cache.set(relativePath, entry);\n  }\n};\n\nFilter.prototype.processFile =\n    function processFile(srcDir, destDir, relativePath) {\n  var self = this;\n  var inputEncoding = this.inputEncoding;\n  var outputEncoding = this.outputEncoding;\n  if (inputEncoding === undefined) inputEncoding = 'utf8';\n  if (outputEncoding === undefined) outputEncoding = 'utf8';\n  var contents = fs.readFileSync(\n      srcDir + '/' + relativePath, { encoding: inputEncoding });\n\n  return Promise.resolve(this.processString(contents, relativePath)).\n      then(function asyncOutputFilteredFile(outputString) {\n        var outputPath = self.getDestFilePath(relativePath);\n        if (outputPath == null) {\n          throw new Error('canProcessFile(\"' + relativePath + '\") is true, but getDestFilePath(\"' + relativePath + '\") is null');\n        }\n        outputPath = destDir + '/' + outputPath;\n        mkdirp.sync(path.dirname(outputPath));\n        fs.writeFileSync(outputPath, outputString, {\n          encoding: outputEncoding\n        });\n      });\n};\n\nFilter.prototype.processString =\n    function unimplementedProcessString(contents, relativePath) {\n  throw new Error(\n      'When subclassing broccoli-filter you must implement the ' +\n      '`processString()` method.');\n};\n\nfunction hash(src, filePath) {\n  var path = src + '/' + filePath;\n  var key = keyForFile(path);\n\n  return {\n    key: key,\n    hash: helpers.hashStrings([\n      path,\n      key.size,\n      key.mode,\n      key.mtime\n    ])\n  };\n}\n\nfunction symlinkOrCopyFromCache(entry, dest, relativePath) {\n  try {\n    symlinkOrCopySync(entry.cacheFile, dest + '/' + relativePath);\n  } catch(err) {\n    if (err.code === 'ENOENT') {\n      // assume that the destination directory is missing create it and retry\n      mkdirp.sync(path.dirname(entry.outputFile))\n      symlinkOrCopySync(entry.cacheFile, dest + '/' + relativePath)\n    } else {\n      throw err;\n    }\n  }\n}\n"]}