exports.id=921,exports.ids=[921],exports.modules={8921:(e,t,r)=>{"use strict";r.d(t,{Html5Qrcode:()=>j}),function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"}(n||(n={}));var n,i,o,s,a,l,h=new Map([[n.QR_CODE,"QR_CODE"],[n.AZTEC,"AZTEC"],[n.CODABAR,"CODABAR"],[n.CODE_39,"CODE_39"],[n.CODE_93,"CODE_93"],[n.CODE_128,"CODE_128"],[n.DATA_MATRIX,"DATA_MATRIX"],[n.MAXICODE,"MAXICODE"],[n.ITF,"ITF"],[n.EAN_13,"EAN_13"],[n.EAN_8,"EAN_8"],[n.PDF_417,"PDF_417"],[n.RSS_14,"RSS_14"],[n.RSS_EXPANDED,"RSS_EXPANDED"],[n.UPC_A,"UPC_A"],[n.UPC_E,"UPC_E"],[n.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]);(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(i||(i={})),function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"}(o||(o={}));var c=function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[o.SCAN_TYPE_CAMERA,o.SCAN_TYPE_FILE],e}(),u=function(){function e(e,t){this.format=e,this.formatName=t}return e.prototype.toString=function(){return this.formatName},e.create=function(t){if(!h.has(t))throw"".concat(t," not in html5QrcodeSupportedFormatsTextMap");return new e(t,h.get(t))},e}(),d=function(){function e(){}return e.createFromText=function(e){return{decodedText:e,result:{text:e}}},e.createFromQrcodeResult=function(e){return{decodedText:e.text,result:e}},e}();!function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"}(s||(s={}));var f=function(){function e(){}return e.createFrom=function(e){return{errorMessage:e,type:s.UNKWOWN_ERROR}},e}(),g=function(){function e(e){this.verbose=e}return e.prototype.log=function(e){this.verbose&&console.log(e)},e.prototype.warn=function(e){this.verbose&&console.warn(e)},e.prototype.logError=function(e,t){(this.verbose||!0===t)&&console.error(e)},e.prototype.logErrors=function(e){if(0===e.length)throw"Logger#logError called without arguments";this.verbose&&console.error(e)},e}();function w(e){return null==e}var m=function(){function e(){}return e.codeParseError=function(e){return"QR code parse error, error = ".concat(e)},e.errorGettingUserMedia=function(e){return"Error getting userMedia, error = ".concat(e)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e}(),p=function(){function e(){}return e.scanningStatus=function(){return"Scanning"},e.idleStatus=function(){return"Idle"},e.errorStatus=function(){return"Error"},e.permissionStatus=function(){return"Permission"},e.noCameraFoundErrorStatus=function(){return"No Cameras"},e.lastMatch=function(e){return"Last Match: ".concat(e)},e.codeScannerTitle=function(){return"Code Scanner"},e.cameraPermissionTitle=function(){return"Request Camera Permissions"},e.cameraPermissionRequesting=function(){return"Requesting camera permissions..."},e.noCameraFound=function(){return"No camera found"},e.scanButtonStopScanningText=function(){return"Stop Scanning"},e.scanButtonStartScanningText=function(){return"Start Scanning"},e.torchOnButton=function(){return"Switch On Torch"},e.torchOffButton=function(){return"Switch Off Torch"},e.torchOnFailedMessage=function(){return"Failed to turn on torch"},e.torchOffFailedMessage=function(){return"Failed to turn off torch"},e.scanButtonScanningStarting=function(){return"Launching Camera..."},e.textIfCameraScanSelected=function(){return"Scan an Image File"},e.textIfFileScanSelected=function(){return"Scan using camera directly"},e.selectCamera=function(){return"Select Camera"},e.fileSelectionChooseImage=function(){return"Choose Image"},e.fileSelectionChooseAnother=function(){return"Choose Another"},e.fileSelectionNoImageSelected=function(){return"No image choosen"},e.anonymousCameraPrefix=function(){return"Anonymous Camera"},e.dragAndDropMessage=function(){return"Or drop an image to scan"},e.dragAndDropMessageOnlyImages=function(){return"Or drop an image to scan (other files not supported)"},e.zoom=function(){return"zoom"},e.loadingImage=function(){return"Loading image..."},e.cameraScanAltText=function(){return"Camera based scan"},e.fileScanAltText=function(){return"Fule based scan"},e}(),A=function(){function e(){}return e.poweredBy=function(){return"Powered by "},e.reportIssues=function(){return"Report issues"},e}(),C=function(){function e(){}return e.isMediaStreamConstraintsValid=function(e,t){if("object"!=typeof e){var r=typeof e;return t.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(r,"."),!0),!1}for(var n=new Set(["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"]),i=Object.keys(e),o=0;o0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]r&&(r=o,t=i)}if(!t)throw"No largest barcode found";return t},e.prototype.createBarcodeDetectorFormats=function(e){for(var t=[],r=0;r0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=n&&(e.isClosed=!0,e.parentElement.removeChild(e.surface),t())})})},e.prototype.getCapabilities=function(){return new L(this.getFirstTrackOrFail())},e}(),v=function(){function e(e){this.mediaStream=e}return e.prototype.render=function(e,t,r){return M(this,void 0,void 0,function(){return R(this,function(n){return[2,P.create(e,this.mediaStream,t,r)]})})},e.create=function(t){return M(this,void 0,void 0,function(){var r;return R(this,function(n){switch(n.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return r={audio:!1,video:t},[4,navigator.mediaDevices.getUserMedia(r)];case 1:return[2,new e(n.sent())]}})})},e}(),F=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})},x=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]e&&(this.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),n=e),n)},e.prototype.validateQrboxConfig=function(e){if("number"!=typeof e&&"function"!=typeof e&&(void 0===e.width||void 0===e.height))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(e,t,r){if("number"==typeof r)return{width:r,height:r};if("function"==typeof r)try{return r(e,t)}catch(e){throw Error("qrbox config was passed as a function but it failed with unknown error"+e)}return r},e.prototype.setupUi=function(e,t,r){r.isShadedBoxEnabled()&&this.validateQrboxSize(e,t,r);var n=w(r.qrbox)?{width:e,height:t}:r.qrbox;this.validateQrboxConfig(n);var i=this.toQrdimensions(e,t,n);i.height>t&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var o=r.isShadedBoxEnabled()&&i.height<=t,s=o?this.getShadedRegionBounds(e,t,i):{x:0,y:0,width:e,height:t},a=this.createCanvasElement(s.width,s.height),l=a.getContext("2d",{willReadFrequently:!0});l.canvas.width=s.width,l.canvas.height=s.height,this.element.append(a),o&&this.possiblyInsertShadingElement(this.element,e,t,i),this.createScannerPausedUiElement(this.element),this.qrRegion=s,this.context=l,this.canvasElement=a},e.prototype.createScannerPausedUiElement=function(e){var t=document.createElement("div");t.innerText=m.scannerPaused(),t.style.display="none",t.style.position="absolute",t.style.top="0px",t.style.zIndex="1",t.style.background="rgba(9, 9, 9, 0.46)",t.style.color="#FFECEC",t.style.textAlign="center",t.style.width="100%",e.appendChild(t),this.scannerPausedUiElement=t},e.prototype.scanContext=function(e,t){var r=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(t){return e(t.text,d.createFromQrcodeResult(t)),r.possiblyUpdateShaders(!0),!0}).catch(function(e){r.possiblyUpdateShaders(!1);var n=m.codeParseError(e);return t(n,f.createFrom(n)),!1})},e.prototype.foreverScan=function(e,t,r){var n=this;if(this.shouldScan&&this.renderedCamera){var i=this.renderedCamera.getSurface(),o=i.videoWidth/i.clientWidth,s=i.videoHeight/i.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var a=this.qrRegion.width*o,l=this.qrRegion.height*s,h=this.qrRegion.x*o,c=this.qrRegion.y*s;this.context.drawImage(i,h,c,a,l,0,0,this.qrRegion.width,this.qrRegion.height);var u=function(){n.foreverScanTimeout=setTimeout(function(){n.foreverScan(e,t,r)},n.getTimeoutFps(e.fps))};this.scanContext(t,r).then(function(i){i||!0===e.disableFlip?u():(n.context.translate(n.context.canvas.width,0),n.context.scale(-1,1),n.scanContext(t,r).finally(function(){u()}))}).catch(function(e){n.logger.logError("Error happend while scanning context",e),u()})}},e.prototype.createVideoConstraints=function(e){if("string"==typeof e)return{deviceId:{exact:e}};if("object"==typeof e){var t="facingMode",r="deviceId",n={user:!0,environment:!0},i="exact",o=function(e){if(e in n)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(e,"'")},s=Object.keys(e);if(1!==s.length)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(s.length," keys");var a=Object.keys(e)[0];if(a!==t&&a!==r)throw"Only '".concat(t,"' and '").concat(r,"' ")+" are supported for 'cameraIdOrConfig'";if(a===t){var l=e.facingMode;if("string"==typeof l){if(o(l))return{facingMode:l}}else if("object"==typeof l){if(i in l){if(o(l["".concat(i)]))return{facingMode:{exact:l["".concat(i)]}}}else throw"'facingMode' should be string or object with"+" ".concat(i," as key.")}else{var h=typeof l;throw"Invalid type of 'facingMode' = ".concat(h)}}else{var c=e.deviceId;if("string"==typeof c)return{deviceId:c};if("object"==typeof c){if(i in c)return{deviceId:{exact:c["".concat(i)]}};throw"'deviceId' should be string or object with"+" ".concat(i," as key.")}throw"Invalid type of 'deviceId' = ".concat(typeof c)}}var u=typeof e;throw"Invalid type of 'cameraIdOrConfig' = ".concat(u)},e.prototype.computeCanvasDrawConfig=function(e,t,r,n){if(e<=r&&t<=n)return{x:(r-e)/2,y:(n-t)/2,width:e,height:t};var i=e,o=t;return e>r&&(t=r/e*t,e=r),t>n&&(e=n/t*e,t=n),this.logger.log("Image downsampled from "+"".concat(i,"X").concat(o)+" to ".concat(e,"X").concat(t,".")),this.computeCanvasDrawConfig(e,t,r,n)},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var e=document.getElementById(this.elementId);e&&(e.innerHTML="")},e.prototype.possiblyUpdateShaders=function(e){this.qrMatch!==e&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(t){t.style.backgroundColor=e?X.BORDER_SHADER_MATCH_COLOR:X.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=e)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(e,t,r){var n=document.createElement("canvas");return n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"),n.style.display="none",n.id=w(r)?"qr-canvas":r,n},e.prototype.getShadedRegionBounds=function(e,t,r){if(r.width>e||r.height>t)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(e-r.width)/2,y:(t-r.height)/2,width:r.width,height:r.height}},e.prototype.possiblyInsertShadingElement=function(e,t,r,n){if(!(t-n.width<1)&&!(r-n.height<1)){var i=document.createElement("div");i.style.position="absolute";var o=(t-n.width)/2,s=(r-n.height)/2;i.style.borderLeft="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderRight="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderTop="".concat(s,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderBottom="".concat(s,"px solid rgba(0, 0, 0, 0.48)"),i.style.boxSizing="border-box",i.style.top="0px",i.style.bottom="0px",i.style.left="0px",i.style.right="0px",i.id="".concat(X.SHADED_REGION_ELEMENT_ID),t-n.width<11||r-n.height<11?this.hasBorderShaders=!1:(this.insertShaderBorders(i,40,5,-5,null,0,!0),this.insertShaderBorders(i,40,5,-5,null,0,!1),this.insertShaderBorders(i,40,5,null,-5,0,!0),this.insertShaderBorders(i,40,5,null,-5,0,!1),this.insertShaderBorders(i,5,45,-5,null,-5,!0),this.insertShaderBorders(i,5,45,null,-5,-5,!0),this.insertShaderBorders(i,5,45,-5,null,-5,!1),this.insertShaderBorders(i,5,45,null,-5,-5,!1),this.hasBorderShaders=!0),e.append(i)}},e.prototype.insertShaderBorders=function(e,t,r,n,i,o,s){var a=document.createElement("div");a.style.position="absolute",a.style.backgroundColor=X.BORDER_SHADER_DEFAULT_COLOR,a.style.width="".concat(t,"px"),a.style.height="".concat(r,"px"),null!==n&&(a.style.top="".concat(n,"px")),null!==i&&(a.style.bottom="".concat(i,"px")),s?a.style.left="".concat(o,"px"):a.style.right="".concat(o,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(a),e.appendChild(a)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(e){return 1e3/e},e}(),Z="data:image/svg+xml;base64,",Q=Z+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM3MS42NDMgMzcxLjY0MyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTEwNS4wODQgMzguMjcxaDE2My43Njh2MjBIMTA1LjA4NHoiLz48cGF0aCBkPSJNMzExLjU5NiAxOTAuMTg5Yy03LjQ0MS05LjM0Ny0xOC40MDMtMTYuMjA2LTMyLjc0My0yMC41MjJWMzBjMC0xNi41NDItMTMuNDU4LTMwLTMwLTMwSDEyNS4wODRjLTE2LjU0MiAwLTMwIDEzLjQ1OC0zMCAzMHYxMjAuMTQzaC04LjI5NmMtMTYuNTQyIDAtMzAgMTMuNDU4LTMwIDMwdjEuMzMzYTI5LjgwNCAyOS44MDQgMCAwIDAgNC42MDMgMTUuOTM5Yy03LjM0IDUuNDc0LTEyLjEwMyAxNC4yMjEtMTIuMTAzIDI0LjA2MXYxLjMzM2MwIDkuODQgNC43NjMgMTguNTg3IDEyLjEwMyAyNC4wNjJhMjkuODEgMjkuODEgMCAwIDAtNC42MDMgMTUuOTM4djEuMzMzYzAgMTYuNTQyIDEzLjQ1OCAzMCAzMCAzMGg4LjMyNGMuNDI3IDExLjYzMSA3LjUwMyAyMS41ODcgMTcuNTM0IDI2LjE3Ny45MzEgMTAuNTAzIDQuMDg0IDMwLjE4NyAxNC43NjggNDUuNTM3YTkuOTg4IDkuOTg4IDAgMCAwIDguMjE2IDQuMjg4IDkuOTU4IDkuOTU4IDAgMCAwIDUuNzA0LTEuNzkzYzQuNTMzLTMuMTU1IDUuNjUtOS4zODggMi40OTUtMTMuOTIxLTYuNzk4LTkuNzY3LTkuNjAyLTIyLjYwOC0xMC43Ni0zMS40aDgyLjY4NWMuMjcyLjQxNC41NDUuODE4LjgxNSAxLjIxIDMuMTQyIDQuNTQxIDkuMzcyIDUuNjc5IDEzLjkxMyAyLjUzNCA0LjU0Mi0zLjE0MiA1LjY3Ny05LjM3MSAyLjUzNS0xMy45MTMtMTEuOTE5LTE3LjIyOS04Ljc4Ny0zNS44ODQgOS41ODEtNTcuMDEyIDMuMDY3LTIuNjUyIDEyLjMwNy0xMS43MzIgMTEuMjE3LTI0LjAzMy0uODI4LTkuMzQzLTcuMTA5LTE3LjE5NC0xOC42NjktMjMuMzM3YTkuODU3IDkuODU3IDAgMCAwLTEuMDYxLS40ODZjLS40NjYtLjE4Mi0xMS40MDMtNC41NzktOS43NDEtMTUuNzA2IDEuMDA3LTYuNzM3IDE0Ljc2OC04LjI3MyAyMy43NjYtNy42NjYgMjMuMTU2IDEuNTY5IDM5LjY5OCA3LjgwMyA0Ny44MzYgMTguMDI2IDUuNzUyIDcuMjI1IDcuNjA3IDE2LjYyMyA1LjY3MyAyOC43MzMtLjQxMyAyLjU4NS0uODI0IDUuMjQxLTEuMjQ1IDcuOTU5LTUuNzU2IDM3LjE5NC0xMi45MTkgODMuNDgzLTQ5Ljg3IDExNC42NjEtNC4yMjEgMy41NjEtNC43NTYgOS44Ny0xLjE5NCAxNC4wOTJhOS45OCA5Ljk4IDAgMCAwIDcuNjQ4IDMuNTUxIDkuOTU1IDkuOTU1IDAgMCAwIDYuNDQ0LTIuMzU4YzQyLjY3Mi0zNi4wMDUgNTAuODAyLTg4LjUzMyA1Ni43MzctMTI2Ljg4OC40MTUtMi42ODQuODIxLTUuMzA5IDEuMjI5LTcuODYzIDIuODM0LTE3LjcyMS0uNDU1LTMyLjY0MS05Ljc3Mi00NC4zNDV6bS0yMzIuMzA4IDQyLjYyYy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi0xLjMzM2MwLTUuNTE0IDQuNDg2LTEwIDEwLTEwaDE1djIxLjMzM2gtMTV6bS0yLjUtNTIuNjY2YzAtNS41MTQgNC40ODYtMTAgMTAtMTBoNy41djIxLjMzM2gtNy41Yy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi0xLjMzM3ptMTcuNSA5My45OTloLTcuNWMtNS41MTQgMC0xMC00LjQ4Ni0xMC0xMHYtMS4zMzNjMC01LjUxNCA0LjQ4Ni0xMCAxMC0xMGg3LjV2MjEuMzMzem0zMC43OTYgMjguODg3Yy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi04LjI3MWg5MS40NTdjLS44NTEgNi42NjgtLjQzNyAxMi43ODcuNzMxIDE4LjI3MWgtODIuMTg4em03OS40ODItMTEzLjY5OGMtMy4xMjQgMjAuOTA2IDEyLjQyNyAzMy4xODQgMjEuNjI1IDM3LjA0IDUuNDQxIDIuOTY4IDcuNTUxIDUuNjQ3IDcuNzAxIDcuMTg4LjIxIDIuMTUtMi41NTMgNS42ODQtNC40NzcgNy4yNTEtLjQ4Mi4zNzgtLjkyOS44LTEuMzM1IDEuMjYxLTYuOTg3IDcuOTM2LTExLjk4MiAxNS41Mi0xNS40MzIgMjIuNjg4aC05Ny41NjRWMzBjMC01LjUxNCA0LjQ4Ni0xMCAxMC0xMGgxMjMuNzY5YzUuNTE0IDAgMTAgNC40ODYgMTAgMTB2MTM1LjU3OWMtMy4wMzItLjM4MS02LjE1LS42OTQtOS4zODktLjkxNC0yNS4xNTktMS42OTQtNDIuMzcgNy43NDgtNDQuODk4IDI0LjY2NnoiLz48cGF0aCBkPSJNMTc5LjEyOSA4My4xNjdoLTI0LjA2YTUgNSAwIDAgMC01IDV2MjQuMDYxYTUgNSAwIDAgMCA1IDVoMjQuMDZhNSA1IDAgMCAwIDUtNVY4OC4xNjdhNSA1IDAgMCAwLTUtNXpNMTcyLjYyOSAxNDIuODZoLTEyLjU2VjEzMC44YTUgNSAwIDEgMC0xMCAwdjE3LjA2MWE1IDUgMCAwIDAgNSA1aDE3LjU2YTUgNSAwIDEgMCAwLTEwLjAwMXpNMjE2LjU2OCA4My4xNjdoLTI0LjA2YTUgNSAwIDAgMC01IDV2MjQuMDYxYTUgNSAwIDAgMCA1IDVoMjQuMDZhNSA1IDAgMCAwIDUtNVY4OC4xNjdhNSA1IDAgMCAwLTUtNXptLTUgMjQuMDYxaC0xNC4wNlY5My4xNjdoMTQuMDZ2MTQuMDYxek0yMTEuNjY5IDEyNS45MzZIMTk3LjQxYTUgNSAwIDAgMC01IDV2MTQuMjU3YTUgNSAwIDAgMCA1IDVoMTQuMjU5YTUgNSAwIDAgMCA1LTV2LTE0LjI1N2E1IDUgMCAwIDAtNS01eiIvPjwvc3ZnPg==",K=Z+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1OS4wMTggNTkuMDE4IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OS4wMTggNTkuMDE4IiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJtNTguNzQxIDU0LjgwOS01Ljk2OS02LjI0NGExMC43NCAxMC43NCAwIDAgMCAyLjgyLTcuMjVjMC01Ljk1My00Ljg0My0xMC43OTYtMTAuNzk2LTEwLjc5NlMzNCAzNS4zNjEgMzQgNDEuMzE0IDM4Ljg0MyA1Mi4xMSA0NC43OTYgNTIuMTFjMi40NDEgMCA0LjY4OC0uODI0IDYuNDk5LTIuMTk2bDYuMDAxIDYuMjc3YS45OTguOTk4IDAgMCAwIDEuNDE0LjAzMiAxIDEgMCAwIDAgLjAzMS0xLjQxNHpNMzYgNDEuMzE0YzAtNC44NSAzLjk0Ni04Ljc5NiA4Ljc5Ni04Ljc5NnM4Ljc5NiAzLjk0NiA4Ljc5NiA4Ljc5Ni0zLjk0NiA4Ljc5Ni04Ljc5NiA4Ljc5NlMzNiA0Ni4xNjQgMzYgNDEuMzE0ek0xMC40MzEgMTYuMDg4YzAgMy4wNyAyLjQ5OCA1LjU2OCA1LjU2OSA1LjU2OHM1LjU2OS0yLjQ5OCA1LjU2OS01LjU2OGMwLTMuMDcxLTIuNDk4LTUuNTY5LTUuNTY5LTUuNTY5cy01LjU2OSAyLjQ5OC01LjU2OSA1LjU2OXptOS4xMzggMGMwIDEuOTY4LTEuNjAyIDMuNTY4LTMuNTY5IDMuNTY4cy0zLjU2OS0xLjYwMS0zLjU2OS0zLjU2OCAxLjYwMi0zLjU2OSAzLjU2OS0zLjU2OSAzLjU2OSAxLjYwMSAzLjU2OSAzLjU2OXoiLz48cGF0aCBkPSJtMzAuODgyIDI4Ljk4NyA5LjE4LTEwLjA1NCAxMS4yNjIgMTAuMzIzYTEgMSAwIDAgMCAxLjM1MS0xLjQ3NWwtMTItMTFhMSAxIDAgMCAwLTEuNDE0LjA2M2wtOS43OTQgMTAuNzI3LTQuNzQzLTQuNzQzYTEuMDAzIDEuMDAzIDAgMCAwLTEuMzY4LS4wNDRMNi4zMzkgMzcuNzY4YTEgMSAwIDEgMCAxLjMyMiAxLjUwMWwxNi4zMTMtMTQuMzYyIDcuMzE5IDcuMzE4YS45OTkuOTk5IDAgMSAwIDEuNDE0LTEuNDE0bC0xLjgyNS0xLjgyNHoiLz48cGF0aCBkPSJNMzAgNDYuNTE4SDJ2LTQyaDU0djI4YTEgMSAwIDEgMCAyIDB2LTI5YTEgMSAwIDAgMC0xLTFIMWExIDEgMCAwIDAtMSAxdjQ0YTEgMSAwIDAgMCAxIDFoMjlhMSAxIDAgMSAwIDAtMnoiLz48L3N2Zz4=",q=Z+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NjAgNDYwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA0NjAgNDYwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJNMjMwIDBDMTAyLjk3NSAwIDAgMTAyLjk3NSAwIDIzMHMxMDIuOTc1IDIzMCAyMzAgMjMwIDIzMC0xMDIuOTc0IDIzMC0yMzBTMzU3LjAyNSAwIDIzMCAwem0zOC4zMzMgMzc3LjM2YzAgOC42NzYtNy4wMzQgMTUuNzEtMTUuNzEgMTUuNzFoLTQzLjEwMWMtOC42NzYgMC0xNS43MS03LjAzNC0xNS43MS0xNS43MVYyMDIuNDc3YzAtOC42NzYgNy4wMzMtMTUuNzEgMTUuNzEtMTUuNzFoNDMuMTAxYzguNjc2IDAgMTUuNzEgNy4wMzMgMTUuNzEgMTUuNzFWMzc3LjM2ek0yMzAgMTU3Yy0yMS41MzkgMC0zOS0xNy40NjEtMzktMzlzMTcuNDYxLTM5IDM5LTM5IDM5IDE3LjQ2MSAzOSAzOS0xNy40NjEgMzktMzkgMzl6Ii8+PC9zdmc+",J=function(){function e(){}return e.createDefault=function(){return{hasPermission:!1,lastUsedCameraId:null}},e}(),$=function(){function e(){this.data=J.createDefault();var t=localStorage.getItem(e.LOCAL_STORAGE_KEY);t?this.data=JSON.parse(t):this.reset()}return e.prototype.hasCameraPermissions=function(){return this.data.hasPermission},e.prototype.getLastUsedCameraId=function(){return this.data.lastUsedCameraId},e.prototype.setHasPermission=function(e){this.data.hasPermission=e,this.flush()},e.prototype.setLastUsedCameraId=function(e){this.data.lastUsedCameraId=e,this.flush()},e.prototype.resetLastUsedCameraId=function(){this.data.lastUsedCameraId=null,this.flush()},e.prototype.reset=function(){this.data=J.createDefault(),this.flush()},e.prototype.flush=function(){localStorage.setItem(e.LOCAL_STORAGE_KEY,JSON.stringify(this.data))},e.LOCAL_STORAGE_KEY="HTML5_QRCODE_DATA",e}(),ee=function(){function e(){this.infoDiv=document.createElement("div")}return e.prototype.renderInto=function(e){this.infoDiv.style.position="absolute",this.infoDiv.style.top="10px",this.infoDiv.style.right="10px",this.infoDiv.style.zIndex="2",this.infoDiv.style.display="none",this.infoDiv.style.padding="5pt",this.infoDiv.style.border="1px solid #171717",this.infoDiv.style.fontSize="10pt",this.infoDiv.style.background="rgb(0 0 0 / 69%)",this.infoDiv.style.borderRadius="5px",this.infoDiv.style.textAlign="center",this.infoDiv.style.fontWeight="400",this.infoDiv.style.color="white",this.infoDiv.innerText=A.poweredBy();var t=document.createElement("a");t.innerText="ScanApp",t.href="https://scanapp.org",t.target="new",t.style.color="white",this.infoDiv.appendChild(t);var r=document.createElement("br"),n=document.createElement("br");this.infoDiv.appendChild(r),this.infoDiv.appendChild(n);var i=document.createElement("a");i.innerText=A.reportIssues(),i.href="https://github.com/mebjas/html5-qrcode/issues",i.target="new",i.style.color="white",this.infoDiv.appendChild(i),e.appendChild(this.infoDiv)},e.prototype.show=function(){this.infoDiv.style.display="block"},e.prototype.hide=function(){this.infoDiv.style.display="none"},e}(),et=function(){function e(e,t){this.isShowingInfoIcon=!0,this.onTapIn=e,this.onTapOut=t,this.infoIcon=document.createElement("img")}return e.prototype.renderInto=function(e){var t=this;this.infoIcon.alt="Info icon",this.infoIcon.src=q,this.infoIcon.style.position="absolute",this.infoIcon.style.top="4px",this.infoIcon.style.right="4px",this.infoIcon.style.opacity="0.6",this.infoIcon.style.cursor="pointer",this.infoIcon.style.zIndex="2",this.infoIcon.style.width="16px",this.infoIcon.style.height="16px",this.infoIcon.onmouseover=function(e){return t.onHoverIn()},this.infoIcon.onmouseout=function(e){return t.onHoverOut()},this.infoIcon.onclick=function(e){return t.onClick()},e.appendChild(this.infoIcon)},e.prototype.onHoverIn=function(){this.isShowingInfoIcon&&(this.infoIcon.style.opacity="1")},e.prototype.onHoverOut=function(){this.isShowingInfoIcon&&(this.infoIcon.style.opacity="0.6")},e.prototype.onClick=function(){this.isShowingInfoIcon?(this.isShowingInfoIcon=!1,this.onTapIn(),this.infoIcon.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAQgAAAEIBarqQRAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE1SURBVDiNfdI7S0NBEAXgLya1otFgpbYSbISAgpXYi6CmiH9KCAiChaVga6OiWPgfRDQ+0itaGVNosXtluWwcuMzePfM4M3sq8lbHBubwg1dc4m1E/J/N4ghDPOIsfk/4xiEao5KX0McFljN4C9d4QTPXuY99jP3DsIoDPGM6BY5i5yI5R7O4q+ImFkJY2DCh3cAH2klyB+9J1xUMMAG7eCh1a+Mr+k48b5diXrFVwwLuS+BJ9MfR7+G0FHOHhTHhnXNWS87VDF4pcnfQK4Ep7XScNLmPTZgURNKKYENYWDpzW1BhscS1WHS8CDgURFJQrWcoF3c13KKbgg1BYQfy8xZWEzTTw1QZbAoKu8FqJnktdu5hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII=",this.infoIcon.style.opacity="1"):(this.isShowingInfoIcon=!0,this.onTapOut(),this.infoIcon.src=q,this.infoIcon.style.opacity="0.6")},e}(),er=function(){function e(){var e=this;this.infoDiv=new ee,this.infoIcon=new et(function(){e.infoDiv.show()},function(){e.infoDiv.hide()})}return e.prototype.renderInto=function(e){this.infoDiv.renderInto(e),this.infoIcon.renderInto(e)},e}(),en=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]1},e.prototype.isCameraScanRequired=function(){for(var t=0,r=this.supportedScanTypes;tt)throw"Max ".concat(t," values expected for ")+"supportedScanTypes";for(var r=0;r0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]20){var t=e.substring(0,8),r=e.length,n=e.substring(r-8,r);e="".concat(t,"....").concat(n)}var i=p.fileSelectionChooseAnother()+" - "+e;this.fileSelectionButton.innerText=i},e.prototype.setInitialValueToButton=function(){var e=p.fileSelectionChooseImage()+" - "+p.fileSelectionNoImageSelected();this.fileSelectionButton.innerText=e},e.prototype.getFileScanInputId=function(){return"html5-qrcode-private-filescan-input"},e.create=function(t,r,n){return new e(t,r,n)},e}(),ef=function(){function e(e){this.selectElement=ea.createElement("select",es.CAMERA_SELECTION_SELECT_ID),this.cameras=e,this.options=[]}return e.prototype.render=function(e){var t=document.createElement("span");t.style.marginRight="10px";var r=this.cameras.length;if(0===r)throw Error("No cameras found");if(1===r)t.style.display="none";else{var n=p.selectCamera();t.innerText="".concat(n," (").concat(this.cameras.length,") ")}for(var i=1,o=0,s=this.cameras;o0?(e.removeChild(t),n.renderCameraSelection(r)):(n.setHeaderMessage(p.noCameraFound(),l.STATUS_WARNING),i())}).catch(function(e){n.persistedDataManager.setHasPermission(!1),r?r.disabled=!1:i(),n.setHeaderMessage(e,l.STATUS_WARNING),n.showHideScanTypeSwapLink(!0)})},e.prototype.createPermissionButton=function(e,t){var r=this,n=ea.createElement("button",this.getCameraPermissionButtonId());n.innerText=p.cameraPermissionTitle(),n.addEventListener("click",function(){n.disabled=!0,r.createCameraListUi(e,t,n)}),t.appendChild(n)},e.prototype.createPermissionsUi=function(e,t){var r=this;if(eo.isCameraScanType(this.currentScanType)&&this.persistedDataManager.hasCameraPermissions()){ei.hasPermissions().then(function(n){n?r.createCameraListUi(e,t):(r.persistedDataManager.setHasPermission(!1),r.createPermissionButton(e,t))}).catch(function(n){r.persistedDataManager.setHasPermission(!1),r.createPermissionButton(e,t)});return}this.createPermissionButton(e,t)},e.prototype.createSectionControlPanel=function(){var e=document.getElementById(this.getDashboardSectionId()),t=document.createElement("div");e.appendChild(t);var r=document.createElement("div");r.id=this.getDashboardSectionCameraScanRegionId(),r.style.display=eo.isCameraScanType(this.currentScanType)?"block":"none",t.appendChild(r);var n=document.createElement("div");n.style.textAlign="center",r.appendChild(n),this.scanTypeSelector.isCameraScanRequired()&&this.createPermissionsUi(r,n),this.renderFileScanUi(t)},e.prototype.renderFileScanUi=function(e){var t=eo.isFileScanType(this.currentScanType),r=this;this.fileSelectionUi=ed.create(e,t,function(e){if(!r.html5Qrcode)throw"html5Qrcode not defined";eo.isFileScanType(r.currentScanType)&&(r.setHeaderMessage(p.loadingImage()),r.html5Qrcode.scanFileV2(e,!0).then(function(e){r.resetHeaderMessage(),r.qrCodeSuccessCallback(e.decodedText,e)}).catch(function(e){r.setHeaderMessage(e,l.STATUS_WARNING),r.qrCodeErrorCallback(e,f.createFrom(e))}))})},e.prototype.renderCameraSelection=function(e){var t,r=this,n=this,i=document.getElementById(this.getDashboardSectionCameraScanRegionId());i.style.textAlign="center";var o=eg.create(i,!1),s=function(e){var t,n,i,s=e.zoomFeature();if(s.isSupported()){o.setOnCameraZoomValueChangeCallback(function(e){s.apply(e)});var a=1;r.config.defaultZoomValueIfSupported&&(a=r.config.defaultZoomValueIfSupported),t=a,n=s.min(),a=t>(i=s.max())?i:t",t.appendChild(this.cameraScanImage);return}this.cameraScanImage=new Image,this.cameraScanImage.onload=function(r){t.innerHTML="
",t.appendChild(e.cameraScanImage)},this.cameraScanImage.width=64,this.cameraScanImage.style.opacity="0.8",this.cameraScanImage.src=Q,this.cameraScanImage.alt=p.cameraScanAltText()},e.prototype.insertFileScanImageToScanRegion=function(){var e=this,t=document.getElementById(this.getScanRegionId());if(this.fileScanImage){t.innerHTML="
",t.appendChild(this.fileScanImage);return}this.fileScanImage=new Image,this.fileScanImage.onload=function(r){t.innerHTML="
",t.appendChild(e.fileScanImage)},this.fileScanImage.width=64,this.fileScanImage.style.opacity="0.8",this.fileScanImage.src=K,this.fileScanImage.alt=p.fileScanAltText()},e.prototype.clearScanRegion=function(){document.getElementById(this.getScanRegionId()).innerHTML=""},e.prototype.getDashboardSectionId=function(){return"".concat(this.elementId,"__dashboard_section")},e.prototype.getDashboardSectionCameraScanRegionId=function(){return"".concat(this.elementId,"__dashboard_section_csr")},e.prototype.getDashboardSectionSwapLinkId=function(){return es.SCAN_TYPE_CHANGE_ANCHOR_ID},e.prototype.getScanRegionId=function(){return"".concat(this.elementId,"__scan_region")},e.prototype.getDashboardId=function(){return"".concat(this.elementId,"__dashboard")},e.prototype.getHeaderMessageContainerId=function(){return"".concat(this.elementId,"__header_message")},e.prototype.getCameraPermissionButtonId=function(){return es.CAMERA_PERMISSION_BUTTON_ID},e.prototype.getCameraScanRegion=function(){return document.getElementById(this.getDashboardSectionCameraScanRegionId())},e.prototype.getDashboardSectionSwapLink=function(){return document.getElementById(this.getDashboardSectionSwapLinkId())},e.prototype.getHeaderMessageDiv=function(){return document.getElementById(this.getHeaderMessageContainerId())}}()},943:function(e,t){(function(e){"use strict";let t;var r,n,i,o,s,a,l,h,c,u,d,f,g,w,m,p,A,C,E,I,S,_,T=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},y=function(e){function t(t){var r,n,i,o,s=this.constructor,a=e.call(this,t)||this;return Object.defineProperty(a,"name",{value:s.name,enumerable:!1}),r=s.prototype,(n=Object.setPrototypeOf)?n(a,r):a.__proto__=r,void 0===i&&(i=a.constructor),(o=Error.captureStackTrace)&&o(a,i),a}return function(e,t){function r(){this.constructor=e}T(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t}(Error);class N extends y{constructor(e){super(e),this.message=e}getKind(){return this.constructor.kind}}N.kind="Exception";class D extends N{}D.kind="ArgumentException";class M extends N{}M.kind="IllegalArgumentException";class R{constructor(e){if(this.binarizer=e,null===e)throw new M("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,t){return this.binarizer.getBlackRow(e,t)}getBlackMatrix(){return(null===this.matrix||void 0===this.matrix)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,t,r,n){let i=this.binarizer.getLuminanceSource().crop(e,t,r,n);return new R(this.binarizer.createBinarizer(i))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){let e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new R(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){let e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new R(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch(e){return""}}}class O extends N{static getChecksumInstance(){return new O}}O.kind="ChecksumException";class b{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class B{static arraycopy(e,t,r,n,i){for(;i--;)r[n++]=e[t++]}static currentTimeMillis(){return Date.now()}}class L extends N{}L.kind="IndexOutOfBoundsException";class P extends L{constructor(e,t){super(t),this.index=e,this.message=t}}P.kind="ArrayIndexOutOfBoundsException";class v{static fill(e,t){for(let r=0,n=e.length;rr)throw new M("fromIndex("+t+") > toIndex("+r+")");if(t<0)throw new P(t);if(r>e)throw new P(r)}static asList(...e){return e}static create(e,t,r){return Array.from({length:e}).map(e=>Array.from({length:t}).fill(r))}static createInt32Array(e,t,r){return Array.from({length:e}).map(e=>Int32Array.from({length:t}).fill(r))}static equals(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(let r=0,n=e.length;r>1,s=r(t,e[o]);if(s>0)n=o+1;else{if(!(s<0))return o;i=o-1}}return-n-1}static numberComparator(e,t){return e-t}}class F{static numberOfTrailingZeros(e){let t;if(0===e)return 32;let r=31;return 0!=(t=e<<16)&&(r-=16,e=t),0!=(t=e<<8)&&(r-=8,e=t),0!=(t=e<<4)&&(r-=4,e=t),0!=(t=e<<2)&&(r-=2,e=t),r-(e<<1>>>31)}static numberOfLeadingZeros(e){if(0===e)return 32;let t=1;return e>>>16==0&&(t+=16,e<<=16),e>>>24==0&&(t+=8,e<<=8),e>>>28==0&&(t+=4,e<<=4),e>>>30==0&&(t+=2,e<<=2),t-=e>>>31}static toHexString(e){return e.toString(16)}static toBinaryString(e){return String(parseInt(String(e),2))}static bitCount(e){return e-=e>>>1&1431655765,e=(e=(858993459&e)+(e>>>2&858993459))+(e>>>4)&252645135,e+=e>>>8,63&(e+=e>>>16)}static truncDivision(e,t){return Math.trunc(e/t)}static parseInt(e,t){return parseInt(e,t)}}F.MIN_VALUE_32_BITS=-2147483648,F.MAX_VALUE=Number.MAX_SAFE_INTEGER;class x{constructor(e,t){void 0===e?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,null==t?this.bits=x.makeArray(e):this.bits=t)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(e){if(e>32*this.bits.length){let t=x.makeArray(e);B.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}}get(e){return(this.bits[Math.floor(e/32)]&1<<(31&e))!=0}set(e){this.bits[Math.floor(e/32)]|=1<<(31&e)}flip(e){this.bits[Math.floor(e/32)]^=1<<(31&e)}getNextSet(e){let t=this.size;if(e>=t)return t;let r=this.bits,n=Math.floor(e/32),i=r[n];i&=~((1<<(31&e))-1);let o=r.length;for(;0===i;){if(++n===o)return t;i=r[n]}let s=32*n+F.numberOfTrailingZeros(i);return s>t?t:s}getNextUnset(e){let t=this.size;if(e>=t)return t;let r=this.bits,n=Math.floor(e/32),i=~r[n];i&=~((1<<(31&e))-1);let o=r.length;for(;0===i;){if(++n===o)return t;i=~r[n]}let s=32*n+F.numberOfTrailingZeros(i);return s>t?t:s}setBulk(e,t){this.bits[Math.floor(e/32)]=t}setRange(e,t){if(tthis.size)throw new M;if(t===e)return;let r=Math.floor(e/32),n=Math.floor(--t/32),i=this.bits;for(let o=r;o<=n;o++){let s=o>r?0:31&e,a=(2<<(othis.size)throw new M;if(t===e)return!0;let n=Math.floor(e/32),i=Math.floor(--t/32),o=this.bits;for(let s=n;s<=i;s++){let a=s>n?0:31&e,l=(2<<(s32)throw new M("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(let r=t;r>0;r--)this.appendBit((e>>r-1&1)==1)}appendBitArray(e){let t=e.size;this.ensureCapacity(this.size+t);for(let r=0;r>1&1431655765|(1431655765&r)<<1)>>2&858993459|(858993459&r)<<2)>>4&252645135|(252645135&r)<<4)>>8&16711935|(16711935&r)<<8)>>16&65535|(65535&r)<<16,e[t-i]=r}if(this.size!==32*r){let t=32*r-this.size,n=e[0]>>>t;for(let i=1;i>>t}e[r-1]=n}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){return e instanceof x&&this.size===e.size&&v.equals(this.bits,e.bits)}hashCode(){return 31*this.size+v.hashCode(this.bits)}toString(){let e="";for(let t=0,r=this.size;t=900)throw new U("incorect value");let t=H.VALUES_TO_ECI.get(e);if(void 0===t)throw new U("incorect value");return t}static getCharacterSetECIByName(e){let t=H.NAME_TO_ECI.get(e);if(void 0===t)throw new U("incorect value");return t}equals(e){return e instanceof H&&this.getName()===e.getName()}}H.VALUE_IDENTIFIER_TO_ECI=new Map,H.VALUES_TO_ECI=new Map,H.NAME_TO_ECI=new Map,H.Cp437=new H(g.Cp437,Int32Array.from([0,2]),"Cp437"),H.ISO8859_1=new H(g.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),H.ISO8859_2=new H(g.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),H.ISO8859_3=new H(g.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),H.ISO8859_4=new H(g.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),H.ISO8859_5=new H(g.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),H.ISO8859_6=new H(g.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),H.ISO8859_7=new H(g.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),H.ISO8859_8=new H(g.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),H.ISO8859_9=new H(g.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),H.ISO8859_10=new H(g.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),H.ISO8859_11=new H(g.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),H.ISO8859_13=new H(g.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),H.ISO8859_14=new H(g.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),H.ISO8859_15=new H(g.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),H.ISO8859_16=new H(g.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),H.SJIS=new H(g.SJIS,20,"SJIS","Shift_JIS"),H.Cp1250=new H(g.Cp1250,21,"Cp1250","windows-1250"),H.Cp1251=new H(g.Cp1251,22,"Cp1251","windows-1251"),H.Cp1252=new H(g.Cp1252,23,"Cp1252","windows-1252"),H.Cp1256=new H(g.Cp1256,24,"Cp1256","windows-1256"),H.UnicodeBigUnmarked=new H(g.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),H.UTF8=new H(g.UTF8,26,"UTF8","UTF-8"),H.ASCII=new H(g.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),H.Big5=new H(g.Big5,28,"Big5"),H.GB18030=new H(g.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),H.EUC_KR=new H(g.EUC_KR,30,"EUC_KR","EUC-KR");class V extends N{}V.kind="UnsupportedOperationException";class z{static decode(e,t){let r=this.encodingName(t);return this.customDecoder?this.customDecoder(e,r):"undefined"==typeof TextDecoder||this.shouldDecodeOnFallback(r)?this.decodeFallback(e,r):new TextDecoder(r).decode(e)}static shouldDecodeOnFallback(e){return!z.isBrowser()&&"ISO-8859-1"===e}static encode(e,t){let r=this.encodingName(t);return this.customEncoder?this.customEncoder(e,r):"undefined"==typeof TextEncoder?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return"undefined"!=typeof window&&"[object Window]"===({}).toString.call(window)}static encodingName(e){return"string"==typeof e?e:e.getName()}static encodingCharacterSet(e){return e instanceof H?e:H.getCharacterSetECIByName(e)}static decodeFallback(e,t){let r=this.encodingCharacterSet(t);if(z.isDecodeFallbackSupported(r)){let t="";for(let r=0,n=e.length;r3&&239===e[0]&&187===e[1]&&191===e[2];for(let t=0;t0?(128&r)==0?o=!1:s--:(128&r)!=0&&((64&r)==0?o=!1:(s++,(32&r)==0?a++:(s++,(16&r)==0?l++:(s++,(8&r)==0?h++:o=!1))))),n&&(r>127&&r<160?n=!1:r>159&&(r<192||215===r||247===r)&&m++),i&&(c>0?r<64||127===r||r>252?i=!1:c--:128===r||160===r||r>239?i=!1:r>160&&r<224?(u++,f=0,++d>g&&(g=d)):r>127?(c++,d=0,++f>w&&(w=f)):(d=0,f=0))}return(o&&s>0&&(o=!1),i&&c>0&&(i=!1),o&&(p||a+l+h>0))?G.UTF8:i&&(G.ASSUME_SHIFT_JIS||g>=3||w>=3)?G.SHIFT_JIS:n&&i?2===g&&2===u||10*m>=r?G.SHIFT_JIS:G.ISO88591:n?G.ISO88591:i?G.SHIFT_JIS:o?G.UTF8:G.PLATFORM_DEFAULT_ENCODING}static format(e,...t){let r=-1;return e.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g,function(e,n,i,o,s,a){let l;if("%%"===e)return"%";if(void 0===t[++r])return;e=o?parseInt(o.substr(1)):void 0;let h=s?parseInt(s.substr(1)):void 0;switch(a){case"s":l=t[r];break;case"c":l=t[r][0];break;case"f":l=parseFloat(t[r]).toFixed(e);break;case"p":l=parseFloat(t[r]).toPrecision(e);break;case"e":l=parseFloat(t[r]).toExponential(e);break;case"x":l=parseInt(t[r]).toString(h||16);break;case"d":l=parseFloat(parseInt(t[r],h||10).toPrecision(e)).toFixed(0)}l="object"==typeof l?JSON.stringify(l):(+l).toString(h);let c=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;l.lengtho){if(-1===s)s=i-o;else if(i-o!==s)throw new M("row lengths do not match");o=i,a++}l++}else if(e.substring(l,l+t.length)===t)l+=t.length,n[i]=!0,i++;else if(e.substring(l,l+r.length)===r)l+=r.length,n[i]=!1,i++;else throw new M("illegal character encountered: "+e.substring(l));if(i>o){if(-1===s)s=i-o;else if(i-o!==s)throw new M("row lengths do not match");a++}let h=new X(s,a);for(let e=0;e>>(31&e)&1)!=0}set(e,t){let r=t*this.rowSize+Math.floor(e/32);this.bits[r]|=1<<(31&e)&4294967295}unset(e,t){let r=t*this.rowSize+Math.floor(e/32);this.bits[r]&=~(1<<(31&e)&4294967295)}flip(e,t){let r=t*this.rowSize+Math.floor(e/32);this.bits[r]^=1<<(31&e)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new M("input matrix dimensions do not match");let t=new x(Math.floor(this.width/32)+1),r=this.rowSize,n=this.bits;for(let i=0,o=this.height;ithis.height||i>this.width)throw new M("The region must fit inside the matrix");let s=this.rowSize,a=this.bits;for(let r=t;ra&&(a=e),32*ts){let e=31;for(;l>>>e==0;)e--;32*t+e>s&&(s=32*t+e)}}}return s=0&&0===t[r];)r--;if(r<0)return null;let n=Math.floor(r/e),i=32*Math.floor(r%e),o=t[r],s=31;for(;o>>>s==0;)s--;return i+=s,Int32Array.from([i,n])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){return e instanceof X&&this.width===e.width&&this.height===e.height&&this.rowSize===e.rowSize&&v.equals(this.bits,e.bits)}hashCode(){let e=this.width;return 31*(e=31*(e=31*(e=31*e+this.width)+this.height)+this.rowSize)+v.hashCode(this.bits)}toString(e="X ",t=" ",r="\n"){return this.buildToString(e,t,r)}buildToString(e,t,r){let n=new Y;for(let i=0,o=this.height;i>j.LUMINANCE_SHIFT]++;let s=j.estimateBlackPoint(o);if(n<3)for(let e=0;e>j.LUMINANCE_SHIFT]++}}let o=j.estimateBlackPoint(i),s=e.getMatrix();for(let e=0;ei&&(n=o,i=e[o]),e[o]>r&&(r=e[o]);let o=0,s=0;for(let r=0;rs&&(o=r,s=i)}if(n>o){let e=n;n=o,o=e}if(o-n<=t/16)throw new W;let a=o-1,l=-1;for(let t=o-1;t>n;t--){let i=t-n,s=i*i*(o-t)*(r-e[t]);s>l&&(a=t,l=s)}return a<=Z.MINIMUM_DIMENSION&&r>=Z.MINIMUM_DIMENSION){let n=e.getMatrix(),i=t>>Z.BLOCK_SIZE_POWER;(t&Z.BLOCK_SIZE_MASK)!=0&&i++;let o=r>>Z.BLOCK_SIZE_POWER;(r&Z.BLOCK_SIZE_MASK)!=0&&o++;let s=Z.calculateBlackPoints(n,i,o,t,r),a=new X(t,r);Z.calculateThresholdForBlock(n,i,o,t,r,s,a),this.matrix=a}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new Z(e)}static calculateThresholdForBlock(e,t,r,n,i,o,s){let a=i-Z.BLOCK_SIZE,l=n-Z.BLOCK_SIZE;for(let i=0;ia&&(h=a);let c=Z.cap(i,2,r-3);for(let r=0;rl&&(i=l);let a=Z.cap(r,2,t-3),u=0;for(let e=-2;e<=2;e++){let t=o[c+e];u+=t[a-2]+t[a-1]+t[a]+t[a+1]+t[a+2]}let d=u/25;Z.thresholdBlock(e,i,h,d,n,s)}}}static cap(e,t,r){return er?r:e}static thresholdBlock(e,t,r,n,i,o){for(let s=0,a=r*i+t;so&&(r=o);for(let o=0;os&&(t=s);let l=0,h=255,c=0;for(let i=0,o=r*n+t;ic&&(c=r)}if(c-h>Z.MIN_DYNAMIC_RANGE)for(i++,o+=n;i>2*Z.BLOCK_SIZE_POWER;if(c-h<=Z.MIN_DYNAMIC_RANGE&&(u=h/2,i>0&&o>0)){let e=(a[i-1][o]+2*a[i][o-1]+a[i-1][o-1])/4;h>10,n[r]=i}return n}getRow(e,t){if(e<0||e>=this.getHeight())throw new M("Requested row is outside the image: "+e);let r=this.getWidth(),n=e*r;return null===t?t=this.buffer.slice(n,n+r):(t.lengthnew J(e.deviceId,e.label))})}findDeviceById(e){return $(this,void 0,void 0,function*(){let t=yield this.listVideoInputDevices();return t?t.find(t=>t.deviceId===e):null})}decodeFromInputVideoDevice(e,t){return $(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,t)})}decodeOnceFromVideoDevice(e,t){return $(this,void 0,void 0,function*(){return this.reset(),yield this.decodeOnceFromConstraints({video:e?{deviceId:{exact:e}}:{facingMode:"environment"}},t)})}decodeOnceFromConstraints(e,t){return $(this,void 0,void 0,function*(){let r=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(r,t)})}decodeOnceFromStream(e,t){return $(this,void 0,void 0,function*(){this.reset();let r=yield this.attachStreamToVideo(e,t);return yield this.decodeOnce(r)})}decodeFromInputVideoDeviceContinuously(e,t,r){return $(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,t,r)})}decodeFromVideoDevice(e,t,r){return $(this,void 0,void 0,function*(){return yield this.decodeFromConstraints({video:e?{deviceId:{exact:e}}:{facingMode:"environment"}},t,r)})}decodeFromConstraints(e,t,r){return $(this,void 0,void 0,function*(){let n=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(n,t,r)})}decodeFromStream(e,t,r){return $(this,void 0,void 0,function*(){this.reset();let n=yield this.attachStreamToVideo(e,t);return yield this.decodeContinuously(n,r)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,t){return $(this,void 0,void 0,function*(){let r=this.prepareVideoElement(t);return this.addVideoSource(r,e),this.videoElement=r,this.stream=e,yield this.playVideoOnLoadAsync(r),r})}playVideoOnLoadAsync(e){return new Promise((t,r)=>this.playVideoOnLoad(e,()=>t()))}playVideoOnLoad(e,t){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return $(this,void 0,void 0,function*(){if(this.isVideoPlaying(e)){console.warn("Trying to play video that is already playing.");return}try{yield e.play()}catch(e){console.warn("It was not possible to play the video.")}})}getMediaElement(e,t){let r=document.getElementById(e);if(!r)throw new D(`element with id '${e}' not found`);if(r.nodeName.toLowerCase()!==t.toLowerCase())throw new D(`element with id '${e}' must be an ${t} element`);return r}decodeFromImage(e,t){if(!e&&!t)throw new D("either imageElement with a src set or an url must be provided");return t&&!e?this.decodeFromImageUrl(t):this.decodeFromImageElement(e)}decodeFromVideo(e,t){if(!e&&!t)throw new D("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,t,r){if(void 0===e&&void 0===t)throw new D("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,r):this.decodeFromVideoElementContinuously(e,r)}decodeFromImageElement(e){if(!e)throw new D("An image element must be provided.");this.reset();let t=this.prepareImageElement(e);return this.imageElement=t,this.isImageLoaded(t)?this.decodeOnce(t,!1,!0):this._decodeOnLoadImage(t)}decodeFromVideoElement(e){let t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)}decodeFromVideoElementContinuously(e,t){let r=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(r,t)}_decodeFromVideoElementSetup(e){if(!e)throw new D("A video element must be provided.");this.reset();let t=this.prepareVideoElement(e);return this.videoElement=t,t}decodeFromImageUrl(e){if(!e)throw new D("An URL must be provided.");this.reset();let t=this.prepareImageElement();this.imageElement=t;let r=this._decodeOnLoadImage(t);return t.src=e,r}decodeFromVideoUrl(e){if(!e)throw new D("An URL must be provided.");this.reset();let t=this.prepareVideoElement(),r=this.decodeFromVideoElement(t);return t.src=e,r}decodeFromVideoUrlContinuously(e,t){if(!e)throw new D("An URL must be provided.");this.reset();let r=this.prepareVideoElement(),n=this.decodeFromVideoElementContinuously(r,t);return r.src=e,n}_decodeOnLoadImage(e){return new Promise((t,r)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(t,r),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return $(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,t){return $(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,t)})}isImageLoaded(e){return!!e.complete&&0!==e.naturalWidth}prepareImageElement(e){let t;return void 0===e&&((t=document.createElement("img")).width=200,t.height=200),"string"==typeof e&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t}prepareVideoElement(e){let t;return e||"undefined"==typeof document||((t=document.createElement("video")).width=200,t.height=200),"string"==typeof e&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t}decodeOnce(e,t=!0,r=!0){this._stopAsyncDecode=!1;let n=(i,o)=>{if(this._stopAsyncDecode){o(new W("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{let t=this.decode(e);i(t)}catch(a){let e=t&&a instanceof W,s=a instanceof O||a instanceof U;if(e||s&&r)return setTimeout(n,this._timeBetweenDecodingAttempts,i,o);o(a)}};return new Promise((e,t)=>n(e,t))}decodeContinuously(e,t){this._stopContinuousDecode=!1;let r=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{let n=this.decode(e);t(n,null),setTimeout(r,this.timeBetweenScansMillis)}catch(i){t(null,i);let e=i instanceof O||i instanceof U,n=i instanceof W;(e||n)&&setTimeout(r,this._timeBetweenDecodingAttempts)}};r()}decode(e){let t=this.createBinaryBitmap(e);return this.decodeBitmap(t)}_isHTMLVideoElement(e){return 0!==e.videoWidth}drawFrameOnCanvas(e,t,r){t||(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),r||(r=this.captureCanvasContext),r.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}drawImageOnCanvas(e,t,r=this.captureCanvasContext){t||(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),r||(r=this.captureCanvasContext),r.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}createBinaryBitmap(e){return this.getCaptureCanvasContext(e),this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e),new R(new Z(new q(this.getCaptureCanvas(e))))}getCaptureCanvasContext(e){if(!this.captureCanvasContext){let t=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=t}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){let t=this.createCaptureCanvas(e);this.captureCanvas=t}return this.captureCanvas}decodeBitmap(e){return this.reader.decode(e,this._hints)}createCaptureCanvas(e){let t,r;if("undefined"==typeof document)return this._destroyCaptureCanvas(),null;let n=document.createElement("canvas");return void 0!==e&&(e instanceof HTMLVideoElement?(t=e.videoWidth,r=e.videoHeight):e instanceof HTMLImageElement&&(t=e.naturalWidth||e.width,r=e.naturalHeight||e.height)),n.style.width=t+"px",n.style.height=r+"px",n.width=t,n.height=r,n}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),!1===this._stopAsyncDecode&&this.stopAsyncDecode(),!1===this._stopContinuousDecode&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(void 0!==this.videoEndedListener&&this.videoElement.removeEventListener("ended",this.videoEndedListener),void 0!==this.videoPlayingEventListener&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),void 0!==this.videoCanPlayListener&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(void 0!==this.imageLoadedListener&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(e,t){try{e.srcObject=t}catch(r){e.src=URL.createObjectURL(t)}}cleanVideoSource(e){try{e.srcObject=null}catch(t){e.src=""}this.videoElement.removeAttribute("src")}}class et{constructor(e,t,r=null==t?0:8*t.length,n,i,o=B.currentTimeMillis()){this.text=e,this.rawBytes=t,this.numBits=r,this.resultPoints=n,this.format=i,this.timestamp=o,this.text=e,this.rawBytes=t,null==r?this.numBits=null==t?0:8*t.length:this.numBits=r,this.resultPoints=n,this.format=i,this.resultMetadata=null,null==o?this.timestamp=B.currentTimeMillis():this.timestamp=o}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(e,t){null===this.resultMetadata&&(this.resultMetadata=new Map),this.resultMetadata.set(e,t)}putAllMetadata(e){null!==e&&(null===this.resultMetadata?this.resultMetadata=e:this.resultMetadata=new Map(e))}addResultPoints(e){let t=this.resultPoints;if(null===t)this.resultPoints=e;else if(null!==e&&e.length>0){let r=Array(t.length+e.length);B.arraycopy(t,0,r,0,t.length),B.arraycopy(e,0,r,t.length,e.length),this.resultPoints=r}}getTimestamp(){return this.timestamp}toString(){return this.text}}(i=w||(w={}))[i.AZTEC=0]="AZTEC",i[i.CODABAR=1]="CODABAR",i[i.CODE_39=2]="CODE_39",i[i.CODE_93=3]="CODE_93",i[i.CODE_128=4]="CODE_128",i[i.DATA_MATRIX=5]="DATA_MATRIX",i[i.EAN_8=6]="EAN_8",i[i.EAN_13=7]="EAN_13",i[i.ITF=8]="ITF",i[i.MAXICODE=9]="MAXICODE",i[i.PDF_417=10]="PDF_417",i[i.QR_CODE=11]="QR_CODE",i[i.RSS_14=12]="RSS_14",i[i.RSS_EXPANDED=13]="RSS_EXPANDED",i[i.UPC_A=14]="UPC_A",i[i.UPC_E=15]="UPC_E",i[i.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION";var er=w;(o=m||(m={}))[o.OTHER=0]="OTHER",o[o.ORIENTATION=1]="ORIENTATION",o[o.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",o[o.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",o[o.ISSUE_NUMBER=4]="ISSUE_NUMBER",o[o.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",o[o.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",o[o.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",o[o.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",o[o.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",o[o.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY";var en=m;class ei{constructor(e,t,r,n,i=-1,o=-1){this.rawBytes=e,this.text=t,this.byteSegments=r,this.ecLevel=n,this.structuredAppendSequenceNumber=i,this.structuredAppendParity=o,this.numBits=null==e?0:8*e.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(e){this.numBits=e}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(e){this.errorsCorrected=e}getErasures(){return this.erasures}setErasures(e){this.erasures=e}getOther(){return this.other}setOther(e){this.other=e}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class eo{exp(e){return this.expTable[e]}log(e){if(0===e)throw new M;return this.logTable[e]}static addOrSubtract(e,t){return e^t}}class es{constructor(e,t){if(0===t.length)throw new M;this.field=e;let r=t.length;if(r>1&&0===t[0]){let e=1;for(;er.length){let e=t;t=r,r=e}let n=new Int32Array(r.length),i=r.length-t.length;B.arraycopy(r,0,n,0,i);for(let e=i;e=e.getDegree()&&!n.isZero();){let i=n.getDegree()-e.getDegree(),s=t.multiply(n.getCoefficient(n.getDegree()),o),a=e.multiplyByMonomial(i,s),l=t.buildMonomial(i,s);r=r.addOrSubtract(l),n=n.addOrSubtract(a)}return[r,n]}toString(){let e="";for(let t=this.getDegree();t>=0;t--){let r=this.getCoefficient(t);if(0!==r){if(r<0?(e+=" - ",r=-r):e.length>0&&(e+=" + "),0===t||1!==r){let t=this.field.log(r);0===t?e+="1":1===t?e+="a":e+="a^"+t}0!==t&&(1===t?e+="x":e+="x^"+t)}}return e}}class ea extends N{}ea.kind="ArithmeticException";class el extends eo{constructor(e,t,r){super(),this.primitive=e,this.size=t,this.generatorBase=r;let n=new Int32Array(t),i=1;for(let r=0;r=t&&(i^=e,i&=t-1);this.expTable=n;let o=new Int32Array(t);for(let e=0;e=(r/2|0);){let e=i,t=s;if(i=o,s=a,i.isZero())throw new eh("r_{i-1} was zero");o=e;let r=n.getZero(),l=i.getCoefficient(i.getDegree()),h=n.inverse(l);for(;o.getDegree()>=i.getDegree()&&!o.isZero();){let e=o.getDegree()-i.getDegree(),t=n.multiply(o.getCoefficient(o.getDegree()),h);r=r.addOrSubtract(n.buildMonomial(e,t)),o=o.addOrSubtract(i.multiplyByMonomial(e,t))}if(a=r.multiply(s).addOrSubtract(t),o.getDegree()>=i.getDegree())throw new ec("Division algorithm failed to reduce polynomial?")}let l=a.getCoefficient(0);if(0===l)throw new eh("sigmaTilde(0) was zero");let h=n.inverse(l);return[a.multiplyScalar(h),o.multiplyScalar(h)]}findErrorLocations(e){let t=e.getDegree();if(1===t)return Int32Array.from([e.getCoefficient(1)]);let r=new Int32Array(t),n=0,i=this.field;for(let o=1;o=this.ddata.getNbLayers()?(r=6,t=el.AZTEC_DATA_6):8>=this.ddata.getNbLayers()?(r=8,t=el.AZTEC_DATA_8):22>=this.ddata.getNbLayers()?(r=10,t=el.AZTEC_DATA_10):(r=12,t=el.AZTEC_DATA_12);let n=this.ddata.getNbDatablocks(),i=e.length/r;if(i1,c,c+r-1),c+=r-1;else for(let e=r-1;e>=0;--e)h[c++]=(t&1<=8?ed.readCode(e,t,8):ed.readCode(e,t,r)<<8-r}static convertBoolArrayToByteArray(e){let t=new Uint8Array((e.length+7)/8);for(let r=0;r","?","[","]","{","}","CTRL_UL"],ed.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class ef{constructor(){}static round(e){return e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,t,r,n){let i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}static sum(e){let t=0;for(let r=0,n=e.length;r!==n;r++)t+=e[r];return t}}class eg{static floatToIntBits(e){return e}}eg.MAX_VALUE=Number.MAX_SAFE_INTEGER;class ew{constructor(e,t){this.x=e,this.y=t}getX(){return this.x}getY(){return this.y}equals(e){return e instanceof ew&&this.x===e.x&&this.y===e.y}hashCode(){return 31*eg.floatToIntBits(this.x)+eg.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){let t,r,n;let i=this.distance(e[0],e[1]),o=this.distance(e[1],e[2]),s=this.distance(e[0],e[2]);if(o>=i&&o>=s?(r=e[0],t=e[1],n=e[2]):s>=o&&s>=i?(r=e[1],t=e[0],n=e[2]):(r=e[2],t=e[0],n=e[1]),0>this.crossProductZ(t,r,n)){let e=t;t=n,n=e}e[0]=t,e[1]=r,e[2]=n}static distance(e,t){return ef.distance(e.x,e.y,t.x,t.y)}static crossProductZ(e,t,r){let n=t.x,i=t.y;return(r.x-n)*(e.y-i)-(r.y-i)*(e.x-n)}}class em{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class ep extends em{constructor(e,t,r,n,i){super(e,t),this.compact=r,this.nbDatablocks=n,this.nbLayers=i}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class eA{constructor(e,t,r,n){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),null==t&&(t=eA.INIT_SIZE),null==r&&(r=e.getWidth()/2|0),null==n&&(n=e.getHeight()/2|0);let i=t/2|0;if(this.leftInit=r-i,this.rightInit=r+i,this.upInit=n-i,this.downInit=n+i,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new W}detect(){let e=this.leftInit,t=this.rightInit,r=this.upInit,n=this.downInit,i=!1,o=!0,s=!1,a=!1,l=!1,h=!1,c=!1,u=this.width,d=this.height;for(;o;){o=!1;let f=!0;for(;(f||!a)&&t=u){i=!0;break}let g=!0;for(;(g||!l)&&n=d){i=!0;break}let w=!0;for(;(w||!h)&&e>=0;)(w=this.containsBlackPoint(r,n,e,!1))?(e--,o=!0,h=!0):!h&&e--;if(e<0){i=!0;break}let m=!0;for(;(m||!c)&&r>=0;)(m=this.containsBlackPoint(e,t,r,!0))?(r--,o=!0,c=!0):!c&&r--;if(r<0){i=!0;break}o&&(s=!0)}if(!i&&s){let i=t-e,o=null;for(let t=1;null===o&&tr||s<-1||s>n)throw new W;i=!1,-1===o?(t[e]=0,i=!0):o===r&&(t[e]=r-1,i=!0),-1===s?(t[e+1]=0,i=!0):s===n&&(t[e+1]=n-1,i=!0)}i=!0;for(let e=t.length-2;e>=0&&i;e-=2){let o=Math.floor(t[e]),s=Math.floor(t[e+1]);if(o<-1||o>r||s<-1||s>n)throw new W;i=!1,-1===o?(t[e]=0,i=!0):o===r&&(t[e]=r-1,i=!0),-1===s?(t[e+1]=0,i=!0):s===n&&(t[e+1]=n-1,i=!0)}}}class eE{constructor(e,t,r,n,i,o,s,a,l){this.a11=e,this.a21=t,this.a31=r,this.a12=n,this.a22=i,this.a32=o,this.a13=s,this.a23=a,this.a33=l}static quadrilateralToQuadrilateral(e,t,r,n,i,o,s,a,l,h,c,u,d,f,g,w){let m=eE.quadrilateralToSquare(e,t,r,n,i,o,s,a);return eE.squareToQuadrilateral(l,h,c,u,d,f,g,w).times(m)}transformPoints(e){let t=e.length,r=this.a11,n=this.a12,i=this.a13,o=this.a21,s=this.a22,a=this.a23,l=this.a31,h=this.a32,c=this.a33;for(let u=0;u>1&127):(n<<=10,n+=(t>>2&992)+(t>>1&31))}let i=this.getCorrectedParameterData(n,this.compact);this.compact?(this.nbLayers=(i>>6)+1,this.nbDataBlocks=(63&i)+1):(this.nbLayers=(i>>11)+1,this.nbDataBlocks=(2047&i)+1)}getRotation(e,t){let r=0;e.forEach((e,n,i)=>{r=(r<<3)+((e>>t-2<<1)+(1&e))}),r=((1&r)<<11)+(r>>1);for(let e=0;e<4;e++)if(2>=F.bitCount(r^this.EXPECTED_CORNER_BITS[e]))return e;throw new W}getCorrectedParameterData(e,t){let r,n;t?(r=7,n=2):(r=10,n=4);let i=r-n,o=new Int32Array(r);for(let t=r-1;t>=0;--t)o[t]=15&e,e>>=4;try{new eu(el.AZTEC_PARAM).decode(o,i)}catch(e){throw new W}let s=0;for(let e=0;e2){let r=this.distancePoint(l,e)*this.nbCenterLayers/(this.distancePoint(i,t)*(this.nbCenterLayers+2));if(r<.75||r>1.25||!this.isWhiteOrBlackRectangle(e,s,a,l))break}t=e,r=s,n=a,i=l,o=!o}if(5!==this.nbCenterLayers&&7!==this.nbCenterLayers)throw new W;this.compact=5===this.nbCenterLayers;let s=new ew(t.getX()+.5,t.getY()-.5),a=new ew(r.getX()+.5,r.getY()+.5),l=new ew(n.getX()-.5,n.getY()+.5),h=new ew(i.getX()-.5,i.getY()-.5);return this.expandSquare([s,a,l,h],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,t,r,n;try{let i=new eA(this.image).detect();e=i[0],t=i[1],r=i[2],n=i[3]}catch(s){let i=this.image.getWidth()/2,o=this.image.getHeight()/2;e=this.getFirstDifferent(new e_(i+7,o-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new e_(i+7,o+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new e_(i-7,o+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new e_(i-7,o-7),!1,-1,-1).toResultPoint()}let i=ef.round((e.getX()+n.getX()+t.getX()+r.getX())/4),o=ef.round((e.getY()+n.getY()+t.getY()+r.getY())/4);try{let s=new eA(this.image,15,i,o).detect();e=s[0],t=s[1],r=s[2],n=s[3]}catch(s){e=this.getFirstDifferent(new e_(i+7,o-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new e_(i+7,o+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new e_(i-7,o+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new e_(i-7,o-7),!1,-1,-1).toResultPoint()}return new e_(i=ef.round((e.getX()+n.getX()+t.getX()+r.getX())/4),o=ef.round((e.getY()+n.getY()+t.getY()+r.getY())/4))}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,t,r,n,i){let o=eS.getInstance(),s=this.getDimension(),a=s/2-this.nbCenterLayers,l=s/2+this.nbCenterLayers;return o.sampleGrid(e,s,s,a,a,l,a,l,l,a,l,t.getX(),t.getY(),r.getX(),r.getY(),n.getX(),n.getY(),i.getX(),i.getY())}sampleLine(e,t,r){let n=0,i=this.distanceResultPoint(e,t),o=i/r,s=e.getX(),a=e.getY(),l=o*(t.getX()-e.getX())/i,h=o*(t.getY()-e.getY())/i;for(let e=0;e.1&&c<.9?0:c<=.1===l?1:-1}getFirstDifferent(e,t,r,n){let i=e.getX()+r,o=e.getY()+n;for(;this.isValid(i,o)&&this.image.get(i,o)===t;)i+=r,o+=n;for(i-=r,o-=n;this.isValid(i,o)&&this.image.get(i,o)===t;)i+=r;for(i-=r;this.isValid(i,o)&&this.image.get(i,o)===t;)o+=n;return new e_(i,o-=n)}expandSquare(e,t,r){let n=r/(2*t),i=e[0].getX()-e[2].getX(),o=e[0].getY()-e[2].getY(),s=(e[0].getX()+e[2].getX())/2,a=(e[0].getY()+e[2].getY())/2,l=new ew(s+n*i,a+n*o),h=new ew(s-n*i,a-n*o);return i=e[1].getX()-e[3].getX(),o=e[1].getY()-e[3].getY(),[l,new ew((s=(e[1].getX()+e[3].getX())/2)+n*i,(a=(e[1].getY()+e[3].getY())/2)+n*o),h,new ew(s-n*i,a-n*o)]}isValid(e,t){return e>=0&&e0&&t{r.foundPossibleResultPoint(e)})}}reset(){}}class eN extends ee{constructor(e=500){super(new ey,e)}}class eD{decode(e,t){try{return this.doDecode(e,t)}catch(r){if(t&&!0===t.get(k.TRY_HARDER)&&e.isRotateSupported()){let r=e.rotateCounterClockwise(),n=this.doDecode(r,t),i=n.getResultMetadata(),o=270;null!==i&&!0===i.get(en.ORIENTATION)&&(o+=i.get(en.ORIENTATION)%360),n.putMetadata(en.ORIENTATION,o);let s=n.getResultPoints();if(null!==s){let e=r.getHeight();for(let t=0;t>(s?8:5));r=s?i:15;let l=Math.trunc(i/2);for(let s=0;s=i)break;try{o=e.getBlackRow(h,o)}catch(e){continue}for(let e=0;e<2;e++){if(1===e&&(o.reverse(),t&&!0===t.get(k.NEED_RESULT_POINT_CALLBACK))){let e=new Map;t.forEach((t,r)=>e.set(r,t)),e.delete(k.NEED_RESULT_POINT_CALLBACK),t=e}try{let r=this.decodeRow(h,o,t);if(1===e){r.putMetadata(en.ORIENTATION,180);let e=r.getResultPoints();null!==e&&(e[0]=new ew(n-e[0].getX()-1,e[0].getY()),e[1]=new ew(n-e[1].getX()-1,e[1].getY()))}return r}catch(e){}}}throw new W}static recordPattern(e,t,r){let n=r.length;for(let e=0;e=i)throw new W;let o=!e.get(t),s=0,a=t;for(;a0&&n>=0;)e.get(--t)!==i&&(n--,i=!i);if(n>=0)throw new W;eD.recordPattern(e,t+1,r)}static patternMatchVariance(e,t,r){let n=e.length,i=0,o=0;for(let r=0;ro?n-o:o-n;if(l>r)return Number.POSITIVE_INFINITY;a+=l}return a/i}}class eM extends eD{static findStartPattern(e){let t=e.getSize(),r=e.getNextSet(0),n=0,i=Int32Array.from([0,0,0,0,0,0]),o=r,s=!1;for(let a=r;a=0&&e.isRange(Math.max(0,o-(a-o)/2),o,!1))return Int32Array.from([o,a,r]);o+=i[0]+i[1],(i=i.slice(2,i.length-1))[n-1]=0,i[n]=0,n--}else n++;i[n]=1,s=!s}throw new W}static decodeCode(e,t,r){eD.recordPattern(e,r,t);let n=eM.MAX_AVG_VARIANCE,i=-1;for(let e=0;e=0)return i;throw new W}decodeRow(e,t,r){let n;let i=r&&!0===r.get(k.ASSUME_GS1),o=eM.findStartPattern(t),s=o[2],a=0,l=new Uint8Array(20);switch(l[a++]=s,s){case eM.CODE_START_A:n=eM.CODE_CODE_A;break;case eM.CODE_START_B:n=eM.CODE_CODE_B;break;case eM.CODE_START_C:n=eM.CODE_CODE_C;break;default:throw new U}let h=!1,c=!1,u="",d=o[0],f=o[1],g=Int32Array.from([0,0,0,0,0,0]),w=0,m=0,p=s,A=0,C=!0,E=!1,I=!1;for(;!h;){let e=c;switch(c=!1,w=m,m=eM.decodeCode(t,g,f),l[a++]=m,m!==eM.CODE_STOP&&(C=!0),m!==eM.CODE_STOP&&(p+=++A*m),d=f,f+=g.reduce((e,t)=>e+t,0),m){case eM.CODE_START_A:case eM.CODE_START_B:case eM.CODE_START_C:throw new U}switch(n){case eM.CODE_CODE_A:if(m<64)I===E?u+=String.fromCharCode(32+m):u+=String.fromCharCode(32+m+128),I=!1;else if(m<96)I===E?u+=String.fromCharCode(m-64):u+=String.fromCharCode(m+64),I=!1;else switch(m!==eM.CODE_STOP&&(C=!1),m){case eM.CODE_FNC_1:i&&(0===u.length?u+="]C1":u+="\x1d");break;case eM.CODE_FNC_2:case eM.CODE_FNC_3:break;case eM.CODE_FNC_4_A:!E&&I?(E=!0,I=!1):E&&I?(E=!1,I=!1):I=!0;break;case eM.CODE_SHIFT:c=!0,n=eM.CODE_CODE_B;break;case eM.CODE_CODE_B:n=eM.CODE_CODE_B;break;case eM.CODE_CODE_C:n=eM.CODE_CODE_C;break;case eM.CODE_STOP:h=!0}break;case eM.CODE_CODE_B:if(m<96)I===E?u+=String.fromCharCode(32+m):u+=String.fromCharCode(32+m+128),I=!1;else switch(m!==eM.CODE_STOP&&(C=!1),m){case eM.CODE_FNC_1:i&&(0===u.length?u+="]C1":u+="\x1d");break;case eM.CODE_FNC_2:case eM.CODE_FNC_3:break;case eM.CODE_FNC_4_B:!E&&I?(E=!0,I=!1):E&&I?(E=!1,I=!1):I=!0;break;case eM.CODE_SHIFT:c=!0,n=eM.CODE_CODE_A;break;case eM.CODE_CODE_A:n=eM.CODE_CODE_A;break;case eM.CODE_CODE_C:n=eM.CODE_CODE_C;break;case eM.CODE_STOP:h=!0}break;case eM.CODE_CODE_C:if(m<100)m<10&&(u+="0"),u+=m;else switch(m!==eM.CODE_STOP&&(C=!1),m){case eM.CODE_FNC_1:i&&(0===u.length?u+="]C1":u+="\x1d");break;case eM.CODE_CODE_A:n=eM.CODE_CODE_A;break;case eM.CODE_CODE_B:n=eM.CODE_CODE_B;break;case eM.CODE_STOP:h=!0}}e&&(n=n===eM.CODE_CODE_A?eM.CODE_CODE_B:eM.CODE_CODE_A)}let S=f-d;if(f=t.getNextUnset(f),!t.isRange(f,Math.min(t.getSize(),f+(f-d)/2),!1))throw new W;if((p-=A*w)%103!==w)throw new O;let _=u.length;if(0===_)throw new W;_>0&&C&&(u=n===eM.CODE_CODE_C?u.substring(0,_-2):u.substring(0,_-1));let T=(o[1]+o[0])/2,y=d+S/2,N=l.length,D=new Uint8Array(N);for(let e=0;en&&(i=t);n=i,t=0;let o=0,s=0;for(let i=0;in&&(s|=1<0;i++){let r=e[i];if(r>n&&(t--,2*r>=o))return -1}return s}}while(t>3);return -1}static patternToChar(e){for(let t=0;t="A"&&i<="Z")o=String.fromCharCode(i.charCodeAt(0)+32);else throw new U;break;case"$":if(i>="A"&&i<="Z")o=String.fromCharCode(i.charCodeAt(0)-64);else throw new U;break;case"%":if(i>="A"&&i<="E")o=String.fromCharCode(i.charCodeAt(0)-38);else if(i>="F"&&i<="J")o=String.fromCharCode(i.charCodeAt(0)-11);else if(i>="K"&&i<="O")o=String.fromCharCode(i.charCodeAt(0)+16);else if(i>="P"&&i<="T")o=String.fromCharCode(i.charCodeAt(0)+43);else if("U"===i)o="\0";else if("V"===i)o="@";else if("W"===i)o="`";else if("X"===i||"Y"===i||"Z"===i)o="\x7f";else throw new U;break;case"/":if(i>="A"&&i<="O")o=String.fromCharCode(i.charCodeAt(0)-32);else if("Z"===i)o=":";else throw new U}r+=o,n++}else r+=t}return r}}eR.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",eR.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],eR.ASTERISK_ENCODING=148;class eO extends eD{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,t,r){let n=this.decodeStart(t),i=this.decodeEnd(t),o=new Y;eO.decodeMiddle(t,n[1],i[0],o);let s=o.toString(),a=null;null!=r&&(a=r.get(k.ALLOWED_LENGTHS)),null==a&&(a=eO.DEFAULT_ALLOWED_LENGTHS);let l=s.length,h=!1,c=0;for(let e of a){if(l===e){h=!0;break}e>c&&(c=e)}if(!h&&l>c&&(h=!0),!h)throw new U;return new et(s,null,0,[new ew(n[1],e),new ew(i[0],e)],er.ITF,new Date().getTime())}static decodeMiddle(e,t,r,n){let i=new Int32Array(10),o=new Int32Array(5),s=new Int32Array(5);for(i.fill(0),o.fill(0),s.fill(0);t0&&n>=0&&!e.get(n);n--)r--;if(0!==r)throw new W}static skipWhiteSpace(e){let t=e.getSize(),r=e.getNextSet(0);if(r===t)throw new W;return r}decodeEnd(e){e.reverse();try{let t,r=eO.skipWhiteSpace(e);try{t=eO.findGuardPattern(e,r,eO.END_PATTERN_REVERSED[0])}catch(n){n instanceof W&&(t=eO.findGuardPattern(e,r,eO.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,t[0]);let n=t[0];return t[0]=e.getSize()-t[1],t[1]=e.getSize()-n,t}finally{e.reverse()}}static findGuardPattern(e,t,r){let n=r.length,i=new Int32Array(n),o=e.getSize(),s=!1,a=0,l=t;i.fill(0);for(let h=t;h=0)return r%10;throw new W}}eO.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],eO.MAX_AVG_VARIANCE=.38,eO.MAX_INDIVIDUAL_VARIANCE=.5,eO.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],eO.START_PATTERN=Int32Array.from([1,1,1,1]),eO.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class eb extends eD{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let t,r=!1,n=0,i=Int32Array.from([0,0,0]);for(;!r;){i=Int32Array.from([0,0,0]);let o=(t=eb.findGuardPattern(e,n,!1,this.START_END_PATTERN,i))[0],s=o-((n=t[1])-o);s>=0&&(r=e.isRange(s,o,!1))}return t}static checkChecksum(e){return eb.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(0===t)return!1;let r=parseInt(e.charAt(t-1),10);return eb.getStandardUPCEANChecksum(e.substring(0,t-1))===r}static getStandardUPCEANChecksum(e){let t=e.length,r=0;for(let n=t-1;n>=0;n-=2){let t=e.charAt(n).charCodeAt(0)-48;if(t<0||t>9)throw new U;r+=t}r*=3;for(let n=t-2;n>=0;n-=2){let t=e.charAt(n).charCodeAt(0)-48;if(t<0||t>9)throw new U;r+=t}return(1e3-r)%10}static decodeEnd(e,t){return eb.findGuardPattern(e,t,!1,eb.START_END_PATTERN,new Int32Array(eb.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,t,r,n){return this.findGuardPattern(e,t,r,n,new Int32Array(n.length))}static findGuardPattern(e,t,r,n,i){let o=e.getSize();t=r?e.getNextUnset(t):e.getNextSet(t);let s=0,a=t,l=n.length,h=r;for(let r=t;r=0)return o;throw new W}}eb.MAX_AVG_VARIANCE=.48,eb.MAX_INDIVIDUAL_VARIANCE=.7,eb.START_END_PATTERN=Int32Array.from([1,1,1]),eb.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),eb.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),eb.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class eB{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,r){let n=this.decodeRowStringBuffer,i=this.decodeMiddle(t,r,n),o=n.toString(),s=eB.parseExtensionString(o),a=new et(o,null,0,[new ew((r[0]+r[1])/2,e),new ew(i,e)],er.UPC_EAN_EXTENSION,new Date().getTime());return null!=s&&a.putAllMetadata(s),a}decodeMiddle(e,t,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=e.getSize(),o=t[1],s=0;for(let t=0;t<5&&o=10&&(s|=1<<4-t),4!==t&&(o=e.getNextSet(o),o=e.getNextUnset(o))}if(5!==r.length)throw new W;let a=this.determineCheckDigit(s);if(eB.extensionChecksum(r.toString())!==a)throw new W;return o}static extensionChecksum(e){let t=e.length,r=0;for(let n=t-2;n>=0;n-=2)r+=e.charAt(n).charCodeAt(0)-48;r*=3;for(let n=t-1;n>=0;n-=2)r+=e.charAt(n).charCodeAt(0)-48;return(r*=3)%10}determineCheckDigit(e){for(let t=0;t<10;t++)if(e===this.CHECK_DIGIT_ENCODINGS[t])return t;throw new W}static parseExtensionString(e){if(5!==e.length)return null;let t=eB.parseExtension5String(e);return null==t?null:new Map([[en.SUGGESTED_PRICE,t]])}static parseExtension5String(e){let t;switch(e.charAt(0)){case"0":t="\xa3";break;case"5":t="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}t="";break;default:t=""}let r=parseInt(e.substring(1)),n=(r/100).toString(),i=r%100;return t+n+"."+(i<10?"0"+i:i.toString())}}class eL{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,r){let n=this.decodeRowStringBuffer,i=this.decodeMiddle(t,r,n),o=n.toString(),s=eL.parseExtensionString(o),a=new et(o,null,0,[new ew((r[0]+r[1])/2,e),new ew(i,e)],er.UPC_EAN_EXTENSION,new Date().getTime());return null!=s&&a.putAllMetadata(s),a}decodeMiddle(e,t,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=e.getSize(),o=t[1],s=0;for(let t=0;t<2&&o=10&&(s|=1<<1-t),1!==t&&(o=e.getNextSet(o),o=e.getNextUnset(o))}if(2!==r.length||parseInt(r.toString())%4!==s)throw new W;return o}static parseExtensionString(e){return 2!==e.length?null:new Map([[en.ISSUE_NUMBER,parseInt(e)]])}}class eP{static decodeRow(e,t,r){let n=eb.findGuardPattern(t,r,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new eB().decodeRow(e,t,n)}catch(r){return new eL().decodeRow(e,t,n)}}}eP.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class ev extends eb{constructor(){super(),this.decodeRowStringBuffer="",ev.L_AND_G_PATTERNS=ev.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let t=ev.L_PATTERNS[e-10],r=new Int32Array(t.length);for(let e=0;e=t.getSize()||!t.isRange(h,c,!1))throw new W;let u=a.toString();if(u.length<8)throw new U;if(!ev.checkChecksum(u))throw new O;let d=(n[1]+n[0])/2,f=(l[1]+l[0])/2,g=this.getBarcodeFormat(),w=new et(u,null,0,[new ew(d,e),new ew(f,e)],g,new Date().getTime()),m=0;try{let r=eP.decodeRow(e,t,l[1]);w.putMetadata(en.UPC_EAN_EXTENSION,r.getText()),w.putAllMetadata(r.getResultMetadata()),w.addResultPoints(r.getResultPoints()),m=r.getText().length}catch(e){}let p=null==r?null:r.get(k.ALLOWED_EAN_EXTENSIONS);if(null!=p){let e=!1;for(let t in p)if(m.toString()===t){e=!0;break}if(!e)throw new W}return w}decodeEnd(e,t){return ev.findGuardPattern(e,t,!1,ev.START_END_PATTERN,new Int32Array(ev.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return ev.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(0===t)return!1;let r=parseInt(e.charAt(t-1),10);return ev.getStandardUPCEANChecksum(e.substring(0,t-1))===r}static getStandardUPCEANChecksum(e){let t=e.length,r=0;for(let n=t-1;n>=0;n-=2){let t=e.charAt(n).charCodeAt(0)-48;if(t<0||t>9)throw new U;r+=t}r*=3;for(let n=t-2;n>=0;n-=2){let t=e.charAt(n).charCodeAt(0)-48;if(t<0||t>9)throw new U;r+=t}return(1e3-r)%10}}class eF extends ev{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=e.getSize(),o=t[1],s=0;for(let t=0;t<6&&o=10&&(s|=1<<5-t)}r=eF.determineFirstDigit(r,s),o=ev.findGuardPattern(e,o,!0,ev.MIDDLE_PATTERN,new Int32Array(ev.MIDDLE_PATTERN.length).fill(0))[1];for(let t=0;t<6&&oe);n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=e.getSize(),o=t[1],s=0;for(let t=0;t<6&&o=10&&(s|=1<<5-t)}return{rowOffset:o,resultString:eU.determineNumSysAndCheckDigit(r,s)}}decodeEnd(e,t){return eU.findGuardPatternWithoutCounters(e,t,!0,eU.MIDDLE_END_PATTERN)}checkChecksum(e){return ev.checkChecksum(eU.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,t){for(let r=0;r<=1;r++)for(let n=0;n<10;n++)if(t===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[r][n])return String.fromCharCode(48+r)+e+String.fromCharCode(48+n);throw W.getNotFoundInstance()}getBarcodeFormat(){return er.UPC_E}static convertUPCEtoUPCA(e){let t=e.slice(1,7).split("").map(e=>e.charCodeAt(0)),r=new Y;r.append(e.charAt(0));let n=t[5];switch(n){case 0:case 1:case 2:r.appendChars(t,0,2),r.append(n),r.append("0000"),r.appendChars(t,2,3);break;case 3:r.appendChars(t,0,3),r.append("00000"),r.appendChars(t,3,2);break;case 4:r.appendChars(t,0,4),r.append("00000"),r.append(t[4]);break;default:r.appendChars(t,0,5),r.append("0000"),r.append(n)}return e.length>=8&&r.append(e.charAt(7)),r.toString()}}eU.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),eU.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class eH extends eD{constructor(e){super();let t=null==e?null:e.get(k.POSSIBLE_FORMATS),r=[];null==t?(r.push(new eF),r.push(new ek),r.push(new ex),r.push(new eU)):(t.indexOf(er.EAN_13)>-1&&r.push(new eF),t.indexOf(er.UPC_A)>-1&&r.push(new ek),t.indexOf(er.EAN_8)>-1&&r.push(new ex),t.indexOf(er.UPC_E)>-1&&r.push(new eU)),this.readers=r}decodeRow(e,t,r){for(let n of this.readers)try{let i=n.decodeRow(e,t,r),o=i.getBarcodeFormat()===er.EAN_13&&"0"===i.getText().charAt(0),s=null==r?null:r.get(k.POSSIBLE_FORMATS),a=null==s||s.includes(er.UPC_A);if(o&&a){let e=i.getRawBytes(),t=new et(i.getText().substring(1),e,e?e.length:null,i.getResultPoints(),er.UPC_A);return t.putAllMetadata(i.getResultMetadata()),t}return i}catch(e){}throw new W}reset(){for(let e of this.readers)e.reset()}}class eV extends eD{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=[,,,,],this.evenRoundingErrors=[,,,,],this.oddCounts=Array(this.dataCharacterCounters.length/2),this.evenCounts=Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,t){for(let r=0;rn&&(n=t[i],r=i);e[r]++}static decrement(e,t){let r=0,n=t[0];for(let i=1;i=eV.MIN_FINDER_PATTERN_RATIO&&n<=eV.MAX_FINDER_PATTERN_RATIO){let t=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n of e)n>r&&(r=n),n=s-a-1&&(e-=eY.combins(n-l-(s-a),s-a-2)),s-a-1>1){let r=0;for(let e=n-l-(s-a-2);e>t;e--)r+=eY.combins(n-l-e-1,s-a-3);e-=r*(s-1-a)}else n-l>t&&e--;i+=e}n-=l}return i}static combins(e,t){let r,n;e-t>t?(n=t,r=e-t):(n=e-t,r=t);let i=1,o=1;for(let t=e;t>r;t--)i*=t,o<=n&&(i/=o,o++);for(;o<=n;)i/=o,o++;return i}}class eX{static buildBitArray(e){let t=2*e.length-1;null==e[e.length-1].getRightChar()&&(t-=1);let r=new x(12*t),n=0,i=e[0].getRightChar().getValue();for(let e=11;e>=0;--e)(i&1<=0;--e)(o&1<=0;--t)(e&1<10||r<0||r>10)throw new U;this.firstDigit=t,this.secondDigit=r}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return 10*this.firstDigit+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===eK.FNC1}isSecondDigitFNC1(){return this.secondDigit===eK.FNC1}isAnyFNC1(){return this.firstDigit===eK.FNC1||this.secondDigit===eK.FNC1}}eK.FNC1=10;class eq{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new W;let t=e.substring(0,2);for(let r of eq.TWO_DIGIT_DATA_LENGTH)if(r[0]===t){if(r[1]===eq.VARIABLE_LENGTH)return eq.processVariableAI(2,r[2],e);return eq.processFixedAI(2,r[1],e)}if(e.length<3)throw new W;let r=e.substring(0,3);for(let t of eq.THREE_DIGIT_DATA_LENGTH)if(t[0]===r){if(t[1]===eq.VARIABLE_LENGTH)return eq.processVariableAI(3,t[2],e);return eq.processFixedAI(3,t[1],e)}for(let t of eq.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(t[0]===r){if(t[1]===eq.VARIABLE_LENGTH)return eq.processVariableAI(4,t[2],e);return eq.processFixedAI(4,t[1],e)}if(e.length<4)throw new W;let n=e.substring(0,4);for(let t of eq.FOUR_DIGIT_DATA_LENGTH)if(t[0]===n){if(t[1]===eq.VARIABLE_LENGTH)return eq.processVariableAI(4,t[2],e);return eq.processFixedAI(4,t[1],e)}throw new W}static processFixedAI(e,t,r){if(r.lengththis.information.getSize())return e+4<=this.information.getSize();for(let t=e;tthis.information.getSize()){let t=this.extractNumericValueFromBitArray(e,4);return 0===t?new eK(this.information.getSize(),eK.FNC1,eK.FNC1):new eK(this.information.getSize(),t-1,eK.FNC1)}let t=this.extractNumericValueFromBitArray(e,7);return new eK(e+7,(t-8)/11,(t-8)%11)}extractNumericValueFromBitArray(e,t){return eJ.extractNumericValueFromBitArray(this.information,e,t)}static extractNumericValueFromBitArray(e,t,r){let n=0;for(let i=0;ithis.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+7>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,7);if(r>=64&&r<116)return!0;if(e+8>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,8);return n>=232&&n<253}decodeIsoIec646(e){let t,r=this.extractNumericValueFromBitArray(e,5);if(15===r)return new eZ(e+5,eZ.FNC1);if(r>=5&&r<15)return new eZ(e+5,"0"+(r-5));let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<90)return new eZ(e+7,""+(n+1));if(n>=90&&n<116)return new eZ(e+7,""+(n+7));switch(this.extractNumericValueFromBitArray(e,8)){case 232:t="!";break;case 233:t='"';break;case 234:t="%";break;case 235:t="&";break;case 236:t="'";break;case 237:t="(";break;case 238:t=")";break;case 239:t="*";break;case 240:t="+";break;case 241:t=",";break;case 242:t="-";break;case 243:t=".";break;case 244:t="/";break;case 245:t=":";break;case 246:t=";";break;case 247:t="<";break;case 248:t="=";break;case 249:t=">";break;case 250:t="?";break;case 251:t="_";break;case 252:t=" ";break;default:throw new U}return new eZ(e+8,t)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+6>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,6);return r>=16&&r<63}decodeAlphanumeric(e){let t,r=this.extractNumericValueFromBitArray(e,5);if(15===r)return new eZ(e+5,eZ.FNC1);if(r>=5&&r<15)return new eZ(e+5,"0"+(r-5));let n=this.extractNumericValueFromBitArray(e,6);if(n>=32&&n<58)return new eZ(e+6,""+(n+33));switch(n){case 58:t="*";break;case 59:t=",";break;case 60:t="-";break;case 61:t=".";break;case 62:t="/";break;default:throw new ec("Decoding invalid alphanumeric value: "+n)}return new eZ(e+6,t)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<5&&t+ethis.information.getSize())return!1;for(let t=e;tthis.information.getSize())return!1;for(let t=0;t<4&&t+e{t.forEach(t=>{e.getLeftChar().getValue()===t.getLeftChar().getValue()&&e.getRightChar().getValue()===t.getRightChar().getValue()&&e.getFinderPatter().getValue()===t.getFinderPatter().getValue()&&(r=!0)})}),r}}class tn extends eV{constructor(e){super(...arguments),this.pairs=Array(tn.MAX_PAIRS),this.rows=[],this.startEnd=[2],this.verbose=!0===e}decodeRow(e,t,r){this.pairs.length=0,this.startFromEven=!1;try{return tn.constructResult(this.decodeRow2pairs(e,t))}catch(e){this.verbose&&console.log(e)}return this.pairs.length=0,this.startFromEven=!0,tn.constructResult(this.decodeRow2pairs(e,t))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,t){let r,n=!1;for(;!n;)try{this.pairs.push(this.retrieveNextPair(t,this.pairs,e))}catch(e){if(e instanceof W){if(!this.pairs.length)throw new W;n=!0}}if(this.checkChecksum())return this.pairs;if(r=!!this.rows.length,this.storeRow(e,!1),r){let e=this.checkRowsBoolean(!1);if(null!=e||null!=(e=this.checkRowsBoolean(!0)))return e}throw new W}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let t=null;try{t=this.checkRows([],0)}catch(e){this.verbose&&console.log(e)}return e&&(this.rows=this.rows.reverse()),t}checkRows(e,t){for(let r=t;rt.length)continue;let r=!0;for(let n=0;ne){i=t.isEquivalent(this.pairs);break}n=t.isEquivalent(this.pairs),r++}i||n||tn.isPartialRow(this.pairs,this.rows)||(this.rows.push(r,new tr(this.pairs,e,t)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,t){for(let r of t)if(r.getPairs().length!==e.length){for(let t of r.getPairs())for(let r of e)if(tt.equals(t,r))break}}static isPartialRow(e,t){for(let r of t){let t=!0;for(let n of e){let e=!1;for(let t of r.getPairs())if(n.equals(t)){e=!0;break}if(!e){t=!1;break}}if(t)return!0}return!1}getRows(){return this.rows}static constructResult(e){let t=te(eX.buildBitArray(e)).parseInformation(),r=e[0].getFinderPattern().getResultPoints(),n=e[e.length-1].getFinderPattern().getResultPoints();return new et(t,null,null,[r[0],r[1],n[0],n[1]],er.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),t=e.getLeftChar(),r=e.getRightChar();if(null==r)return!1;let n=r.getChecksumPortion(),i=2;for(let e=1;e=0?r:this.isEmptyPair(t)?0:t[t.length-1].getFinderPattern().getStartEnd()[1];let s=t.length%2!=0;this.startFromEven&&(s=!s);let a=!1;for(;n=0&&!e.get(t);)t--;t++,n=this.startEnd[0]-t,i=t,o=this.startEnd[1]}else i=this.startEnd[0],n=(o=e.getNextUnset(this.startEnd[1]+1))-this.startEnd[1];let a=this.getDecodeFinderCounters();B.arraycopy(a,0,a,1,a.length-1),a[0]=n;try{s=this.parseFinderValue(a,tn.FINDER_PATTERNS)}catch(e){return null}return new eG(s,[i,o],i,o,t)}decodeDataCharacter(e,t,r,n){let i=this.getDataCharacterCounters();for(let e=0;e.3)throw new W;let a=this.getOddCounts(),l=this.getEvenCounts(),h=this.getOddRoundingErrors(),c=this.getEvenRoundingErrors();for(let e=0;e8){if(t>8.7)throw new W;r=8}let n=e/2;(1&e)==0?(a[n]=r,h[n]=t-r):(l[n]=r,c[n]=t-r)}this.adjustOddEvenCounts(17);let u=4*t.getValue()+(r?0:2)+(n?0:1)-1,d=0,f=0;for(let e=a.length-1;e>=0;e--){if(tn.isNotA1left(t,r,n)){let t=tn.WEIGHTS[u][2*e];f+=a[e]*t}d+=a[e]}let g=0;for(let e=l.length-1;e>=0;e--)if(tn.isNotA1left(t,r,n)){let t=tn.WEIGHTS[u][2*e+1];g+=l[e]*t}let w=f+g;if((1&d)!=0||d>13||d<4)throw new W;let m=(13-d)/2,p=tn.SYMBOL_WIDEST[m],A=eY.getRSSvalue(a,p,!0),C=eY.getRSSvalue(l,9-p,!1);return new ez(A*tn.EVEN_TOTAL_SUBSET[m]+C+tn.GSUM[m],w)}static isNotA1left(e,t,r){return!(0==e.getValue()&&t&&r)}adjustOddEvenCounts(e){let t=ef.sum(new Int32Array(this.getOddCounts())),r=ef.sum(new Int32Array(this.getEvenCounts())),n=!1,i=!1;t>13?i=!0:t<4&&(n=!0);let o=!1,s=!1;r>13?s=!0:r<4&&(o=!0);let a=t+r-e,l=(1&t)==1,h=(1&r)==0;if(1==a){if(l){if(h)throw new W;i=!0}else{if(!h)throw new W;s=!0}}else if(-1==a){if(l){if(h)throw new W;n=!0}else{if(!h)throw new W;o=!0}}else if(0==a){if(l){if(!h)throw new W;t1){for(let t of this.possibleRightPairs)if(t.getCount()>1&&to.checkChecksum(e,t))return to.constructResult(e,t)}throw new W}static addOrTally(e,t){if(null==t)return;let r=!1;for(let n of e)if(n.getValue()===t.getValue()){n.incrementCount(),r=!0;break}r||e.push(t)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,t){let r=new String(4537077*e.getValue()+t.getValue()).toString(),n=new Y;for(let e=13-r.length;e>0;e--)n.append("0");n.append(r);let i=0;for(let e=0;e<13;e++){let t=n.charAt(e).charCodeAt(0)-48;i+=(1&e)==0?3*t:t}10==(i=10-i%10)&&(i=0),n.append(i.toString());let o=e.getFinderPattern().getResultPoints(),s=t.getFinderPattern().getResultPoints();return new et(n.toString(),null,0,[o[0],o[1],s[0],s[1]],er.RSS_14,new Date().getTime())}static checkChecksum(e,t){let r=(e.getChecksumPortion()+16*t.getChecksumPortion())%79,n=9*e.getFinderPattern().getValue()+t.getFinderPattern().getValue();return n>72&&n--,n>8&&n--,r===n}decodePair(e,t,r,n){try{let i=this.findFinderPattern(e,t),o=this.parseFoundFinderPattern(e,r,t,i),s=null==n?null:n.get(k.NEED_RESULT_POINT_CALLBACK);if(null!=s){let n=(i[0]+i[1])/2;t&&(n=e.getSize()-1-n),s.foundPossibleResultPoint(new ew(n,r))}let a=this.decodeDataCharacter(e,o,!0),l=this.decodeDataCharacter(e,o,!1);return new ti(1597*a.getValue()+l.getValue(),a.getChecksumPortion()+4*l.getChecksumPortion(),o)}catch(e){return null}}decodeDataCharacter(e,t,r){let n=this.getDataCharacterCounters();for(let e=0;e8&&(r=8);let i=Math.floor(e/2);(1&e)==0?(s[i]=r,l[i]=t-r):(a[i]=r,h[i]=t-r)}this.adjustOddEvenCounts(r,i);let c=0,u=0;for(let e=s.length-1;e>=0;e--)u*=9,u+=s[e],c+=s[e];let d=0,f=0;for(let e=a.length-1;e>=0;e--)d*=9,d+=a[e],f+=a[e];let g=u+3*d;if(r){if((1&c)!=0||c>12||c<4)throw new W;let e=(12-c)/2,t=to.OUTSIDE_ODD_WIDEST[e],r=eY.getRSSvalue(s,t,!1),n=eY.getRSSvalue(a,9-t,!0);return new ez(r*to.OUTSIDE_EVEN_TOTAL_SUBSET[e]+n+to.OUTSIDE_GSUM[e],g)}{if((1&f)!=0||f>10||f<4)throw new W;let e=(10-f)/2,t=to.INSIDE_ODD_WIDEST[e],r=eY.getRSSvalue(s,t,!0);return new ez(eY.getRSSvalue(a,9-t,!1)*to.INSIDE_ODD_TOTAL_SUBSET[e]+r+to.INSIDE_GSUM[e],g)}}findFinderPattern(e,t){let r=this.getDecodeFinderCounters();r[0]=0,r[1]=0,r[2]=0,r[3]=0;let n=e.getSize(),i=!1,o=0;for(;o=0&&i!==e.get(o);)o--;o++;let s=n[0]-o,a=this.getDecodeFinderCounters(),l=new Int32Array(a.length);B.arraycopy(a,0,l,1,a.length-1),l[0]=s;let h=this.parseFinderValue(l,to.FINDER_PATTERNS),c=o,u=n[1];return r&&(c=e.getSize()-1-c,u=e.getSize()-1-u),new eG(h,[o,n[1]],c,u,t)}adjustOddEvenCounts(e,t){let r=ef.sum(new Int32Array(this.getOddCounts())),n=ef.sum(new Int32Array(this.getEvenCounts())),i=!1,o=!1,s=!1,a=!1;e?(r>12?o=!0:r<4&&(i=!0),n>12?a=!0:n<4&&(s=!0)):(r>11?o=!0:r<5&&(i=!0),n>10?a=!0:n<4&&(s=!0));let l=r+n-t,h=(1&r)==(e?1:0),c=(1&n)==1;if(1===l){if(h){if(c)throw new W;o=!0}else{if(!c)throw new W;a=!0}}else if(-1===l){if(h){if(c)throw new W;i=!0}else{if(!c)throw new W;s=!0}}else if(0===l){if(h){if(!c)throw new W;re.reset())}}class ta extends ee{constructor(e=500,t){super(new ts(t),e,t)}}class tl{constructor(e,t,r){this.ecCodewords=e,this.ecBlocks=[t],r&&this.ecBlocks.push(r)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class th{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class tc{constructor(e,t,r,n,i,o){this.versionNumber=e,this.symbolSizeRows=t,this.symbolSizeColumns=r,this.dataRegionSizeRows=n,this.dataRegionSizeColumns=i,this.ecBlocks=o;let s=0,a=o.getECCodewords();for(let e of o.getECBlocks())s+=e.getCount()*(e.getDataCodewords()+a);this.totalCodewords=s}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(e,t){if((1&e)!=0||(1&t)!=0)throw new U;for(let r of tc.VERSIONS)if(r.symbolSizeRows===e&&r.symbolSizeColumns===t)return r;throw new U}toString(){return""+this.versionNumber}static buildVersions(){return[new tc(1,10,10,8,8,new tl(5,new th(1,3))),new tc(2,12,12,10,10,new tl(7,new th(1,5))),new tc(3,14,14,12,12,new tl(10,new th(1,8))),new tc(4,16,16,14,14,new tl(12,new th(1,12))),new tc(5,18,18,16,16,new tl(14,new th(1,18))),new tc(6,20,20,18,18,new tl(18,new th(1,22))),new tc(7,22,22,20,20,new tl(20,new th(1,30))),new tc(8,24,24,22,22,new tl(24,new th(1,36))),new tc(9,26,26,24,24,new tl(28,new th(1,44))),new tc(10,32,32,14,14,new tl(36,new th(1,62))),new tc(11,36,36,16,16,new tl(42,new th(1,86))),new tc(12,40,40,18,18,new tl(48,new th(1,114))),new tc(13,44,44,20,20,new tl(56,new th(1,144))),new tc(14,48,48,22,22,new tl(68,new th(1,174))),new tc(15,52,52,24,24,new tl(42,new th(2,102))),new tc(16,64,64,14,14,new tl(56,new th(2,140))),new tc(17,72,72,16,16,new tl(36,new th(4,92))),new tc(18,80,80,18,18,new tl(48,new th(4,114))),new tc(19,88,88,20,20,new tl(56,new th(4,144))),new tc(20,96,96,22,22,new tl(68,new th(4,174))),new tc(21,104,104,24,24,new tl(56,new th(6,136))),new tc(22,120,120,18,18,new tl(68,new th(6,175))),new tc(23,132,132,20,20,new tl(62,new th(8,163))),new tc(24,144,144,22,22,new tl(62,new th(8,156),new th(2,155))),new tc(25,8,18,6,16,new tl(7,new th(1,5))),new tc(26,8,32,6,14,new tl(11,new th(1,10))),new tc(27,12,26,10,24,new tl(14,new th(1,16))),new tc(28,12,36,10,16,new tl(18,new th(1,22))),new tc(29,16,36,14,16,new tl(24,new th(1,32))),new tc(30,16,48,14,22,new tl(28,new th(1,49)))]}}tc.VERSIONS=tc.buildVersions();class tu{constructor(e){let t=e.getHeight();if(t<8||t>144||(1&t)!=0)throw new U;this.version=tu.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new X(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){let t=e.getHeight(),r=e.getWidth();return tc.getVersionForDimensions(t,r)}readCodewords(){let e=new Int8Array(this.version.getTotalCodewords()),t=0,r=4,n=0,i=this.mappingBitMatrix.getHeight(),o=this.mappingBitMatrix.getWidth(),s=!1,a=!1,l=!1,h=!1;do if(r!==i||0!==n||s){if(r!==i-2||0!==n||(3&o)==0||a){if(r!==i+4||2!==n||(7&o)!=0||l){if(r!==i-2||0!==n||(7&o)!=4||h){do r=0&&!this.readMappingMatrix.get(n,r)&&(e[t++]=255&this.readUtah(r,n,i,o)),r-=2,n+=2;while(r>=0&&n=0&&n=0);r+=3,n+=1}else e[t++]=255&this.readCorner4(i,o),r-=2,n+=2,h=!0}else e[t++]=255&this.readCorner3(i,o),r-=2,n+=2,l=!0}else e[t++]=255&this.readCorner2(i,o),r-=2,n+=2,a=!0}else e[t++]=255&this.readCorner1(i,o),r-=2,n+=2,s=!0;while(r7?t-1:t;o[n].codewords[i]=e[h++]}if(h!==e.length)throw new M;return o}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class tf{constructor(e){this.bytes=e,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(e){if(e<1||e>32||e>this.available())throw new M(""+e);let t=0,r=this.bitOffset,n=this.byteOffset,i=this.bytes;if(r>0){let o=8-r,s=e>8-s<>a,e-=s,8===(r+=s)&&(r=0,n++)}if(e>0){for(;e>=8;)t=t<<8|255&i[n],n++,e-=8;if(e>0){let o=8-e;t=t<>o<>o,r+=e}}return this.bitOffset=r,this.byteOffset=n,t}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}(a=A||(A={}))[a.PAD_ENCODE=0]="PAD_ENCODE",a[a.ASCII_ENCODE=1]="ASCII_ENCODE",a[a.C40_ENCODE=2]="C40_ENCODE",a[a.TEXT_ENCODE=3]="TEXT_ENCODE",a[a.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",a[a.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",a[a.BASE256_ENCODE=6]="BASE256_ENCODE";class tg{static decode(e){let t=new tf(e),r=new Y,n=new Y,i=[],o=A.ASCII_ENCODE;do if(o===A.ASCII_ENCODE)o=this.decodeAsciiSegment(t,r,n);else{switch(o){case A.C40_ENCODE:this.decodeC40Segment(t,r);break;case A.TEXT_ENCODE:this.decodeTextSegment(t,r);break;case A.ANSIX12_ENCODE:this.decodeAnsiX12Segment(t,r);break;case A.EDIFACT_ENCODE:this.decodeEdifactSegment(t,r);break;case A.BASE256_ENCODE:this.decodeBase256Segment(t,r,i);break;default:throw new U}o=A.ASCII_ENCODE}while(o!==A.PAD_ENCODE&&t.available()>0);return n.length()>0&&r.append(n.toString()),new ei(e,r.toString(),0===i.length?null:i,null)}static decodeAsciiSegment(e,t,r){let n=!1;do{let i=e.readBits(8);if(0===i)throw new U;if(i<=128){n&&(i+=128),t.append(String.fromCharCode(i-1));break}if(129===i)return A.PAD_ENCODE;if(i<=229){let e=i-130;e<10&&t.append("0"),t.append(""+e)}else switch(i){case 230:return A.C40_ENCODE;case 231:return A.BASE256_ENCODE;case 232:t.append("\x1d");break;case 233:case 234:case 241:break;case 235:n=!0;break;case 236:t.append("[)>\x1e05\x1d"),r.insert(0,"\x1e\x04");break;case 237:t.append("[)>\x1e06\x1d"),r.insert(0,"\x1e\x04");break;case 238:return A.ANSIX12_ENCODE;case 239:return A.TEXT_ENCODE;case 240:return A.EDIFACT_ENCODE;default:if(254!==i||0!==e.available())throw new U}}while(e.available()>0);return A.ASCII_ENCODE}static decodeC40Segment(e,t){let r=!1,n=[],i=0;do{if(8===e.available())return;let o=e.readBits(8);if(254===o)return;this.parseTwoBytes(o,e.readBits(8),n);for(let e=0;e<3;e++){let o=n[e];switch(i){case 0:if(o<3)i=o+1;else if(o0)}static decodeTextSegment(e,t){let r=!1,n=[],i=0;do{if(8===e.available())return;let o=e.readBits(8);if(254===o)return;this.parseTwoBytes(o,e.readBits(8),n);for(let e=0;e<3;e++){let o=n[e];switch(i){case 0:if(o<3)i=o+1;else if(o0)}static decodeAnsiX12Segment(e,t){let r=[];do{if(8===e.available())return;let n=e.readBits(8);if(254===n)return;this.parseTwoBytes(n,e.readBits(8),r);for(let e=0;e<3;e++){let n=r[e];switch(n){case 0:t.append("\r");break;case 1:t.append("*");break;case 2:t.append(">");break;case 3:t.append(" ");break;default:if(n<14)t.append(String.fromCharCode(n+44));else if(n<40)t.append(String.fromCharCode(n+51));else throw new U}}}while(e.available()>0)}static parseTwoBytes(e,t,r){let n=(e<<8)+t-1,i=Math.floor(n/1600);r[0]=i,n-=1600*i,i=Math.floor(n/40),r[1]=i,r[2]=n-40*i}static decodeEdifactSegment(e,t){do{if(16>=e.available())return;for(let r=0;r<4;r++){let r=e.readBits(6);if(31===r){let t=8-e.getBitOffset();8!==t&&e.readBits(t);return}(32&r)==0&&(r|=64),t.append(String.fromCharCode(r))}}while(e.available()>0)}static decodeBase256Segment(e,t,r){let n,i=1+e.getByteOffset(),o=this.unrandomize255State(e.readBits(8),i++);if((n=0===o?e.available()/8|0:o<250?o:250*(o-249)+this.unrandomize255State(e.readBits(8),i++))<0)throw new U;let s=new Uint8Array(n);for(let t=0;te.available())throw new U;s[t]=this.unrandomize255State(e.readBits(8),i++)}r.push(s);try{t.append(z.decode(s,G.ISO88591))}catch(e){throw new ec("Platform does not support required encoding: "+e.message)}}static unrandomize255State(e,t){let r=e-(149*t%255+1);return r>=0?r:r+256}}tg.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],tg.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],tg.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],tg.TEXT_SHIFT2_SET_CHARS=tg.C40_SHIFT2_SET_CHARS,tg.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~","\x7f"];class tw{constructor(){this.rsDecoder=new eu(el.DATA_MATRIX_FIELD_256)}decode(e){let t=new tu(e),r=t.getVersion(),n=t.readCodewords(),i=td.getDataBlocks(n,r),o=0;for(let e of i)o+=e.getNumDataCodewords();let s=new Uint8Array(o),a=i.length;for(let e=0;es&&(h=s,c[0]=t,c[1]=r,c[2]=n,c[3]=i),h>a&&(h=a,c[0]=r,c[1]=n,c[2]=i,c[3]=t),h>l&&(c[0]=n,c[1]=i,c[2]=t,c[3]=r),c}detectSolid2(e){let t=e[0],r=e[1],n=e[2],i=e[3],o=this.transitionsBetween(t,i),s=tm.shiftPoint(r,n,(o+1)*4),a=tm.shiftPoint(n,r,(o+1)*4);return this.transitionsBetween(s,t)this.transitionsBetween(a,c)+this.transitionsBetween(l,c)?h:c:h:this.isValid(c)?c:null}shiftToModuleCenter(e){let t,r,n=e[0],i=e[1],o=e[2],s=e[3],a=this.transitionsBetween(n,s)+1,l=this.transitionsBetween(o,s)+1,h=tm.shiftPoint(n,i,4*l),c=tm.shiftPoint(o,i,4*a);a=this.transitionsBetween(h,s)+1,l=this.transitionsBetween(c,s)+1,(1&a)==1&&(a+=1),(1&l)==1&&(l+=1);let u=(n.getX()+i.getX()+o.getX()+s.getX())/4,d=(n.getY()+i.getY()+o.getY()+s.getY())/4;return n=tm.moveAway(n,u,d),i=tm.moveAway(i,u,d),o=tm.moveAway(o,u,d),s=tm.moveAway(s,u,d),h=tm.shiftPoint(n,i,4*l),h=tm.shiftPoint(h,s,4*a),t=tm.shiftPoint(i,n,4*l),t=tm.shiftPoint(t,o,4*a),c=tm.shiftPoint(o,s,4*l),c=tm.shiftPoint(c,i,4*a),r=tm.shiftPoint(s,o,4*l),[h,t,c,r=tm.shiftPoint(r,n,4*a)]}isValid(e){return e.getX()>=0&&e.getX()0&&e.getY()Math.abs(i-r);if(s){let e=r;r=n,n=e,e=i,i=o,o=e}let a=Math.abs(i-r),l=Math.abs(o-n),h=-a/2,c=n0){if(t===o)break;t+=c,h-=a}}return d}}class tp{constructor(){this.decoder=new tw}decode(e,t=null){let r,n;if(null!=t&&t.has(k.PURE_BARCODE)){let t=tp.extractPureBits(e.getBlackMatrix());r=this.decoder.decode(t),n=tp.NO_POINTS}else{let t=new tm(e.getBlackMatrix()).detect();r=this.decoder.decode(t.getBits()),n=t.getPoints()}let i=r.getRawBytes(),o=new et(r.getText(),i,8*i.length,n,er.DATA_MATRIX,B.currentTimeMillis()),s=r.getByteSegments();null!=s&&o.putMetadata(en.BYTE_SEGMENTS,s);let a=r.getECLevel();return null!=a&&o.putMetadata(en.ERROR_CORRECTION_LEVEL,a),o}reset(){}static extractPureBits(e){let t=e.getTopLeftOnBit(),r=e.getBottomRightOnBit();if(null==t||null==r)throw new W;let n=this.moduleSize(t,e),i=t[1],o=r[1],s=t[0],a=(r[0]-s+1)/n,l=(o-i+1)/n;if(a<=0||l<=0)throw new W;let h=n/2;i+=h,s+=h;let c=new X(a,l);for(let t=0;t=tC.FOR_BITS.size)throw new M;return tC.FOR_BITS.get(e)}}tC.FOR_BITS=new Map,tC.FOR_VALUE=new Map,tC.L=new tC(C.L,"L",1),tC.M=new tC(C.M,"M",0),tC.Q=new tC(C.Q,"Q",3),tC.H=new tC(C.H,"H",2);class tE{constructor(e){this.errorCorrectionLevel=tC.forBits(e>>3&3),this.dataMask=7&e}static numBitsDiffering(e,t){return F.bitCount(e^t)}static decodeFormatInformation(e,t){let r=tE.doDecodeFormatInformation(e,t);return null!==r?r:tE.doDecodeFormatInformation(e^tE.FORMAT_INFO_MASK_QR,t^tE.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,t){let r=Number.MAX_SAFE_INTEGER,n=0;for(let i of tE.FORMAT_INFO_DECODE_LOOKUP){let o=i[0];if(o===e||o===t)return new tE(i[1]);let s=tE.numBitsDiffering(e,o);s40)throw new M;return t_.VERSIONS[e-1]}static decodeVersionInformation(e){let t=Number.MAX_SAFE_INTEGER,r=0;for(let n=0;n6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t}toString(){return""+this.versionNumber}}t_.VERSION_DECODE_INFO=Int32Array.from([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]),t_.VERSIONS=[new t_(1,new Int32Array(0),new tI(7,new tS(1,19)),new tI(10,new tS(1,16)),new tI(13,new tS(1,13)),new tI(17,new tS(1,9))),new t_(2,Int32Array.from([6,18]),new tI(10,new tS(1,34)),new tI(16,new tS(1,28)),new tI(22,new tS(1,22)),new tI(28,new tS(1,16))),new t_(3,Int32Array.from([6,22]),new tI(15,new tS(1,55)),new tI(26,new tS(1,44)),new tI(18,new tS(2,17)),new tI(22,new tS(2,13))),new t_(4,Int32Array.from([6,26]),new tI(20,new tS(1,80)),new tI(18,new tS(2,32)),new tI(26,new tS(2,24)),new tI(16,new tS(4,9))),new t_(5,Int32Array.from([6,30]),new tI(26,new tS(1,108)),new tI(24,new tS(2,43)),new tI(18,new tS(2,15),new tS(2,16)),new tI(22,new tS(2,11),new tS(2,12))),new t_(6,Int32Array.from([6,34]),new tI(18,new tS(2,68)),new tI(16,new tS(4,27)),new tI(24,new tS(4,19)),new tI(28,new tS(4,15))),new t_(7,Int32Array.from([6,22,38]),new tI(20,new tS(2,78)),new tI(18,new tS(4,31)),new tI(18,new tS(2,14),new tS(4,15)),new tI(26,new tS(4,13),new tS(1,14))),new t_(8,Int32Array.from([6,24,42]),new tI(24,new tS(2,97)),new tI(22,new tS(2,38),new tS(2,39)),new tI(22,new tS(4,18),new tS(2,19)),new tI(26,new tS(4,14),new tS(2,15))),new t_(9,Int32Array.from([6,26,46]),new tI(30,new tS(2,116)),new tI(22,new tS(3,36),new tS(2,37)),new tI(20,new tS(4,16),new tS(4,17)),new tI(24,new tS(4,12),new tS(4,13))),new t_(10,Int32Array.from([6,28,50]),new tI(18,new tS(2,68),new tS(2,69)),new tI(26,new tS(4,43),new tS(1,44)),new tI(24,new tS(6,19),new tS(2,20)),new tI(28,new tS(6,15),new tS(2,16))),new t_(11,Int32Array.from([6,30,54]),new tI(20,new tS(4,81)),new tI(30,new tS(1,50),new tS(4,51)),new tI(28,new tS(4,22),new tS(4,23)),new tI(24,new tS(3,12),new tS(8,13))),new t_(12,Int32Array.from([6,32,58]),new tI(24,new tS(2,92),new tS(2,93)),new tI(22,new tS(6,36),new tS(2,37)),new tI(26,new tS(4,20),new tS(6,21)),new tI(28,new tS(7,14),new tS(4,15))),new t_(13,Int32Array.from([6,34,62]),new tI(26,new tS(4,107)),new tI(22,new tS(8,37),new tS(1,38)),new tI(24,new tS(8,20),new tS(4,21)),new tI(22,new tS(12,11),new tS(4,12))),new t_(14,Int32Array.from([6,26,46,66]),new tI(30,new tS(3,115),new tS(1,116)),new tI(24,new tS(4,40),new tS(5,41)),new tI(20,new tS(11,16),new tS(5,17)),new tI(24,new tS(11,12),new tS(5,13))),new t_(15,Int32Array.from([6,26,48,70]),new tI(22,new tS(5,87),new tS(1,88)),new tI(24,new tS(5,41),new tS(5,42)),new tI(30,new tS(5,24),new tS(7,25)),new tI(24,new tS(11,12),new tS(7,13))),new t_(16,Int32Array.from([6,26,50,74]),new tI(24,new tS(5,98),new tS(1,99)),new tI(28,new tS(7,45),new tS(3,46)),new tI(24,new tS(15,19),new tS(2,20)),new tI(30,new tS(3,15),new tS(13,16))),new t_(17,Int32Array.from([6,30,54,78]),new tI(28,new tS(1,107),new tS(5,108)),new tI(28,new tS(10,46),new tS(1,47)),new tI(28,new tS(1,22),new tS(15,23)),new tI(28,new tS(2,14),new tS(17,15))),new t_(18,Int32Array.from([6,30,56,82]),new tI(30,new tS(5,120),new tS(1,121)),new tI(26,new tS(9,43),new tS(4,44)),new tI(28,new tS(17,22),new tS(1,23)),new tI(28,new tS(2,14),new tS(19,15))),new t_(19,Int32Array.from([6,30,58,86]),new tI(28,new tS(3,113),new tS(4,114)),new tI(26,new tS(3,44),new tS(11,45)),new tI(26,new tS(17,21),new tS(4,22)),new tI(26,new tS(9,13),new tS(16,14))),new t_(20,Int32Array.from([6,34,62,90]),new tI(28,new tS(3,107),new tS(5,108)),new tI(26,new tS(3,41),new tS(13,42)),new tI(30,new tS(15,24),new tS(5,25)),new tI(28,new tS(15,15),new tS(10,16))),new t_(21,Int32Array.from([6,28,50,72,94]),new tI(28,new tS(4,116),new tS(4,117)),new tI(26,new tS(17,42)),new tI(28,new tS(17,22),new tS(6,23)),new tI(30,new tS(19,16),new tS(6,17))),new t_(22,Int32Array.from([6,26,50,74,98]),new tI(28,new tS(2,111),new tS(7,112)),new tI(28,new tS(17,46)),new tI(30,new tS(7,24),new tS(16,25)),new tI(24,new tS(34,13))),new t_(23,Int32Array.from([6,30,54,78,102]),new tI(30,new tS(4,121),new tS(5,122)),new tI(28,new tS(4,47),new tS(14,48)),new tI(30,new tS(11,24),new tS(14,25)),new tI(30,new tS(16,15),new tS(14,16))),new t_(24,Int32Array.from([6,28,54,80,106]),new tI(30,new tS(6,117),new tS(4,118)),new tI(28,new tS(6,45),new tS(14,46)),new tI(30,new tS(11,24),new tS(16,25)),new tI(30,new tS(30,16),new tS(2,17))),new t_(25,Int32Array.from([6,32,58,84,110]),new tI(26,new tS(8,106),new tS(4,107)),new tI(28,new tS(8,47),new tS(13,48)),new tI(30,new tS(7,24),new tS(22,25)),new tI(30,new tS(22,15),new tS(13,16))),new t_(26,Int32Array.from([6,30,58,86,114]),new tI(28,new tS(10,114),new tS(2,115)),new tI(28,new tS(19,46),new tS(4,47)),new tI(28,new tS(28,22),new tS(6,23)),new tI(30,new tS(33,16),new tS(4,17))),new t_(27,Int32Array.from([6,34,62,90,118]),new tI(30,new tS(8,122),new tS(4,123)),new tI(28,new tS(22,45),new tS(3,46)),new tI(30,new tS(8,23),new tS(26,24)),new tI(30,new tS(12,15),new tS(28,16))),new t_(28,Int32Array.from([6,26,50,74,98,122]),new tI(30,new tS(3,117),new tS(10,118)),new tI(28,new tS(3,45),new tS(23,46)),new tI(30,new tS(4,24),new tS(31,25)),new tI(30,new tS(11,15),new tS(31,16))),new t_(29,Int32Array.from([6,30,54,78,102,126]),new tI(30,new tS(7,116),new tS(7,117)),new tI(28,new tS(21,45),new tS(7,46)),new tI(30,new tS(1,23),new tS(37,24)),new tI(30,new tS(19,15),new tS(26,16))),new t_(30,Int32Array.from([6,26,52,78,104,130]),new tI(30,new tS(5,115),new tS(10,116)),new tI(28,new tS(19,47),new tS(10,48)),new tI(30,new tS(15,24),new tS(25,25)),new tI(30,new tS(23,15),new tS(25,16))),new t_(31,Int32Array.from([6,30,56,82,108,134]),new tI(30,new tS(13,115),new tS(3,116)),new tI(28,new tS(2,46),new tS(29,47)),new tI(30,new tS(42,24),new tS(1,25)),new tI(30,new tS(23,15),new tS(28,16))),new t_(32,Int32Array.from([6,34,60,86,112,138]),new tI(30,new tS(17,115)),new tI(28,new tS(10,46),new tS(23,47)),new tI(30,new tS(10,24),new tS(35,25)),new tI(30,new tS(19,15),new tS(35,16))),new t_(33,Int32Array.from([6,30,58,86,114,142]),new tI(30,new tS(17,115),new tS(1,116)),new tI(28,new tS(14,46),new tS(21,47)),new tI(30,new tS(29,24),new tS(19,25)),new tI(30,new tS(11,15),new tS(46,16))),new t_(34,Int32Array.from([6,34,62,90,118,146]),new tI(30,new tS(13,115),new tS(6,116)),new tI(28,new tS(14,46),new tS(23,47)),new tI(30,new tS(44,24),new tS(7,25)),new tI(30,new tS(59,16),new tS(1,17))),new t_(35,Int32Array.from([6,30,54,78,102,126,150]),new tI(30,new tS(12,121),new tS(7,122)),new tI(28,new tS(12,47),new tS(26,48)),new tI(30,new tS(39,24),new tS(14,25)),new tI(30,new tS(22,15),new tS(41,16))),new t_(36,Int32Array.from([6,24,50,76,102,128,154]),new tI(30,new tS(6,121),new tS(14,122)),new tI(28,new tS(6,47),new tS(34,48)),new tI(30,new tS(46,24),new tS(10,25)),new tI(30,new tS(2,15),new tS(64,16))),new t_(37,Int32Array.from([6,28,54,80,106,132,158]),new tI(30,new tS(17,122),new tS(4,123)),new tI(28,new tS(29,46),new tS(14,47)),new tI(30,new tS(49,24),new tS(10,25)),new tI(30,new tS(24,15),new tS(46,16))),new t_(38,Int32Array.from([6,32,58,84,110,136,162]),new tI(30,new tS(4,122),new tS(18,123)),new tI(28,new tS(13,46),new tS(32,47)),new tI(30,new tS(48,24),new tS(14,25)),new tI(30,new tS(42,15),new tS(32,16))),new t_(39,Int32Array.from([6,26,54,82,110,138,166]),new tI(30,new tS(20,117),new tS(4,118)),new tI(28,new tS(40,47),new tS(7,48)),new tI(30,new tS(43,24),new tS(22,25)),new tI(30,new tS(10,15),new tS(67,16))),new t_(40,Int32Array.from([6,30,58,86,114,142,170]),new tI(30,new tS(19,118),new tS(6,119)),new tI(28,new tS(18,47),new tS(31,48)),new tI(30,new tS(34,24),new tS(34,25)),new tI(30,new tS(20,15),new tS(61,16)))],(h=E||(E={}))[h.DATA_MASK_000=0]="DATA_MASK_000",h[h.DATA_MASK_001=1]="DATA_MASK_001",h[h.DATA_MASK_010=2]="DATA_MASK_010",h[h.DATA_MASK_011=3]="DATA_MASK_011",h[h.DATA_MASK_100=4]="DATA_MASK_100",h[h.DATA_MASK_101=5]="DATA_MASK_101",h[h.DATA_MASK_110=6]="DATA_MASK_110",h[h.DATA_MASK_111=7]="DATA_MASK_111";class tT{constructor(e,t){this.value=e,this.isMasked=t}unmaskBitMatrix(e,t){for(let r=0;r(e+t&1)==0)],[E.DATA_MASK_001,new tT(E.DATA_MASK_001,(e,t)=>(1&e)==0)],[E.DATA_MASK_010,new tT(E.DATA_MASK_010,(e,t)=>t%3==0)],[E.DATA_MASK_011,new tT(E.DATA_MASK_011,(e,t)=>(e+t)%3==0)],[E.DATA_MASK_100,new tT(E.DATA_MASK_100,(e,t)=>(Math.floor(e/2)+Math.floor(t/3)&1)==0)],[E.DATA_MASK_101,new tT(E.DATA_MASK_101,(e,t)=>e*t%6==0)],[E.DATA_MASK_110,new tT(E.DATA_MASK_110,(e,t)=>e*t%6<3)],[E.DATA_MASK_111,new tT(E.DATA_MASK_111,(e,t)=>(e+t+e*t%3&1)==0)]]);class ty{constructor(e){let t=e.getHeight();if(t<21||(3&t)!=1)throw new U;this.bitMatrix=e}readFormatInformation(){if(null!==this.parsedFormatInfo&&void 0!==this.parsedFormatInfo)return this.parsedFormatInfo;let e=0;for(let t=0;t<6;t++)e=this.copyBit(t,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let t=5;t>=0;t--)e=this.copyBit(8,t,e);let t=this.bitMatrix.getHeight(),r=0,n=t-7;for(let e=t-1;e>=n;e--)r=this.copyBit(8,e,r);for(let e=t-8;e=0;t--)for(let i=e-9;i>=n;i--)r=this.copyBit(i,t,r);let i=t_.decodeVersionInformation(r);if(null!==i&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;r=0;for(let t=5;t>=0;t--)for(let i=e-9;i>=n;i--)r=this.copyBit(t,i,r);if(null!==(i=t_.decodeVersionInformation(r))&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;throw new U}copyBit(e,t,r){return(this.isMirror?this.bitMatrix.get(t,e):this.bitMatrix.get(e,t))?r<<1|1:r<<1}readCodewords(){let e=this.readFormatInformation(),t=this.readVersion(),r=tT.values.get(e.getDataMask()),n=this.bitMatrix.getHeight();r.unmaskBitMatrix(this.bitMatrix,n);let i=t.buildFunctionPattern(),o=!0,s=new Uint8Array(t.getTotalCodewords()),a=0,l=0,h=0;for(let e=n-1;e>0;e-=2){6===e&&e--;for(let t=0;t=0&&s[h].codewords.length!==l;)h--;h++;let c=l-n.getECCodewordsPerBlock(),u=0;for(let t=0;ti.available())e=tD.TERMINATOR;else{let t=i.readBits(4);e=tD.forBits(t)}switch(e){case tD.TERMINATOR:break;case tD.FNC1_FIRST_POSITION:case tD.FNC1_SECOND_POSITION:h=!0;break;case tD.STRUCTURED_APPEND:if(16>i.available())throw new U;a=i.readBits(8),l=i.readBits(8);break;case tD.ECI:let c=tM.parseECIValue(i);if(r=H.getCharacterSetECIByValue(c),null===r)throw new U;break;case tD.HANZI:let u=i.readBits(4),d=i.readBits(e.getCharacterCountBits(t));u===tM.GB2312_SUBSET&&tM.decodeHanziSegment(i,o,d);break;default:let f=i.readBits(e.getCharacterCountBits(t));switch(e){case tD.NUMERIC:tM.decodeNumericSegment(i,o,f);break;case tD.ALPHANUMERIC:tM.decodeAlphanumericSegment(i,o,f,h);break;case tD.BYTE:tM.decodeByteSegment(i,o,f,r,s,n);break;case tD.KANJI:tM.decodeKanjiSegment(i,o,f);break;default:throw new U}}}while(e!==tD.TERMINATOR)}catch(e){throw new U}return new ei(e,o.toString(),0===s.length?null:s,null===r?null:r.toString(),a,l)}static decodeHanziSegment(e,t,r){if(13*r>e.available())throw new U;let n=new Uint8Array(2*r),i=0;for(;r>0;){let t=e.readBits(13),o=t/96<<8&4294967295|t%96;o<959?o+=41377:o+=42657,n[i]=o>>8&255,n[i+1]=255&o,i+=2,r--}try{t.append(z.decode(n,G.GB2312))}catch(e){throw new U(e)}}static decodeKanjiSegment(e,t,r){if(13*r>e.available())throw new U;let n=new Uint8Array(2*r),i=0;for(;r>0;){let t=e.readBits(13),o=t/192<<8&4294967295|t%192;o<7936?o+=33088:o+=49472,n[i]=o>>8,n[i+1]=o,i+=2,r--}try{t.append(z.decode(n,G.SHIFT_JIS))}catch(e){throw new U(e)}}static decodeByteSegment(e,t,r,n,i,o){let s;if(8*r>e.available())throw new U;let a=new Uint8Array(r);for(let t=0;t=tM.ALPHANUMERIC_CHARS.length)throw new U;return tM.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,t,r,n){let i=t.length();for(;r>1;){if(11>e.available())throw new U;let n=e.readBits(11);t.append(tM.toAlphaNumericChar(Math.floor(n/45))),t.append(tM.toAlphaNumericChar(n%45)),r-=2}if(1===r){if(6>e.available())throw new U;t.append(tM.toAlphaNumericChar(e.readBits(6)))}if(n)for(let e=i;e=3;){if(10>e.available())throw new U;let n=e.readBits(10);if(n>=1e3)throw new U;t.append(tM.toAlphaNumericChar(Math.floor(n/100))),t.append(tM.toAlphaNumericChar(Math.floor(n/10)%10)),t.append(tM.toAlphaNumericChar(n%10)),r-=3}if(2===r){if(7>e.available())throw new U;let r=e.readBits(7);if(r>=100)throw new U;t.append(tM.toAlphaNumericChar(Math.floor(r/10))),t.append(tM.toAlphaNumericChar(r%10))}else if(1===r){if(4>e.available())throw new U;let r=e.readBits(4);if(r>=10)throw new U;t.append(tM.toAlphaNumericChar(r))}}static parseECIValue(e){let t=e.readBits(8);if((128&t)==0)return 127&t;if((192&t)==128)return(63&t)<<8&4294967295|e.readBits(8);if((224&t)==192)return(31&t)<<16&4294967295|e.readBits(16);throw new U}}tM.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",tM.GB2312_SUBSET=1;class tR{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||null===e||e.length<3)return;let t=e[0];e[0]=e[2],e[2]=t}}class tO{constructor(){this.rsDecoder=new eu(el.QR_CODE_FIELD_256)}decodeBooleanArray(e,t){return this.decodeBitMatrix(X.parseFromBooleanArray(e),t)}decodeBitMatrix(e,t){let r=new ty(e),n=null;try{return this.decodeBitMatrixParser(r,t)}catch(e){n=e}try{r.remask(),r.setMirror(!0),r.readVersion(),r.readFormatInformation(),r.mirror();let e=this.decodeBitMatrixParser(r,t);return e.setOther(new tR(!0)),e}catch(e){if(null!==n)throw n;throw e}}decodeBitMatrixParser(e,t){let r=e.readVersion(),n=e.readFormatInformation().getErrorCorrectionLevel(),i=e.readCodewords(),o=tN.getDataBlocks(i,r,n),s=0;for(let e of o)s+=e.getNumDataCodewords();let a=new Uint8Array(s),l=0;for(let e of o){let t=e.getCodewords(),r=e.getNumDataCodewords();this.correctErrors(t,r);for(let e=0;e=r)return!1;return!0}crossCheckVertical(e,t,r,n){let i=this.image,o=i.getHeight(),s=this.crossCheckStateCount;s[0]=0,s[1]=0,s[2]=0;let a=e;for(;a>=0&&i.get(t,a)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&!i.get(t,a)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=e+1;ar)return NaN;for(;ar||5*Math.abs(s[0]+s[1]+s[2]-n)>=2*n?NaN:this.foundPatternCross(s)?tB.centerFromEnd(s,a):NaN}handlePossibleCenter(e,t,r){let n=e[0]+e[1]+e[2],i=tB.centerFromEnd(e,r),o=this.crossCheckVertical(t,i,2*e[1],n);if(!isNaN(o)){let t=(e[0]+e[1]+e[2])/3;for(let e of this.possibleCenters)if(e.aboutEquals(t,o,i))return e.combineEstimate(o,i,t);let r=new tb(i,o,t);this.possibleCenters.push(r),null!==this.resultPointCallback&&void 0!==this.resultPointCallback&&this.resultPointCallback.foundPossibleResultPoint(r)}return null}}class tL extends ew{constructor(e,t,r,n){super(e,t),this.estimatedModuleSize=r,this.count=n,void 0===n&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,t,r){if(Math.abs(t-this.getY())<=e&&Math.abs(r-this.getX())<=e){let t=Math.abs(e-this.estimatedModuleSize);return t<=1||t<=this.estimatedModuleSize}return!1}combineEstimate(e,t,r){let n=this.count+1;return new tL((this.count*this.getX()+t)/n,(this.count*this.getY()+e)/n,(this.count*this.estimatedModuleSize+r)/n,n)}}class tP{constructor(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class tv{constructor(e,t){this.image=e,this.resultPointCallback=t,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=t}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(e){let t=null!=e&&void 0!==e.get(k.TRY_HARDER),r=null!=e&&void 0!==e.get(k.PURE_BARCODE),n=this.image,i=n.getHeight(),o=n.getWidth(),s=Math.floor(3*i/(4*tv.MAX_MODULES));(sl[2]&&(e+=t-l[2]-s,i=o-1)}}else{l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,t=3;continue}t=0,l[0]=0,l[1]=0,l[2]=0,l[3]=0,l[4]=0}else l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,t=3}else l[++t]++}else l[t]++;tv.foundPatternCross(l)&&!0===this.handlePossibleCenter(l,e,o,r)&&(s=l[0],this.hasSkipped&&(a=this.haveMultiplyConfirmedCenters()))}let h=this.selectBestPatterns();return ew.orderBestPatterns(h),new tP(h)}static centerFromEnd(e,t){return t-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let t=0;for(let r=0;r<5;r++){let n=e[r];if(0===n)return!1;t+=n}if(t<7)return!1;let r=t/7,n=r/2;return Math.abs(r-e[0])=o&&t>=o&&s.get(t-o,e-o);)i[2]++,o++;if(e=o&&t>=o&&!s.get(t-o,e-o)&&i[1]<=r;)i[1]++,o++;if(er)return!1;for(;e>=o&&t>=o&&s.get(t-o,e-o)&&i[0]<=r;)i[0]++,o++;if(i[0]>r)return!1;let a=s.getHeight(),l=s.getWidth();for(o=1;e+o=a||t+o>=l)return!1;for(;e+o=a||t+o>=l||i[3]>=r)return!1;for(;e+o=r)&&Math.abs(i[0]+i[1]+i[2]+i[3]+i[4]-n)<2*n&&tv.foundPatternCross(i)}crossCheckVertical(e,t,r,n){let i=this.image,o=i.getHeight(),s=this.getCrossCheckStateCount(),a=e;for(;a>=0&&i.get(t,a);)s[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(t,a)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&i.get(t,a)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=e+1;a=r)return NaN;for(;a=r||5*Math.abs(s[0]+s[1]+s[2]+s[3]+s[4]-n)>=2*n?NaN:tv.foundPatternCross(s)?tv.centerFromEnd(s,a):NaN}crossCheckHorizontal(e,t,r,n){let i=this.image,o=i.getWidth(),s=this.getCrossCheckStateCount(),a=e;for(;a>=0&&i.get(a,t);)s[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(a,t)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&i.get(a,t)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=e+1;a=r)return NaN;for(;a=r||5*Math.abs(s[0]+s[1]+s[2]+s[3]+s[4]-n)>=n?NaN:tv.foundPatternCross(s)?tv.centerFromEnd(s,a):NaN}handlePossibleCenter(e,t,r,n){let i=e[0]+e[1]+e[2]+e[3]+e[4],o=tv.centerFromEnd(e,r),s=this.crossCheckVertical(t,Math.floor(o),e[2],i);if(!isNaN(s)&&!isNaN(o=this.crossCheckHorizontal(Math.floor(o),Math.floor(s),e[2],i))&&(!n||this.crossCheckDiagonal(Math.floor(s),Math.floor(o),e[2],i))){let e=i/7,t=!1,r=this.possibleCenters;for(let n=0,i=r.length;n=tv.CENTER_QUORUM){if(null!=e)return this.hasSkipped=!0,Math.floor((Math.abs(e.getX()-t.getX())-Math.abs(e.getY()-t.getY()))/2);e=t}return 0}haveMultiplyConfirmedCenters(){let e=0,t=0,r=this.possibleCenters.length;for(let r of this.possibleCenters)r.getCount()>=tv.CENTER_QUORUM&&(e++,t+=r.getEstimatedModuleSize());if(e<3)return!1;let n=t/r,i=0;for(let e of this.possibleCenters)i+=Math.abs(e.getEstimatedModuleSize()-n);return i<=.05*t}selectBestPatterns(){let e;let t=this.possibleCenters.length;if(t<3)throw new W;let r=this.possibleCenters;if(t>3){let n=0,i=0;for(let e of this.possibleCenters){let t=e.getEstimatedModuleSize();n+=t,i+=t*t}e=n/t;let o=Math.sqrt(i/t-e*e);r.sort((t,r)=>{let n=Math.abs(r.getEstimatedModuleSize()-e),i=Math.abs(t.getEstimatedModuleSize()-e);return ni?1:0});let s=Math.max(.2*e,o);for(let t=0;t3;t++)Math.abs(r[t].getEstimatedModuleSize()-e)>s&&(r.splice(t,1),t--)}if(r.length>3){let t=0;for(let e of r)t+=e.getEstimatedModuleSize();e=t/r.length,r.sort((t,r)=>{if(r.getCount()!==t.getCount())return r.getCount()-t.getCount();{let n=Math.abs(r.getEstimatedModuleSize()-e),i=Math.abs(t.getEstimatedModuleSize()-e);return ni?-1:0}}),r.splice(3)}return[r[0],r[1],r[2]]}}tv.CENTER_QUORUM=2,tv.MIN_SKIP=3,tv.MAX_MODULES=57;class tF{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=null==e?null:e.get(k.NEED_RESULT_POINT_CALLBACK);let t=new tv(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(t)}processFinderPatternInfo(e){let t=e.getTopLeft(),r=e.getTopRight(),n=e.getBottomLeft(),i=this.calculateModuleSize(t,r,n);if(i<1)throw new W("No pattern found in proccess finder.");let o=tF.computeDimension(t,r,n,i),s=t_.getProvisionalVersionForDimension(o),a=s.getDimensionForVersion()-7,l=null;if(s.getAlignmentPatternCenters().length>0){let e=r.getX()-t.getX()+n.getX(),o=r.getY()-t.getY()+n.getY(),s=1-3/a,h=Math.floor(t.getX()+s*(e-t.getX())),c=Math.floor(t.getY()+s*(o-t.getY()));for(let e=4;e<=16;e<<=1)try{l=this.findAlignmentInRegion(i,h,c,e);break}catch(e){if(!(e instanceof W))throw e}}let h=tF.createTransform(t,r,n,l,o);return new em(tF.sampleGrid(this.image,h,o),null===l?[n,t,r]:[n,t,r,l])}static createTransform(e,t,r,n,i){let o,s,a,l;let h=i-3.5;return null!==n?(o=n.getX(),s=n.getY(),l=a=h-3):(o=t.getX()-e.getX()+r.getX(),s=t.getY()-e.getY()+r.getY(),a=h,l=h),eE.quadrilateralToQuadrilateral(3.5,3.5,h,3.5,a,l,3.5,h,e.getX(),e.getY(),t.getX(),t.getY(),o,s,r.getX(),r.getY())}static sampleGrid(e,t,r){return eS.getInstance().sampleGridWithTransform(e,r,r,t)}static computeDimension(e,t,r,n){let i=Math.floor((ef.round(ew.distance(e,t)/n)+ef.round(ew.distance(e,r)/n))/2)+7;switch(3&i){case 0:i++;break;case 2:i--;break;case 3:throw new W("Dimensions could be not found.")}return i}calculateModuleSize(e,t,r){return(this.calculateModuleSizeOneWay(e,t)+this.calculateModuleSizeOneWay(e,r))/2}calculateModuleSizeOneWay(e,t){let r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY())),n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(r)?n/7:isNaN(n)?r/7:(r+n)/14}sizeOfBlackWhiteBlackRunBothWays(e,t,r,n){let i=this.sizeOfBlackWhiteBlackRun(e,t,r,n),o=1,s=e-(r-e);s<0?(o=e/(e-s),s=0):s>=this.image.getWidth()&&(o=(this.image.getWidth()-1-e)/(s-e),s=this.image.getWidth()-1);let a=Math.floor(t-(n-t)*o);return o=1,a<0?(o=t/(t-a),a=0):a>=this.image.getHeight()&&(o=(this.image.getHeight()-1-t)/(a-t),a=this.image.getHeight()-1),s=Math.floor(e+(s-e)*o),(i+=this.sizeOfBlackWhiteBlackRun(e,t,s,a))-1}sizeOfBlackWhiteBlackRun(e,t,r,n){let i=Math.abs(n-t)>Math.abs(r-e);if(i){let i=e;e=t,t=i,i=r,r=n,n=i}let o=Math.abs(r-e),s=Math.abs(n-t),a=-o/2,l=e0){if(d===n)break;d+=h,a-=o}}return 2===c?ef.distance(r+l,n,e,t):NaN}findAlignmentInRegion(e,t,r,n){let i=Math.floor(n*e),o=Math.max(0,t-i),s=Math.min(this.image.getWidth()-1,t+i);if(s-o<3*e)throw new W("Alignment top exceeds estimated module size.");let a=Math.max(0,r-i),l=Math.min(this.image.getHeight()-1,r+i);if(l-a<3*e)throw new W("Alignment bottom exceeds estimated module size.");return new tB(this.image,o,a,s-o,l-a,e,this.resultPointCallback).find()}}class tx{constructor(){this.decoder=new tO}getDecoder(){return this.decoder}decode(e,t){let r,n;if(null!=t&&void 0!==t.get(k.PURE_BARCODE)){let i=tx.extractPureBits(e.getBlackMatrix());r=this.decoder.decodeBitMatrix(i,t),n=tx.NO_POINTS}else{let i=new tF(e.getBlackMatrix()).detect(t);r=this.decoder.decodeBitMatrix(i.getBits(),t),n=i.getPoints()}r.getOther() instanceof tR&&r.getOther().applyMirroredCorrection(n);let i=new et(r.getText(),r.getRawBytes(),void 0,n,er.QR_CODE,void 0),o=r.getByteSegments();null!==o&&i.putMetadata(en.BYTE_SEGMENTS,o);let s=r.getECLevel();return null!==s&&i.putMetadata(en.ERROR_CORRECTION_LEVEL,s),r.hasStructuredAppend()&&(i.putMetadata(en.STRUCTURED_APPEND_SEQUENCE,r.getStructuredAppendSequenceNumber()),i.putMetadata(en.STRUCTURED_APPEND_PARITY,r.getStructuredAppendParity())),i}reset(){}static extractPureBits(e){let t=e.getTopLeftOnBit(),r=e.getBottomRightOnBit();if(null===t||null===r)throw new W;let n=this.moduleSize(t,e),i=t[1],o=r[1],s=t[0],a=r[0];if(s>=a||i>=o||o-i!=a-s&&(a=s+(o-i))>=e.getWidth())throw new W;let l=Math.round((a-s+1)/n),h=Math.round((o-i+1)/n);if(l<=0||h<=0||h!==l)throw new W;let c=Math.floor(n/2);i+=c;let u=(s+=c)+Math.floor((l-1)*n)-a;if(u>0){if(u>c)throw new W;s-=u}let d=i+Math.floor((h-1)*n)-o;if(d>0){if(d>c)throw new W;i-=d}let f=new X(l,h);for(let t=0;t0;){let s=tH.findGuardPattern(e,i,--n,r,!1,o,l);if(null!=s)t=s;else{n++;break}}s[0]=new ew(t[0],n),s[1]=new ew(t[1],n),a=!0;break}}let h=n+1;if(a){let n=0,i=Int32Array.from([Math.trunc(s[0].getX()),Math.trunc(s[1].getX())]);for(;htH.SKIPPED_ROW_COUNT_MAX)break;n++}}h-=n+1,s[2]=new ew(i[0],h),s[3]=new ew(i[1],h)}return h-n0&&l++o?n-o:o-n;if(l>r)return 1/0;a+=l}return a/i}}tH.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),tH.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),tH.MAX_AVG_VARIANCE=.42,tH.MAX_INDIVIDUAL_VARIANCE=.8,tH.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),tH.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),tH.MAX_PIXEL_DRIFT=3,tH.MAX_PATTERN_DRIFT=5,tH.SKIPPED_ROW_COUNT_MAX=25,tH.ROW_STEP=5,tH.BARCODE_MIN_HEIGHT=10;class tV{constructor(e,t){if(0===t.length)throw new M;this.field=e;let r=t.length;if(r>1&&0===t[0]){let e=1;for(;er.length){let e=t;t=r,r=e}let n=new Int32Array(r.length),i=r.length-t.length;B.arraycopy(r,0,n,0,i);for(let e=i;e=0;t--){let r=this.getCoefficient(t);0!==r&&(r<0?(e.append(" - "),r=-r):e.length()>0&&e.append(" + "),(0===t||1!==r)&&e.append(r),0!==t&&(1===t?e.append("x"):(e.append("x^"),e.append(t))))}return e.toString()}}class tz{add(e,t){return(e+t)%this.modulus}subtract(e,t){return(this.modulus+e-t)%this.modulus}exp(e){return this.expTable[e]}log(e){if(0===e)throw new M;return this.logTable[e]}inverse(e){if(0===e)throw new ea;return this.expTable[this.modulus-this.logTable[e]-1]}multiply(e,t){return 0===e||0===t?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.modulus-1)]}getSize(){return this.modulus}equals(e){return e===this}}class tG extends tz{constructor(e,t){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let r=1;for(let n=0;n0;e--){let r=n.evaluateAt(this.field.exp(e));i[t-e]=r,0!==r&&(o=!0)}if(!o)return 0;let s=this.field.getOne();if(null!=r)for(let t of r){let r=this.field.exp(e.length-1-t),n=new tV(this.field,new Int32Array([this.field.subtract(0,r),1]));s=s.multiply(n)}let a=new tV(this.field,i),l=this.runEuclideanAlgorithm(this.field.buildMonomial(t,1),a,t),h=l[0],c=l[1],u=this.findErrorLocations(h),d=this.findErrorMagnitudes(c,h,u);for(let t=0;t=Math.round(r/2);){let e=n,t=o;if(n=i,o=s,n.isZero())throw O.getChecksumInstance();i=e;let r=this.field.getZero(),a=n.getCoefficient(n.getDegree()),l=this.field.inverse(a);for(;i.getDegree()>=n.getDegree()&&!i.isZero();){let e=i.getDegree()-n.getDegree(),t=this.field.multiply(i.getCoefficient(i.getDegree()),l);r=r.add(this.field.buildMonomial(e,t)),i=i.subtract(n.multiplyByMonomial(e,t))}s=r.multiply(o).subtract(t).negative()}let a=s.getCoefficient(0);if(0===a)throw O.getChecksumInstance();let l=this.field.inverse(a);return[s.multiply(l),i.multiply(l)]}findErrorLocations(e){let t=e.getDegree(),r=new Int32Array(t),n=0;for(let i=1;i0){let t=r?this.topLeft:this.topRight,i=Math.trunc(t.getY()-e);i<0&&(i=0);let s=new ew(t.getX(),i);r?n=s:o=s}if(t>0){let e=r?this.bottomLeft:this.bottomRight,n=Math.trunc(e.getY()+t);n>=this.image.getHeight()&&(n=this.image.getHeight()-1);let o=new ew(e.getX(),n);r?i=o:s=o}return new tX(this.image,n,i,o,s)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class tW{constructor(e,t,r,n){this.columnCount=e,this.errorCorrectionLevel=n,this.rowCountUpperPart=t,this.rowCountLowerPart=r,this.rowCount=t+r}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class tj{constructor(){this.buffer=""}static form(e,t){let r=-1;return e.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g,function(e,n,i,o,s,a){let l;if("%%"===e)return"%";if(void 0===t[++r])return;e=o?parseInt(o.substr(1)):void 0;let h=s?parseInt(s.substr(1)):void 0;switch(a){case"s":l=t[r];break;case"c":l=t[r][0];break;case"f":l=parseFloat(t[r]).toFixed(e);break;case"p":l=parseFloat(t[r]).toPrecision(e);break;case"e":l=parseFloat(t[r]).toExponential(e);break;case"x":l=parseInt(t[r]).toString(h||16);break;case"d":l=parseFloat(parseInt(t[r],h||10).toPrecision(e)).toFixed(0)}l="object"==typeof l?JSON.stringify(l):(+l).toString(h);let c=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;l.length=0&&null!=(t=this.codewords[n])||(n=this.imageRowToCodewordIndex(e)+r)r,getValue:()=>n};i.getValue()>e?(e=i.getValue(),(t=[]).push(i.getKey())):i.getValue()===e&&t.push(i.getKey())}return tk.toIntArray(t)}getConfidence(e){return this.values.get(e)}}class tK extends tZ{constructor(e,t){super(e),this._isLeft=t}setRowNumbers(){for(let e of this.getCodewords())null!=e&&e.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let t=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(t,e);let r=this.getBoundingBox(),n=this._isLeft?r.getTopLeft():r.getTopRight(),i=this._isLeft?r.getBottomLeft():r.getBottomRight(),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.imageRowToCodewordIndex(Math.trunc(i.getY())),a=-1,l=1,h=0;for(let r=o;r=e.getRowCount()||i>r)t[r]=null;else{let e;let o=(e=l>2?(l-2)*i:i)>=r;for(let n=1;n<=e&&!o;n++)o=null!=t[r-n];o?t[r]=null:(a=n.getRowNumber(),h=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(null==e)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let t=new Int32Array(e.getRowCount());for(let e of this.getCodewords())if(null!=e){let r=e.getRowNumber();if(r>=t.length)continue;t[r]++}return t}adjustIncompleteIndicatorColumnRowNumbers(e){let t=this.getBoundingBox(),r=this._isLeft?t.getTopLeft():t.getTopRight(),n=this._isLeft?t.getBottomLeft():t.getBottomRight(),i=this.imageRowToCodewordIndex(Math.trunc(r.getY())),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.getCodewords(),a=-1;for(let t=i;t=e.getRowCount()?s[t]=null:a=r.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),t=new tQ,r=new tQ,n=new tQ,i=new tQ;for(let o of e){if(null==o)continue;o.setRowNumberAsRowIndicatorColumn();let e=o.getValue()%30,s=o.getRowNumber();switch(this._isLeft||(s+=2),s%3){case 0:r.setValue(3*e+1);break;case 1:i.setValue(e/3),n.setValue(e%3);break;case 2:t.setValue(e+1)}}if(0===t.getValue().length||0===r.getValue().length||0===n.getValue().length||0===i.getValue().length||t.getValue()[0]<1||r.getValue()[0]+n.getValue()[0]tk.MAX_ROWS_IN_BARCODE)return null;let o=new tW(t.getValue()[0],r.getValue()[0],n.getValue()[0],i.getValue()[0]);return this.removeIncorrectCodewords(e,o),o}removeIncorrectCodewords(e,t){for(let r=0;rt.getRowCount()){e[r]=null;continue}switch(this._isLeft||(o+=2),o%3){case 0:3*i+1!==t.getRowCountUpperPart()&&(e[r]=null);break;case 1:(Math.trunc(i/3)!==t.getErrorCorrectionLevel()||i%3!==t.getRowCountLowerPart())&&(e[r]=null);break;case 2:i+1!==t.getColumnCount()&&(e[r]=null)}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+"\n"+super.toString()}}class tq{constructor(e,t){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=e,this.barcodeColumnCount=e.getColumnCount(),this.boundingBox=t,this.detectionResultColumns=Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){let e;this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let t=tk.MAX_CODEWORDS_IN_BARCODE;do e=t,t=this.adjustRowNumbersAndGetCount();while(t>0&&t0&&i0&&(s[0]=r[t-1],s[4]=i[t-1],s[5]=o[t-1]),t>1&&(s[8]=r[t-2],s[10]=i[t-2],s[11]=o[t-2]),t>=1;r=1&t,t$.RATIOS_TABLE[e]||(t$.RATIOS_TABLE[e]=Array(tk.BARS_IN_MODULE)),t$.RATIOS_TABLE[e][tk.BARS_IN_MODULE-n-1]=Math.fround(i/tk.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let t=t$.getDecodedCodewordValue(t$.sampleBitCounts(e));return -1!==t?t:t$.getClosestDecodedValue(e)}static sampleBitCounts(e){let t=ef.sum(e),r=new Int32Array(tk.BARS_IN_MODULE),n=0,i=0;for(let o=0;o1)for(let n=0;n=n)break}tArray(tk.BARS_IN_MODULE));class t1{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(e){this.segmentIndex=e}getFileId(){return this.fileId}setFileId(e){this.fileId=e}getOptionalData(){return this.optionalData}setOptionalData(e){this.optionalData=e}isLastSegment(){return this.lastSegment}setLastSegment(e){this.lastSegment=e}getSegmentCount(){return this.segmentCount}setSegmentCount(e){this.segmentCount=e}getSender(){return this.sender||null}setSender(e){this.sender=e}getAddressee(){return this.addressee||null}setAddressee(e){this.addressee=e}getFileName(){return this.fileName}setFileName(e){this.fileName=e}getFileSize(){return this.fileSize}setFileSize(e){this.fileSize=e}getChecksum(){return this.checksum}setChecksum(e){this.checksum=e}getTimestamp(){return this.timestamp}setTimestamp(e){this.timestamp=e}}class t2{static parseLong(e,t){return parseInt(e,t)}}class t0 extends N{}t0.kind="NullPointerException";class t3{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,t,r){if(null==e)throw new t0;if(t<0||t>e.length||r<0||t+r>e.length||t+r<0)throw new L;if(0!==r)for(let n=0;n0&&this.grow(e)}grow(e){let t=this.buf.length<<1;if(t-e<0&&(t=e),t<0){if(e<0)throw new t4;t=F.MAX_VALUE}this.buf=v.copyOfUint8Array(this.buf,t)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,t,r){if(t<0||t>e.length||r<0||t+r-e.length>0)throw new L;this.ensureCapacity(this.count+r),B.arraycopy(e,t,this.buf,this.count,r),this.count+=r}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return v.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(e){return e?"string"==typeof e?this.toString_string(e):this.toString_number(e):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(e){return new String(this.buf).toString()}toString_number(e){return new String(this.buf).toString()}close(){}}function t6(){if("undefined"!=typeof window)return window.BigInt||null;if("undefined"!=typeof global)return global.BigInt||null;if("undefined"!=typeof self)return self.BigInt||null;throw Error("Can't search globals for BigInt!")}function t5(e){if(void 0===t&&(t=t6()),null===t)throw Error("BigInt is not supported!");return t(e)}(u=S||(S={}))[u.ALPHA=0]="ALPHA",u[u.LOWER=1]="LOWER",u[u.MIXED=2]="MIXED",u[u.PUNCT=3]="PUNCT",u[u.ALPHA_SHIFT=4]="ALPHA_SHIFT",u[u.PUNCT_SHIFT=5]="PUNCT_SHIFT";class t7{static decode(e,t){let r=new Y(""),n=H.ISO8859_1;r.enableDecoding(n);let i=1,o=e[i++],s=new t1;for(;ie[0])throw U.getFormatInstance();let n=new Int32Array(t7.NUMBER_OF_SEQUENCE_CODEWORDS);for(let r=0;r0){for(let e=0;e<6;++e)o.write(Number(t5(a)>>t5(8*(5-e))));a=0,s=0}}n===t[0]&&c0){for(let e=0;e<6;++e)o.write(Number(t5(a)>>t5(8*(5-e))));a=0,s=0}}}return i.append(z.decode(o.toByteArray(),r)),n}static numericCompaction(e,t,r){let n=0,i=!1,o=new Int32Array(t7.MAX_NUMERIC_CODEWORDS);for(;t0&&(r.append(t7.decodeBase900toBase10(o,n)),n=0)}return t}static decodeBase900toBase10(e,t){let r=t5(0);for(let n=0;n@[\\]_`~!\r ,:\n-.$/\"|*()?{}'",t7.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",t7.EXP900=t6()?function(){let e=[];e[0]=t5(1);let t=t5(900);e[1]=t;for(let r=2;r<16;r++)e[r]=e[r-1]*t;return e}():[],t7.NUMBER_OF_SEQUENCE_CODEWORDS=2;class t9{constructor(){}static decode(e,t,r,n,i,o,s){let a,l=new tX(e,t,r,n,i),h=null,c=null;for(let r=!0;;r=!1){if(null!=t&&(h=t9.getRowIndicatorColumn(e,l,t,!0,o,s)),null!=n&&(c=t9.getRowIndicatorColumn(e,l,n,!1,o,s)),null==(a=t9.merge(h,c)))throw W.getNotFoundInstance();let i=a.getBoundingBox();if(r&&null!=i&&(i.getMinY()l.getMaxY()))l=i;else break}a.setBoundingBox(l);let u=a.getBarcodeColumnCount()+1;a.setDetectionResultColumn(0,h),a.setDetectionResultColumn(u,c);let d=null!=h;for(let t=1;t<=u;t++){let r,n=d?t:u-t;if(void 0!==a.getDetectionResultColumn(n))continue;r=0===n||n===u?new tK(l,0===n):new tZ(l),a.setDetectionResultColumn(n,r);let i=-1,h=-1;for(let t=l.getMinY();t<=l.getMaxY();t++){if((i=t9.getStartColumn(a,n,t,d))<0||i>l.getMaxX()){if(-1===h)continue;i=h}let c=t9.detectCodeword(e,l.getMinX(),l.getMaxX(),d,i,t,o,s);null!=c&&(r.setCodeword(t,c),h=i,o=Math.min(o,c.getWidth()),s=Math.max(s,c.getWidth()))}}return t9.createDecoderResult(a)}static merge(e,t){if(null==e&&null==t)return null;let r=t9.getBarcodeMetadata(e,t);return null==r?null:new tq(r,tX.merge(t9.adjustBoundingBox(e),t9.adjustBoundingBox(t)))}static adjustBoundingBox(e){if(null==e)return null;let t=e.getRowHeights();if(null==t)return null;let r=t9.getMax(t),n=0;for(let e of t)if(n+=r-e,e>0)break;let i=e.getCodewords();for(let e=0;n>0&&null==i[e];e++)n--;let o=0;for(let e=t.length-1;e>=0&&(o+=r-t[e],!(t[e]>0));e--);for(let e=i.length-1;o>0&&null==i[e];e--)o--;return e.getBoundingBox().addMissingRows(n,o,e.isLeft())}static getMax(e){let t=-1;for(let r of e)t=Math.max(t,r);return t}static getBarcodeMetadata(e,t){let r,n;return null==e||null==(r=e.getBarcodeMetadata())?null==t?null:t.getBarcodeMetadata():null==t||null==(n=t.getBarcodeMetadata())?r:r.getColumnCount()!==n.getColumnCount()&&r.getErrorCorrectionLevel()!==n.getErrorCorrectionLevel()&&r.getRowCount()!==n.getRowCount()?null:r}static getRowIndicatorColumn(e,t,r,n,i,o){let s=new tK(t,n);for(let a=0;a<2;a++){let l=0===a?1:-1,h=Math.trunc(Math.trunc(r.getX()));for(let a=Math.trunc(Math.trunc(r.getY()));a<=t.getMaxY()&&a>=t.getMinY();a+=l){let t=t9.detectCodeword(e,0,e.getWidth(),n,h,a,i,o);null!=t&&(s.setCodeword(a,t),h=n?t.getStartX():t.getEndX())}}return s}static adjustCodewordCount(e,t){let r=t[0][1],n=r.getValue(),i=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-t9.getNumberOfECCodeWords(e.getBarcodeECLevel());if(0===n.length){if(i<1||i>tk.MAX_CODEWORDS_IN_BARCODE)throw W.getNotFoundInstance();r.setValue(i)}else n[0]!==i&&r.setValue(i)}static createDecoderResult(e){let t=t9.createBarcodeMatrix(e);t9.adjustCodewordCount(e,t);let r=[],n=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),i=[],o=[];for(let s=0;s0;){for(let e=0;eArray(e.getBarcodeColumnCount()+2));for(let e=0;e=0){if(n>=t.length)continue;t[n][r].setValue(e.getValue())}}}r++}return t}static isValidBarcodeColumn(e,t){return t>=0&&t<=e.getBarcodeColumnCount()+1}static getStartColumn(e,t,r,n){let i=n?1:-1,o=null;if(t9.isValidBarcodeColumn(e,t-i)&&(o=e.getDetectionResultColumn(t-i).getCodeword(r)),null!=o)return n?o.getEndX():o.getStartX();if(null!=(o=e.getDetectionResultColumn(t).getCodewordNearby(r)))return n?o.getStartX():o.getEndX();if(t9.isValidBarcodeColumn(e,t-i)&&(o=e.getDetectionResultColumn(t-i).getCodewordNearby(r)),null!=o)return n?o.getEndX():o.getStartX();let s=0;for(;t9.isValidBarcodeColumn(e,t-i);){for(let r of(t-=i,e.getDetectionResultColumn(t).getCodewords()))if(null!=r)return(n?r.getEndX():r.getStartX())+i*s*(r.getEndX()-r.getStartX());s++}return n?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,t,r,n,i,o,s,a){let l;i=t9.adjustCodewordStartColumn(e,t,r,n,i,o);let h=t9.getModuleBitCount(e,t,r,n,i,o);if(null==h)return null;let c=ef.sum(h);if(n)l=i+c;else{for(let e=0;e=t)&&l=t:st9.CODEWORD_SKEW_SIZE)return i;s+=a}a=-a,n=!n}return s}static checkCodewordSkew(e,t,r){return t-t9.CODEWORD_SKEW_SIZE<=e&&e<=r+t9.CODEWORD_SKEW_SIZE}static decodeCodewords(e,t,r){if(0===e.length)throw U.getFormatInstance();let n=1<r/2+t9.MAX_ERRORS||r<0||r>t9.MAX_EC_CODEWORDS)throw O.getChecksumInstance();return t9.errorCorrection.decode(e,r,t)}static verifyCodewordCount(e,t){if(e.length<4)throw U.getFormatInstance();let r=e[0];if(r>e.length)throw U.getFormatInstance();if(0===r){if(t>=1;return t}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return t9.getCodewordBucketNumber(t9.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let t=new tj;for(let r=0;re)}static getMaxWidth(e,t){return null==e||null==t?0:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMinWidth(e,t){return null==e||null==t?F.MAX_VALUE:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(re.getMaxWidth(e[0],e[4]),re.getMaxWidth(e[6],e[2])*tk.MODULES_IN_CODEWORD/tk.MODULES_IN_STOP_PATTERN),Math.max(re.getMaxWidth(e[1],e[5]),re.getMaxWidth(e[7],e[3])*tk.MODULES_IN_CODEWORD/tk.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(re.getMinWidth(e[0],e[4]),re.getMinWidth(e[6],e[2])*tk.MODULES_IN_CODEWORD/tk.MODULES_IN_STOP_PATTERN),Math.min(re.getMinWidth(e[1],e[5]),re.getMinWidth(e[7],e[3])*tk.MODULES_IN_CODEWORD/tk.MODULES_IN_STOP_PATTERN)))}reset(){}}class rt extends N{}rt.kind="ReaderException";class rr{constructor(e,t){this.verbose=!0===e,t&&this.setHints(t)}decode(e,t){return t&&this.setHints(t),this.decodeInternal(e)}decodeWithState(e){return(null===this.readers||void 0===this.readers)&&this.setHints(null),this.decodeInternal(e)}setHints(e){this.hints=e;let t=null!=e&&!0===e.get(k.TRY_HARDER),r=null==e?null:e.get(k.POSSIBLE_FORMATS),n=[];if(null!=r){let i=r.some(e=>e===er.UPC_A||e===er.UPC_E||e===er.EAN_13||e===er.EAN_8||e===er.CODABAR||e===er.CODE_39||e===er.CODE_93||e===er.CODE_128||e===er.ITF||e===er.RSS_14||e===er.RSS_EXPANDED);i&&!t&&n.push(new ts(e,this.verbose)),r.includes(er.QR_CODE)&&n.push(new tx),r.includes(er.DATA_MATRIX)&&n.push(new tp),r.includes(er.AZTEC)&&n.push(new ey),r.includes(er.PDF_417)&&n.push(new re),i&&t&&n.push(new ts(e,this.verbose))}0===n.length&&(t||n.push(new ts(e,this.verbose)),n.push(new tx),n.push(new tp),n.push(new ey),n.push(new re),t&&n.push(new ts(e,this.verbose))),this.readers=n}reset(){if(null!==this.readers)for(let e of this.readers)e.reset()}decodeInternal(e){if(null===this.readers)throw new rt("No readers where selected, nothing can be read.");for(let t of this.readers)try{return t.decode(e,this.hints)}catch(e){if(e instanceof rt)continue}throw new W("No MultiFormat Readers were able to detect the code.")}}class rn extends ee{constructor(e=null,t=500){let r=new rr;r.setHints(e),super(r,t)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class ri extends ee{constructor(e=500){super(new re,e)}}class ro extends ee{constructor(e=500){super(new tx,e)}}(d=_||(_={}))[d.ERROR_CORRECTION=0]="ERROR_CORRECTION",d[d.CHARACTER_SET=1]="CHARACTER_SET",d[d.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",d[d.MIN_SIZE=3]="MIN_SIZE",d[d.MAX_SIZE=4]="MAX_SIZE",d[d.MARGIN=5]="MARGIN",d[d.PDF417_COMPACT=6]="PDF417_COMPACT",d[d.PDF417_COMPACTION=7]="PDF417_COMPACTION",d[d.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",d[d.AZTEC_LAYERS=9]="AZTEC_LAYERS",d[d.QR_VERSION=10]="QR_VERSION";var rs=_;class ra{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new es(e,Int32Array.from([1])))}buildGenerator(e){let t=this.cachedGenerators;if(e>=t.length){let r=t[t.length-1],n=this.field;for(let i=t.length;i<=e;i++){let e=r.multiply(new es(n,Int32Array.from([1,n.exp(i-1+n.getGeneratorBase())])));t.push(e),r=e}}return t[e]}encode(e,t){if(0===t)throw new M("No error correction bytes");let r=e.length-t;if(r<=0)throw new M("No data bytes provided");let n=this.buildGenerator(t),i=new Int32Array(r);B.arraycopy(e,0,i,0,r);let o=new es(this.field,i),s=(o=o.multiplyByMonomial(t,1)).divide(n)[1].getCoefficients(),a=t-s.length;for(let t=0;t=5&&(r+=rl.N1+(n-5)),n=1,s=i)}n>=5&&(r+=rl.N1+(n-5))}return r}}rl.N1=3,rl.N2=3,rl.N3=40,rl.N4=10;class rh{constructor(e,t){this.width=e,this.height=t;let r=Array(t);for(let n=0;n!==t;n++)r[n]=new Uint8Array(e);this.bytes=r}getHeight(){return this.height}getWidth(){return this.width}get(e,t){return this.bytes[t][e]}getArray(){return this.bytes}setNumber(e,t,r){this.bytes[t][e]=r}setBoolean(e,t,r){this.bytes[t][e]=r?1:0}clear(e){for(let t of this.bytes)v.fill(t,e)}equals(e){if(!(e instanceof rh)||this.width!==e.width||this.height!==e.height)return!1;for(let t=0,r=this.height;t>\n"),e.toString()}setMode(e){this.mode=e}setECLevel(e){this.ecLevel=e}setVersion(e){this.version=e}setMaskPattern(e){this.maskPattern=e}setMatrix(e){this.matrix=e}static isValidMaskPattern(e){return e>=0&&ee.getVersionNumber())return;let r=new x;rd.makeVersionInfoBits(e,r);let n=17;for(let e=0;e<6;++e)for(let i=0;i<3;++i){let o=r.get(n);n--,t.setBoolean(e,t.getHeight()-11+i,o),t.setBoolean(t.getHeight()-11+i,e,o)}}static embedDataBits(e,t,r){let n=0,i=-1,o=r.getWidth()-1,s=r.getHeight()-1;for(;o>0;){for(6===o&&(o-=1);s>=0&&s=r;)e^=t<e.getVersionNumber())return;let r=e.getVersionNumber()-1,n=rd.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[r];for(let e=0,r=n.length;e!==r;e++){let i=n[e];if(i>=0)for(let e=0;e!==r;e++){let r=n[e];r>=0&&rd.isEmpty(t.get(r,i))&&rd.embedPositionAdjustmentPattern(r-2,i-2,t)}}}}rd.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),rd.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),rd.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),rd.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),rd.VERSION_INFO_POLY=7973,rd.TYPE_INFO_POLY=1335,rd.TYPE_INFO_MASK_PATTERN=21522;class rf{constructor(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class rg{constructor(){}static calculateMaskPenalty(e){return rl.applyMaskPenaltyRule1(e)+rl.applyMaskPenaltyRule2(e)+rl.applyMaskPenaltyRule3(e)+rl.applyMaskPenaltyRule4(e)}static encode(e,t,r=null){let n,i=rg.DEFAULT_BYTE_MODE_ENCODING,o=null!==r&&void 0!==r.get(rs.CHARACTER_SET);o&&(i=r.get(rs.CHARACTER_SET).toString());let s=this.chooseMode(e,i),a=new x;if(s===tD.BYTE&&(o||rg.DEFAULT_BYTE_MODE_ENCODING!==i)){let e=H.getCharacterSetECIByName(i);void 0!==e&&this.appendECI(e,a)}this.appendModeInfo(s,a);let l=new x;if(this.appendBytes(e,s,l,i),null!==r&&void 0!==r.get(rs.QR_VERSION)){let e=Number.parseInt(r.get(rs.QR_VERSION).toString(),10);n=t_.getVersionForNumber(e);let i=this.calculateBitsNeeded(s,a,l,n);if(!this.willFit(i,n,t))throw new ru("Data too big for requested version")}else n=this.recommendVersion(t,s,a,l);let h=new x;h.appendBitArray(a);let c=s===tD.BYTE?l.getSizeInBytes():e.length;this.appendLengthInfo(c,n,s,h),h.appendBitArray(l);let u=n.getECBlocksForLevel(t),d=n.getTotalCodewords()-u.getTotalECCodewords();this.terminateBits(d,h);let f=this.interleaveWithECBytes(h,n.getTotalCodewords(),d,u.getNumBlocks()),g=new rc;g.setECLevel(t),g.setMode(s),g.setVersion(n);let w=n.getDimensionForVersion(),m=new rh(w,w),p=this.chooseMaskPattern(f,t,n,m);return g.setMaskPattern(p),rd.buildMatrix(f,t,n,p,m),g.setMatrix(m),g}static recommendVersion(e,t,r,n){let i=this.calculateBitsNeeded(t,r,n,t_.getVersionForNumber(1)),o=this.chooseVersion(i,e),s=this.calculateBitsNeeded(t,r,n,o);return this.chooseVersion(s,e)}static calculateBitsNeeded(e,t,r,n){return t.getSize()+e.getCharacterCountBits(n)+r.getSize()}static getAlphanumericCode(e){return e159)&&(r<224||r>235))return!1}return!0}static chooseMaskPattern(e,t,r,n){let i=Number.MAX_SAFE_INTEGER,o=-1;for(let s=0;s=(e+7)/8}static terminateBits(e,t){let r=8*e;if(t.getSize()>r)throw new ru("data bits cannot fit in the QR Code"+t.getSize()+" > "+r);for(let e=0;e<4&&t.getSize()0)for(let e=n;e<8;e++)t.appendBit(!1);let i=e-t.getSizeInBytes();for(let e=0;e=r)throw new ru("Block ID too large");let s=e%r,a=r-s,l=Math.floor(e/r),h=Math.floor(t/r),c=h+1,u=l-h,d=l+1-c;if(u!==d)throw new ru("EC bytes mismatch");if(r!==a+s)throw new ru("RS blocks mismatch");if(e!==(h+u)*a+(c+d)*s)throw new ru("Total bytes mismatch");n=1<=0&&t<=9}static appendNumericBytes(e,t){let r=e.length,n=0;for(;n=33088&&n<=40956?i=n-33088:n>=57408&&n<=60351&&(i=n-49472),-1===i)throw new ru("Invalid byte sequence");let o=(i>>8)*192+(255&i);t.appendBits(o,13)}}static appendECI(e,t){t.appendBits(tD.ECI.getBits(),4),t.appendBits(e.getValue(),8)}}rg.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),rg.DEFAULT_BYTE_MODE_ENCODING=H.UTF8.getName();class rw{write(e,t,r,n=null){if(0===e.length)throw new M("Found empty contents");if(t<0||r<0)throw new M("Requested dimensions are too small: "+t+"x"+r);let i=tC.L,o=rw.QUIET_ZONE_SIZE;null!==n&&(void 0!==n.get(rs.ERROR_CORRECTION)&&(i=tC.fromString(n.get(rs.ERROR_CORRECTION).toString())),void 0!==n.get(rs.MARGIN)&&(o=Number.parseInt(n.get(rs.MARGIN).toString(),10)));let s=rg.encode(e,i,n);return this.renderResult(s,t,r,o)}writeToDom(e,t,r,n,i=null){"string"==typeof e&&(e=document.querySelector(e));let o=this.write(t,r,n,i);e&&e.appendChild(o)}renderResult(e,t,r,n){let i=e.getMatrix();if(null===i)throw new ec;let o=i.getWidth(),s=i.getHeight(),a=o+2*n,l=s+2*n,h=Math.max(t,a),c=Math.max(r,l),u=Math.min(Math.floor(h/a),Math.floor(c/l)),d=Math.floor((h-o*u)/2),f=Math.floor((c-s*u)/2),g=this.createSVGElement(h,c);for(let e=0,t=f;et||i+s>r)throw new M("Crop rectangle does not fit within image data.");a&&this.reverseHorizontal(o,s)}getRow(e,t){if(e<0||e>=this.getHeight())throw new M("Requested row is outside the image: "+e);let r=this.getWidth();(null==t||t.length>16&255,o=r>>7&510,s=255&r;i[t]=(n+o+s)/4&255}this.luminances=i}else this.luminances=e;if(void 0===n&&(this.dataWidth=t),void 0===i&&(this.dataHeight=r),void 0===o&&(this.left=0),void 0===s&&(this.top=0),this.left+t>this.dataWidth||this.top+r>this.dataHeight)throw new M("Crop rectangle does not fit within image data.")}getRow(e,t){if(e<0||e>=this.getHeight())throw new M("Requested row is outside the image: "+e);let r=this.getWidth();(null==t||t.length"}}class rN extends ry{constructor(e,t,r){super(e,0,0),this.binaryShiftStart=t,this.binaryShiftByteCount=r}appendTo(e,t){for(let r=0;r62?e.appendBits(this.binaryShiftByteCount-31,16):0===r?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(t[this.binaryShiftStart+r],8)}addBinaryShift(e,t){return new rN(this,e,t)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function rD(e,t,r){return new ry(e,t,r)}let rM=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],rR=new ry(null,0,0),rO=[Int32Array.from([0,327708,327710,327709,656318]),Int32Array.from([590318,0,327710,327709,656318]),Int32Array.from([262158,590300,0,590301,932798]),Int32Array.from([327709,327708,656318,0,327710]),Int32Array.from([327711,656380,656382,656381,0])],rb=function(e){for(let t of e)v.fill(t,-1);return e[0][4]=0,e[1][4]=0,e[1][0]=28,e[3][4]=0,e[2][4]=0,e[2][0]=15,e}(v.createInt32Array(6,6));class rB{constructor(e,t,r,n){this.token=e,this.mode=t,this.binaryShiftByteCount=r,this.bitCount=n}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,t){let r=this.bitCount,n=this.token;if(e!==this.mode){let t=rO[this.mode][e];n=rD(n,65535&t,t>>16),r+=t>>16}let i=2===e?4:5;return new rB(n=rD(n,t,i),e,0,r+i)}shiftAndAppend(e,t){let r=this.token,n=2===this.mode?4:5;return r=rD(r,rb[this.mode][e],n),new rB(r=rD(r,t,5),this.mode,0,this.bitCount+n+5)}addBinaryShiftChar(e){let t=this.token,r=this.mode,n=this.bitCount;if(4===this.mode||2===this.mode){let e=rO[r][0];t=rD(t,65535&e,e>>16),n+=e>>16,r=0}let i=0===this.binaryShiftByteCount||31===this.binaryShiftByteCount?18:62===this.binaryShiftByteCount?9:8,o=new rB(t,r,this.binaryShiftByteCount+1,n+i);return 2078===o.binaryShiftByteCount&&(o=o.endBinaryShift(e+1)),o}endBinaryShift(e){if(0===this.binaryShiftByteCount)return this;let t=this.token;return new rB(t=new rN(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let t=this.bitCount+(rO[this.mode][e.mode]>>16);return this.binaryShiftByteCounte.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount}toBitArray(e){let t=[];for(let r=this.endBinaryShift(e.length).token;null!==r;r=r.getPrevious())t.unshift(r);let r=new x;for(let n of t)n.appendTo(r,e);return r}toString(){return G.format("%s bits=%d bytes=%d",rM[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}rB.INITIAL_STATE=new rB(rR,0,0,0);let rL=function(e){let t=G.getCharCode(" "),r=G.getCharCode("."),n=G.getCharCode(",");e[0][t]=1;let i=G.getCharCode("Z"),o=G.getCharCode("A");for(let t=o;t<=i;t++)e[0][t]=t-o+2;e[1][t]=1;let s=G.getCharCode("z"),a=G.getCharCode("a");for(let t=a;t<=s;t++)e[1][t]=t-a+2;e[2][t]=1;let l=G.getCharCode("9"),h=G.getCharCode("0");for(let t=h;t<=l;t++)e[2][t]=t-h+2;e[2][n]=12,e[2][r]=13;let c=["\0"," ","\x01","\x02","\x03","\x04","\x05","\x06","\x07","\b"," ","\n","\v","\f","\r","\x1b","\x1c","\x1d","\x1e","\x1f","@","\\","^","_","`","|","~","\x7f"];for(let t=0;t","?","[","]","{","}"];for(let t=0;t0&&(e[4][G.getCharCode(u[t])]=t);return e}(v.createInt32Array(5,256));class rP{constructor(e){this.text=e}encode(){let e=G.getCharCode(" "),t=G.getCharCode("\n"),r=r_.singletonList(rB.INITIAL_STATE);for(let n=0;n0?(r=rP.updateStateListForPair(r,n,i),n++):r=this.updateStateListForChar(r,n)}return r_.min(r,(e,t)=>e.getBitCount()-t.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,t){let r=[];for(let n of e)this.updateStateForChar(n,t,r);return rP.simplifyStates(r)}updateStateForChar(e,t,r){let n=255&this.text[t],i=rL[e.getMode()][n]>0,o=null;for(let s=0;s<=4;s++){let a=rL[s][n];if(a>0){if(null==o&&(o=e.endBinaryShift(t)),!i||s===e.getMode()||2===s){let e=o.latchAndAppend(s,a);r.push(e)}if(!i&&rb[e.getMode()][s]>=0){let e=o.shiftAndAppend(s,a);r.push(e)}}}if(e.getBinaryShiftByteCount()>0||0===rL[e.getMode()][n]){let n=e.addBinaryShiftChar(t);r.push(n)}}static updateStateListForPair(e,t,r){let n=[];for(let i of e)this.updateStateForPair(i,t,r,n);return this.simplifyStates(n)}static updateStateForPair(e,t,r,n){let i=e.endBinaryShift(t);if(n.push(i.latchAndAppend(4,r)),4!==e.getMode()&&n.push(i.shiftAndAppend(4,r)),3===r||4===r){let e=i.latchAndAppend(2,16-r).latchAndAppend(2,1);n.push(e)}if(e.getBinaryShiftByteCount()>0){let r=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);n.push(r)}}static simplifyStates(e){let t=[];for(let r of e){let e=!0;for(let n of t){if(n.isBetterThanOrEqualTo(r)){e=!1;break}r.isBetterThanOrEqualTo(n)&&(t=t.filter(e=>e!==n))}e&&t.push(r)}return t}}class rv{constructor(){}static encodeBytes(e){return rv.encode(e,rv.DEFAULT_EC_PERCENT,rv.DEFAULT_AZTEC_LAYERS)}static encode(e,t,r){let n,i,o,s,a,l,h=new rP(e).encode(),c=F.truncDivision(h.getSize()*t,100)+11,u=h.getSize()+c;if(r!==rv.DEFAULT_AZTEC_LAYERS){if(n=r<0,(i=Math.abs(r))>(n?rv.MAX_NB_BITS_COMPACT:rv.MAX_NB_BITS))throw new M(G.format("Illegal value %s for layers",r));let e=(o=rv.totalBitsInLayer(i,n))-o%(s=rv.WORD_SIZE[i]);if((a=rv.stuffBits(h,s)).getSize()+c>e||n&&a.getSize()>64*s)throw new M("Data to large for user specified layer")}else{s=0,a=null;for(let e=0;;e++){if(e>rv.MAX_NB_BITS)throw new M("Data too large for an Aztec code");if(i=(n=e<=3)?e+1:e,u>(o=rv.totalBitsInLayer(i,n)))continue;(null==a||s!==rv.WORD_SIZE[i])&&(s=rv.WORD_SIZE[i],a=rv.stuffBits(h,s));let t=o-o%s;if(!(n&&a.getSize()>64*s)&&a.getSize()+c<=t)break}}let d=rv.generateCheckWords(a,o,s),f=a.getSize()/s,g=rv.generateModeMessage(n,i,f),w=(n?11:14)+4*i,m=new Int32Array(w);if(n){l=w;for(let e=0;e=n||e.get(o+r))&&(s|=1<