web-cardscan
Version:
This library provides payment card scanning and verification functionality for your web app.
29 lines (23 loc) • 104 kB
JavaScript
/*!
This library is available under paid and free licenses. See the bouncer_cardscan.bundle.js.LICENSE.txt file for the full license text.
Quick Summary
=============
In short, this library will remain free forever for non-commercial applications, but use by commercial applications is limited to 90 days, after which time a licensing agreement is required. We're also adding some legal liability protections.
After this period commercial applications need to convert to a licensing agreement to continue to use this library.
Details of licensing (pricing, etc) are available at https://cardscan.io/pricing, or you can contact us at license@getbouncer.com.
More Detailed Summary
=====================
What's allowed under the license:
- Free use for any app for 90 days (for demos, evaluations, hackathons, etc).
- Contributions (contributors must agree to the Contributor License Agreement)
- Any modifications as needed to work in your app
What's not allowed under the license:
- Commercial applications using the license for longer than 90 days without a license agreement.
- Using us now in a commercial app today? No worries! Just email license@getbouncer.com and we’ll get you set up.
- Redistribution under a different license
- Removing attribution
- Modifying logos
- Indemnification: using this free software is ‘at your own risk’, so you can’t sue Bouncer Technologies, Inc. for problems caused by this library
Questions? Concerns? Please email us at license@getbouncer.com or ask us on slack at https://getbouncer.slack.com/.
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tensorflow/tfjs")):"function"==typeof define&&define.amd?define("bouncerCardScan",["@tensorflow/tfjs"],t):"object"==typeof exports?exports.bouncerCardScan=t(require("@tensorflow/tfjs")):e.bouncerCardScan=t(e["@tensorflow/tfjs"])}("undefined"!=typeof self?self:this,(function(e){return(()=>{"use strict";var t={521:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.SavedFramesAnalyzer=t.CardDetectAnalyzer=void 0;var o=n(993),a=n(232),s=n(848),u=n(749),c=n(757),l=n(438),d=n(477),h=new c.Mutex,g=null,M=function(){function e(t,n,r,i,o,a,s,u){this.debugCanvasElement=null,this.cardCanvasElement=t,this.fullCanvasElement=n,this.centerCanvasElement=r,this.videoElement=i,this.cardViewFinderElement=o,this.squareViewFinderElement=a,this.fullViewFinderElement=s,this.debugCanvasElement=u,t.width=e.IMAGE_SIZE_CARD.width,t.height=e.IMAGE_SIZE_CARD.height,n.width=e.IMAGE_SIZE_FULL.width,n.height=e.IMAGE_SIZE_FULL.height,r.width=e.IMAGE_SIZE_SQUARE.width,r.height=e.IMAGE_SIZE_SQUARE.height}return e.warmUp=function(t){return r(this,void 0,void 0,(function(){var n=this;return i(this,(function(o){switch(o.label){case 0:return[4,h.dispatch((function(){return r(n,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:if(!e.isTensorFlowAvailable())return console.warn("Unable to warm up ML model. TensorFlow is not available."),[2];if(null!=g)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),n=Date.now(),[4,this.downloadModel(a.BouncerConfig.modelDownloadAttempts)];case 2:return g=i.sent(),r=Date.now(),l.tidy((function(){var n=l.browser.fromPixels(t).expandDims(0),r=l.image.cropAndResize(n,[[0,0,1,1]],[0],[e.IMAGE_SIZE_SQUARE.height,e.IMAGE_SIZE_SQUARE.width]).squeeze(),i=e.processImage(r);g.predict(i)})),u.PerformanceStats.networkDownloadSpeedKbS=864/(r-n)*1e3,u.PerformanceStats.modelFirstInferenceDurationMs=Date.now()-r,console.debug("Analyzer downloaded after "+(r-n)+"ms, is warmed up after "+(Date.now()-r)+"ms using "+l.getBackend()),[3,4];case 3:return o=i.sent(),console.warn("Unable to warm up ML model "+o),[3,4];case 4:return[2]}}))}))}))];case 1:return o.sent(),[2]}}))}))},e.downloadModel=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.loadLayersModel("https://cardscan-web.s3.us-east-2.amazonaws.com/ux_0_5_23_8_model.json")];case 1:if(g=n.sent())return[2,g];throw new Error("Model was not loaded. Model is null");case 2:return t=n.sent(),console.warn("Unable to download ML model "+t),e>0?[2,this.downloadModel(e-1)]:[3,3];case 3:return[2]}}))}))},e.isTensorFlowAvailable=function(){return void 0!==l},e.prototype.calculateCrop=function(e){var t=this.videoElement.getBoundingClientRect(),n=e.getBoundingClientRect();return new s.Rectangle((n.left-t.left)/t.width,(n.top-t.top)/t.height,(n.right-t.left)/t.width,(n.bottom-t.top)/t.height)},e.prototype.calculateCenterCrop=function(){var t=e.IMAGE_SIZE_SQUARE.width/this.videoElement.videoWidth,n=e.IMAGE_SIZE_SQUARE.height/this.videoElement.videoHeight;return new s.Rectangle(.5-t/2,.5-n/2,.5+t/2,.5+n/2)},e.prototype.loadModel=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,e.warmUp(this.debugCanvasElement)];case 1:return[2,t.sent()]}}))}))},e.processImage=function(e){return l.tidy((function(){return e.expandDims(0).toFloat().div(255)}))},e.prototype.analyze=function(t,n){return r(this,void 0,void 0,(function(){var r,o,u,c,l,h;return i(this,(function(i){switch(i.label){case 0:return r=d.supportsWebP?e.IMAGE_FORMAT_WEBP:1==a.BouncerConfig.imageQualityOcr?e.IMAGE_FORMAT_PNG:e.IMAGE_FORMAT_JPG,o=d.supportsWebP?e.IMAGE_FORMAT_WEBP:1==a.BouncerConfig.imageQualityFull?e.IMAGE_FORMAT_PNG:e.IMAGE_FORMAT_JPG,u=d.supportsWebP?e.IMAGE_FORMAT_WEBP:1==a.BouncerConfig.imageQualityCenter?e.IMAGE_FORMAT_PNG:e.IMAGE_FORMAT_JPG,[4,this.runCardDetectModel(t)];case 1:return c=i.sent(),l=!!c&&this.isCardVisible(c),n.stateMachine.consumeAnalyzerResult(l),h=this.calculateCrop(this.fullViewFinderElement),n.stateMachine.getCurrentState().runOcr?[4,this.getCardImagesSameThread(t)]:[3,3];case 2:if(i.sent())return[2,new s.CardEnergies(this.cardCanvasElement.toDataURL(r,a.BouncerConfig.imageQualityOcr),this.fullCanvasElement.toDataURL(o,a.BouncerConfig.imageQualityFull),this.centerCanvasElement.toDataURL(u,a.BouncerConfig.imageQualityCenter),new s.Size(Math.round(h.width*this.videoElement.videoWidth),Math.round(h.height*this.videoElement.videoHeight)),l)];i.label=3;case 3:return[2,new s.CardEnergies(null,null,null,new s.Size(Math.round(h.width*this.videoElement.videoWidth),Math.round(h.height*this.videoElement.videoHeight)),l)]}}))}))},e.prototype.runCardDetectModel=function(t){return r(this,void 0,void 0,(function(){var n,r,o,a;return i(this,(function(i){switch(i.label){case 0:if(r=this.calculateCrop(this.squareViewFinderElement),!g)throw new Error("Model is not available when starting analyzer.");i.label=1;case 1:return i.trys.push([1,3,4,5]),o=l.tidy((function(){var n=l.browser.fromPixels(t).expandDims(0),i=l.image.cropAndResize(n,[[r.top,r.left,r.bottom,r.right]],[0],[e.IMAGE_SIZE_SQUARE.height,e.IMAGE_SIZE_SQUARE.width]).squeeze();return e.processImage(i)})),[4,(n=g.predict(o)).data()];case 2:return[2,i.sent()];case 3:throw a=i.sent(),console.error("Error running card detect model: "+a),a;case 4:return n&&n.dispose(),[7];case 5:return[2]}}))}))},e.prototype.getCardImagesSameThread=function(t){return r(this,void 0,void 0,(function(){var n,r,o,a,s,u,c,d,h,g,M;return i(this,(function(i){switch(i.label){case 0:n=this.calculateCrop(this.cardViewFinderElement),r=this.calculateCrop(this.fullViewFinderElement),o=this.calculateCenterCrop(),a=e.IMAGE_SIZE_CARD,s=e.IMAGE_SIZE_FULL,u=e.IMAGE_SIZE_SQUARE,i.label=1;case 1:return i.trys.push([1,3,4,5]),M=l.tidy((function(){var e=l.browser.fromPixels(t).expandDims(0);return[l.image.cropAndResize(e,[[n.top,n.left,n.bottom,n.right]],[0],[a.height,a.width]).toFloat().div(255).squeeze(),l.image.cropAndResize(e,[[r.top,r.left,r.bottom,r.right]],[0],[s.height,s.width]).toFloat().div(255).squeeze(),l.image.cropAndResize(e,[[o.top,o.left,o.bottom,o.right]],[0],[u.width,u.height]).toFloat().div(255).squeeze()]})),c=M[0],d=M[1],h=M[2],[4,Promise.all([l.browser.toPixels(c,this.cardCanvasElement),l.browser.toPixels(d,this.fullCanvasElement),l.browser.toPixels(h,this.centerCanvasElement)])];case 2:return i.sent(),[2,!0];case 3:return g=i.sent(),console.error("Error transforming image "+g),[2,!1];case 4:return c&&c.dispose(),d&&d.dispose(),h&&h.dispose(),[7];case 5:return[2]}}))}))},e.prototype.isCardVisible=function(e){var t=e[1],n=e[2],r=e[0];return n>t||r>t},e.IMAGE_SIZE_SQUARE=new s.Size(224,224),e.IMAGE_SIZE_FULL=new s.Size(360,640),e.IMAGE_SIZE_CARD=new s.Size(600,375),e.IMAGE_FORMAT_WEBP="image/webp",e.IMAGE_FORMAT_JPG="image/jpeg",e.IMAGE_FORMAT_PNG="image/png",e}();t.CardDetectAnalyzer=M;var p=function(){function e(){}return e.prototype.analyze=function(e,t){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return t=o.handleNetworkResult,[4,o.BouncerApi.uploadSavedFrames(e)];case 1:return[2,t.apply(void 0,[n.sent(),this.onNetworkResult,this.onNetworkFailure])]}}))}))},e.prototype.onNetworkResult=function(e){return e&&e.body?(e.body.verification_result||console.error("Verification network result does not contain `verification_result`"),e.body.verification_result):(console.error("Empty verification network result"),null)},e.prototype.onNetworkFailure=function(e){return console.warn("Error verification network result: "+e.failure),null},e}();t.SavedFramesAnalyzer=p},993:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.NetworkResultFailure=t.NetworkResultSuccess=t.handleNetworkResultPromise=t.handleNetworkResult=t.isNetworkResultFailure=t.isNetworkResultSuccess=t.BouncerApi=void 0;var o=n(232),a=n(535),s=n(757),u=function(){function e(){}return e.uploadOcrImage=function(t,n){return r(this,void 0,void 0,(function(){var r,o;return i(this,(function(i){return r=t.split(",")[1],o=t.split(",")[0].split(":")[1].split(";")[0],[2,e.postJsonVGS(e.OCR_UPLOAD_PATH,{mode:"scan",ocr_image_data:r,ocr_image_mime_type:o,full_image_end_data:n})]}))}))},e.uploadSavedFrames=function(t){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){return n=t.map((function(e){return{full_image_data:e.cardEnergies.fullImage.split(",")[1],full_image_mime_type:e.cardEnergies.fullImage.split(",")[0].split(":")[1].split(";")[0],cropped_center_image_data:e.cardEnergies.originalPixels.split(",")[1],cropped_center_mime_type:e.cardEnergies.originalPixels.split(",")[0].split(":")[1].split(";")[0],original_image_width:e.cardEnergies.originalImageSize.width,original_image_height:e.cardEnergies.originalImageSize.height,full_image_end_data_signature:e.fullImageSignature}})),[2,e.postJsonVGS(e.CARD_VERIFY_PATH,{mode:"verify",frames:n})]}))}))},e.uploadScanStats=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,e.postJson(e.HOST_BOUNCER,e.SCAN_STATS_PATH,a.ScanStats.json())]}))}))},e.postJsonVGS=function(t,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=o.BouncerConfig.useSandbox?e.HOST_VGS_SANDBOX:e.HOST_VGS_PROD,[2,e.postJson(r,t,n)]}))}))},e.postJson=function(t,n,a){return r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){return r=new XMLHttpRequest,u=Date.now(),r.open("POST",t+n,!0),r.setRequestHeader("content-type","application/json"),r.setRequestHeader("x-bouncer-auth",o.BouncerConfig.apiKey),c=new Promise((function(t){r.onreadystatechange=function(){s.removeAllArrayItems(e.OPEN_REQUESTS,this),4==this.readyState&&200==this.status?t(new h(this.status,Date.now()-u,JSON.parse(r.responseText))):4==this.readyState&&t(new g(this.status,Date.now()-u,r.responseText))}})),e.OPEN_REQUESTS.push(r),r.send(JSON.stringify(a)),[2,c]}))}))},e.abortAllOpenRequests=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){return t=e.OPEN_REQUESTS,e.OPEN_REQUESTS=new Array,[2,new Promise((function(e){t.forEach((function(e){return e.abort()})),e(t.length)}))]}))}))},e.HOST_VGS_PROD="https://tntnoj7srjy.live.verygoodproxy.com",e.HOST_VGS_SANDBOX="https://tnt4h6lh3pi.sandbox.verygoodproxy.com",e.HOST_BOUNCER="https://api.getbouncer.com",e.OCR_UPLOAD_PATH="/cardverify-web",e.CARD_VERIFY_PATH="/cardverify-web",e.SCAN_STATS_PATH="/scan_stats",e.OPEN_REQUESTS=new Array,e}();function c(e){return void 0!==e.body}function l(e){return void 0!==e.failure}function d(e,t,n){return c(e)?t(e):l(e)?n(e):void 0}t.BouncerApi=u,t.isNetworkResultSuccess=c,t.isNetworkResultFailure=l,t.handleNetworkResult=d,t.handleNetworkResultPromise=function(e,t,n){return new Promise((function(r){e.then((function(e){r(d(e,t,n))}))}))};var h=function(e,t,n){this.responseCode=e,this.durationMs=t,this.body=n};t.NetworkResultSuccess=h;var g=function(e,t,n){this.responseCode=e,this.durationMs=t,this.failure=n};t.NetworkResultFailure=g},256:function(e,t,n){var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.CameraInitResult=t.CameraAdapter=void 0;var a,s=n(109),u=n(535),c=function(){function e(e,t){this.captureContext=null,this.cameraLoadPromise=null,this.torchOn=!1,this.videoIndex=null,this.videoElement=e,this.captureElement=t}return e.isCameraSupported=function(){return s.hasDom()&&"mediaDevices"in s.getNavigator()&&"getUserMedia"in s.getNavigator().mediaDevices},e.prototype.initCamera=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return this.cameraLoadPromise=new Promise((function(t){try{if(4==e.videoElement.readyState)console.debug("Camera was available immediately"),e.captureElement.width=e.videoElement.videoWidth,e.captureElement.height=e.videoElement.videoHeight,e.captureContext=e.captureElement.getContext("2d"),t();else{console.debug("Waiting for camera to be available");var n=e;e.videoElement.onloadeddata=function(){console.debug("Camera has become available"),n.captureElement.width=n.videoElement.videoWidth,n.captureElement.height=n.videoElement.videoHeight,n.captureContext=n.captureElement.getContext("2d"),t()}}}catch(e){console.error("Unable to check if the video is ready: "+e),t()}})),[2,this.setCamera()]}))}))},e.prototype.setCamera=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:if(!e.isCameraSupported())return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getCameraStream()];case 2:return t=n.sent(),this.isCameraFacingUser(t)?this.mirrorVideo():this.unMirrorVideo(),this.videoElement.srcObject=t,[2,a.Success];case 3:return n.sent(),[2,a.Unavailable];case 4:return[3,6];case 5:return[2,a.Unsupported];case 6:return[2]}}))}))},e.prototype.getCameraStream=function(){return i(this,void 0,void 0,(function(){var e,t;return o(this,(function(n){switch(n.label){case 0:return e={video:{width:1920,height:1080},audio:!1},s.getNavigator().mediaDevices.getSupportedConstraints().facingMode&&null==this.videoIndex&&(e.video=r(r({},e.video),{facingMode:"environment"})),null===this.videoIndex?[3,2]:[4,s.getNavigator().mediaDevices.enumerateDevices()];case 1:t=n.sent().filter((function(e){return"videoinput"==e.kind})),this.videoIndex>=t.length&&(this.videoIndex=0),e.video.deviceId={},e.video.deviceId.exact=t[this.videoIndex].deviceId,n.label=2;case 2:return[4,s.getNavigator().mediaDevices.getUserMedia(e)];case 3:return[2,n.sent()]}}))}))},e.prototype.hasMultipleCameras=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,s.getNavigator().mediaDevices.enumerateDevices()];case 1:return[2,e.sent().filter((function(e){return"videoinput"==e.kind})).length>1]}}))}))},e.prototype.swapCamera=function(){null===this.videoIndex?this.videoIndex=0:this.videoIndex++,this.setCamera()},e.prototype.startCamera=function(){this.videoElement.srcObject&&this.videoElement.play()},e.prototype.stopCamera=function(){try{this.videoElement.pause();var e=this.videoElement.srcObject;if(e)for(var t=e.getTracks(),n=0;n<t.length;n++)t[n].stop()}catch(e){console.debug("Error shutting down camera "+e)}},e.prototype.clearCamera=function(){this.stopCamera(),this.videoElement.srcObject=null},e.prototype.isCameraFacingUser=function(e){return!s.getNavigator().mediaDevices.getSupportedConstraints().facingMode||"environment"!=e.getVideoTracks()[0].getSettings().facingMode},e.prototype.mirrorVideo=function(){this.videoElement.classList.add("mirrored")},e.prototype.forceRefocus=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.cameraLoadPromise)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.cameraLoadPromise];case 2:if(o.sent(),e=this.videoElement.srcObject)for(t=e.getTracks(),n=0;n<t.length;n++)r=t[n].getSettings().focusDistance,t[n].applyConstraints({focusMode:"manual",focusDistance:0}),t[n].getSettings().focusMode="manual",t[n].getSettings().focusDistance=0,t[n].applyConstraints({focusMode:"continuous",focusDistance:r}),t[n].getSettings().focusMode="continuous",t[n].getSettings().focusDistance=r;return[3,4];case 3:return i=o.sent(),console.error("Unable to force refocus "+i),[3,4];case 4:return[2]}}))}))},e.prototype.toggleTorch=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:if(!this.cameraLoadPromise)return[2,!1];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.cameraLoadPromise];case 2:if(i.sent(),e=this.videoElement.srcObject)for(this.torchOn=!this.torchOn,t=e.getTracks(),n=0;n<t.length;n++)t[n].applyConstraints({advanced:[{torch:this.torchOn}]});return[3,4];case 3:return r=i.sent(),console.error("Unable to toggle torch "+r),[2,!1];case 4:return[2,this.torchOn]}}))}))},e.prototype.supportsTorch=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:if(!this.cameraLoadPromise)return[2,!1];i.label=1;case 1:return i.trys.push([1,7,,8]),[4,this.cameraLoadPromise];case 2:if(i.sent(),!(e=this.videoElement.srcObject))return[3,6];t=e.getTracks(),n=0,i.label=3;case 3:return n<t.length?[4,new ImageCapture(t[n]).getPhotoCapabilities()]:[3,6];case 4:if(void 0!==i.sent().fillLightMode)return u.ScanStats.setTorchSupported("supported"),[2,!0];i.label=5;case 5:return n++,[3,3];case 6:return[3,8];case 7:return r=i.sent(),console.error("Unable to determine torch support "+r),u.ScanStats.setTorchSupported("unsupported"),[2,!1];case 8:return u.ScanStats.setTorchSupported("unsupported"),[2,!1]}}))}))},e.prototype.unMirrorVideo=function(){this.videoElement.classList.remove("mirrored")},e.prototype.captureImage=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:if(!this.cameraLoadPromise)return console.error("Attempting to capture image before initCamera."),[2,null];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.cameraLoadPromise];case 2:return t.sent(),this.captureContext.drawImage(this.videoElement,0,0,this.captureElement.width,this.captureElement.height),[2,this.captureContext.getImageData(0,0,this.captureElement.width,this.captureElement.height)];case 3:return e=t.sent(),console.error("Unable to capture camera image "+e),[2,null];case 4:return[2]}}))}))},e}();t.CameraAdapter=c,function(e){e[e.Success=0]="Success",e[e.Unsupported=1]="Unsupported",e[e.Unavailable=2]="Unavailable"}(a=t.CameraInitResult||(t.CameraInitResult={}))},817:function(e,t,n){var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.CardMatcher=t.isValidPanLastFour=t.isValidCvc=t.isValidIin=t.isValidPan=t.lastFourFromPan=t.iinFromPan=t.normalizeCardNumber=t.getCardIssuer=t.formatPan=t.formatIssuer=t.CardIssuer=void 0;var o,a=n(757),s=new a.IntRange(3,4);!function(e){e.AmericanExpress="American Express",e.DinersClub="Diners Club",e.Discover="Discover",e.JCB="JCB",e.MasterCard="MasterCard",e.UnionPay="UnionPay",e.Unknown="Unknown",e.Visa="Visa"}(o=t.CardIssuer||(t.CardIssuer={})),t.formatIssuer=function(e){return e.toString()};var u=function(e,t,n,r,i){this.iinRange=e,this.issuer=t,this.panLengths=n,this.cvcLengths=r,this.panValidator=i},c=function(){function e(){}return e.prototype.append=function(e){return new l(this,e)},e}(),l=function(e){function t(t,n){var r=e.call(this)||this;return r.validator1=t,r.validator2=n,r}return i(t,e),t.prototype.isValidPan=function(e){return this.validator1.isValidPan(e)&&this.validator2.isValidPan(e)},t}(c),d=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isValidPan=function(e){var t=m(e);return!!t&&t.panLengths.indexOf(e.length)>=0},t}(c)),h=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isValidPan=function(e){if(!e)return!1;for(var t=parseInt(e.substring(e.length-1)),n=e.length%2,r=0;r<e.length-1;r++)t+=r%2==n?this.doubleDigit(parseInt(e[r])):parseInt(e[r]);return t%10==0},t.prototype.doubleDigit=function(e){return 2*e>9?2*e-9:2*e},t}(c)),g=function(){function e(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.blockSizes=t,this.blockIndices=e.blockSizesToIndicies(this.blockSizes)}return e.blockSizesToIndicies=function(e){var t=0;return e.map((function(e){var n=e+t;return t=n,n}))},e.prototype.formatPan=function(e){for(var t=[],n=0;n<e.length;n++)this.blockIndices.indexOf(n)>=0&&t.push(" "),t.push(e[n]);return t.join("")},e}(),M=[new u(new a.IntRange(34e4,349999),o.AmericanExpress,[15],new a.IntRange(3,4).toList(),d.append(h)),new u(new a.IntRange(37e4,379999),o.AmericanExpress,[15],new a.IntRange(3,4).toList(),d.append(h)),new u(new a.IntRange(3e5,305999),o.DinersClub,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(309500,309599),o.DinersClub,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(36e4,369999),o.DinersClub,new a.IntRange(14,19).toList(),[3],d.append(h)),new u(new a.IntRange(38e4,399999),o.DinersClub,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(601100,601199),o.Discover,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(622126,622925),o.Discover,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(624e3,626999),o.Discover,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(628200,628899),o.Discover,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(64e4,659999),o.Discover,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(352800,358999),o.JCB,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(62e4,629999),o.UnionPay,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(81e4,819999),o.UnionPay,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(222100,272099),o.MasterCard,new a.IntRange(16,16).toList(),[3],d.append(h)),new u(new a.IntRange(51e4,559999),o.MasterCard,new a.IntRange(16,16).toList(),[3],d.append(h)),new u(new a.IntRange(5e5,509999),o.MasterCard,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(56e4,699999),o.MasterCard,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(675900,675999),o.MasterCard,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(676770,676770),o.MasterCard,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(676774,676774),o.MasterCard,new a.IntRange(16,19).toList(),[3],d.append(h)),new u(new a.IntRange(4e5,499999),o.Visa,new a.IntRange(16,19).toList(),[3],d.append(h))],p=new Map([[o.AmericanExpress,new Map([[15,new g(4,6,5)]])],[o.DinersClub,new Map([[14,new g(4,6,4)],[15,new g(4,6,5)],[16,new g(4,4,4,4)],[17,new g(4,4,4,5)],[18,new g(4,4,4,6)],[19,new g(4,4,4,4,3)]])],[o.Discover,new Map([[16,new g(4,4,4,4)],[17,new g(4,4,4,4,1)],[18,new g(4,4,4,4,2)],[19,new g(4,4,4,4,3)]])],[o.MasterCard,new Map([[12,new g(4,4,4)],[13,new g(4,4,5)],[14,new g(4,6,4)],[15,new g(4,6,5)],[16,new g(4,4,4,4)],[17,new g(4,4,4,5)],[18,new g(4,4,4,6)],[19,new g(4,4,4,4,3)]])],[o.UnionPay,new Map([[16,new g(4,4,4,4)],[17,new g(4,4,4,5)],[18,new g(4,4,4,6)],[19,new g(6,13)]])],[o.Visa,new Map([[16,new g(4,4,4,4)]])]]),f=new Map([[12,new g(4,4,4)],[13,new g(4,4,5)],[14,new g(4,6,4)],[15,new g(4,6,5)],[16,new g(4,4,4,4)],[17,new g(4,4,4,5)],[18,new g(4,4,4,2)],[19,new g(4,4,4,4,3)]]);function m(e){for(var t=0;t<M.length;t++)if(M[t].iinRange.contains(parseInt(I(e))))return M[t];return null}function w(e){var t=y(e);if(!t)return o.Unknown;var n=m(t);return n?n.issuer:o.Unknown}function y(e){return e?e.replace(/\D/g,""):""}function I(e){return e.length<6?e.padEnd(6,"0"):e.substring(0,6)}t.formatPan=function(e){var t=y(e);if(!t)return"";var n,r=w(t),i=p.get(r);return(n=i&&i.get(t.length)?i.get(t.length):f.get(t.length))?n.formatPan(t):t},t.getCardIssuer=w,t.normalizeCardNumber=y,t.iinFromPan=I,t.lastFourFromPan=function(e){return e.length<4?e:e.substring(e.length-4)},t.isValidPan=function(e){var t=y(e);if(!t)return!1;var n=m(t);return!!n&&n.panValidator.isValidPan(t)},t.isValidIin=function(e){var t=y(e);if(!t)return!1;var n=m(t);return!!n&&n.issuer!=o.Unknown},t.isValidCvc=function(e,t){var n=y(e);if(!n)return!1;var r=function(e){return M.filter((function(t){return t.issuer==e}))}(null!=t?t:o.Unknown);if(0==r.length)return s.contains(n.length);for(var i=0;i<r.length;i++)if(r[i].cvcLengths.indexOf(n.length)>=0)return!0;return!1},t.isValidPanLastFour=function(e){return 4==y(e).length};var v=function(){function e(e,t){this.requiredIin=e,this.requiredLastFour=t}return e.prototype.matchesRequiredCard=function(e){return e&&this.panMatches(e)},e.prototype.doesNotMatchRequiredCard=function(e){return e&&!this.panMatches(e)},e.prototype.panMatches=function(e){var t=!this.requiredIin||this.requiredIin==e.substring(0,this.requiredIin.length),n=!this.requiredLastFour||this.requiredLastFour==e.substring(e.length-this.requiredLastFour.length);return t&&n},e}();t.CardMatcher=v},232:(e,t)=>{t.__esModule=!0,t.BouncerConfig=void 0;var n=function(){function e(){}return e.prototype.setDebug=function(t){e.isDebug=t},e.prototype.setApiKey=function(t){e.apiKey=t},e.prototype.setModelDownloadAttempts=function(t){e.modelDownloadAttempts=t},e.prototype.setImageQuality=function(t,n,r){void 0===t&&(t=.92),void 0===n&&(n=.92),void 0===r&&(r=.92),e.imageQualityOcr=t,e.imageQualityFull=n,e.imageQualityCenter=r},e.prototype.setImageSizeEstimates=function(t,n,r){void 0===t&&(t=27),void 0===n&&(n=36),void 0===r&&(r=330),e.imageSizeOcrWebpKb=t,e.imageSizeOcrJpgKb=n,e.imageSizeOcrPngKb=r},e.prototype.setUseSandbox=function(t){e.useSandbox=t},e.prototype.setCardDetectDecay=function(t){e.cardDetectDecayTimeMs=t},e.prototype.setMaxErrorCorrectionTime=function(t){e.maxErrorCorrectionTimeMs=t},e.prototype.setWrongCardDuration=function(t){e.wrongCardDurationMs=t},e.prototype.setTroubleScanningTimeout=function(t){e.troubleScanningTimeoutMs=t},e.prototype.setMinimumMatchingValues=function(t){void 0===t&&(t=2),e.minimumMatchingPanCount=t},e.prototype.setDesiredMatchingValues=function(t,n,r){void 0===t&&(t=5),void 0===n&&(n=1),void 0===r&&(r=1),e.desiredMatchingPanCount=t,e.desiredMatchingExpiryCount=n,e.desiredMatchingCardholderNameCount=r},e.prototype.setMemoryUsage=function(t,n,r){void 0===t&&(t=50),void 0===n&&(n=6),void 0===r&&(r=7),e.maxSavedFrames=t,e.maxVerificationResultsPerType=n,e.maxVerificationResultsTotal=r},e.prototype.setRunVerifyPipeline=function(t){e.runVerifyPipeline=t},e.prototype.setDownloadUploadNetworkSpeedRatio=function(t){e.downloadUploadNetworkSpeedRatio=t},e.prototype.setNetworkQueueLimits=function(t,n){void 0===t&&(t=2),void 0===n&&(n=20),e.networkQueueMaxSize=n,e.networkQueueMinSize=t},e.prototype.localize=function(t){null===t.instructionsLoading?e.instructionsLoadingString="":void 0!==t.instructionsLoading&&(e.instructionsLoadingString=t.instructionsLoading),null===t.instructionsScan?e.instructionsScanString="":void 0!==t.instructionsScan&&(e.instructionsScanString=t.instructionsScan),null===t.instructionsReading?e.instructionsReadingString="":void 0!==t.instructionsReading&&(e.instructionsReadingString=t.instructionsReading),null===t.instructionsCapturing?e.instructionsCapturingImages="":void 0!==t.instructionsCapturing&&(e.instructionsCapturingImages=t.instructionsCapturing),null===t.instructionsProcessing?e.instructionsProcessingString="":void 0!==t.instructionsProcessing&&(e.instructionsProcessingString=t.instructionsProcessing),null===t.instructionsWrongCard?e.instructionsWrongCardString="":void 0!==t.instructionsWrongCard&&(e.instructionsWrongCardString=t.instructionsWrongCard),null===t.instructionsTroubleScanning?e.instructionsTroubleScanningString="":void 0!==t.instructionsTroubleScanning&&(e.instructionsTroubleScanningString=t.instructionsTroubleScanning),null===t.securityNotification?e.securityNotificationString="":void 0!==t.securityNotification&&(e.securityNotificationString=t.securityNotification),null===t.networkError?e.networkErrorString="":void 0!==t.networkError&&(e.networkErrorString=t.networkError),null===t.cardDetails?e.cardDetailsString="":void 0!==t.cardDetails&&(e.cardDetailsString=t.cardDetails),null===t.cannotScan?e.cannotScanString="":void 0!==t.cannotScan&&(e.cannotScanString=t.cannotScan)},e.isDebug=!1,e.apiKey=null,e.modelDownloadAttempts=3,e.imageQualityOcr=.92,e.imageQualityFull=.92,e.imageQualityCenter=.92,e.imageSizeOcrWebpKb=27,e.imageSizeOcrJpgKb=36,e.imageSizeOcrPngKb=330,e.useSandbox=!1,e.cardDetectDecayTimeMs=3e3,e.maxErrorCorrectionTimeMs=1e4,e.wrongCardDurationMs=2e3,e.troubleScanningTimeoutMs=1e4,e.minimumMatchingPanCount=2,e.desiredMatchingPanCount=5,e.desiredMatchingExpiryCount=0,e.desiredMatchingCardholderNameCount=0,e.maxSavedFrames=50,e.maxVerificationResultsPerType=6,e.maxVerificationResultsTotal=7,e.runVerifyPipeline=!1,e.downloadUploadNetworkSpeedRatio=6,e.networkQueueMaxSize=20,e.networkQueueMinSize=2,e.instructionsLoadingString="Loading...",e.instructionsScanString="Scan Your Card",e.instructionsReadingString="Reading card...",e.instructionsCapturingImages="Almost done...",e.instructionsProcessingString="Processing...",e.instructionsWrongCardString="Wrong card!",e.instructionsTroubleScanningString="We're having trouble scanning this card",e.securityNotificationString="Your card info is secure",e.networkErrorString="Network Error",e.cardDetailsString="{issuer} {iin} **** {lastFour}",e.cannotScanString="I can't scan this card",e.appPackageName="com.getbouncer.web",e.version="0.1.52",e.scanStatsPayloadVersion=2,e}();t.BouncerConfig=n},109:(e,t)=>{t.__esModule=!0,t.hasDom=t.getWindow=t.getNavigator=t.createElementNS=t.createElement=t.getElementBySelector=t.getSvgBySelector=t.getHtmlBySelector=t.getElementById=t.getDocument=void 0;var n="undefined"!=typeof document?document:null;function r(){return n}t.getDocument=r,t.getElementById=function(e){if(null!=n)return n.getElementById(e)},t.getHtmlBySelector=function(e){if(null!=n)return n.querySelector(e)},t.getSvgBySelector=function(e){if(null!=n)return n.querySelector(e)},t.getElementBySelector=function(e){if(null!=n)return n.querySelector(e)},t.createElement=function(e,t){if(null!=n)return n.createElement(e,t)},t.createElementNS=function(e,t){if(null!=n)return n.createElementNS(e,t)};var i="undefined"!=typeof navigator?navigator:null;function o(){return i}t.getNavigator=o;var a="undefined"!=typeof window?window:null;function s(){return a}t.getWindow=s,t.hasDom=function(){return void 0!==s()&&void 0!==r()&&void 0!==o()&&null!=s()&&null!=r()&&null!=o()}},848:(e,t,n)=>{t.__esModule=!0,t.SavedFrames=t.SavedFrame=t.Size=t.Rectangle=t.CardEnergies=void 0;var r=n(232),i=function(e,t,n,r,i){this.cardImage=e,this.fullImage=t,this.originalPixels=n,this.originalImageSize=r,this.isCardVisible=i,Object.seal(this)};t.CardEnergies=i;var o=function(e,t,n,r){this.left=e,this.top=t,this.right=n,this.bottom=r,this.width=this.right-this.left,this.height=this.bottom-this.top,this.size=new a(this.width,this.height)};t.Rectangle=o;var a=function(e,t){this.width=e,this.height=t};t.Size=a;var s=function(e,t,n){this.pan=e,this.cardEnergies=t,this.fullImageSignature=n};t.SavedFrame=s;var u=function(){function e(){this.uxAndPan=[],this.uxOnly=[],this.panOnly=[]}return e.prototype.saveFrame=function(e){e.pan&&e.cardEnergies.isCardVisible?this.pushImage(this.uxAndPan,e):e.cardEnergies.isCardVisible?this.pushImage(this.uxOnly,e):e.pan&&this.pushImage(this.panOnly,e)},e.prototype.pushImage=function(e,t){e.push(t),e.length>r.BouncerConfig.maxSavedFrames&&e.splice(-r.BouncerConfig.maxSavedFrames)},e.prototype.selectSavedFrames=function(e){var t=this.uxAndPan.filter((function(e){e.pan})),n=this.panOnly.filter((function(e){e.pan})),i=this.uxAndPan.filter((function(e){e.pan})),o=this.panOnly.filter((function(e){e.pan})),a=t.concat(this.uxOnly.concat(n.concat(i.concat(o))));return a.length>r.BouncerConfig.maxVerificationResultsTotal?a.slice(-r.BouncerConfig.maxVerificationResultsTotal):a},e}();t.SavedFrames=u},491:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.TrackedFrameRate=t.FrameRateTracker=void 0;var o=n(757),a=function(){function e(){this.frameTrackMutex=new o.Mutex,this.framesTracked=0,this.firstFrameTime=null,this.lastFrameTime=null}return e.prototype.countFrame=function(){return r(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return[4,this.frameTrackMutex.dispatch((function(){return r(e,void 0,void 0,(function(){var e;return i(this,(function(t){return e=this.framesTracked>1?new s(((this.framesTracked-1)/(Date.now()-this.firstFrameTime)*1e3).toFixed(2),(1e3/(Date.now()-this.lastFrameTime)).toFixed(2)):new s("0","0"),this.framesTracked++,null==this.firstFrameTime&&(this.firstFrameTime=Date.now()),this.lastFrameTime=Date.now(),[2,e]}))}))}))];case 1:return[2,t.sent()]}}))}))},e}();t.FrameRateTracker=a;var s=function(e,t){this.averageRate=e,this.instantRate=t};t.TrackedFrameRate=s},477:(e,t,n)=>{t.__esModule=!0,t.supportsWebP=void 0;var r=n(109);t.supportsWebP=function(){if(r.hasDom()){var e=r.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))&&0==e.toDataURL("image/webp").indexOf("data:image/webp")}return!1}()},950:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.setUpScan=t.warmUp=t.getConfig=t.cancelScan=t.scanCard=t.isSupported=void 0;var o=n(466),a=n(178),s=n(381),u=n(529),c=n(677),l=n(255),d=n(521),h=n(256),g=n(232),M=n(109),p=n(693);function f(){var e=p.getScanInstance();e&&e.stopScan()}function m(){return r(this,void 0,void 0,(function(){return i(this,(function(e){return d.CardDetectAnalyzer.warmUp(M.getElementById("bouncer_debug_view")),[2]}))}))}function w(){if(null===M.getElementById("bouncer_scan")){var e=document.createElement("style");e.innerText=o.default;var t=M.createElement("div");t.id="bouncer_scan",t.style.display="none";var n=M.createElement("div");n.className="bouncer_modal";var r=M.createElement("img");r.className="bouncer_logo",r.src=a;var i=M.createElement("img");i.className="bouncer_close_button",i.src=s,i.onclick=function(){f()};var d=M.createElement("img");d.className="bouncer_torch_button",d.src=l;var h=M.createElement("img");h.className="bouncer_swap_button",h.src=c;var g=M.createElementNS("http://www.w3.org/2000/svg","svg");g.id="bouncer_loading_spinner",g.classList.add("bouncer_spinner"),g.setAttribute("viewBox","0 0 100 100"),g.setAttribute("version","1.1");var p=M.createElementNS("http://www.w3.org/2000/svg","circle");p.cx.baseVal.value=50,p.cy.baseVal.value=50,p.r.baseVal.value=45;var w=M.createElement("div");w.className="bouncer_message";var y=M.createElement("div");y.className="bouncer_frame_rate_tracker";var I=M.createElement("video");I.setAttribute("autoplay",null),I.setAttribute("playsinline",null),I.setAttribute("muted",null);var v=M.createElement("div");v.id="bouncer_full_view_finder";var C=M.createElement("div");C.id="bouncer_square_view_finder";var N=M.createElement("div");N.id="bouncer_card_view_finder";var D=M.createElementNS("http://www.w3.org/2000/svg","svg");D.id="bouncer_svg_view_finder",D.setAttribute("viewBox","0 0 200 126"),D.setAttribute("version","1.1");var b=M.createElementNS("http://www.w3.org/2000/svg","path");b.id="bouncer_card_path",b.setAttribute("d","\n M 2.5,20.5\n L 2.5,7.5\n a 5,5,0,0,1,5,-5\n L 192.5,2.5\n a 5,5,0,0,1,5,5\n L 197.5,118.5\n a 5,5,0,0,1,-5,5\n L 7.5,123.5\n a 5,5,0,0,1,-5,-5\n Z\n ");var S=M.createElement("div");S.className="bouncer_instructions";var T=M.createElement("div");T.className="bouncer_card_details";var E=M.createElement("div");E.className="bouncer_cannot_scan";var A=M.createElement("span"),_=M.createElement("div");_.className="bouncer_security_notification";var j=M.createElement("div");j.className="bouncer_centered_notification";var x=M.createElement("div");x.id="bouncer_card_number";var z=M.createElement("img");z.src=u;var L=M.createElement("span");L.className="bouncer_security_text";var k=M.createElement("canvas");k.id="bouncer_debug_view";var O=M.createElement("div");O.className="debug_queue_background";var R=M.createElement("div");R.className="debug_queue_foreground";var P=M.createElement("div");P.className="debug_queue_label",P.innerText="Q";var B=M.createElement("canvas");B.id="bouncer_card_image_capture";var U=M.createElement("canvas");U.id="bouncer_full_image_capture";var Q=M.createElement("canvas");Q.id="bouncer_original_pixels_capture";var F=M.createElement("canvas");F.id="bouncer_scan_video_capture",M.getDocument().head.appendChild(e),E.appendChild(A),O.appendChild(R),O.appendChild(P),_.appendChild(z),_.appendChild(L),j.appendChild(x),g.appendChild(p),D.appendChild(b),N.appendChild(D),N.appendChild(_),v.appendChild(j),n.appendChild(I),n.appendChild(v),n.appendChild(C),n.appendChild(N),n.appendChild(S),n.appendChild(T),n.appendChild(E),n.appendChild(i),n.appendChild(d),n.appendChild(h),n.appendChild(r),n.appendChild(w),n.appendChild(y),n.appendChild(O),n.appendChild(g),t.appendChild(n),t.appendChild(k),t.appendChild(B),t.appendChild(U),t.appendChild(Q),t.appendChild(F),M.getDocument().body.appendChild(t),m()}}t.isSupported=function(){return h.CameraAdapter.isCameraSupported()&&M.hasDom()},t.scanCard=function(e,t,n,r,i,o,a){void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=null),w(),g.BouncerConfig.apiKey=e;var s=p.createScanInstance();s.localize(),s.startScan(t,n,r,i,o,a)},t.cancelScan=f,t.getConfig=function(){return new g.BouncerConfig},t.warmUp=m,t.setUpScan=w},280:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.ItemCounter=void 0;var o=n(757),a=function(){function e(e){this.storage=new Map,this.mutex=new o.Mutex,void 0!==e&&this.storage.set(e,1)}return e.prototype.countItem=function(e){return r(this,void 0,void 0,(function(){var t=this;return i(this,(function(n){switch(n.label){case 0:return e?[4,this.mutex.dispatch((function(){return r(t,void 0,void 0,(function(){var t;return i(this,(function(n){return t=(this.storage.get(e)||0)+1,this.storage.set(e,t),[2,t]}))}))}))]:[3,2];case 1:return[2,n.sent()];case 2:return[2,-1]}}))}))},e.prototype.getMostLikelyField=function(){if(0==this.storage.size)return[null,0];for(var e=Array.from(this.storage.keys()),t=e[0],n=this.storage.get(t),r=1;r<this.storage.size;r++){var i=e[r],o=this.storage.get(i);o>n&&(n=o,t=i)}return[t,n]},e}();t.ItemCounter=a},307:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};t.__esModule=!0,t.ProcessBoundAnalyzerLoop=t.MainLoopState=void 0;var o=n(153),a=n(535),s=function(e,t){this.isStarted=!1,this.isRunning=!1,this.stateMachine=new o.StateMachine(new o.MachineStateLoading(e),t)};t.MainLoopState=s;var u=function(){function e(e,t,n,r,i,o){this.cameraAdapter=t,this.analyzer=n,this.resultAggregator=r,this.stateListener=i,this.state=new s(e,i),this.onScanError=o}return e.prototype.runLoop=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){re