@microblink/blinkcard-in-browser-sdk
Version:
BlinkCard SDK is credit or payment cards scanning library for WebAssembly-enabled browsers.
9 lines (8 loc) • 345 kB
JavaScript
import{r as e,c as t,h as i,H as o,g as a}from"./p-dd16dec0.js";
/*! ****************************************************************************
Copyright (c) Microblink. All rights reserved.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
***************************************************************************** */let r=0;class s{constructor(e){this.action=e,this.messageID=function(){const e=r;return r+=1,e}()}}class n extends s{constructor(e,t){super(n.action),this.wasmModuleName=e.wasmModuleName,this.licenseKey=e.licenseKey,this.userId=t,this.registerLoadCallback=null!==e.loadProgressCallback,this.allowHelloMessage=e.allowHelloMessage,this.engineLocation=e.engineLocation,this.wasmType=e.wasmType,this.wasmFlavor=e.wasmFlavor,this.numberOfWorkers=e.numberOfWorkers}}var l,c,d,h,M;n.action="init",function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback"}(l||(l={}));class g extends s{constructor(e,t){super(g.action),this.className=e,this.params=t}}g.action="createNewNativeObject";class C extends s{constructor(e,t,i){super(C.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}C.action="createRecognizerRunner";class u extends s{constructor(e,t){super(u.action),this.recognizerHandles=e,this.allowMultipleResults=t}}u.action="reconfigureRecognizerRunner";class b extends s{constructor(){super(b.action)}}b.action="deleteRecognizerRunner";class p extends s{constructor(e,t,i){super(p.action),this.objectHandle=e,this.methodName=t,this.params=i}}p.action="invokeObject";class m extends s{constructor(e){super(m.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}m.action="processImage";class N extends s{constructor(e){super(N.action),this.hardReset=e}}N.action="resetRecognizers";class D{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1,this.onGlare=!1}}class I extends s{constructor(e){super(I.action),this.registeredMetadataCallbacks=e}}I.action="registerMetadataCallbacks";class j extends s{constructor(e){super(j.action),this.detectionOnlyMode=e}}j.action="setDetectionOnly";class x extends s{constructor(e){super(x.action),this.cameraPreviewMirrored=e}}x.action="setCameraPreviewMirrored";class y extends s{constructor(e){super(y.action),this.userId=e}}y.action="getProductIntegrationInfo",function(e){e[e.onDebugText=0]="onDebugText",e[e.onDetectionFailed=1]="onDetectionFailed",e[e.onQuadDetection=2]="onQuadDetection",e[e.onPointsDetection=3]="onPointsDetection",e[e.onFirstSideResult=4]="onFirstSideResult",e[e.clearTimeoutCallback=5]="clearTimeoutCallback",e[e.onGlare=6]="onGlare",e[e.recognizerCallback=7]="recognizerCallback"}(c||(c={})),function(e){e.Basic="BASIC",e.Advanced="ADVANCED",e.AdvancedWithThreads="ADVANCED_WITH_THREADS"}(d||(d={}));class z extends Error{constructor(e,t){if(super(),!e.code||!e.message)throw new Error("Instance of SDKError is required to have code and message.");if(this.message=e.message,this.code=e.code,e instanceof f&&e.details&&"message"in e.details){const t=new Error(e.details.message);"stack"in e.details&&(t.stack=e.details.stack),this.details=t}else this.details=t}}class f{constructor(e,t){if(!e.code||!e.message)throw new Error("Instance of SerializableSDKError is required to have code and message.");this.message=e.message,this.code=e.code,this.details=t instanceof Error?new A(t):t}}class A{constructor(e){this.message=e.message,this.name=e.name,this.stack=e.stack}}function w(e,t){return i=>{const o=i;o.success?e():t("string"==typeof o.error||null===o.error?o.error:new z(o.error))}}function T(e,t){return i=>{const o=i;o.success?e(i):t("string"==typeof o.error||null===o.error?o.error:new z(o.error))}}class L{constructor(e,t,i){this.wasmSDKWorker=e,this.objectHandle=i,this.recognizerName=t,this.callbacks=new Map}getRemoteObjectHandle(){return this.objectHandle}currentSettings(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());const i=new p(this.objectHandle,"currentSettings",[]),o=T((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,o)}))}toSignedJSON(){return Promise.resolve(null)}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const o of t){const t=e[o];"function"==typeof t&&(this.callbacks.set(o,t),e[o]={parameter:{recognizerHandle:this.objectHandle,callbackName:o},type:l.Callback},i=!0)}return i&&this.wasmSDKWorker.registerRecognizerCallbacks(this.objectHandle,this),e}updateSettings(e){return new Promise(((t,i)=>{if(this.objectHandle<0)return void i("Invalid object handle: "+this.objectHandle.toString());const o=new p(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:l.RecognizerSettings}]),a=w(t,i);this.wasmSDKWorker.postMessage(o,a)}))}invokeCallback(e,t){const i=this.callbacks.get(e);void 0!==i?i(...t):console.warn("Cannot find callback",e)}getResult(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());const i=new p(this.objectHandle,"getResult",[]),o=T((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,o)}))}delete(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());this.clearAllCallbacks();const i=new p(this.objectHandle,"delete",[]),o=w((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(i,o)}))}}function v(e){const t=new D;return t.onDebugText=!!e.onDebugText,t.onDetectionFailed=!!e.onDetectionFailed,t.onPointsDetection=!!e.onPointsDetection,t.onQuadDetection=!!e.onQuadDetection,t.onFirstSideResult=!!e.onFirstSideResult,t}class E{constructor(e,t){this.deleted=!1,this.wasmSDKWorker=e,this.recognizers=t}processImage(e){return new Promise(((t,i)=>{if(this.deleted)return void i("Recognizer runner is deleted. It cannot be used anymore!");const o=new m(e),a=T((e=>{t(e.recognitionState)}),i);this.wasmSDKWorker.postTransferrableMessage(o,a)}))}reconfigureRecognizers(e,t){return new Promise(((i,o)=>{if(this.deleted)return void o("Recognizer runner is deleted. It cannot be used anymore!");const a=k(e),r=new u(a,t),s=w(i,o);this.wasmSDKWorker.postMessage(r,s),this.recognizers=e}))}setMetadataCallbacks(e){return new Promise(((t,i)=>{const o=new I(v(e)),a=w(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(o,e,a)}))}resetRecognizers(e){return new Promise(((t,i)=>{const o=new N(e),a=w(t,i);this.wasmSDKWorker.postMessage(o,a)}))}setDetectionOnlyMode(e){return new Promise(((t,i)=>{const o=new j(e),a=w(t,i);this.wasmSDKWorker.postMessage(o,a)}))}setCameraPreviewMirrored(e){return new Promise(((t,i)=>{const o=new x(e),a=w(t,i);this.wasmSDKWorker.postMessage(o,a)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const i=new b,o=w((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(i,o)}))}}function k(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class O{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise(((o,a)=>{const r=k(e),s=new C(r,t,v(i)),n=w((()=>{o(new E(this.wasmSDKWorker,e))}),a);this.wasmSDKWorker.postMessageAndRegisterCallbacks(s,i,n)}))}newRecognizer(e,...t){return new Promise(((i,o)=>{const a=new g(e,function(e){const t=[];for(let i of e){let e=l.Any;i instanceof L&&(e=l.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),r=T((t=>{const o=new L(this.wasmSDKWorker,e,t.objectHandle);i(o)}),o);this.wasmSDKWorker.postMessage(a,r)}))}}class S{constructor(e,t,i,o){this.eventHandlers={},this.metadataCallbacks={},this.loadedWasmType=d.Basic,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{o("Problem during initialization of worker file!")},this.mbWasmModule=new O(this),this.loadCallback=t,this.recognizersWithCallbacks=new Map,this.userId=i,this.showOverlay=!1}postMessage(e,t){this.eventHandlers[e.messageID]=t,this.mbWasmWorker.postMessage(e)}postTransferrableMessage(e,t){this.eventHandlers[e.messageID]=t,this.mbWasmWorker.postMessage(e,e.getTransferrables())}postMessageAndRegisterCallbacks(e,t,i){this.eventHandlers[e.messageID]=i,this.metadataCallbacks=t,this.mbWasmWorker.postMessage(e)}registerRecognizerCallbacks(e,t){this.recognizersWithCallbacks.set(e,t)}unregisterRecognizerCallbacks(e){this.recognizersWithCallbacks.delete(e)}delete(){this.mbWasmWorker.terminate()}getProductIntegrationInfo(){return new Promise(((e,t)=>{const i=new y(this.userId),o=T((t=>{e(t.result)}),t);this.postMessage(i,o)}))}handleWorkerEvent(e){if("isCallbackMessage"in e.data){const t=e.data;switch(t.callbackType){case c.onDebugText:"function"==typeof this.metadataCallbacks.onDebugText&&this.metadataCallbacks.onDebugText(t.callbackParameters[0]);break;case c.onDetectionFailed:"function"==typeof this.metadataCallbacks.onDetectionFailed&&this.metadataCallbacks.onDetectionFailed();break;case c.onPointsDetection:"function"==typeof this.metadataCallbacks.onPointsDetection&&this.metadataCallbacks.onPointsDetection(t.callbackParameters[0]);break;case c.onQuadDetection:"function"==typeof this.metadataCallbacks.onQuadDetection&&this.metadataCallbacks.onQuadDetection(t.callbackParameters[0]);break;case c.onFirstSideResult:"function"==typeof this.metadataCallbacks.onFirstSideResult&&this.metadataCallbacks.onFirstSideResult();break;case c.recognizerCallback:{const e=t.callbackParameters.shift(),i=this.recognizersWithCallbacks.get(e.recognizerHandle);void 0!==i?i.invokeCallback(e.callbackName,t.callbackParameters):console.warn("Cannot find recognizer to deliver callback message. Maybe it's destroyed?",e);break}default:throw new Error(`Unknown callback type: ${c[t.callbackType]}`)}}else if("isLoadProgressMessage"in e.data)"function"==typeof this.loadCallback&&this.loadCallback(e.data.progress);else{const t=e.data,i=this.eventHandlers[t.messageID];delete this.eventHandlers[t.messageID],i(t)}}static async createWasmWorker(e,t,i){return new Promise(((o,a)=>{const r=new S(e,t.loadProgressCallback,i,a),s=new n(t,i),l=T((e=>{const t=e;r.showOverlay=t.showOverlay,r.loadedWasmType=t.wasmType,o(r)}),(e=>{r&&"function"==typeof r.delete&&r.delete(),a(e)}));r.postMessage(s,l)}))}}!function(e){e.WORKER_WASM_LOAD_FAILURE="WORKER_WASM_LOAD_FAILURE",e.WORKER_WASM_INIT_MISSING="WORKER_WASM_INIT_MISSING",e.WORKER_FUNCTION_INVOKE_FAILURE="WORKER_FUNCTION_INVOKE_FAILURE",e.WORKER_RECOGNIZER_CREATION_FAILURE="WORKER_RECOGNIZER_CREATION_FAILURE",e.WORKER_RUNNER_EXISTS="WORKER_RUNNER_EXISTS",e.WORKER_RUNNER_CREATION_FAILURE="WORKER_RUNNER_CREATION_FAILURE",e.WORKER_RUNNER_MISSING="WORKER_RUNNER_MISSING",e.WORKER_RUNNER_RECONFIGURE_FAILURE="WORKER_RUNNER_RECONFIGURE_FAILURE",e.WORKER_RUNNER_DELETED="WORKER_RUNNER_DELETED",e.WORKER_RUNNER_DELETE_FAILURE="WORKER_RUNNER_DELETE_FAILURE",e.WORKER_OBJECT_INVOKE_FAILURE="WORKER_OBJECT_INVOKE_FAILURE",e.WORKER_IMAGE_PROCESS_FAILURE="WORKER_IMAGE_PROCESS_FAILURE",e.WORKER_HANDLE_UNDEFINED="WORKER_HANDLE_UNDEFINED",e.WORKER_MESSAGE_ACTION_UNKNOWN="WORKER_MESSAGE_ACTION_UNKNOWN",e.WORKER_LICENSE_UNLOCK_ERROR="WORKER_LICENSE_UNLOCK_ERROR",e.WORKER_INTEGRATION_INFO_FAILURE="WORKER_INTEGRATION_INFO_FAILURE",e.LOCAL_SDK_RUNNER_MISSING="LOCAL_SDK_RUNNER_MISSING",e.LOCAL_SDK_RUNNER_EMPTY="LOCAL_SDK_RUNNER_EMPTY",e.LICENSE_UNLOCK_ERROR="LICENSE_UNLOCK_ERROR",e.FRAME_CAPTURE_SVG_UNSUPPORTED="FRAME_CAPTURE_SVG_UNSUPPORTED",e.FRAME_CAPTURE_CANVAS_MISSING="FRAME_CAPTURE_CANVAS_MISSING",e.SDK_WASM_SETTINGS_MISSING="SDK_WASM_SETTINGS_MISSING",e.SDK_LICENSE_KEY_MISSING="SDK_LICENSE_KEY_MISSING",e.SDK_WASM_MODULE_NAME_MISSING="SDK_WASM_MODULE_NAME_MISSING",e.SDK_ENGINE_LOCATION_INVALID="SDK_ENGINE_LOCATION_INVALID",e.SDK_WORKER_LOCATION_INVALID="SDK_WORKER_LOCATION_INVALID",e.SDK_MISSING="SDK_MISSING",e.SDK_RECOGNIZERS_MISSING="SDK_RECOGNIZERS_MISSING",e.VIDEO_RECOGNIZER_ELEMENT_MISSING="VIDEO_RECOGNIZER_ELEMENT_MISSING",e.VIDEO_RECOGNIZER_CAMERA_MISSING="VIDEO_RECOGNIZER_CAMERA_MISSING",e.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED="VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED",e.VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE="VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE",e.VIDEO_RECOGNIZER_CAMERA_IN_USE="VIDEO_RECOGNIZER_CAMERA_IN_USE",e.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED="VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED",e.VIDEO_RECOGNIZER_FEED_RELEASED="VIDEO_RECOGNIZER_FEED_RELEASED",e.VIDEO_RECOGNIZER_FEED_NOT_PAUSED="VIDEO_RECOGNIZER_FEED_NOT_PAUSED",e.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED="VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED",e.VIDEO_RECOGNIZER_FEED_PAUSED="VIDEO_RECOGNIZER_FEED_PAUSED",e.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE="VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE",e.VIDEO_RECOGNIZER_FEED_MISSING="VIDEO_RECOGNIZER_FEED_MISSING"}(h||(h={})),function(e){e.WORKER_HANDLE_UNDEFINED="Cannot find object with handle: undefined",e.WORKER_WASM_LOAD_FAILURE="Failed to load WASM in web worker!",e.WORKER_WASM_INIT_MISSING="WASM module is not initialized!",e.WORKER_FUNCTION_INVOKE_FAILURE="Failed to invoke function!",e.WORKER_RECOGNIZER_CREATION_FAILURE="Failed to create new recognizer!",e.WORKER_RUNNER_EXISTS="Recognizer runner is already created! Multiple instances are not allowed!",e.WORKER_RUNNER_CREATION_FAILURE="Failed to create new recognizer runner!",e.WORKER_RUNNER_MISSING="Recognizer runner is not created! There is nothing to reconfigure!",e.WORKER_RUNNER_RECONFIGURE_FAILURE="Failed to reconfigure recognizer runner!",e.WORKER_RUNNER_DELETED="Recognizer runner is already deleted!",e.WORKER_RUNNER_DELETE_FAILURE="Failed to delete recognizer runner!",e.WORKER_OBJECT_INVOKE_FAILURE="Failed to invoke object!",e.WORKER_IMAGE_PROCESS_FAILURE="Recognizer runner is not initialized! Cannot process image!",e.WORKER_INTEGRATION_INFO_FAILURE="Failed to get product integration info!",e.LOCAL_SDK_RUNNER_MISSING="Property nativeRecognizerRunner is not available!",e.LOCAL_SDK_RUNNER_EMPTY="Native RecognizerRunner cannot be empty!",e.LICENSE_TOKEN_STATE_INCORRECT="Internal error (Incorrect token state)",e.LICENSE_PAYLOAD_VERIFICATION_FAILED="Failed to verify server permission's digital signature!",e.LICENSE_PAYLOAD_CORRUPTED="Server permission payload is corrupted!",e.LICENSE_PERMISSION_EXPIRED="Internal error (server permission expired)",e.LICENSE_REMOTE_LOCKED="Provided license key has been remotely locked. Please contact support for more information!",e.FRAME_CAPTURE_SVG_UNSUPPORTED="Recognition of SVG elements not supported!",e.FRAME_CAPTURE_CANVAS_MISSING="Could not get canvas 2d context!",e.SDK_WASM_SETTINGS_MISSING="Missing WASM load settings!",e.SDK_LICENSE_KEY_MISSING="Missing license key!",e.SDK_WASM_MODULE_NAME_MISSING="Missing WASM module name!",e.SDK_ENGINE_LOCATION_INVALID="Setting property 'engineLocation' must be a string!",e.SDK_WORKER_LOCATION_INVALID="Setting property 'workerLocation' must be a string!",e.SDK_MISSING="SDK is not provided!",e.SDK_RECOGNIZERS_MISSING="To create RecognizerRunner at least 1 recognizer is required.",e.VIDEO_RECOGNIZER_ELEMENT_MISSING="Video element, i.e. camera feed is not provided!",e.VIDEO_RECOGNIZER_CAMERA_MISSING="Camera not found!",e.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED="Camera not allowed!",e.VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE="Camera not available!",e.VIDEO_RECOGNIZER_CAMERA_IN_USE="Camera in use!",e.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED="Media devices not supported by browser.",e.VIDEO_RECOGNIZER_FEED_RELEASED="The associated video feed has been released!",e.VIDEO_RECOGNIZER_FEED_NOT_PAUSED="The associated video feed is not paused. Use resumeRecognition instead!",e.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED="The play() request was interrupted or prevented by browser security rules!",e.VIDEO_RECOGNIZER_FEED_PAUSED="Cannot resume recognition while video feed is paused! Use recognize or startRecognition",e.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE="Could not reset recognizers!",e.VIDEO_RECOGNIZER_FEED_MISSING="Missing video feed!"}(M||(M={}));const Z={feedMissing:{message:M.VIDEO_RECOGNIZER_FEED_MISSING,code:h.VIDEO_RECOGNIZER_FEED_MISSING},recognizersResetFailure:{message:M.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE,code:h.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE},feedPaused:{message:M.VIDEO_RECOGNIZER_FEED_PAUSED,code:h.VIDEO_RECOGNIZER_FEED_PAUSED},playRequestInterrupted:{message:M.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED,code:h.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED},videoFeedNotPaused:{message:M.VIDEO_RECOGNIZER_FEED_NOT_PAUSED,code:h.VIDEO_RECOGNIZER_FEED_NOT_PAUSED},videoFeedReleased:{message:M.VIDEO_RECOGNIZER_FEED_RELEASED,code:h.VIDEO_RECOGNIZER_FEED_RELEASED},mediaDevicesUnsupported:{code:h.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED,message:M.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED},cameraMissing:{code:h.VIDEO_RECOGNIZER_CAMERA_MISSING,message:M.VIDEO_RECOGNIZER_CAMERA_MISSING},cameraNotAllowed:{code:h.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED,message:M.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED},elementMissing:{message:M.VIDEO_RECOGNIZER_ELEMENT_MISSING,code:h.VIDEO_RECOGNIZER_ELEMENT_MISSING}},Q={wasmSettingsMissing:{message:M.SDK_WASM_SETTINGS_MISSING,code:h.SDK_WASM_SETTINGS_MISSING},licenseKeyMissing:{message:M.SDK_LICENSE_KEY_MISSING,code:h.SDK_LICENSE_KEY_MISSING},wasmModuleNameMissing:{message:M.SDK_WASM_MODULE_NAME_MISSING,code:h.SDK_WASM_MODULE_NAME_MISSING},engineLocationInvalid:{message:M.SDK_ENGINE_LOCATION_INVALID,code:h.SDK_ENGINE_LOCATION_INVALID},workerLocationInvalid:{message:M.SDK_WORKER_LOCATION_INVALID,code:h.SDK_WORKER_LOCATION_INVALID},missing:{message:M.SDK_MISSING,code:h.SDK_MISSING},recognizersMissing:{message:M.SDK_RECOGNIZERS_MISSING,code:h.SDK_RECOGNIZERS_MISSING}},U={svgUnsupported:{message:M.FRAME_CAPTURE_SVG_UNSUPPORTED,code:h.FRAME_CAPTURE_SVG_UNSUPPORTED},canvasMissing:{message:M.FRAME_CAPTURE_CANVAS_MISSING,code:h.FRAME_CAPTURE_CANVAS_MISSING}},Y={licenseTokenStateIncorrect:{code:h.LICENSE_UNLOCK_ERROR,message:M.LICENSE_TOKEN_STATE_INCORRECT},licensePayloadVerificationFailed:{code:h.LICENSE_UNLOCK_ERROR,message:M.LICENSE_PAYLOAD_VERIFICATION_FAILED},licensePayloadCorrupted:{code:h.LICENSE_UNLOCK_ERROR,message:M.LICENSE_PAYLOAD_CORRUPTED},licensePermissionExpired:{code:h.LICENSE_UNLOCK_ERROR,message:M.LICENSE_PERMISSION_EXPIRED},licenseRemoteLocked:{code:h.LICENSE_UNLOCK_ERROR,message:M.LICENSE_REMOTE_LOCKED},licenseNetworkError:{code:h.LICENSE_UNLOCK_ERROR},licenseInvalid:{code:h.LICENSE_UNLOCK_ERROR}},V={runnerMissing:{message:M.LOCAL_SDK_RUNNER_MISSING,code:h.LOCAL_SDK_RUNNER_MISSING},runnerEmpty:{message:M.LOCAL_SDK_RUNNER_EMPTY,code:h.LOCAL_SDK_RUNNER_EMPTY}},_={imageProcessFailure:{message:M.WORKER_IMAGE_PROCESS_FAILURE,code:h.WORKER_IMAGE_PROCESS_FAILURE},objectInvokeFailure:{message:M.WORKER_OBJECT_INVOKE_FAILURE,code:h.WORKER_OBJECT_INVOKE_FAILURE},runnerDeleteFailure:{message:M.WORKER_RUNNER_DELETE_FAILURE,code:h.WORKER_RUNNER_DELETE_FAILURE},runnerDeleted:{message:M.WORKER_RUNNER_DELETED,code:h.WORKER_RUNNER_DELETED},runnerReconfigureFailure:{message:M.WORKER_RUNNER_RECONFIGURE_FAILURE,code:h.WORKER_RUNNER_RECONFIGURE_FAILURE},runnerMissing:{message:M.WORKER_RUNNER_MISSING,code:h.WORKER_RUNNER_MISSING},runnerCreationFailure:{message:M.WORKER_RUNNER_CREATION_FAILURE,code:h.WORKER_RUNNER_CREATION_FAILURE},runnerExists:{message:M.WORKER_RUNNER_EXISTS,code:h.WORKER_RUNNER_EXISTS},recognizerCreationFailure:{message:M.WORKER_RECOGNIZER_CREATION_FAILURE,code:h.WORKER_RECOGNIZER_CREATION_FAILURE},functionInvokeFailure:{message:M.WORKER_FUNCTION_INVOKE_FAILURE,code:h.WORKER_FUNCTION_INVOKE_FAILURE},wasmInitMissing:{message:M.WORKER_WASM_INIT_MISSING,code:h.WORKER_WASM_INIT_MISSING},wasmLoadFailure:{message:M.WORKER_WASM_LOAD_FAILURE,code:h.WORKER_WASM_LOAD_FAILURE},handleUndefined:{message:M.WORKER_HANDLE_UNDEFINED,code:h.WORKER_HANDLE_UNDEFINED},integrationInfoFailure:{message:M.WORKER_INTEGRATION_INFO_FAILURE,code:h.WORKER_INTEGRATION_INFO_FAILURE}};var R;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(R||(R={}));const G=["rear","back","rück","arrière","trasera","trás","traseira","posteriore","posterior","后面","後面","背面","后置","後置","背置","задней","الخلفية","후","arka","achterzijde","หลัง","baksidan","bagside","sau","bak","tylny","takakamera","belakang","אחורית","πίσω","spate","hátsó","zadní","darrere","zadná","задня","stražnja","belakang","बैक"],H=["Cameră dublă cu obiectiv superangular spate","מצלמה כפולה רחבה אחורית","Артқы қос кең бұрышты камера","Câmara grande angular dupla traseira","Πίσω διπλή ευρεία κάμερα","後置雙廣角鏡頭相機","Задна двойна широкоъгълна камера","Càmera dual posterior amb gran angular","Zadná duálna širokouhlá kamera","كاميرا خلفية مزدوجة عريضة","Задняя двойная широкоугольная камера","Задня здвоєна ширококутна камера","Cámara amplia posterior doble","Dwikamera Lebar Belakang","Tylny dwuobiektywowy aparat szerokokątny","Dubbel vidvinkelkamera på baksidan","Back Dual Wide Camera","Hátsó, kettős, széles látószögű kamera","후면 듀얼 와이드 카메라","Double caméra grand angle arrière","Fotocamera doppia con grandangolo (posteriore)","Double appareil photo grand angle arrière","Zadní duální širokoúhlý fotoaparát","Çift Geniş Kamera Arka Yüzü","Laajakulmainen kaksoistakakamera","Rückseitige Dual-Weitwinkelkamera","बैक ड्युअल वाइड कैमरा","后置双广角镜头","Câmera Dupla Grande-Angular Traseira","後置雙廣角相機","กล้องคู่ด้านหลังมุมกว้าง","Kamera Lebar Belakang Ganda","Dobbelt vidvinkelkamera bak","Camera kép rộng mặt sau","Cámara trasera dual con gran angular","背面デュアル広角カメラ","Stražnja dvostruka široka kamera"],F=["후면 카메라","後置相機","Задна камера","後置鏡頭","Camera mặt sau","Hátoldali kamera","Cámara trasera","Back Camera","Kamera på baksidan","Πίσω κάμερα","Bagsidekamera","Zadná kamera","Fotocamera (posteriore)","Câmara traseira","מצלמה אחורית","Takakamera","Rückkamera","Caméra arrière","Zadní fotoaparát","Артқы камера","Tylny aparat","बैक कैमरा","Hátsó kamera","Camera aan achterzijde","Kamera Belakang","Câmera Traseira","Stražnja kamera","الكاميرا الخلفية","Càmera posterior","Fotocamera posteriore","Càmera del darrere","กล้องด้านหลัง","Cameră spate","Kamera, bagside","背面カメラ","Задня камера","Arka Kamera","后置相机","Камера на задней панели","后置镜头","Kamera bak","Задняя камера","Aparat tylny","Kamera på baksiden","Câmera de Trás"],W=()=>!!navigator.userAgent.match(/Android/i),P=()=>!!navigator.userAgent.match(/iPhone/i);function B(e){const t=e.toLowerCase();return G.some((e=>t.includes(e)))}class J{constructor(e,t,i){this.deviceId=e.deviceId,this.facing=t,this.groupId=e.groupId,this.label=i||e.label}}async function K(){const e=[],t=[];let i=await navigator.mediaDevices.enumerateDevices();if(i.filter((e=>"videoinput"===e.kind)).every((e=>""===e.label))){const e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});i=await navigator.mediaDevices.enumerateDevices(),e.getTracks().forEach((e=>e.stop()))}const o=i.filter((e=>"videoinput"===e.kind));let a=0,r=0;for(const i of o)if(B(i.label)){let e;a++,W()&&(e=`Back camera ${a}`),t.push(new J(i,R.BackFacingCamera,e))}else{let t;r++,W()&&(t=`Front camera ${r}`),e.push(new J(i,R.FrontFacingCamera,t))}return{frontCameras:e,backCameras:t}}async function X(e,t){const{frontCameras:i,backCameras:o}=await K();if(!i.length&&!o.length)return null;if(e){let t;return t=i.find((t=>t.deviceId===e)),t||(t=o.find((t=>t.deviceId===e))),t||null}let a=null;if(P()&&t===R.BackFacingCamera){let e=o.find((e=>H.includes(e.label)));e||(e=o.find((e=>F.includes(e.label)))),e&&(a=e)}else if(W()&&t===R.BackFacingCamera){let e={deviceId:"",score:-1};const t=(e,t)=>{let i=0;return e&&i++,t&&i++,i};for(const i of o){const o=await navigator.mediaDevices.getUserMedia({video:{deviceId:i.deviceId,width:1920,height:1080}});if("getCapabilities"in o.getVideoTracks()[0]){const a=o.getVideoTracks()[0].getCapabilities(),r=Boolean(a.torch),s=a.focusMode?.includes("single-shot"),n=t(r,s);n>e.score&&(e={deviceId:i.deviceId,score:n})}$(o)}a=o.find((t=>t.deviceId===e.deviceId))||null}if(null===a){let e=o.length>0?o:i;t===R.BackFacingCamera&&o.length>0&&(e=o),t===R.FrontFacingCamera&&i.length>0&&(e=i),e=e.sort(((e,t)=>e.label.localeCompare(t.label)));let a=e.length-1;const r=e.map((e=>{const t=RegExp(/\b([0-9]+)MP?\b/,"i").exec(e.label);return null!==t?parseInt(t[1],10):NaN}));return r.some((e=>isNaN(e)))||(a=r.lastIndexOf(Math.max(...r))),e[a]}return a}const $=e=>{const t=e.getTracks();for(const e of t)e.stop()};async function q(e,t,i=R.BackFacingCamera){const o={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};""===e.deviceId?o.video.facingMode={ideal:i===R.BackFacingCamera?"environment":"user"}:o.video.deviceId={exact:e.deviceId};const a=await navigator.mediaDevices.getUserMedia(o);t.controls=!1,t.srcObject=a;let r=!1;return e.facing===R.FrontFacingCamera&&(r=!0),r}var ee,te,ie,oe;function ae(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){return!1}return!1}let re,se;!function(e){e[e.RotatedLeft90=0]="RotatedLeft90",e[e.NoRotation=1]="NoRotation",e[e.RotatedRight90=2]="RotatedRight90",e[e.Rotated180=3]="Rotated180"}(ee||(ee={})),function(e){e[e.Empty=0]="Empty",e[e.Uncertain=1]="Uncertain",e[e.Valid=2]="Valid",e[e.StageValid=3]="StageValid"}(te||(te={})),function(e){e[e.Off=0]="Off",e[e.Low=1]="Low",e[e.Mid=2]="Mid",e[e.High=3]="High"}(ie||(ie={})),function(e){e[e.Front=0]="Front",e[e.Back=1]="Back"}(oe||(oe={}));class ne{constructor(e,t,i){this.imageData={data:e.data,width:e.width,height:e.height,colorSpace:e.colorSpace},this.orientation=t,this.videoFrame=i}}function le(e,t=!1){let i,o,a=!1;if(e instanceof HTMLVideoElement)i=e.videoWidth,o=e.videoHeight,a=!0;else if(e instanceof HTMLImageElement)i=e.naturalWidth,o=e.naturalHeight;else{if(e instanceof SVGImageElement)throw new z(U.svgUnsupported);i=e.width,o=e.height}if(re=re||document.createElement("canvas"),re.width!==i&&re.height!==o&&(re.width=i,re.height=o),se=se||re.getContext("2d",{willReadFrequently:!0,alpha:!1}),!se)throw new z(U.canvasMissing);se.drawImage(e,0,0,re.width,re.height);const r=t?.66:1,s=re.width*r,n=re.height*r,l=se.getImageData((re.width-s)/2,(re.height-n)/2,s,n);return new ne(l,ee.NoRotation,a)}var ce,de,he,Me;function ge(e){return{licenseId:e.licenseId,licensee:e.licensee,applicationIds:e.applicationIds,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}async function Ce(e,t){try{const i=await fetch("https://baltazar.microblink.com/api/v2/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(ge(e))});if(i.ok){const e=(await i.text()).toString();return t.submitServerPermission(e)}return{status:he.NetworkError,lease:0,networkErrorDescription:`Server responded with status ${i.status}`}}catch(e){return{status:he.NetworkError,lease:0,networkErrorDescription:`Unexpected error: ${JSON.stringify(e)}`}}}!function(e){e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid"}(ce||(ce={})),function(e){e.LicenseTokenStateInvalid="LICENSE_TOKEN_STATE_INVALID",e.NetworkError="NETWORK_ERROR",e.RemoteLock="REMOTE_LOCK",e.PermissionExpired="PERMISSION_EXPIRED",e.PayloadCorrupted="PAYLOAD_CORRUPTED",e.PayloadSignatureVerificationFailed="PAYLOAD_SIGNATURE_VERIFICATION_FAILED",e.IncorrectTokenState="INCORRECT_TOKEN_STATE"}(de||(de={})),function(e){e[e.Ok=0]="Ok",e[e.NetworkError=1]="NetworkError",e[e.RemoteLock=2]="RemoteLock",e[e.PermissionExpired=3]="PermissionExpired",e[e.PayloadCorrupted=4]="PayloadCorrupted",e[e.PayloadSignatureVerificationFailed=5]="PayloadSignatureVerificationFailed",e[e.IncorrectTokenState=6]="IncorrectTokenState"}(he||(he={})),function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success",e[e.CameraTooFar=2]="CameraTooFar",e[e.CameraTooClose=3]="CameraTooClose",e[e.CameraAngleTooSteep=4]="CameraAngleTooSteep",e[e.DocumentTooCloseToCameraEdge=5]="DocumentTooCloseToCameraEdge",e[e.DocumentPartiallyVisible=6]="DocumentPartiallyVisible",e[e.FallbackSuccess=7]="FallbackSuccess"}(Me||(Me={}));class ue extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}}const be=function({limit:e,interval:t,strict:i}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=new Map;let a=0,r=0;const s=[],n=i?function(){const i=Date.now();if(s.length<e)return s.push(i),0;const o=s.shift()+t;return i>=o?(s.push(i),0):(s.push(o),o-i)}:function(){const i=Date.now();return i-a>t?(r=1,a=i,0):(r<e?r++:(a+=t,r=1),a-i)};return e=>{const t=function(...i){if(!t.isEnabled)return(async()=>e.apply(this,i))();let a;return new Promise(((t,r)=>{a=setTimeout((()=>{t(e.apply(this,i)),o.delete(a)}),n()),o.set(a,r)}))};return t.abort=()=>{for(const e of o.keys())clearTimeout(e),o.get(e)(new ue);o.clear(),s.splice(0,s.length)},t.isEnabled=!0,Object.defineProperty(t,"queueSize",{get:()=>o.size}),t}}({limit:1,interval:Math.round(1/15*1e3),strict:!0});var pe;!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(pe||(pe={}));class me{constructor(e,t,i=!1,o=null){this.deviceId=null,this.recognitionCancelRequested=!1,this.recognitionPauseRequested=!1,this.recognitionTimeoutMs=2e4,this.timeoutStartedAt=0,this.currentTimeoutCount=0,this.videoRecognitionMode=pe.Recognition,this.onScanningDone=null,this.onFrameProcessed=null,this.cameraFlipped=!1,this.threadBusy=!1,this.handleFlippingVideo=async()=>{this.videoElement.style.transform=`scaleX(${this.cameraFlipped?-1:1})`,await this.recognizerRunner.setCameraPreviewMirrored(this.cameraFlipped)},this.setOnFrameProcessed=e=>{this.onFrameProcessed=e},this.flipCamera=async()=>{this.cameraFlipped=!this.cameraFlipped,await this.handleFlippingVideo()},this.isCameraFlipped=()=>this.cameraFlipped,this.setVideoRecognitionMode=async e=>{this.videoRecognitionMode=e;const t=this.videoRecognitionMode===pe.DetectionTest;await this.recognizerRunner.setDetectionOnlyMode(t)},this.startRecognition=async(e,t=2e4)=>{try{await this.videoElement.play()}catch(e){throw new Error(M.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED)}this.recognitionPauseRequested=!1,this.recognitionCancelRequested=!1,this.clearTimeout(),this.recognitionTimeoutMs=t,this.onScanningDone=e,await this.throttledQueueFrame()},this.resumeRecognition=async e=>{if(e)try{await this.resetRecognizers(!0)}catch(e){throw new z(Z.recognizersResetFailure)}try{await this.videoElement.play()}catch(e){throw new Error(M.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED)}try{this.recognitionPauseRequested=!1,await this.throttledQueueFrame()}catch(e){this.recognitionPauseRequested=!0,console.error(e)}},this.recognize=(e=2e4)=>new Promise((t=>{this.startRecognition((e=>{this.pauseVideoFeed(),t(e)}),e)})),this.pauseVideoFeed=()=>{this.videoElement.readyState>this.videoElement.HAVE_CURRENT_DATA&&!this.videoElement.paused&&(this.videoElement.pause(),this.pauseRecognition())},this.pauseRecognition=()=>{this.recognitionPauseRequested=!0},this.cancelRecognition=()=>{this.recognitionCancelRequested=!0},this.resetRecognizers=async e=>{await this.recognizerRunner.resetRecognizers(e)},this.getRecognizerRunner=()=>this.recognizerRunner,this.getVideoElement=()=>this.videoElement,this.changeCameraDevice=async e=>{this.pauseRecognition(),this.releaseVideoFeed(),await q(e,this.videoElement,R.BackFacingCamera),await this.resumeRecognition(!0)},this.queueFrame=()=>new Promise((e=>{this.frameCallback((()=>{this.recognitionLoop().then((()=>e()))}))})),this.throttledQueueFrame=be(this.queueFrame),this.recognitionLoop=async()=>{if(this.threadBusy)return;if(this.recognitionPauseRequested)return;if(this.recognitionCancelRequested)return this.clearTimeout(),await this.resetRecognizers(!0),this.onScanningDone=null,void(this.recognitionCancelRequested=!1);const e=le(this.videoElement);await new Promise((e=>setTimeout(e,0))),this.threadBusy=!0;const t=await this.recognizerRunner.processImage(e),i=await this.recognizerRunner.recognizers[0].getResult();if(this.threadBusy=!1,"function"==typeof this.onFrameProcessed&&this.onFrameProcessed(i,e.imageData),this.videoRecognitionMode===pe.DetectionTest||this.videoRecognitionMode===pe.RecognitionTest)return await this.recognizerRunner.resetRecognizers(!0),this.clearTimeout(),void this.throttledQueueFrame();switch(t){case te.Valid:return this.clearTimeout(),void("function"==typeof this.onScanningDone&&this.onScanningDone(t));case te.Uncertain:{const e=performance.now();return 0===this.timeoutStartedAt&&(this.timeoutStartedAt=e),this.currentTimeoutCount=e-this.timeoutStartedAt,this.currentTimeoutCount<this.recognitionTimeoutMs?void this.throttledQueueFrame():(this.clearTimeout(),void("function"==typeof this.onScanningDone&&this.onScanningDone(t)))}case te.StageValid:case te.Empty:return this.clearTimeout(),void this.throttledQueueFrame()}},this.clearTimeout=()=>{this.currentTimeoutCount=0,this.timeoutStartedAt=0},this.releaseVideoFeed=()=>{this.videoElement&&null!==this.videoElement.srcObject&&this.videoElement.srcObject instanceof MediaStream&&(this.videoElement.srcObject.getTracks().forEach((e=>e.stop())),this.videoElement.srcObject=null)},this.videoElement=e,this.recognizerRunner=t,this.cameraFlipped=i,this.deviceId=o,this.frameCallback="requestVideoFrameCallback"in HTMLVideoElement.prototype?this.videoElement.requestVideoFrameCallback.bind(this.videoElement):window.requestAnimationFrame.bind(window),this.handleFlippingVideo(),this.videoElement.setAttribute("playsinline",""),this.videoElement.setAttribute("mute","")}static async createVideoRecognizerFromCameraStream(e,t,i=null,o=R.BackFacingCamera){if(!(e&&e instanceof HTMLVideoElement))throw new z(Z.elementMissing);if(!navigator.mediaDevices.getUserMedia)throw new z(Z.mediaDevicesUnsupported);const a=await X(i,o);if(!a)throw new z(Z.cameraMissing);const r=await q(a,e,o);return new me(e,t,r,a.deviceId)}static createVideoRecognizerFromVideoPath(e,t,i){const o=new me(t,i);return t.src=e,t.currentTime=0,t.onended=()=>{o.cancelRecognition()},o}}class Ne{constructor(e){if(this.allowHelloMessage=!0,this.engineLocation="",this.workerLocation="",this.wasmType=null,this.wasmFlavor="",this.numberOfWorkers=null,this.loadProgressCallback=null,this.wasmModuleName="BlinkCardWasmSDK",!e)throw new z(Q.licenseKeyMissing);this.licenseKey=e}}const De=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),Ie=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])),je=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),xe=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])),ye=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])),ze=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]));function fe(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}async function Ae(){if(!await(async e=>{try{return"undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))return!1;if(!("importScripts"in self))throw Error("Not implemented");return!fe()&&"Worker"in self}function we(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))}async function Te(e){return new Promise(((t,i)=>{if(!e||"object"!=typeof e)return void i(new z(Q.wasmSettingsMissing));if("string"!=typeof e.licenseKey)return void i(new z(Q.licenseKeyMissing));if(!e.wasmModuleName)return void i(new z(Q.wasmModuleNameMissing));if("string"!=typeof e.engineLocation)return void i(new z(Q.engineLocationInvalid));if("string"!=typeof e.workerLocation)return void i(new z(Q.workerLocationInvalid));const o=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=we(),localStorage.setItem("mb-user-id",e)),e}catch(e){return we()}}();try{const a=`/resources/${e.wasmModuleName}.worker.min.js`,r=window.location.origin+a,s=e.workerLocation||r;e.allowHelloMessage&&console.log("Worker location is:",s);const n=new Worker(s);S.createWasmWorker(n,e,o).then((e=>{t(e)}),i)}catch(e){i(e)}}))}async function Le(e,t,i=!1,o={}){if("object"!=typeof e)throw new z(Q.missing);if("object"!=typeof t||t.length<1)throw new z(Q.recognizersMissing);return e.mbWasmModule.createRecognizerRunner(t,i,o)}async function ve(e,t){const i=await e.mbWasmModule.newRecognizer("SuccessFrameGrabberRecognizer",t);return i.wrappedRecognizer=t,i}class Ee{constructor(e=0,t=0,i=0,o=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(o),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=o}checkExtensionFactor(e){if(e>1||e<-1)throw new Error("Extension factor must be in range [-1.0, 1.0]")}}var ke,Oe,Se,Ze,Qe,Ue;!function(e){e[e.NotAvailable=0]="NotAvailable",e[e.HandNotPresent=1]="HandNotPresent",e[e.NotEnoughHandPresent=2]="NotEnoughHandPresent",e[e.DocumentNotInHand=3]="DocumentNotInHand",e[e.DocumentInHand=4]="DocumentInHand"}(ke||(ke={})),function(e){e[e.NotPerformed=0]="NotPerformed",e[e.Pass=1]="Pass",e[e.Fail=2]="Fail"}(Oe||(Oe={})),function(e){e[e.Disabled=0]="Disabled",e[e.Level1=1]="Level1",e[e.Level2=2]="Level2",e[e.Level3=3]="Level3",e[e.Level4=4]="Level4",e[e.Level5=5]="Level5",e[e.Level6=6]="Level6",e[e.Level7=7]="Level7",e[e.Level8=8]="Level8",e[e.Level9=9]="Level9",e[e.Level10=10]="Level10"}(Se||(Se={})),function(e){e[e.None=0]="None",e[e.ImageOnly=1]="ImageOnly",e[e.ResultFieldsOnly=2]="ResultFieldsOnly",e[e.FullResult=3]="FullResult",e[e.Count=4]="Count"}(Ze||(Ze={}));class Ye{constructor(){this.mode=Ze.ImageOnly,this.prefixDigitsVisible=0,this.suffixDigitsVisible=4}}class Ve{constructor(){this.cardNumberAnonymizationSettings=new Ye,this.cardNumberPrefixAnonymizationMode=Ze.None,this.cvvAnonymizationMode=Ze.None,this.ibanAnonymizationMode=Ze.ImageOnly,this.ownerAnonymizationMode=Ze.None,this.fallbackAnonymization=!1}}!function(e){e[e.Other=0]="Other",e[e.AmericanExpress=1]="AmericanExpress",e[e.ChinaUnionPay=2]="ChinaUnionPay",e[e.Diners=3]="Diners",e[e.DiscoverCard=4]="DiscoverCard",e[e.Elo=5]="Elo",e[e.Jcb=6]="Jcb",e[e.Maestro=7]="Maestro",e[e.Mastercard=8]="Mastercard",e[e.RuPay=9]="RuPay",e[e.Verve=10]="Verve",e[e.Visa=11]="Visa",e[e.VPay=12]="VPay",e[e.Count=13]="Count"}(Qe||(Qe={})),function(e){e[e.Success=0]="Success",e[e.DetectionFailed=1]="DetectionFailed",e[e.ImagePreprocessingFailed=2]="ImagePreprocessingFailed",e[e.StabilityTestFailed=3]="StabilityTestFailed",e[e.ScanningWrongSide=4]="ScanningWrongSide",e[e.FieldIdentificationFailed=5]="FieldIdentificationFailed",e[e.ImageReturnFailed=6]="ImageReturnFailed",e[e.UnsupportedCard=7]="UnsupportedCard",e[e.Count=8]="Count"}(Ue||(Ue={}));const _e=Object.freeze({__proto__:null,get AnonymizationMode(){return Ze},AnonymizationSettings:Ve,BlinkCardRecognizerSettings:class{constructor(){this.allowBlurFilter=!0,this.anonymizationSettings=new Ve,this.paddingEdge=0,this.allowInvalidCardNumber=!1,this.tiltDetectionLevel=ie.Mid,this.extractCvv=!0,this.extractExpiryDate=!0,this.extractIban=!0,this.extractOwner=!0,this.returnFullDocumentImage=!0,this.returnEncodedFullDocumentImage=!1,this.handScaleThreshold=.15,this.handDocumentOverlapThreshold=.05,this.screenAnalysisMatchLevel=Se.Level5,this.photocopyAnalysisMatchLevel=Se.Level5,this.documentLivenessCallback=null,this._fullDocumentImageDpi=250,this.fullDocumentImageExtensionFactors=new Ee}get fullDocumentImageDpi(){return this._fullDocumentImageDpi}set fullDocumentImageDpi(e){!function(e){if(e<100||e>400)throw new Error("DPI must be from interval [100, 400]")}(e),this._fullDocumentImageDpi=e}},CapturedFrame:ne,get CardIssuer(){return Qe},CardNumberAnonymizationSettings:Ye,get CheckResult(){return Oe},get DetectionLevel(){return ie},get DetectionStatus(){return Me},get DocumentSide(){return oe},get ErrorCodes(){return h},get ErrorMessages(){return M},get ImageOrientation(){return ee},get LicenseErrorType(){return de},get LicenseTokenState(){return ce},get LivenessStatus(){return ke},get MatchLevel(){return Se},get PreferredCameraType(){return R},get ProcessingStatus(){return Ue},get RecognizerResultState(){return te},SDKError:z,SelectedCamera:J,SerializableSDKError:f,get ServerPermissionSubmitResultStatus(){return he},get VideoRecognitionMode(){return pe},VideoRecognizer:me,WasmSDKLoadSettings:Ne,get WasmType(){return d},bindCameraToVideoFeed:q,captureFrame:le,createBlinkCardRecognizer:async function(e){return e.mbWasmModule.newRecognizer("BlinkCardRecognizer")},createRecognizerRunner:Le,createSuccessFrameGrabberRecognizer:ve,detectWasmFeatures:async function(){const e=[Ie(),je(),De(),xe(),ye()];if(!(await Promise.all(e)).every(Boolean))throw new Error("Browser doesn't meet minimum requirements!");return await ze()?await Ae()?d.AdvancedWithThreads:d.Advanced:d.Basic},detectWasmType:async function(){const e=await ze(),t=await Ae();return e?t?d.AdvancedWithThreads:d.Advanced:d.Basic},frameCaptureErrors:U,getCameraDevices:K,isAndroidDevice:W,isBrowserSupported:ae,isIOSDevice:P,isIOSUserAgent:function(){return/iOS|iPhone|iPad|iPod/i.test(navigator.userAgent)},isInAppBrowser:function(){const e=navigator.userAgent||navigator.vendor;return!!/(instagram|fbav|linkedinapp|twitter|micromessenger|whatsapp|tiktok)[/\s]?([\w.]*)/i.exec(e)},isMobileDevice:()=>W()||P(),isSafari:fe,licenseErrors:Y,loadWasmModule:Te,localSdkErrors:V,obtainNewServerPermission:Ce,sdkErrors:Q,selectCamera:X,unlockWasmSDK:async function(e,t,i,o){const a=o.initializeWithLicenseKey(e,i,t);switch(a.unlockResult){case ce.Invalid:return{error:new z({...Y.licenseInvalid,message:a.licenseError},{type:de.LicenseTokenStateInvalid})};case ce.Valid:return{error:null,showOverlay:(r=a.isTrial,s=a.allowRemoveDemoOverlay,n=a.allowRemoveProductionOverlay,!(r&&s||!r&&n))};case ce.RequiresServerPermission:{const e=await Ce(a,o);switch(e.status){case he.Ok:return{error:null,lease:e.lease};case he.NetworkError:{let t="";return e.networkErrorDescription&&(t=" "+e.networkErrorDescription),{error:new z({...Y.licenseNetworkError,message:"There has been a network error while obtaining the server permission!"+t},{type:de.NetworkError})}}case he.RemoteLock:return{error:new z(Y.licenseRemoteLocked,{type:de.RemoteLock}),lease:e.lease};case he.PermissionExpired:return{error:new z(Y.licensePermissionExpired,{type:de.PermissionExpired}),lease:e.lease};case he.PayloadCorrupted:return{error:new z(Y.licensePayloadCorrupted,{type:de.PayloadCorrupted}),lease:e.lease};case he.PayloadSignatureVerificationFailed:return{error:new z(Y.licensePayloadVerificationFailed,{type:de.PayloadSignatureVerificationFailed}),lease:e.lease};case he.IncorrectTokenState:return{error:new z(Y.licenseTokenStateIncorrect,{type:de.IncorrectTokenState}),lease:e.lease}}}}var r,s,n},videoRecognizerErrors:Z,wasmFolder:function(e){switch(e){case d.AdvancedWithThreads:return"advanced-threads";case d.Advanced:return"advanced";case d.Basic:return"basic"}},workerErrors:_});class Re{constructor(e){this.sdk=e}}var Ge;!function(e){e.EmptyResult="EMPTY_RESULT",e.InvalidRecognizerOptions="INVALID_RECOGNIZER_OPTIONS",e.NoImageFileFound="NO_IMAGE_FILE_FOUND",e.NoFirstImageFileFound="NO_FIRST_IMAGE_FILE_FOUND",e.NoSecondImageFileFound="NO_SECOND_IMAGE_FILE_FOUND",e.GenericScanError="GENERIC_SCAN_ERROR",e.CameraNotAllowed="CAMERA_NOT_ALLOWED",e.CameraInUse="CAMERA_IN_USE",e.CameraGenericError="CAMERA_GENERIC_ERROR"}(Ge||(Ge={}));const He={BlinkCardRecognizer:"createBlinkCardRecognizer"};var Fe,We,Pe,Be,Je;!function(e){e.SingleSide="SingleSide",e.MultiSide="MultiSide"}(Fe||(Fe={})),function(e){e.First="First",e.Second="Second"}(We||(We={})),function(e){e.NoImageFileFound="NoImageFileFound",e.NoFirstImageFileFound="NoFirstImageFileFound",e.NoSecondImageFileFound="NoSecondImageFileFound",e.Preparing="Preparing",e.Ready="Ready",e.Processing="Processing",e.DetectionFailed="DetectionFailed",e.WrongSide="WrongSide",e.EmptyResultState="EmptyResultState",e.OnFirstSideResult="OnFirstSideResult",e.ScanSuccessful="ScanSuccessful",e.DocumentClassified="DocumentClassified",e.DetectionStatusChange="DetectionStatusChange",e.NoSupportForMediaDevices="NoSupportForMediaDevices",e.CameraNotFound="CameraNotFound",e.CameraNotAllowed="CameraNotAllowed",e.UnableToAccessCamera="UnableToAccessCamera",e.CameraInUse="CameraInUse",e.CameraGenericError="CameraGenericError",e.UnknownError="UnknownError",e.DetectionStatusFail="Fail",e.DetectionStatusSuccess="Success",e.DetectionStatusCameraTooHigh="CameraTooHigh",e.DetectionStatusFallbackSuccess="FallbackSuccess",e.DetectionStatusPartial="Partial",e.DetectionStatusCameraAtAngle="CameraAtAngle",e.DetectionStatusCameraTooNear="CameraTooNear",e.DetectionStatusDocumentTooCloseToEdge="DocumentTooCloseToEdge"}(Pe||(Pe={})),function(e){e.Barcode="BARCODE",e.CardMultiSide="CARD_MULTI_SIDE",e.CardSingleSide="CARD_SINGLE_SIDE",e.PaymentCard="PAYMENT_CARD"}(Be||(Be={})),function(e){e.AdjustAngle="AdjustAngle",e.Classification="Classification",e.Default="Default",e.Detection="Detection",e.Done="Done",e.DoneAll="DoneAll",e.Flip="Flip",e.WrongSide="WrongSide",e.MoveCloser="MoveCloser",e.MoveFarther="MoveFarther"}(Je||(Je={}));const Ke=new Map([[Je.AdjustAngle,2500],[Je.Default,500],[Je.Done,300],[Je.DoneAll,400],[Je.Flip,4e3],[Je.WrongSide,1500],[Je.MoveCloser,2500],[Je.MoveFarther,2500]]);var Xe,$e,qe;!function(e){e.CameraDisabled="CAMERA_DISABLED",e.CameraGenericError="CAMERA_GENERIC_ERROR",e.CameraInUse="CAMERA_IN_USE",e.CameraNotAllowed="CAMERA_NOT_ALLOWED",e.GenericScanError="GENERIC_SCAN_ERROR",e.ScanStarted="SCAN_STARTED",e.ScanUnsuccessful="SCAN_UNSUCCESSFUL",e.ScanSuccessful="SCAN_SUCCESSFUL"}(Xe||(Xe={})),function(e){e.BrowserNotSupported="BROWSER_NOT_SUPPORTED",e.LicenseError="LICENSE_ERROR",e.SdkLoadFailed="SDK_LOAD_FAILED",e.InternetNotAvailable="INTERNET_NOT_AVAILABLE",e.InvalidRecognizers="INVALID_RECOGNIZERS"}($e||($e={})),function(e){e.BrowserNotSupported="Browser is not supported!",e.LicenseError="Something is wrong with the license.",e.SdkLoadFailed="Failed to load SDK!"}(qe||(qe={}));const et={browserNotSupported:{code:$e.BrowserNotSupported,message:qe.BrowserNotSupported},licenseError:{code:$e.LicenseError,message:qe.LicenseError},sdkLoadFailed:{code:$e.SdkLoadFailed,message:qe.SdkLoadFailed}};class tt{constructor(){this.cancelInitiatedFromOutside=!1,this.showOverlay=!1,this.isFrontSuccessFrame=!1,this.lastDetectionStatus=Me.Failed,this.eventEmitter$=document.createElement("a")}delete(){var e;null===(e=this.sdk)||void 0===e||e.delete()}initialize(e,t){const i=new Ne(e);return i.allowHelloMessage=t.allowHelloMessage,i.engineLocation=t.engineLocation,i.workerLocation=t.workerLocation,t.wasmType&&(i.wasmType=t.wasmType),new Promise((e=>{Te(i).then((t=>{this.sdk=t,this.showOverlay=t.showOverlay,e(new Re(this.sdk))})).catch((t=>{e(new z(et.sdkLoadFailed,t))}))}))}checkRecognizers(e){if(!e||!e.length)return{status:!1,message:"There are no provided recognizers!"};for(const t of e)if(!this.isRecognizerAvailable(t))return{status:!1,message:`Recognizer "${t}" doesn't exist!`};return{status:!0}}getDesiredCameraExperience(e=[],t={}){return Be.PaymentCard}async scanFromCamera(e,t){t({status:Pe.Preparing}),this.cancelInitiatedFromOutside=!1,this.eventEmitter$.addEventListener("terminate",(async()=>{var e,t,a,r,s;if(null===(t=null===(e=this.videoRecognizer)||void 0===e?void 0:e.cancelRecognition)||void 0===t||t.call(e),window.setTimeout((()=>{var e,t;return null===(t=null===(e=this.videoRecognizer)||void 0===e?void 0:e.releaseVideoFeed)||void 0===t?void 0:t.call(e)}),1),o)try{await o.delete()}catch(e){}for(const e of i)e&&(null===(a=e.recognizer)||void 0===a?void 0:a.objectHandle)>-1&&(null===(s=(r=e.recognizer).delete)||void 0===s||s.call(r))}));const i=await this.createRecognizers(e.recognizers,e.recognizerOptions,e.successFrame),o=await this.createRecognizerRunner(i);try{this.videoRecognizer=await me.createVideoRecognizerFromCameraStream(e.cameraFeed,o,e.cameraId),t({status:Pe.Ready}),await this.videoRecognizer.setVideoRecognitionMode(pe.Recognition),this.videoRecognizer.setOnFrameProcessed((e=>{window.setTimeout((()=>{this.lastDetectionStatus=Me.Failed}),0);const i=this.lastDetectionStatus===Me.Failed;switch(this.lastDetectionStatus){case Me.CameraTooFar:t({status:Pe.DetectionStatusCameraTooHigh});break;case Me.FallbackSuccess:t({status:Pe.DetectionStatusFallbackSuccess});break;case Me.DocumentPartiallyVisible:t({status:Pe.DetectionStatusPartial});break;case Me.CameraAngleTooSteep:t({status:Pe.DetectionStatusCameraAtAngle});break;case Me.CameraTooClose:t({status:Pe.DetectionStatusCameraTooNear});break;case Me.DocumentTooCloseToCameraEdge:t({status:Pe.DetectionStatusDocumentTooCloseToEdge})}if(!i)return thi