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O,KAAK,GACnB,EAAI,EAAsB,EAAG,GAAK,EAAY,IAAK,CAE1D,IADA,IAAI,EAAQ,EAAO,KAAK,GACf,EAAI,EAAG,EAAI,EAAM,MAAM,GAAI,IAClC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,MAAM,GAAI,IACP,IAAvB,EAAM,IAAI,EAAG,EAAG,KAGlB,EAAM,IAAI,EAAG,EAAG,EAAG,EAAU,IAAI,EAAG,EAAG,IACvC,EAAM,IAAI,EAAG,EAAG,EAAG,EAAU,IAAI,EAAG,EAAG,IACvC,EAAM,IAAI,EAAG,EAAG,EAAG,EAAU,IAAI,EAAG,EAAG,IACvC,EAAM,IAAI,EAAG,EAAG,EAAG,EAAU,IAAI,EAAG,EAAG,KAI7C,EAAY,CACd,CACA,EAAsB,CACxB,CACA,OAAO,WAAW,EAAO,KAAK,GAAa,EAAY,CACrD,QAAS,GAEb,EACA,WAAY,EACZ,UAAW,GAAc,EAAW,IAEvC,CAnCD,CAmCG,GAEL,EAAQ,EA5CR,CA6CF,IAEO,CACT,CAEA,OAAO,QAAU","file":"/npm/gif-frames@1.0.1/gif-frames.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/gif-frames@1.0.1/gif-frames.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 MultiRange = require('multi-integer-range').MultiRange;\nvar getPixels = require('get-pixels-frame-info-update');\nvar savePixels = require('save-pixels-jpeg-js-upgrade');\n\nfunction nopromises () {\n  throw new Error(\n    'Promises not supported in your environment. ' +\n    'Use the callback argument or a Promise polyfill.'\n  );\n}\n\nvar brokenPromise = {\n  then: nopromises,\n  catch: nopromises\n};\n\nfunction gifFrames (options, callback) {\n  options = options || {};\n  callback = callback || function () {};\n\n  var promise;\n  var resolve;\n  var reject;\n  if (typeof Promise === 'function') {\n    promise = new Promise(function (_resolve, _reject) {\n      resolve = function (res) {\n        callback(null, res);\n        _resolve(res);\n      };\n      reject = function (err) {\n        callback(err);\n        _reject(err);\n      };\n    });\n  } else {\n    promise = brokenPromise;\n    resolve = function (res) {\n      callback(null, res);\n    };\n    reject = callback;\n  }\n\n  var url = options.url;\n  if (!url) {\n    reject(new Error('\"url\" option is required.'));\n    return promise;\n  }\n  var frames = options.frames;\n  if (!frames && frames !== 0) {\n    reject(new Error('\"frames\" option is required.'));\n    return promise;\n  }\n  var outputType = options.outputType || 'jpg';\n  var quality = options.quality;\n  var cumulative = options.cumulative;\n\n  var acceptedFrames = frames === 'all' ? 'all' : new MultiRange(frames);\n\n  // Necessary to check if we're in Node or the browser until this is fixed:\n  // https://github.com/scijs/get-pixels/issues/33\n  var inputType = typeof window === 'undefined' ? 'image/gif' : '.GIF';\n  getPixels(url, inputType, function (err, pixels, framesInfo) {\n    if (err) {\n      reject(err);\n      return;\n    }\n    if (pixels.shape.length < 4) {\n      reject(new Error('\"url\" input should be multi-frame GIF.'));\n      return;\n    }\n    var frameData = [];\n    var maxAccumulatedFrame = 0;\n    for (var i = 0; i < pixels.shape[0]; i++) {\n      if (acceptedFrames !== 'all' && !acceptedFrames.has(i)) {\n        continue;\n      }\n      (function (frameIndex) {\n        frameData.push({\n          getImage: function () {\n            if (cumulative && frameIndex > maxAccumulatedFrame) {\n              // for each frame, replace any invisible pixel with\n              // the corresponding pixel from the previous frame (beginning\n              // with the second frame).\n              // to avoid doing too much work at once we only compute the\n              // frames up to and including the requested frame.\n              var lastFrame = pixels.pick(maxAccumulatedFrame);\n              for (var f = maxAccumulatedFrame + 1; f <= frameIndex; f++) {\n                var frame = pixels.pick(f);\n                for (var x = 0; x < frame.shape[0]; x++) {\n                  for (var y = 0; y < frame.shape[1]; y++) {\n                    if (frame.get(x, y, 3) === 0) {\n                      // if alpha is fully transparent, use the pixel\n                      // from the last frame\n                      frame.set(x, y, 0, lastFrame.get(x, y, 0));\n                      frame.set(x, y, 1, lastFrame.get(x, y, 1));\n                      frame.set(x, y, 2, lastFrame.get(x, y, 2));\n                      frame.set(x, y, 3, lastFrame.get(x, y, 3));\n                    }\n                  }\n                }\n                lastFrame = frame;\n              }\n              maxAccumulatedFrame = frameIndex;\n            }\n            return savePixels(pixels.pick(frameIndex), outputType, {\n              quality: quality\n            });\n          },\n          frameIndex: frameIndex,\n          frameInfo: framesInfo && framesInfo[frameIndex]\n        });\n      })(i);\n    }\n    resolve(frameData);\n  });\n\n  return promise;\n}\n\nmodule.exports = gifFrames;\n"]}