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X,IACP,OAAO,SAAS,MAKiB,SADtC,EAAS,OAAO,SAAS,GAAU,EAAS,IAAI,OAAO,IAC5C,MAAM,EAAG,GAAG,aAGd,IAAK,qBAAqB,WAAW,IAEzC,IAAI,mBACb","file":"/npm/animated-gif-detector@1.2.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/animated-gif-detector@1.2.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 Writable = require('stream').Writable\n  , inherits = require('inherits')\n  // GIF CONSTANTS: http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp\n  , BLOCK_TERMINATOR = { value: new Buffer('00') }\n  , EXTENSION_INTRODUCER = {\n        value: new Buffer('21')\n      , head: 0\n      , tail: 1\n    }\n  , GRAPHIC_CONTROL_LABEL = {\n        value: new Buffer('f9')\n      , head: 1\n      , tail: 2\n    }\n;\n\ninherits(AnimatedGifDetector, Writable);\nfunction AnimatedGifDetector(buffer, options) {\n  Writable.call(this, options);\n  this.buffer = new Buffer(0);\n  this.count = 0;\n}\n\nAnimatedGifDetector.prototype.isAnimated = function(buffer) {\n  var result = false\n  ;\n  for (var i = 0; i < buffer.length; i++) {\n    result = this.pointer == BLOCK_TERMINATOR.value &&\n             buffer.toString('hex', i + EXTENSION_INTRODUCER.head, i + EXTENSION_INTRODUCER.tail) == EXTENSION_INTRODUCER.value &&\n             buffer.toString('hex', i + GRAPHIC_CONTROL_LABEL.head, i + GRAPHIC_CONTROL_LABEL.tail) == GRAPHIC_CONTROL_LABEL.value;\n\n    if (result)\n      this.count += 1;\n\n    if (this.count > 1)\n      return true;\n    this.pointer = buffer.toString('hex', i, i + 1);\n  }\n  return false;\n}\n\nAnimatedGifDetector.prototype._write = function(chunk, enc, next) {\n  // We can discard the last buffer up to last 2 bytes\n  this.buffer = Buffer.concat([this.buffer.slice(-2), chunk]);\n  var animated = this.isAnimated(this.buffer)\n  ;\n\n  if (this.buffer.length > 4 && this.isGIF == undefined)\n    this.isGIF = this.buffer.slice(0, 3).toString() === 'GIF';\n\n  // If it's the first chunk of stream we analyze and is not GIF, stop\n  if (this.isGIF === false)\n    return this.emit('finish');\n\n  if (animated) {\n    this.emit('animated');\n    return this.emit('finish');\n  }\n\n  next();\n};\n\nmodule.exports = function(buffer) {\n  if (buffer) {\n    var valid = typeof buffer === 'string'\n      || typeof buffer === 'number'\n      || Buffer.isBuffer(buffer)\n    ;\n    if (!valid)\n      return false;\n    buffer = Buffer.isBuffer(buffer) ? buffer : new Buffer(buffer);\n    if (buffer.slice(0, 3).toString() !== 'GIF')\n      return false;\n    else\n      return (new AnimatedGifDetector).isAnimated(buffer);\n  }\n  return new AnimatedGifDetector;\n}\n"]}