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S,GAC7B,IAGI,EAHA,EAAK,EAAI,cACT,EAAS,cAAc,aAG3B,EAAO,MAAQ,EACf,EAAO,OAAS,EAChB,IAAI,EAAM,EAAO,WAAW,MAC5B,EAAI,UAAU,EAAK,EAAG,GACtB,IACE,EAAO,EAAI,aAAa,EAAG,EAAG,EAAG,GAAI,IACvC,CAAE,MAAO,GAEP,OADA,QAAQ,IAAI,sCACL,CACT,CAIA,IAHA,IAAI,EAAK,EACL,EAAK,EACL,EAAK,EACF,EAAK,GAEI,IADN,EAAgB,GAAV,EAAK,GAAS,GAE1B,EAAK,EAEL,EAAK,EAEP,EAAM,EAAK,GAAO,EAEpB,IAAI,EAAS,EAAK,EAClB,OAAkB,IAAV,EAAe,EAAI,CAC7B,EAEA,UAAW,SAAS,GAClB,IAAI,EAAM,EAAO,WAAW,MACxB,EAAY,EAAI,UAepB,OAdA,EAAI,UAAY,SAAS,EAAK,EAAI,EAAI,EAAI,EAAI,EAAI,EAAI,EAAI,GACxD,IAAI,EAAkB,EAChB,GAAwB,QAAjB,EAAI,WACf,EAAkB,cAAc,qBAAqB,IAI9B,IAArB,UAAU,OACZ,EAAU,KAAK,EAAK,EAAK,EAAI,EAAI,EAAI,EAAI,EAAI,EAAI,EAAI,EAAK,QACrC,IAAP,EACd,EAAU,KAAK,EAAK,EAAK,EAAI,EAAI,EAAI,EAAK,GAE1C,EAAU,KAAK,EAAK,EAAK,EAAI,EACjC,EACO,CACT","file":"/npm/barcode-reader@1.6.1/src/BarcodeReader.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/barcode-reader@1.6.1/src/BarcodeReader.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * CallBacks:\n * __________________________________________________________________________________\n * All the callback function should have one parameter:\n * function(result){};\n * And the result parameter will contain an array of objects that look like BarcodeReader.\n * result = [{Format: the barcode type, Value: the value of the barcode}];\n * __________________________________________________________________________________\n *\n * You can use either the set functions or just access the properties directly to set callback or\n * other properties. Just always remember to call Init() before starting to decode something never mess\n * around with the SupportedFormats property.\n *\n */\nBarcodeReader = {\n  Config: {\n    // Set to false if the decoder should look for one barcode and then stop. Increases performance.\n    Multiple: true,\n\n    // The formats that the decoder will look for.\n    DecodeFormats: [\"Code128\", \"Code93\", \"Code39\", \"EAN-13\", \"2Of5\", \"Inter2Of5\", \"Codabar\"],\n\n    // ForceUnique just must makes sure that the callback function isn't repeatedly called\n    // with the same barcode. Especially in the case of a video stream.\n    ForceUnique: true,\n\n    // Set to true if information about the localization should be recieved from the worker.\n    LocalizationFeedback: false,\n\n    // Set to true if checking orientation of the image should be skipped.\n    // Checking orientation takes a bit of time for larger images, so if\n    // you are sure that the image orientation is 1 you should skip it.\n    SkipOrientation: false\n  },\n  SupportedFormats: [\"Code128\", \"Code93\", \"Code39\", \"EAN-13\", \"2Of5\", \"Inter2Of5\", \"Codabar\"], // Don't touch.\n  ScanCanvas: null, // Don't touch the canvas either.\n  ScanContext: null,\n  SquashCanvas: document.createElement(\"canvas\"),\n  ImageCallback: null, // Callback for the decoding of an image.\n  StreamCallback: null, // Callback for the decoding of a video.\n  LocalizationCallback: null, // Callback for localization.\n  Stream: null, // The actual video.\n  DecodeStreamActive: false, // Will be set to false when StopStreamDecode() is called.\n  Decoded: [], // Used to enfore the ForceUnique property.\n  DecoderWorker: new Worker( URL.createObjectURL(new Blob([decoderWorkerBlobString], {type: \"application/javascript\"}) ) ),\n  OrientationCallback: null,\n  // Always call the Init().\n  Init: function() {\n    BarcodeReader.ScanCanvas = BarcodeReader.FixCanvas(document.createElement(\"canvas\"));\n    BarcodeReader.ScanCanvas.width = 640;\n    BarcodeReader.ScanCanvas.height = 480;\n    BarcodeReader.ScanContext = BarcodeReader.ScanCanvas.getContext(\"2d\");\n  },\n\n  // Value should be true or false.\n  SetRotationSkip: function(value) {\n    BarcodeReader.Config.SkipOrientation = value;\n  },\n  // Sets the callback function for the image decoding.\n  SetImageCallback: function(callBack) {\n    BarcodeReader.ImageCallback = callBack;\n  },\n\n  // Sets the callback function for the video decoding.\n  SetStreamCallback: function(callBack) {\n    BarcodeReader.StreamCallback = callBack;\n  },\n\n  // Sets callback for localization, the callback function should take one argument.\n  // This will be an array with objects with format.\n  // {x, y, width, height}\n  // This represents a localization rectangle.\n  // The rectangle comes from a 320, 240 area i.e the search canvas.\n  SetLocalizationCallback: function(callBack) {\n    BarcodeReader.LocalizationCallback = callBack;\n    BarcodeReader.Config.LocalizationFeedback = true;\n  },\n\n  // Set to true if LocalizationCallback is set and you would like to\n  // receive the feedback or false if\n  SwitchLocalizationFeedback: function(bool) {\n    BarcodeReader.Config.LocalizationFeedback = bool;\n  },\n\n  // Switches for changing the Multiple property.\n  DecodeSingleBarcode: function() {\n    BarcodeReader.Config.Multiple = false;\n  },\n  DecodeMultiple: function() {\n    BarcodeReader.Config.Multiple = true;\n  },\n\n  // Sets the formats to decode, formats should be an array of a subset of the supported formats.\n  SetDecodeFormats: function(formats) {\n    BarcodeReader.Config.DecodeFormats = [];\n    for (var i = 0; i < formats.length; i++) {\n      if (BarcodeReader.SupportedFormats.indexOf(formats[i]) !== -1) {\n        BarcodeReader.Config.DecodeFormats.push(formats[i]);\n      }\n    }\n    if (BarcodeReader.Config.DecodeFormats.length === 0) {\n      BarcodeReader.Config.DecodeFormats = BarcodeReader.SupportedFormats.slice();\n    }\n  },\n\n  // Removes a list of formats from the formats to decode.\n  SkipFormats: function(formats) {\n    for (var i = 0; i < formats.length; i++) {\n      var index = BarcodeReader.Config.DecodeFormats.indexOf(formats[i]);\n      if (index >= 0) {\n        BarcodeReader.Config.DecodeFormats.splice(index, 1);\n      }\n    }\n  },\n\n  // Adds a list of formats to the formats to decode.\n  AddFormats: function(formats) {\n    for (var i = 0; i < formats.length; i++) {\n      if (BarcodeReader.SupportedFormats.indexOf(formats[i]) !== -1) {\n        if (BarcodeReader.Config.DecodeFormats.indexOf(formats[i]) === -1) {\n          BarcodeReader.Config.DecodeFormats.push(formats[i]);\n        }\n      }\n    }\n  },\n\n  // The callback function for image decoding used internally by BarcodeReader.\n  BarcodeReaderImageCallback: function(e) {\n    if (e.data.success === \"localization\") {\n      if (BarcodeReader.Config.LocalizationFeedback) {\n        BarcodeReader.LocalizationCallback(e.data.result);\n      }\n      return;\n    }\n    if (e.data.success === \"orientationData\") {\n      BarcodeReader.OrientationCallback(e.data.result);\n      return;\n    }\n    var filteredData = [];\n    for (var i = 0; i < e.data.result.length; i++) {\n      if (BarcodeReader.Decoded.indexOf(e.data.result[i].Value) === -1 || BarcodeReader.Config.ForceUnique === false) {\n        filteredData.push(e.data.result[i]);\n        if (BarcodeReader.Config.ForceUnique) BarcodeReader.Decoded.push(e.data.result[i].Value);\n      }\n    }\n    BarcodeReader.ImageCallback(filteredData);\n    BarcodeReader.Decoded = [];\n  },\n\n  // The callback function for stream decoding used internally by BarcodeReader.\n  BarcodeReaderStreamCallback: function(e) {\n    if (e.data.success === \"localization\") {\n      if (BarcodeReader.Config.LocalizationFeedback) {\n        BarcodeReader.LocalizationCallback(e.data.result);\n      }\n      return;\n    }\n    if (e.data.success && BarcodeReader.DecodeStreamActive) {\n      var filteredData = [];\n      for (var i = 0; i < e.data.result.length; i++) {\n        if (BarcodeReader.Decoded.indexOf(e.data.result[i].Value) === -1 || BarcodeReader.ForceUnique === false) {\n          filteredData.push(e.data.result[i]);\n          if (BarcodeReader.ForceUnique) BarcodeReader.Decoded.push(e.data.result[i].Value);\n        }\n      }\n      if (filteredData.length > 0) {\n        BarcodeReader.StreamCallback(filteredData);\n      }\n    }\n    if (BarcodeReader.DecodeStreamActive) {\n      BarcodeReader.ScanContext.drawImage(BarcodeReader.Stream, 0, 0, BarcodeReader.ScanCanvas.width, BarcodeReader.ScanCanvas.height);\n      BarcodeReader.DecoderWorker.postMessage({\n        scan: BarcodeReader.ScanContext.getImageData(0, 0, BarcodeReader.ScanCanvas.width, BarcodeReader.ScanCanvas.height).data,\n        scanWidth: BarcodeReader.ScanCanvas.width,\n        scanHeight: BarcodeReader.ScanCanvas.height,\n        multiple: BarcodeReader.Config.Multiple,\n        decodeFormats: BarcodeReader.Config.DecodeFormats,\n        cmd: \"normal\",\n        rotation: 1,\n      });\n\n    }\n    if (!BarcodeReader.DecodeStreamActive) {\n      BarcodeReader.Decoded = [];\n    }\n  },\n\n  // The image decoding function, image is a data source for an image or an image element.\n  DecodeImage: function(image) {\n\t\tvar img = new Image();\n\n    if (image instanceof Image || image instanceof HTMLImageElement) {\n      image.exifdata = false;\n      if (image.complete) {\n        if (BarcodeReader.Config.SkipOrientation) {\n          BarcodeReader.BarcodeReaderDecodeImage(image, 1, \"\");\n        } else {\n          EXIF.getData(image, function(exifImage) {\n            var orientation = EXIF.getTag(exifImage, \"Orientation\");\n            var sceneType = EXIF.getTag(exifImage, \"SceneCaptureType\");\n            if (typeof orientation !== 'number') orientation = 1;\n            BarcodeReader.BarcodeReaderDecodeImage(exifImage, orientation, sceneType);\n          });\n        }\n      } else {\n        img.onload = function() {\n          if (BarcodeReader.Config.SkipOrientation) {\n            BarcodeReader.BarcodeReaderDecodeImage(img, 1, \"\");\n          } else {\n            EXIF.getData(this, function(exifImage) {\n              var orientation = EXIF.getTag(exifImage, \"Orientation\");\n              var sceneType = EXIF.getTag(exifImage, \"SceneCaptureType\");\n              if (typeof orientation !== 'number') orientation = 1;\n              BarcodeReader.BarcodeReaderDecodeImage(exifImage, orientation, sceneType);\n            });\n          }\n        };\n        img.src = image.src;\n      }\n    } else {\n      img.onload = function() {\n        if (BarcodeReader.Config.SkipOrientation) {\n          BarcodeReader.BarcodeReaderDecodeImage(img, 1, \"\");\n        } else {\n          EXIF.getData(this, function(exifImage) {\n            var orientation = EXIF.getTag(exifImage, \"Orientation\");\n            var sceneType = EXIF.getTag(exifImage, \"SceneCaptureType\");\n            if (typeof orientation !== 'number') orientation = 1;\n            BarcodeReader.BarcodeReaderDecodeImage(exifImage, orientation, sceneType);\n          });\n        }\n      };\n      img.src = image;\n    }\n  },\n\n  // Starts the decoding of a stream, the stream is a video not a blob i.e it's an element.\n  DecodeStream: function(stream) {\n    BarcodeReader.Stream = stream;\n    BarcodeReader.DecodeStreamActive = true;\n    BarcodeReader.DecoderWorker.onmessage = BarcodeReader.BarcodeReaderStreamCallback;\n    BarcodeReader.ScanContext.drawImage(stream, 0, 0, BarcodeReader.ScanCanvas.width, BarcodeReader.ScanCanvas.height);\n    BarcodeReader.DecoderWorker.postMessage({\n      scan: BarcodeReader.ScanContext.getImageData(0, 0, BarcodeReader.ScanCanvas.width, BarcodeReader.ScanCanvas.height).data,\n      scanWidth: BarcodeReader.ScanCanvas.width,\n      scanHeight: BarcodeReader.ScanCanvas.height,\n      multiple: BarcodeReader.Config.Multiple,\n      decodeFormats: BarcodeReader.Config.DecodeFormats,\n      cmd: \"normal\",\n      rotation: 1,\n    });\n  },\n\n  // Stops the decoding of a stream.\n  StopStreamDecode: function() {\n    BarcodeReader.DecodeStreamActive = false;\n    BarcodeReader.Decoded = [];\n  },\n\n  BarcodeReaderDecodeImage: function(image, orientation, sceneCaptureType) {\n    if (orientation === 8 || orientation === 6) {\n      if (sceneCaptureType === \"Landscape\" && image.width > image.height) {\n        orientation = 1;\n        BarcodeReader.ScanCanvas.width = 640;\n        BarcodeReader.ScanCanvas.height = 480;\n      } else {\n        BarcodeReader.ScanCanvas.width = 480;\n        BarcodeReader.ScanCanvas.height = 640;\n      }\n    } else {\n      BarcodeReader.ScanCanvas.width = 640;\n      BarcodeReader.ScanCanvas.height = 480;\n    }\n    BarcodeReader.DecoderWorker.onmessage = BarcodeReader.BarcodeReaderImageCallback;\n    BarcodeReader.ScanContext.drawImage(image, 0, 0, BarcodeReader.ScanCanvas.width, BarcodeReader.ScanCanvas.height);\n    BarcodeReader.Orientation = orientation;\n    BarcodeReader.DecoderWorker.postMessage({\n      scan: BarcodeReader.ScanContext.getImageData(0, 0, BarcodeReader.ScanCanvas.width, BarcodeReader.ScanCanvas.height).data,\n      scanWidth: BarcodeReader.ScanCanvas.width,\n      scanHeight: BarcodeReader.ScanCanvas.height,\n      multiple: BarcodeReader.Config.Multiple,\n      decodeFormats: BarcodeReader.Config.DecodeFormats,\n      cmd: \"normal\",\n      rotation: orientation,\n      postOrientation: BarcodeReader.PostOrientation\n    });\n  },\n\n  DetectVerticalSquash: function(img) {\n    var ih = img.naturalHeight;\n    var canvas = BarcodeReader.SquashCanvas;\n    var alpha;\n    var data;\n    canvas.width = 1;\n    canvas.height = ih;\n    var ctx = canvas.getContext('2d');\n    ctx.drawImage(img, 0, 0);\n    try {\n      data = ctx.getImageData(0, 0, 1, ih).data;\n    } catch (err) {\n      console.log(\"Cannot check verticalSquash: CORS?\");\n      return 1;\n    }\n    var sy = 0;\n    var ey = ih;\n    var py = ih;\n    while (py > sy) {\n      alpha = data[(py - 1) * 4 + 3];\n      if (alpha === 0) {\n        ey = py;\n      } else {\n        sy = py;\n      }\n      py = (ey + sy) >> 1;\n    }\n    var ratio = (py / ih);\n    return (ratio === 0) ? 1 : ratio;\n  },\n\n  FixCanvas: function(canvas) {\n    var ctx = canvas.getContext('2d');\n    var drawImage = ctx.drawImage;\n    ctx.drawImage = function(img, sx, sy, sw, sh, dx, dy, dw, dh) {\n      var vertSquashRatio = 1;\n      if (!!img && img.nodeName === 'IMG') {\n        vertSquashRatio = BarcodeReader.DetectVerticalSquash(img);\n        // sw || (sw = img.naturalWidth);\n        // sh || (sh = img.naturalHeight);\n      }\n      if (arguments.length === 9)\n        drawImage.call(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);\n      else if (typeof sw !== 'undefined')\n        drawImage.call(ctx, img, sx, sy, sw, sh / vertSquashRatio);\n      else\n        drawImage.call(ctx, img, sx, sy);\n    };\n    return canvas;\n  }\n};\n"]}