cordova-plugin-qrscanner
Version:
Fast, energy-efficient, highly-configurable QR code scanner.
849 lines (777 loc) • 186 kB
JavaScript
// This file is generated by `npm run build`.
/*global exports:false*/
/*jshint unused:false */
// remap parameter names from cordova.define
// see `externals` in webpack.cordova.config.js
var cordovaRequire = require;
var cordovaExports = exports;
var cordovaModule = module;
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 17);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
*/
/* eslint-env node */
var logDisabled_ = true;
// Utility methods.
var utils = {
disableLog: function(bool) {
if (typeof bool !== 'boolean') {
return new Error('Argument type: ' + typeof bool +
'. Please use a boolean.');
}
logDisabled_ = bool;
return (bool) ? 'adapter.js logging disabled' :
'adapter.js logging enabled';
},
log: function() {
if (typeof window === 'object') {
if (logDisabled_) {
return;
}
if (typeof console !== 'undefined' && typeof console.log === 'function') {
console.log.apply(console, arguments);
}
}
},
/**
* Extract browser version out of the provided user agent string.
*
* @param {!string} uastring userAgent string.
* @param {!string} expr Regular expression used as match criteria.
* @param {!number} pos position in the version string to be returned.
* @return {!number} browser version.
*/
extractVersion: function(uastring, expr, pos) {
var match = uastring.match(expr);
return match && match.length >= pos && parseInt(match[pos], 10);
},
/**
* Browser detector.
*
* @return {object} result containing browser and version
* properties.
*/
detectBrowser: function() {
// Returned result object.
var result = {};
result.browser = null;
result.version = null;
// Fail early if it's not a browser
if (typeof window === 'undefined' || !window.navigator) {
result.browser = 'Not a browser.';
return result;
}
// Firefox.
if (navigator.mozGetUserMedia) {
result.browser = 'firefox';
result.version = this.extractVersion(navigator.userAgent,
/Firefox\/(\d+)\./, 1);
} else if (navigator.webkitGetUserMedia) {
// Chrome, Chromium, Webview, Opera, all use the chrome shim for now
if (window.webkitRTCPeerConnection) {
result.browser = 'chrome';
result.version = this.extractVersion(navigator.userAgent,
/Chrom(e|ium)\/(\d+)\./, 2);
} else { // Safari (in an unpublished version) or unknown webkit-based.
if (navigator.userAgent.match(/Version\/(\d+).(\d+)/)) {
result.browser = 'safari';
result.version = this.extractVersion(navigator.userAgent,
/AppleWebKit\/(\d+)\./, 1);
} else { // unknown webkit-based browser.
result.browser = 'Unsupported webkit-based browser ' +
'with GUM support but no WebRTC support.';
return result;
}
}
} else if (navigator.mediaDevices &&
navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) { // Edge.
result.browser = 'edge';
result.version = this.extractVersion(navigator.userAgent,
/Edge\/(\d+).(\d+)$/, 2);
} else if (navigator.mediaDevices &&
navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) {
// Safari, with webkitGetUserMedia removed.
result.browser = 'safari';
result.version = this.extractVersion(navigator.userAgent,
/AppleWebKit\/(\d+)\./, 1);
} else { // Default fallthrough: not supported.
result.browser = 'Not a supported browser.';
return result;
}
return result;
},
// shimCreateObjectURL must be called before shimSourceObject to avoid loop.
shimCreateObjectURL: function() {
if (!(typeof window === 'object' && window.HTMLMediaElement &&
'srcObject' in window.HTMLMediaElement.prototype)) {
// Only shim CreateObjectURL using srcObject if srcObject exists.
return undefined;
}
var nativeCreateObjectURL = URL.createObjectURL.bind(URL);
var nativeRevokeObjectURL = URL.revokeObjectURL.bind(URL);
var streams = new Map(), newId = 0;
URL.createObjectURL = function(stream) {
if ('getTracks' in stream) {
var url = 'polyblob:' + (++newId);
streams.set(url, stream);
console.log('URL.createObjectURL(stream) is deprecated! ' +
'Use elem.srcObject = stream instead!');
return url;
}
return nativeCreateObjectURL(stream);
};
URL.revokeObjectURL = function(url) {
nativeRevokeObjectURL(url);
streams.delete(url);
};
var dsc = Object.getOwnPropertyDescriptor(window.HTMLMediaElement.prototype,
'src');
Object.defineProperty(window.HTMLMediaElement.prototype, 'src', {
get: function() {
return dsc.get.apply(this);
},
set: function(url) {
this.srcObject = streams.get(url) || null;
return dsc.set.apply(this, [url]);
}
});
var nativeSetAttribute = HTMLMediaElement.prototype.setAttribute;
HTMLMediaElement.prototype.setAttribute = function() {
if (arguments.length === 2 &&
('' + arguments[0]).toLowerCase() === 'src') {
this.srcObject = streams.get(arguments[1]) || null;
}
return nativeSetAttribute.apply(this, arguments);
};
}
};
// Export.
module.exports = {
log: utils.log,
disableLog: utils.disableLog,
browserDetails: utils.detectBrowser(),
extractVersion: utils.extractVersion,
shimCreateObjectURL: utils.shimCreateObjectURL,
detectBrowser: utils.detectBrowser.bind(utils)
};
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = cordovaModule;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(8);
var workerScript = __webpack_require__(6);
module.exports = function(){
var ELEMENTS = {
preview: 'cordova-plugin-qrscanner-video-preview',
still: 'cordova-plugin-qrscanner-still'
};
var ZINDEXES = {
preview: -100,
still: -99
};
var backCamera = null;
var frontCamera = null;
var currentCamera = 0;
var activeMediaStream = null;
var scanning = false;
var previewing = false;
var scanWorker = null;
var thisScanCycle = null;
var nextScan = null;
var cancelNextScan = null;
// standard screen widths/heights, from 4k down to 320x240
// widths and heights are each tested separately to account for screen rotation
var standardWidthsAndHeights = [
5120, 4096, 3840, 3440, 3200, 3072, 3000, 2880, 2800, 2736, 2732, 2560,
2538, 2400, 2304, 2160, 2100, 2048, 2000, 1920, 1856, 1824, 1800, 1792,
1776, 1728, 1700, 1680, 1600, 1536, 1440, 1400, 1392, 1366, 1344, 1334,
1280, 1200, 1152, 1136, 1120, 1080, 1050, 1024, 1000, 960, 900, 854, 848,
832, 800, 768, 750, 720, 640, 624, 600, 576, 544, 540, 512, 480, 320, 240
];
var facingModes = [
'environment',
'user'
];
//utils
function killStream(mediaStream){
mediaStream.getTracks().forEach(function(track){
track.stop();
});
}
// For performance, we test best-to-worst constraints. Once we find a match,
// we move to the next test. Since `ConstraintNotSatisfiedError`s are thrown
// much faster than streams can be started and stopped, the scan is much
// faster, even though it may iterate through more constraint objects.
function getCameraSpecsById(deviceId){
// return a getUserMedia Constraints
function getConstraintObj(deviceId, facingMode, width, height){
var obj = { audio: false, video: {} };
obj.video.deviceId = {exact: deviceId};
if(facingMode) {
obj.video.facingMode = {exact: facingMode};
}
if(width) {
obj.video.width = {exact: width};
}
if(height) {
obj.video.height = {exact: height};
}
return obj;
}
var facingModeConstraints = facingModes.map(function(mode){
return getConstraintObj(deviceId, mode);
});
var widthConstraints = standardWidthsAndHeights.map(function(width){
return getConstraintObj(deviceId, null, width);
});
var heightConstraints = standardWidthsAndHeights.map(function(height){
return getConstraintObj(deviceId, null, null, height);
});
// create a promise which tries to resolve the best constraints for this deviceId
// rather than reject, failures return a value of `null`
function getFirstResolvingConstraint(constraintsBestToWorst){
return new Promise(function(resolveBestConstraints){
// build a chain of promises which either resolves or continues searching
return constraintsBestToWorst.reduce(function(chain, next){
return chain.then(function(searchState){
if(searchState.found){
// The best working constraint was found. Skip further tests.
return searchState;
} else {
searchState.nextConstraint = next;
return window.navigator.mediaDevices.getUserMedia(searchState.nextConstraint).then(function(mediaStream){
// We found the first working constraint object, now we can stop
// the stream and short-circuit the search.
killStream(mediaStream);
searchState.found = true;
return searchState;
}, function(){
// didn't get a media stream. The search continues:
return searchState;
});
}
});
}, Promise.resolve({
// kick off the search:
found: false,
nextConstraint: {}
})).then(function(searchState){
if(searchState.found){
resolveBestConstraints(searchState.nextConstraint);
} else {
resolveBestConstraints(null);
}
});
});
}
return getFirstResolvingConstraint(facingModeConstraints).then(function(facingModeSpecs){
return getFirstResolvingConstraint(widthConstraints).then(function(widthSpecs){
return getFirstResolvingConstraint(heightConstraints).then(function(heightSpecs){
return {
deviceId: deviceId,
facingMode: facingModeSpecs === null ? null : facingModeSpecs.video.facingMode.exact,
width: widthSpecs === null ? null : widthSpecs.video.width.exact,
height: heightSpecs === null ? null : heightSpecs.video.height.exact
};
});
});
});
}
function chooseCameras(){
var devices = window.navigator.mediaDevices.enumerateDevices();
return devices.then(function(mediaDeviceInfoList){
var videoDeviceIds = mediaDeviceInfoList.filter(function(elem){
return elem.kind === 'videoinput';
}).map(function(elem){
return elem.deviceId;
});
return videoDeviceIds;
}).then(function(videoDeviceIds){
// there is no standardized way for us to get the specs of each camera
// (due to concerns over user fingerprinting), so we're forced to
// iteratively test each camera for it's capabilities
var searches = [];
videoDeviceIds.forEach(function(id){
searches.push(getCameraSpecsById(id));
});
return Promise.all(searches);
}).then(function(cameraSpecsArray){
return cameraSpecsArray.filter(function(camera){
// filter out any cameras where width and height could not be captured
if(camera !== null && camera.width !== null && camera.height !== null){
return true;
}
}).sort(function(a, b){
// sort cameras from highest resolution (by width) to lowest
return b.width - a.width;
});
}).then(function(bestToWorstCameras){
var backCamera = null,
frontCamera = null;
// choose backCamera
for(var i = 0; i < bestToWorstCameras.length; i++){
if (bestToWorstCameras[i].facingMode === 'environment'){
backCamera = bestToWorstCameras[i];
// (shouldn't be used for frontCamera)
bestToWorstCameras.splice(i, 1);
break;
}
}
// if no back-facing cameras were found, choose the highest resolution
if(backCamera === null){
if(bestToWorstCameras.length > 0){
backCamera = bestToWorstCameras[0];
// (shouldn't be used for frontCamera)
bestToWorstCameras.splice(0, 1);
} else {
// user doesn't have any available cameras
backCamera = false;
}
}
if(bestToWorstCameras.length > 0){
// frontCamera should simply be the next-best resolution camera
frontCamera = bestToWorstCameras[0];
} else {
// user doesn't have any more cameras
frontCamera = false;
}
return {
backCamera: backCamera,
frontCamera: frontCamera
};
});
}
function mediaStreamIsActive(){
return activeMediaStream !== null;
}
function killActiveMediaStream(){
killStream(activeMediaStream);
activeMediaStream = null;
}
function getVideoPreview(){
return document.getElementById(ELEMENTS.preview);
}
function getImg(){
return document.getElementById(ELEMENTS.still);
}
function getCurrentCameraIndex(){
return currentCamera;
}
function getCurrentCamera(){
return currentCamera === 1 ? frontCamera : backCamera;
}
function bringStillToFront(){
var img = getImg();
if(img){
img.style.visibility = 'visible';
previewing = false;
}
}
function bringPreviewToFront(){
var img = getImg();
if(img){
img.style.visibility = 'hidden';
previewing = true;
}
}
function isInitialized(){
return backCamera !== null;
}
function canChangeCamera(){
return !!backCamera && !!frontCamera;
}
function calcStatus(){
return {
// !authorized means the user either has no camera or has denied access.
// This would leave a value of `null` before prepare(), and `false` after.
authorized: (backCamera !== null && backCamera !== false)? '1': '0',
// No applicable API
denied: '0',
// No applicable API
restricted: '0',
prepared: isInitialized() ? '1' : '0',
scanning: scanning? '1' : '0',
previewing: previewing? '1' : '0',
// We leave this true after prepare() to match the mobile experience as
// closely as possible. (Without additional covering, the preview will
// always be visible to the user).
showing: getVideoPreview()? '1' : '0',
// No applicable API
lightEnabled: '0',
// No applicable API
canOpenSettings: '0',
// No applicable API
canEnableLight: '0',
canChangeCamera: canChangeCamera() ? '1' : '0',
currentCamera: currentCamera.toString()
};
}
function startCamera(success, error){
var currentCameraIndex = getCurrentCameraIndex();
var currentCamera = getCurrentCamera();
window.navigator.mediaDevices.getUserMedia({
audio: false,
video: {
deviceId: {exact: currentCamera.deviceId},
width: {ideal: currentCamera.width},
height: {ideal: currentCamera.height}
}
}).then(function(mediaStream){
activeMediaStream = mediaStream;
var video = getVideoPreview();
video.src = URL.createObjectURL(mediaStream);
success(calcStatus());
}, function(err){
// something bad happened
err = null;
var code = currentCameraIndex? 4 : 3;
error(code); // FRONT_CAMERA_UNAVAILABLE : BACK_CAMERA_UNAVAILABLE
});
}
function getTempCanvasAndContext(videoElement){
var tempCanvas = document.createElement('canvas');
var camera = getCurrentCamera();
tempCanvas.height = camera.height;
tempCanvas.width = camera.width;
var tempCanvasContext = tempCanvas.getContext('2d');
tempCanvasContext.drawImage(videoElement, 0, 0, camera.width, camera.height);
return {
canvas: tempCanvas,
context: tempCanvasContext
};
}
function getCurrentImageData(videoElement){
var snapshot = getTempCanvasAndContext(videoElement);
return snapshot.context.getImageData(0, 0, snapshot.canvas.width, snapshot.canvas.height);
}
// take a screenshot of the video preview with a temp canvas
function captureCurrentFrame(videoElement){
return getTempCanvasAndContext(videoElement).canvas.toDataURL('image/png');
}
function initialize(success, error){
if(scanWorker === null){
var workerBlob = new Blob([workerScript],{type: "text/javascript"});
scanWorker = new Worker(URL.createObjectURL(workerBlob));
}
if(!getVideoPreview()){
// prepare DOM (sync)
var videoPreview = document.createElement('video');
videoPreview.setAttribute('autoplay', 'autoplay');
videoPreview.setAttribute('id', ELEMENTS.preview);
videoPreview.setAttribute('style', 'display:block;position:fixed;top:50%;left:50%;' +
'width:auto;height:auto;min-width:100%;min-height:100%;z-index:' + ZINDEXES.preview +
';-moz-transform: translateX(-50%) translateY(-50%);-webkit-transform: ' +
'translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%);' +
'background-size:cover;background-position:50% 50%;background-color:#FFF;');
videoPreview.addEventListener('loadeddata', function(){
bringPreviewToFront();
});
var stillImg = document.createElement('div');
stillImg.setAttribute('id', ELEMENTS.still);
stillImg.setAttribute('style', 'display:block;position:fixed;top:50%;left:50%;visibility: hidden;' +
'width:auto;height:auto;min-width:100%;min-height:100%;z-index:' + ZINDEXES.still +
';-moz-transform: translateX(-50%) translateY(-50%);-webkit-transform: ' +
'translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%);' +
'background-size:cover;background-position:50% 50%;background-color:#FFF;');
document.body.appendChild(videoPreview);
document.body.appendChild(stillImg);
}
if(backCamera === null){
// set instance cameras
chooseCameras().then(function(cameras){
backCamera = cameras.backCamera;
frontCamera = cameras.frontCamera;
if(backCamera !== false){
success();
} else {
error(5); // CAMERA_UNAVAILABLE
}
}, function(err){
// something bad happened
err = null;
error(0); // UNEXPECTED_ERROR
});
} else if (backCamera === false){
error(5); // CAMERA_UNAVAILABLE
} else {
success();
}
}
/*
* --- Begin Public API ---
*/
function prepare(success, error){
initialize(function(){
// return status on success
success(calcStatus());
},
// pass errors through
error);
}
function show(success, error){
function showCamera(){
if(!mediaStreamIsActive()){
startCamera(success, error);
} else {
success(calcStatus());
}
}
if(!isInitialized()){
initialize(function(){
// on successful initialization, attempt to showCamera
showCamera();
},
// pass errors through
error);
} else {
showCamera();
}
}
function hide(success, error){
error = null; // should never error
if(mediaStreamIsActive()){
killActiveMediaStream();
}
var video = getVideoPreview();
if(video){
video.src = '';
}
success(calcStatus());
}
function scan(success, error) {
// initialize and start video preview if not already active
show(function(ignore){
// ignore success output – `scan` method callback should be passed the decoded data
ignore = null;
var video = getVideoPreview();
var returned = false;
scanning = true;
scanWorker.onmessage = function(event){
var obj = event.data;
if(obj.result && !returned){
returned = true;
thisScanCycle = null;
success(obj.result);
}
};
thisScanCycle = function(){
scanWorker.postMessage(getCurrentImageData(video));
if(cancelNextScan !== null){
// avoid race conditions, always clear before starting a cycle
cancelNextScan();
}
// interval in milliseconds at which to try decoding the QR code
var SCAN_INTERVAL = window.QRScanner_SCAN_INTERVAL || 130;
// this value can be adjusted on-the-fly (while a scan is active) to
// balance scan speed vs. CPU/power usage
nextScan = window.setTimeout(thisScanCycle, SCAN_INTERVAL);
cancelNextScan = function(sendError){
window.clearTimeout(nextScan);
nextScan = null;
cancelNextScan = null;
if(sendError){
error(6); // SCAN_CANCELED
}
};
};
thisScanCycle();
}, error);
}
function cancelScan(success, error){
error = null; // should never error
if(cancelNextScan !== null){
cancelNextScan(true);
}
scanning = false;
if(typeof success === "function"){
success(calcStatus());
}
}
function pausePreview(success, error){
error = null; // should never error
if(mediaStreamIsActive()){
// pause scanning too
if(cancelNextScan !== null){
cancelNextScan();
}
var video = getVideoPreview();
video.pause();
var img = new Image();
img.src = captureCurrentFrame(video);
getImg().style.backgroundImage = 'url(' + img.src + ')';
bringStillToFront();
// kill the active stream to turn off the privacy light (the screenshot
// in the stillImg will remain visible)
killActiveMediaStream();
success(calcStatus());
} else {
success(calcStatus());
}
}
function resumePreview(success, error){
// if a scan was happening, resume it
if(thisScanCycle !== null){
thisScanCycle();
}
show(success, error);
}
function enableLight(success, error){
error(7); //LIGHT_UNAVAILABLE
}
function disableLight(success, error){
error(7); //LIGHT_UNAVAILABLE
}
function useCamera(success, error, array){
var requestedCamera = array[0];
var initialized = isInitialized();
if(requestedCamera !== currentCamera){
if(initialized && requestedCamera === 1 && !canChangeCamera()){
error(4); //FRONT_CAMERA_UNAVAILABLE
} else {
currentCamera = requestedCamera;
if(initialized){
hide(function(status){
// Don't need this one
status = null;
});
show(success, error);
} else {
success(calcStatus());
}
}
} else {
success(calcStatus());
}
}
function openSettings(success, error){
error(8); //OPEN_SETTINGS_UNAVAILABLE
}
function getStatus(success, error){
error = null; // should never error
success(calcStatus());
}
// Reset all instance variables to their original state.
// This method might be useful in cases where a new camera is available, and
// the application needs to force the plugin to chooseCameras() again.
function destroy(success, error){
error = null; // should never error
cancelScan();
if(mediaStreamIsActive()){
killActiveMediaStream();
}
backCamera = null;
frontCamera = null;
var preview = getVideoPreview();
var still = getImg();
if(preview){
preview.remove();
}
if(still){
still.remove();
}
success(calcStatus());
}
return {
prepare: prepare,
show: show,
hide: hide,
scan: scan,
cancelScan: cancelScan,
pausePreview: pausePreview,
resumePreview: resumePreview,
enableLight: enableLight,
disableLight: disableLight,
useCamera: useCamera,
openSettings: openSettings,
getStatus: getStatus,
destroy: destroy
};
};
/***/ }),
/* 3 */,
/* 4 */,
/* 5 */
/***/ (function(module, exports) {
module.exports = cordovaRequire;
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = "!function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,\"a\",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p=\"\",e(e.s=19)}([function(t,e,n){\"use strict\";function i(){this.imagedata=null,this.width=0,this.height=0,this.qrCodeSymbol=null,this.debug=!1,this.callback=null}function r(t,e){return t>=0?t>>e:(t>>e)+(2<<~e)}n.d(e,\"b\",function(){return s}),e.a=i,e.c=r;var o=n(14),a=n(13),s={};s.sizeOfDataLengthInfo=[[10,9,8,8],[12,11,16,10],[14,13,16,12]],i.prototype.decode=function(t,e){var n=function(){try{this.error=void 0,this.result=this.process(this.imagedata)}catch(t){this.error=t,this.result=void 0}return null!=this.callback&&this.callback(this.error,this.result),this.result}.bind(this);if(void 0!=t&&void 0!=t.width)this.width=t.width,this.height=t.height,this.imagedata={data:e||t.data},this.imagedata.width=t.width,this.imagedata.height=t.height,n();else{if(\"undefined\"==typeof Image)throw new Error(\"This source format is not supported in your environment, you need to pass an image buffer with width and height (see https://github.com/edi9999/jsqrcode/blob/master/test/qrcode.js)\");var i=new Image;i.crossOrigin=\"Anonymous\",i.onload=function(){var t=document.createElement(\"canvas\"),e=t.getContext(\"2d\"),r=document.getElementById(\"out-canvas\");if(null!=r){var o=r.getContext(\"2d\");o.clearRect(0,0,320,240),o.drawImage(i,0,0,320,240)}t.width=i.width,t.height=i.height,e.drawImage(i,0,0),this.width=i.width,this.height=i.height;try{this.imagedata=e.getImageData(0,0,i.width,i.height)}catch(t){if(this.result=\"Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!\",null!=this.callback)return this.callback(null,this.result)}n()}.bind(this),i.src=t}},i.prototype.decode_utf8=function(t){return decodeURIComponent(escape(t))},i.prototype.process=function(t){for(var e=(new Date).getTime(),n=this.grayScaleToBitmap(this.grayscale(t)),i=new o.a(n),r=i.detect(),s=a.a.decode(r.bits),h=s.DataByte,f=\"\",w=0;w<h.length;w++)for(var u=0;u<h[w].length;u++)f+=String.fromCharCode(h[w][u]);var l=(new Date).getTime(),c=l-e;return this.debug&&console.log(\"QR Code processing time (ms): \"+c),{result:this.decode_utf8(f),points:r.points}},i.prototype.getPixel=function(t,e,n){if(t.width<e)throw\"point error\";if(t.height<n)throw\"point error\";var i=4*e+n*t.width*4;return(33*t.data[i]+34*t.data[i+1]+33*t.data[i+2])/100},i.prototype.binarize=function(t){for(var e=new Array(this.width*this.height),n=0;n<this.height;n++)for(var i=0;i<this.width;i++){var r=this.getPixel(i,n);e[i+n*this.width]=r<=t}return e},i.prototype.getMiddleBrightnessPerArea=function(t){for(var e=Math.floor(t.width/4),n=Math.floor(t.height/4),i=new Array(4),r=0;r<4;r++){i[r]=new Array(4);for(var o=0;o<4;o++)i[r][o]=[0,0]}for(var a=0;a<4;a++)for(var s=0;s<4;s++){i[s][a][0]=255;for(var h=0;h<n;h++)for(var f=0;f<e;f++){var w=t.data[e*s+f+(n*a+h)*t.width];w<i[s][a][0]&&(i[s][a][0]=w),w>i[s][a][1]&&(i[s][a][1]=w)}}for(var u=new Array(4),l=0;l<4;l++)u[l]=new Array(4);for(var a=0;a<4;a++)for(var s=0;s<4;s++)u[s][a]=Math.floor((i[s][a][0]+i[s][a][1])/2);return u},i.prototype.grayScaleToBitmap=function(t){for(var e=this.getMiddleBrightnessPerArea(t),n=e.length,i=Math.floor(t.width/n),r=Math.floor(t.height/n),o=0;o<n;o++)for(var a=0;a<n;a++)for(var s=0;s<r;s++)for(var h=0;h<i;h++)t.data[i*a+h+(r*o+s)*t.width]=t.data[i*a+h+(r*o+s)*t.width]<e[a][o];return t},i.prototype.grayscale=function(t){for(var e=new Array(t.width*t.height),n=0;n<t.height;n++)for(var i=0;i<t.width;i++){var r=this.getPixel(t,i,n);e[i+n*t.width]=r}return{height:t.height,width:t.width,data:e}}},function(t,e,n){\"use strict\";function i(t,e){if(e||(e=t),t<1||e<1)throw\"Both dimensions must be greater than 0\";this.width=t,this.height=e;var n=t>>5;0!=(31&t)&&n++,this.rowSize=n,this.bits=new Array(n*e);for(var i=0;i<this.bits.length;i++)this.bits[i]=0}e.a=i;var r=n(0);Object.defineProperty(i.prototype,\"Dimension\",{get:function(){if(this.width!=this.height)throw\"Can't call getDimension() on a non-square matrix\";return this.width}}),i.prototype.get_Renamed=function(t,e){var i=e*this.rowSize+(t>>5);return 0!=(1&n.i(r.c)(this.bits[i],31&t))},i.prototype.set_Renamed=function(t,e){var n=e*this.rowSize+(t>>5);this.bits[n]|=1<<(31&t)},i.prototype.flip=function(t,e){var n=e*this.rowSize+(t>>5);this.bits[n]^=1<<(31&t)},i.prototype.clear=function(){for(var t=this.bits.length,e=0;e<t;e++)this.bits[e]=0},i.prototype.setRegion=function(t,e,n,i){if(e<0||t<0)throw\"Left and top must be nonnegative\";if(i<1||n<1)throw\"Height and width must be at least 1\";var r=t+n,o=e+i;if(o>this.height||r>this.width)throw\"The region must fit inside the matrix\";for(var a=e;a<o;a++)for(var s=a*this.rowSize,h=t;h<r;h++)this.bits[s+(h>>5)]|=1<<(31&h)}},function(t,e,n){\"use strict\";function i(t){this.errorCorrectionLevel=o.a.forBits(t>>3&3),this.dataMask=7&t}e.a=i;var r=n(0),o=n(15),a=[[21522,0],[20773,1],[24188,2],[23371,3],[17913,4],[16590,5],[20375,6],[19104,7],[30660,8],[29427,9],[32170,10],[30877,11],[26159,12],[25368,13],[27713,14],[26998,15],[5769,16],[5054,17],[7399,18],[6608,19],[1890,20],[597,21],[3340,22],[2107,23],[13663,24],[12392,25],[16177,26],[14854,27],[9396,28],[8579,29],[11994,30],[11245,31]],s=[0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4];i.prototype.GetHashCode=function(){return this.errorCorrectionLevel.ordinal()<<3|this.dataMask},i.prototype.Equals=function(t){var e=t;return this.errorCorrectionLevel==e.errorCorrectionLevel&&this.dataMask==e.dataMask},i.numBitsDiffering=function(t,e){return t^=e,s[15&t]+s[15&n.i(r.c)(t,4)]+s[15&n.i(r.c)(t,8)]+s[15&n.i(r.c)(t,12)]+s[15&n.i(r.c)(t,16)]+s[15&n.i(r.c)(t,20)]+s[15&n.i(r.c)(t,24)]+s[15&n.i(r.c)(t,28)]},i.decodeFormatInformation=function(t){var e=i.doDecodeFormatInformation(t);return null!=e?e:i.doDecodeFormatInformation(21522^t)},i.doDecodeFormatInformation=function(t){for(var e=4294967295,n=0,r=0;r<a.length;r++){var o=a[r],s=o[0];if(s==t)return new i(o[1]);var h=this.numBitsDiffering(t,s);h<e&&(n=o[1],e=h)}return e<=3?new i(n):null}},function(t,e,n){\"use strict\";function i(t){this.expTable=new Array(256),this.logTable=new Array(256);for(var e=1,n=0;n<256;n++)this.expTable[n]=e,(e<<=1)>=256&&(e^=t);for(var n=0;n<255;n++)this.logTable[this.expTable[n]]=n;var i=new Array(1);i[0]=0,this.zero=new r.a(this,new Array(i));var o=new Array(1);o[0]=1,this.one=new r.a(this,new Array(o))}e.a=i;var r=n(4);Object.defineProperty(i.prototype,\"Zero\",{get:function(){return this.zero}}),Object.defineProperty(i.prototype,\"One\",{get:function(){return this.one}}),i.prototype.buildMonomial=function(t,e){if(t<0)throw\"System.ArgumentException\";if(0==e)return this.zero;for(var n=new Array(t+1),i=0;i<n.length;i++)n[i]=0;return n[0]=e,new r.a(this,n)},i.prototype.exp=function(t){return this.expTable[t]},i.prototype.log=function(t){if(0==t)throw\"System.ArgumentException\";return this.logTable[t]},i.prototype.inverse=function(t){if(0==t)throw\"System.ArithmeticException\";return this.expTable[255-this.logTable[t]]},i.prototype.addOrSubtract=function(t,e){return t^e},i.prototype.multiply=function(t,e){return 0==t||0==e?0:1==t?e:1==e?t:this.expTable[(this.logTable[t]+this.logTable[e])%255]},i.QR_CODE_FIELD=new i(285),i.DATA_MATRIX_FIELD=new i(301)},function(t,e,n){\"use strict\";function i(t,e){if(null==e||0==e.length)throw\"System.ArgumentException\";this.field=t;var n=e.length;if(n>1&&0==e[0]){for(var i=1;i<n&&0==e[i];)i++;if(i==n)this.coefficients=t.Zero.coefficients;else{this.coefficients=new Array(n-i);for(var r=0;r<this.coefficients.length;r++)this.coefficients[r]=0;for(var o=0;o<this.coefficients.length;o++)this.coefficients[o]=e[i+o]}}else this.coefficients=e}e.a=i,Object.defineProperty(i.prototype,\"Zero\",{get:function(){return 0==this.coefficients[0]}}),Object.defineProperty(i.prototype,\"Degree\",{get:function(){return this.coefficients.length-1}}),i.prototype.getCoefficient=function(t){return this.coefficients[this.coefficients.length-1-t]},i.prototype.evaluateAt=function(t){if(0==t)return this.getCoefficient(0);var e=this.coefficients.length;if(1==t){for(var n=0,i=0;i<e;i++)n=this.field.addOrSubtract(n,this.coefficients[i]);return n}for(var r=this.coefficients[0],i=1;i<e;i++)r=this.field.addOrSubtract(this.field.multiply(t,r),this.coefficients[i]);return r},i.prototype.addOrSubtract=function(t){if(this.field!=t.field)throw\"GF256Polys do not have same GF256 field\";if(this.Zero)return t;if(t.Zero)return this;var e=this.coefficients,n=t.coefficients;if(e.length>n.length){var r=e;e=n,n=r}for(var o=new Array(n.length),a=n.length-e.length,s=0;s<a;s++)o[s]=n[s];for(var h=a;h<n.length;h++)o[h]=this.field.addOrSubtract(e[h-a],n[h]);return new i(this.field,o)},i.prototype.multiply1=function(t){if(this.field!=t.field)throw\"GF256Polys do not have same GF256 field\";if(this.Zero||t.Zero)return this.field.Zero;for(var e=this.coefficients,n=e.length,r=t.coefficients,o=r.length,a=new Array(n+o-1),s=0;s<n;s++)for(var h=e[s],f=0;f<o;f++)a[s+f]=this.field.addOrSubtract(a[s+f],this.field.multiply(h,r[f]));return new i(this.field,a)},i.prototype.multiply2=function(t){if(0==t)return this.field.Zero;if(1==t)return this;for(var e=this.coefficients.length,n=new Array(e),r=0;r<e;r++)n[r]=this.field.multiply(this.coefficients[r],t);return new i(this.field,n)},i.prototype.multiplyByMonomial=function(t,e){if(t<0)throw\"System.ArgumentException\";if(0==e)return this.field.Zero;for(var n=this.coefficients.length,r=new Array(n+t),o=0;o<r.length;o++)r[o]=0;for(var o=0;o<n;o++)r[o]=this.field.multiply(this.coefficients[o],e);return new i(this.field,r)},i.prototype.divide=function(t){if(this.field!=t.field)throw\"GF256Polys do not have same GF256 field\";if(t.Zero)throw\"Divide by 0\";for(var e=this.field.Zero,n=this,i=t.getCoefficient(t.Degree),r=this.field.inverse(i);n.Degree>=t.Degree&&!n.Zero;){var o=n.Degree-t.Degree,a=this.field.multiply(n.getCoefficient(n.Degree),r),s=t.multiplyByMonomial(o,a),h=this.field.buildMonomial(o,a);e=e.addOrSubtract(h),n=n.addOrSubtract(s)}return[e,n]}},function(t,e,n){\"use strict\";function i(t,e){this.count=t,this.dataCodewords=e}function r(t,e,n){this.ecCodewordsPerBlock=t,this.ecBlocks=n?[e,n]:[e]}function o(t,e,n,i,r,o){this.versionNumber=t,this.alignmentPatternCenters=e,this.ecBlocks=[n,i,r,o];for(var a=0,s=n.ecCodewordsPerBlock,h=n.getECBlocks(),f=0;f<h.length;f++){var w=h[f];a+=w.count*(w.dataCodewords+s)}this.totalCodewords=a}e.a=o;var a=n(2),s=n(1);Object.defineProperty(r.prototype,\"TotalECCodewords\",{get:function(){return this.ecCodewordsPerBlock*this.NumBlocks}}),Object.defineProperty(r.prototype,\"NumBlocks\",{get:function(){for(var t=0,e=0;e<this.ecBlocks.length;e++)t+=this.ecBlocks[e].length;return t}}),r.prototype.getECBlocks=function(){return this.ecBlocks},Object.defineProperty(o.prototype,\"DimensionForVersion\",{get:function(){return 17+4*this.versionNumber}}),o.prototype.buildFunctionPattern=function(){var t=this.DimensionForVersion,e=new s.a(t);e.setRegion(0,0,9,9),e.setRegion(t-8,0,8,9),e.setRegion(0,t-8,9,8);for(var n=this.alignmentPatternCenters.length,i=0;i<n;i++)for(var r=this.alignmentPatternCenters[i]-2,o=0;o<n;o++)0==i&&(0==o||o==n-1)||i==n-1&&0==o||e.setRegion(this.alignmentPatternCenters[o]-2,r,5,5);return e.setRegion(6,9,1,t-17),e.setRegion(9,6,t-17,1),this.versionNumber>6&&(e.setRegion(t-11,0,3,6),e.setRegion(0,t-11,6,3)),e},o.prototype.getECBlocksForLevel=function(t){return this.ecBlocks[t.ordinal()]},o.VERSION_DECODE_INFO=[31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017],o.VERSIONS=function(){return[new o(1,[],new r(7,new i(1,19)),new r(10,new i(1,16)),new r(13,new i(1,13)),new r(17,new i(1,9))),new o(2,[6,18],new r(10,new i(1,34)),new r(16,new i(1,28)),new r(22,new i(1,22)),new r(28,new i(1,16))),new o(3,[6,22],new r(15,new i(1,55)),new r(26,new i(1,44)),new r(18,new i(2,17)),new r(22,new i(2,13))),new o(4,[6,26],new r(20,new i(1,80)),new r(18,new i(2,32)),new r(26,new i(2,24)),new r(16,new i(4,9))),new o(5,[6,30],new r(26,new i(1,108)),new r(24,new i(2,43)),new r(18,new i(2,15),new i(2,16)),new r(22,new i(2,11),new i(2,12))),new o(6,[6,34],new r(18,new i(2,68)),new r(16,new i(4,27)),new r(24,new i(4,19)),new r(28,new i(4,15))),new o(7,[6,22,38],new r(20,new i(2,78)),new r(18,new i(4,31)),new r(18,new i(2,14),new i(4,15)),new r(26,new i(4,13),new i(1,14))),new o(8,[6,24,42],new r(24,new i(2,97)),new r(22,new i(2,38),new i(2,39)),new r(22,new i(4,18),new i(2,19)),new r(26,new i(4,14),new i(2,15))),new o(9,[6,26,46],new r(30,new i(2,116)),new r(22,new i(3,36),new i(2,37)),new r(20,new i(4,16),new i(4,17)),new r(24,new i(4,12),new i(4,13))),new o(10,[6,28,50],new r(18,new i(2,68),new i(2,69)),new r(26,new i(4,43),new i(1,44)),new r(24,new i(6,19),new i(2,20)),new r(28,new i(6,15),new i(2,16))),new o(11,[6,30,54],new r(20,new i(4,81)),new r(30,new i(1,50),new i(4,51)),new r(28,new i(4,22),new i(4,23)),new r(24,new i(3,12),new i(8,13))),new o(12,[6,32,58],new r(24,new i(2,92),new i(2,93)),new r(22,new i(6,36),new i(2,37)),new r(26,new i(4,20),new i(6,21)),new r(28,new i(7,14),new i(4,15))),new o(13,[6,34,62],new r(26,new i(4,107)),new r(22,new i(8,37),new i(1,38)),new r(24,new i(8,20),new i(4,21)),new r(22,new i(12,11),new i(4,12))),new o(14,[6,26,46,66],new r(30,new i(3,115),new i(1,116)),new r(24,new i(4,40),new i(5,41)),new r(20,new i(11,16),new i(5,17)),new r(24,new i(11,12),new i(5,13))),new o(15,[6,26,48,70],new r(22,new i(5,87),new i(1,88)),new r(24,new i(5,41),new i(5,42)),new r(30,new i(5,24),new i(7,25)),new r(24,new i(11,12),new i(7,13))),new o(16,[6,26,50,74],new r(24,new i(5,98),new i(1,99)),new r(28,new i(7,45),new i(3,46)),new r(24,new i(15,19),new i(2,20)),new r(30,new i(3,15),new i(13,16))),new o(17,[6,30,54,78],new r(28,new i(1,107),new i(5,108)),new r(28,new i(10,46),new i(1,47)),new r(28,new i(1,22),new i(15,23)),new r(28,new i(2,14),new i(17,15))),new o(18,[6,30,56,82],new r(30,new i(5,120),new i(1,121)),new r(26,new i(9,43),new i(4,44)),new r(28,new i(17,22),new i(1,23)),new r(28,new i(2,14),new i(19,15))),new o(19,[6,30,58,86],new r(28,new i(3,113),new i(4,114)),new r(26,new i(3,44),new i(11,45)),new r(26,new i(17,21),new i(4,22)),new r(26,new i(9,13),new i(16,14))),new o(20,[6,34,62,90],new r(28,new i(3,107),new i(5,108)),new r(26,new i(3,41),new i(13,42)),new r(30,new i(15,24),new i(5,25)),new r(28,new i(15,15),new i(10,16))),new o(21,[6,28,50,72,94],new r(28,new i(4,116),new i(4,117)),new r(26,new i(17,42)),new r(28,new i(17,22),new i(6,23)),new r(30,new i(19,16),new i(6,17))),new o(22,[6,26,50,74,98],new r(28,new i(2,111),new i(7,112)),new r(28,new i(17,46)),new r(30,new i(7,24),new i(16,25)),new r(24,new i(34,13))),new o(23,[6,30,54,74,102],new r(30,new i(4,121),new i(5,122)),new r(28,new i(4,47),new i(14,48)),new r(30,new i(11,24),new i(14,25)),new r(30,new i(16,15),new i(14,16))),new o(24,[6,28,54,80,106],new r(30,new i(6,117),new i(4,118)),new r(28,new i(6,45),new i(14,46)),new r(30,new i(11,24),new i(16,25)),new r(30,new i(30,16),new i(2,17))),new o(25,[6,32,58,84,110],new r(26,new i(8,106),new i(4,107)),new r(28,new i(8,47),new i(13,48)),new r(30,new i(7,24),new i(22,25)),new r(30,new i(22,15),new i(13,16))),new o(26,[6,30,58,86,114],new r(28,new i(10,114),new i(2,115)),new r(28,new i(19,46),new i(4,47)),new r(28,new i(28,22),new i(6,23)),new r(30,new i(33,16),new i(4,17))),new o(27,[6,34,62,90,118],new r(30,new i(8,122),new i(4,123)),new r(28,new i(22,45),new i(3,46)),new r(30,new i(8,23),new i(26,24)),new r(30,new i(12,15),new i(28,16))),new o(28,[6,26,50,74,98,122],new r(30,new i(3,117),new i(10,118)),new r(28,new i(3,45),new i(23,46)),new r(30,new i(4,24),new i(31,25)),new r(30,new i(11,15),new i(31,16))),new o(29,[6,30,54,78,102,126],new r(30,new i(7,116),new i(7,117)),new r(28,new i(21,45),new i(7,46)),new r(30,new i(1,23),new i(37,24)),new r(30,new i(19,15),new i(26,16))),new o(30,[6,26,52,78,104,130],new r(30,new i(5,115),new i(10,116)),new r(28,new i(19,47),new i(10,48)),new r(30,new i(15,24),new i(25,25)),new r(30,new i(23,15),new i(25,16))),new o(31,[6,30,56,82,108,134],new r(30,new i(13,115),new i(3,116)),new r(28,new i(2,46),new i(29,47)),new r(30,new i(42,24),new i(1,25)),new r(30,new i(23,15),new i(28,16))),new o(32,[6,34,60,86,112,138],new r(30,new i(17,115)),new r(28,new i(10,46),new i(23,47)),new r(30,new i(10,24),new i(35,25)),new r(30,new i(19,15),new i(35,16))),new o(33,[6,30,58,86,114,142],new r(30,new i(17,115),new i(1,116)),new r(28,new i(14,46),new i(21,47)),new r(30,new i(29,24),new i(19,25)),new r(30,new i(11,15),new i(46,16))),new o(34,[6,34,62,90,118,146],new r(30,new i(13,115),new i(6,116)),new r(28,new i(14,46),new i(23,47)),new r(30,new i(44,24),new i(7,25)),new r(30,new i(59,16),new i(1,17))),new o(35,[6,30,54,78,102,126,150],new r(30,new i(12,121),new i(7,122)),new r(28,new i(12,47),new i(26,48)),new r(30,new i(39,24),new i(14,25)),new r(30,new i(22,15),new i(41,16))),new o(36,[6,24,50,76,102,128,154],new r(30,new i(6,121),new i(14,122)),new r(28,new i(6,47),new i(34,48)),new r(30,new i(46,24),new i(10,25)),new r(30,new i(2,15),new i(64,16))),new o(37,[6,28,54,80,106,132,158],new r(30,new i(17,122),new i(4,123)),new r(28,new i(29,46),new i(14,47)),new r(30,new i(49,24),new i(10,25)),new r(30,new i(24,15),new i(46,16))),new o(38,[6,32,58,84,110,136,162],new r(30,new i(4,122),new i(18,123)),new r(28,new i(13,46),new i(32,47)),new r(30,new i(48,24),new i(14,25)),new r(30,new i(42,15),new i(32,16))),new o(39,[6,26,54,82,110,138,166],new r(30,new i(20,117),new i(4,118)),new r(28,new i(40,47),new i(7,48)),new r(30,new i(43,24),new i(22,25)),new r(30,new i(10,15),new i(67,16))),new o(40,[6,30,58,86,114,142,170],new r(30,new i(19,118),new i(6,119)),new r(28,new i(18,47),new i(31,48)),new r(30,new i(34,24),new i(34,25)),new r(30,new i(20,15),new i(61,16)))]}(),o.getVersionForNumber=function(t){if(t<1||t>40)throw\"ArgumentException\";return o.VERSIONS[t-1]},o.getProvisionalVersionForDimension=function(t){if(t%4!=1)throw\"Error getProvisionalVersionForDimension\";try{return o.getVersionForNumber(t-17>>2)}catch(t){throw\"Error getVersionForNumber\"}},o.decodeVersionInformation=function(t){for(var e=4294967295,n=0,i=0;i<o.VERSION_DECODE_INFO.length;i++){var r=o.VERSION_DECODE_INFO[i];if(r==t)return this.getVersionForNumber(i+7);var s=a.a.numBitsDiffering(t,r);s<e&&(n=i+7,e=s)}return e<=3?this.getVersionForNumber(n):null}},function(t,e,n){\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var i=n(0);e.default=i.a},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,\"loaded\",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,\"id\",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){\"use strict\";function i(t,e,n){this.x=t,this.y=e,this.count=1,this.estimatedModuleSize=n}function r(t,e,n,i,r,o,a){this.image=t,this.possibleCenters=[],this.startX=e,this.startY=n,this.width=i,this.height=r,this.moduleSize=o,this.crossCheckStateCount=[0,0,0],this.resultPointCallback=a}e.a=r,Object.defineProperty(i.prototype,\"X\",{get:function(){return Math.floor(this.x)}}),Object.defineProperty(i.prototype,\"Y\",{get:function(){return Math.floor(this.y)}}),i.prototype.incrementCount=function(){this.count++},i.prototype.aboutEquals=function(t,e,n){if(Math.abs(e-this.y)<=t&&Math.abs(n-this.x)<=t){var i=Math.abs(t-this.estimatedModuleSize);return i<=1||i/this.estimatedModuleSize<=1}return!1},r.prototype.centerFromEnd=function(t,e){return e-t[2]-t[1]/2},r.prototype.foundPatternCross=function(t){for(var e=this.moduleSize,n=e/2,i=0;i<3;i++)if(Math.abs(e-t[i])>=n)return!1;return!0},r.prototype.crossCheckVertical=function(t,e,n,i){var r=this.image,o=r.height,a=this.crossCheckStateCount;a[0]=0,a[1]=0,a[2]=0;for(var s=t;s>=0&&r.data[e+s*r.width]&&a[1]<=n;)a[1]++,s--;if(s<0||a[1]>n)return NaN;for(;s>=0&&!r.data[e+s*r.width]&&a[0]<=n;)a[0]++,s--;if(a[0]>n)return NaN;for(s=t+1;s<o&&r.data[e+s*r.width]&&a[1]<=n;)a[1]++,s++;if(s==o||a[1]>n)return NaN;for(;s<o&&!r.data[e+s*r.width]&&a[2]<=n;)a[2]++,s++;if(a[2]>n)return NaN;var h=a[0]+a[1]+a[2];return 5*Math.abs(h-i)>=2*i?NaN:this.foundPatternCross(a)?this.centerFromEnd(a,s):NaN},r.prototype.handlePossibleCenter=function(t,e,n){var r=t[0]+t[1]+t[2],o=this.centerFromEnd(t,n),a=this.crossCheckVertical(e,Math.floor(o),2*t[1],r);if(!isNaN(a)){for(var s=(t[0]+t[1]+t[2])/3,h=this.possibleCenters.length,f=0;f<h;f++){if(this.possibleCenters[f].aboutEquals(s,a,o))return new i(o,a,s)}var w=new i(o,a,s);this.possibleCenters.push(w),null!=this.resultPointCallback&&this.resultPointCallback.foundPossibleResultPoint(w)}return null},r.prototype.find=function(){for(var t=this.image,e=this.startX,n=this.height,i=e+this.width,r=this.startY+(n>>1),o=[0,0,0],a=0;a<n;a++){var s=r+(0==(1&a)?a+1>>1:-(a+1>>1));o[0]=0,o[1]=0,o[2]=0;for(var h=e;h<i&&!t.data[h+t.width*s];)h++;for(var f=0;h<i;){if(t.data[h+s*t.width])if(1==f)o[f]++;else if(2==f){if(this.foundPatternCross(o)){var w=this.handlePossibleCenter(o,s,h);if(null!=w)return w}o[0]=o[2],o[1]=1,o[2]=0,f=1}else o[++f]++;else 1==f&&f++,o[f]++;h++}if(this.foundPatternCross(o)){var w=this.handlePossibleCenter(o,s,i);if(null!=w)return w}}if(0!=this.possibleCenters.length)return this.possibleCenters[0];throw\"Couldn't find enough alignment patterns\"}},function(t,e,n){\"use strict\";function i(t){var e=t.Dimension;if(e<21||1!=(3&e))throw\"Error BitMatrixParser\";this.bitMatrix=t,this.parsedVersion=null,this.parsedFormatInfo=null}e.a=i;var r=n(2),o=n(5),a=n(12);i.prototype.copyBit=function(t,e,n){return this.bitMatrix.get_Renamed(t,e)?n<<1|1:n<<1},i.prototype.readFormatInformation=function(){if(null!=this.parsedFormatInfo)return this.parsedFormatInfo;for(var t=0,e=0;e<6;e++)t=this.copyBit(e,8,t);t=this.copyBit(7,8,t),t=this.copyBit(8,8,t),t=this.copyBit(8,7,t);for(var n=5;n>=0;n--)t=this.copyBit(8,n,t);if(this.parsedFormatInfo=r.a.decodeFormatInformation(t),null!=this.parsedFormatInfo)return this.parsedFormatInfo;var i=this.bitMatrix.Dimension;t=0;for(var o=i-8,e=i-1;e>=o;e--)t=this.copyBit(e,8,t);for(var n=i-7;n<i;n++)t=this.copyBit(8,n,t);if(this.parsedFormatInfo=r.a.decodeFormatInformation(t),null!=this.parsedFormatInfo)return this.parsedFormatInfo;throw\"Error readFormatInformation\"},i.prototype.readVersion=function(){if(null!=this.parsedVersion)return this.parsedVersion;var t=this.bitMatrix.Dimension,e=t-17>>2;if(e<=6)return o.a.getVersionForNumber(e);for(var n=0,i=