@microblink/blinkcard-in-browser-sdk
Version:
BlinkCard SDK is credit or payment cards scanning library for WebAssembly-enabled browsers.
9 lines (8 loc) • 464 kB
JavaScript
import{r as e,c as t,h as i,H as r,g as o}from"./p-b8b42595.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 a=0;class s{constructor(e){this.action=e,this.messageID=function(){const e=a;return a+=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 u extends s{constructor(e,t,i){super(u.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}u.action="createRecognizerRunner";class b extends s{constructor(e,t){super(b.action),this.recognizerHandles=e,this.allowMultipleResults=t}}b.action="reconfigureRecognizerRunner";class m extends s{constructor(){super(m.action)}}m.action="deleteRecognizerRunner";class N extends s{constructor(e,t,i){super(N.action),this.objectHandle=e,this.methodName=t,this.params=i}}N.action="invokeObject";class p extends s{constructor(e){super(p.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}p.action="processImage";class D extends s{constructor(e){super(D.action),this.hardReset=e}}D.action="resetRecognizers";class I{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1,this.onGlare=!1}}class x extends s{constructor(e){super(x.action),this.registeredMetadataCallbacks=e}}x.action="registerMetadataCallbacks";class y extends s{constructor(e){super(y.action),this.detectionOnlyMode=e}}y.action="setDetectionOnly";class A extends s{constructor(e){super(A.action),this.cameraPreviewMirrored=e}}A.action="setCameraPreviewMirrored";class j extends s{constructor(e){super(j.action),this.userId=e}}j.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 f 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 z&&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 z{constructor(e,t){if(!e.code||!e.message)throw new Error("Instance of SDKError is required to have code and message.");this.message=e.message,this.code=e.code,this.details=t instanceof Error?new w(t):t}}class w{constructor(e){this.message=e.message,this.name=e.name,this.stack=e.stack}}function C(e,t){return i=>{const r=i;r.success?e():t("string"==typeof r.error||null===r.error?r.error:new f(r.error))}}function v(e,t){return i=>{const r=i;r.success?e(i):t("string"==typeof r.error||null===r.error?r.error:new f(r.error))}}class T{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 N(this.objectHandle,"currentSettings",[]),r=v((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,r)}))}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 r of t){const t=e[r];"function"==typeof t&&(this.callbacks.set(r,t),e[r]={parameter:{recognizerHandle:this.objectHandle,callbackName:r},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 r=new N(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:l.RecognizerSettings}]),o=C(t,i);this.wasmSDKWorker.postMessage(r,o)}))}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 N(this.objectHandle,"getResult",[]),r=v((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,r)}))}delete(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());this.clearAllCallbacks();const i=new N(this.objectHandle,"delete",[]),r=C((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(i,r)}))}}function L(e){const t=new I;return t.onDebugText=!!e.onDebugText,t.onDetectionFailed=!!e.onDetectionFailed,t.onPointsDetection=!!e.onPointsDetection,t.onQuadDetection=!!e.onQuadDetection,t.onFirstSideResult=!!e.onFirstSideResult,t}class O{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 r=new p(e),o=v((e=>{t(e.recognitionState)}),i);this.wasmSDKWorker.postTransferrableMessage(r,o)}))}reconfigureRecognizers(e,t){return new Promise(((i,r)=>{if(this.deleted)return void r("Recognizer runner is deleted. It cannot be used anymore!");const o=E(e),a=new b(o,t),s=C(i,r);this.wasmSDKWorker.postMessage(a,s),this.recognizers=e}))}setMetadataCallbacks(e){return new Promise(((t,i)=>{const r=new x(L(e)),o=C(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(r,e,o)}))}resetRecognizers(e){return new Promise(((t,i)=>{const r=new D(e),o=C(t,i);this.wasmSDKWorker.postMessage(r,o)}))}setDetectionOnlyMode(e){return new Promise(((t,i)=>{const r=new y(e),o=C(t,i);this.wasmSDKWorker.postMessage(r,o)}))}setCameraPreviewMirrored(e){return new Promise(((t,i)=>{const r=new A(e),o=C(t,i);this.wasmSDKWorker.postMessage(r,o)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const i=new m,r=C((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(i,r)}))}}function E(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class k{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise(((r,o)=>{const a=E(e),s=new u(a,t,L(i)),n=C((()=>{r(new O(this.wasmSDKWorker,e))}),o);this.wasmSDKWorker.postMessageAndRegisterCallbacks(s,i,n)}))}newRecognizer(e,...t){return new Promise(((i,r)=>{const o=new g(e,function(e){const t=[];for(let i of e){let e=l.Any;i instanceof T&&(e=l.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),a=v((t=>{const r=new T(this.wasmSDKWorker,e,t.objectHandle);i(r)}),r);this.wasmSDKWorker.postMessage(o,a)}))}}class S{constructor(e,t,i,r){this.eventHandlers={},this.metadataCallbacks={},this.loadedWasmType=d.Basic,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{r("Problem during initialization of worker file!")},this.mbWasmModule=new k(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 j(this.userId),r=v((t=>{e(t.result)}),t);this.postMessage(i,r)}))}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(((r,o)=>{const a=new S(e,t.loadProgressCallback,i,o),s=new n(t,i),l=v((e=>{const t=e;a.showOverlay=t.showOverlay,a.loadedWasmType=t.wasmType,r(a)}),(e=>{a&&"function"==typeof a.delete&&a.delete(),o(e)}));a.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}},Y={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}},Q={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}},U={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}},G={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}},P={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 W;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(W||(W={}));const R=["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","बैक"],V=["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"],X=()=>!!navigator.userAgent.match(/Android/i),B=()=>!!navigator.userAgent.match(/iPhone/i);function H(e){const t=e.toLowerCase();return R.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 r=i.filter((e=>"videoinput"===e.kind));let o=0,a=0;for(const i of r)if(H(i.label)){let e;o++,X()&&(e=`Back camera ${o}`),t.push(new J(i,W.BackFacingCamera,e))}else{let t;a++,X()&&(t=`Front camera ${a}`),e.push(new J(i,W.FrontFacingCamera,t))}return{frontCameras:e,backCameras:t}}async function q(e,t){const{frontCameras:i,backCameras:r}=await K();if(!i.length&&!r.length)return null;if(e){let t;return t=i.find((t=>t.deviceId===e)),t||(t=r.find((t=>t.deviceId===e))),t||null}let o=null;if(B()&&t===W.BackFacingCamera){let e=r.find((e=>V.includes(e.label)));e||(e=r.find((e=>F.includes(e.label)))),e&&(o=e)}else if(X()&&t===W.BackFacingCamera){let e={deviceId:"",score:-1};const t=(e,t)=>{let i=0;return e&&i++,t&&i++,i};for(const i of r){const r=await navigator.mediaDevices.getUserMedia({video:{deviceId:i.deviceId,width:1920,height:1080}});if("getCapabilities"in r.getVideoTracks()[0]){const o=r.getVideoTracks()[0].getCapabilities(),a=Boolean(o.torch),s=o.focusMode?.includes("single-shot"),n=t(a,s);n>e.score&&(e={deviceId:i.deviceId,score:n})}_(r)}o=r.find((t=>t.deviceId===e.deviceId))||null}if(null===o){let e=r.length>0?r:i;t===W.BackFacingCamera&&r.length>0&&(e=r),t===W.FrontFacingCamera&&i.length>0&&(e=i),e=e.sort(((e,t)=>e.label.localeCompare(t.label)));let o=e.length-1;const a=e.map((e=>{const t=RegExp(/\b([0-9]+)MP?\b/,"i").exec(e.label);return null!==t?parseInt(t[1],10):NaN}));return a.some((e=>isNaN(e)))||(o=a.lastIndexOf(Math.max(...a))),e[o]}return o}const _=e=>{const t=e.getTracks();for(const e of t)e.stop()};async function $(e,t,i=W.BackFacingCamera){const r={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};""===e.deviceId?r.video.facingMode={ideal:i===W.BackFacingCamera?"environment":"user"}:r.video.deviceId={exact:e.deviceId};const o=await navigator.mediaDevices.getUserMedia(r);t.controls=!1,t.srcObject=o;let a=!1;return e.facing===W.FrontFacingCamera&&(a=!0),a}var ee,te,ie;function re(){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 oe,ae;!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.Front=0]="Front",e[e.Back=1]="Back"}(ie||(ie={}));class se{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 ne(e,t=!1){let i,r,o=!1;if(e instanceof HTMLVideoElement)i=e.videoWidth,r=e.videoHeight,o=!0;else if(e instanceof HTMLImageElement)i=e.naturalWidth,r=e.naturalHeight;else{if(e instanceof SVGImageElement)throw new f(Q.svgUnsupported);i=e.width,r=e.height}if(oe=oe||document.createElement("canvas"),oe.width!==i&&oe.height!==r&&(oe.width=i,oe.height=r),ae=ae||oe.getContext("2d",{willReadFrequently:!0,alpha:!1}),!ae)throw new f(Q.canvasMissing);ae.drawImage(e,0,0,oe.width,oe.height);const a=t?.66:1,s=oe.width*a,n=oe.height*a,l=ae.getImageData((oe.width-s)/2,(oe.height-n)/2,s,n);return new se(l,ee.NoRotation,o)}var le,ce,de,he;function Me(e){return{licenseId:e.licenseId,licensee:e.licensee,applicationIds:e.applicationIds,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}async function ge(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(Me(e))});if(i.ok){const e=(await i.text()).toString();return t.submitServerPermission(e)}return{status:de.NetworkError,lease:0,networkErrorDescription:`Server responded with status ${i.status}`}}catch(e){return{status:de.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"}(le||(le={})),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"}(ce||(ce={})),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"}(de||(de={})),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"}(he||(he={}));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 r=new Map;let o=0,a=0;const s=[],n=i?function(){const i=Date.now();if(s.length<e)return s.push(i),0;const r=s.shift()+t;return i>=r?(s.push(i),0):(s.push(r),r-i)}:function(){const i=Date.now();return i-o>t?(a=1,o=i,0):(a<e?a++:(o+=t,a=1),o-i)};return e=>{const t=function(...i){if(!t.isEnabled)return(async()=>e.apply(this,i))();let o;return new Promise(((t,a)=>{o=setTimeout((()=>{t(e.apply(this,i)),r.delete(o)}),n()),r.set(o,a)}))};return t.abort=()=>{for(const e of r.keys())clearTimeout(e),r.get(e)(new ue);r.clear(),s.splice(0,s.length)},t.isEnabled=!0,Object.defineProperty(t,"queueSize",{get:()=>r.size}),t}}({limit:1,interval:Math.round(1/15*1e3),strict:!0});var me;!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(me||(me={}));class Ne{constructor(e,t,i=!1,r=null){this.deviceId=null,this.recognitionCancelRequested=!1,this.recognitionPauseRequested=!1,this.recognitionTimeoutMs=2e4,this.timeoutStartedAt=0,this.currentTimeoutCount=0,this.videoRecognitionMode=me.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===me.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 f(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 $(e,this.videoElement,W.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=ne(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===me.DetectionTest||this.videoRecognitionMode===me.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=r,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,r=W.BackFacingCamera){if(!(e&&e instanceof HTMLVideoElement))throw new f(Z.elementMissing);if(!navigator.mediaDevices.getUserMedia)throw new f(Z.mediaDevicesUnsupported);const o=await q(i,r);if(!o)throw new f(Z.cameraMissing);const a=await $(o,e,r);return new Ne(e,t,a,o.deviceId)}static createVideoRecognizerFromVideoPath(e,t,i){const r=new Ne(t,i);return t.src=e,t.currentTime=0,t.onended=()=>{r.cancelRecognition()},r}}class pe{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 f(Y.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])),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,7,1,5,0,208,112,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,12,1,10,0,67,0,0,0,0,252,0,26,11])),Ae=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])),je=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 ze(){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 Ce(e){return new Promise(((t,i)=>{if(!e||"object"!=typeof e)return void i(new f(Y.wasmSettingsMissing));if("string"!=typeof e.licenseKey)return void i(new f(Y.licenseKeyMissing));if(!e.wasmModuleName)return void i(new f(Y.wasmModuleNameMissing));if("string"!=typeof e.engineLocation)return void i(new f(Y.engineLocationInvalid));if("string"!=typeof e.workerLocation)return void i(new f(Y.workerLocationInvalid));const r=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 o=`/resources/${e.wasmModuleName}.worker.min.js`,a=window.location.origin+o,s=e.workerLocation||a;e.allowHelloMessage&&console.log("Worker location is:",s);const n=new Worker(s);S.createWasmWorker(n,e,r).then((e=>{t(e)}),i)}catch(e){i(e)}}))}async function ve(e,t,i=!1,r={}){if("object"!=typeof e)throw new f(Y.missing);if("object"!=typeof t||t.length<1)throw new f(Y.recognizersMissing);return e.mbWasmModule.createRecognizerRunner(t,i,r)}async function Te(e,t){const i=await e.mbWasmModule.newRecognizer("SuccessFrameGrabberRecognizer",t);return i.wrappedRecognizer=t,i}class Le{constructor(e=0,t=0,i=0,r=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(r),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=r}checkExtensionFactor(e){if(e>1||e<-1)throw new Error("Extension factor must be in range [-1.0, 1.0]")}}var Oe,Ee,ke,Se,Ze,Ye;!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"}(Oe||(Oe={})),function(e){e[e.NotPerformed=0]="NotPerformed",e[e.Pass=1]="Pass",e[e.Fail=2]="Fail"}(Ee||(Ee={})),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"}(ke||(ke={})),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"}(Se||(Se={}));class Qe{constructor(){this.mode=Se.ImageOnly,this.prefixDigitsVisible=0,this.suffixDigitsVisible=4}}class Ue{constructor(){this.cardNumberAnonymizationSettings=new Qe,this.cardNumberPrefixAnonymizationMode=Se.None,this.cvvAnonymizationMode=Se.None,this.ibanAnonymizationMode=Se.ImageOnly,this.ownerAnonymizationMode=Se.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"}(Ze||(Ze={})),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"}(Ye||(Ye={}));const Ge=Object.freeze({__proto__:null,get AnonymizationMode(){return Se},AnonymizationSettings:Ue,BlinkCardRecognizerSettings:class{constructor(){this.allowBlurFilter=!0,this.anonymizationSettings=new Ue,this.paddingEdge=0,this.allowInvalidCardNumber=!1,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=ke.Level5,this.photocopyAnalysisMatchLevel=ke.Level5,this.documentLivenessCallback=null,this._fullDocumentImageDpi=250,this.fullDocumentImageExtensionFactors=new Le}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:se,get CardIssuer(){return Ze},CardNumberAnonymizationSettings:Qe,get CheckResult(){return Ee},get DetectionStatus(){return he},get DocumentSide(){return ie},get ErrorCodes(){return h},get ErrorMessages(){return M},get ImageOrientation(){return ee},get LicenseErrorType(){return ce},get LicenseTokenState(){return le},get LivenessStatus(){return Oe},get MatchLevel(){return ke},get PreferredCameraType(){return W},get ProcessingStatus(){return Ye},get RecognizerResultState(){return te},SDKError:f,SelectedCamera:J,SerializableSDKError:z,get ServerPermissionSubmitResultStatus(){return de},get VideoRecognitionMode(){return me},VideoRecognizer:Ne,WasmSDKLoadSettings:pe,get WasmType(){return d},bindCameraToVideoFeed:$,captureFrame:ne,createBlinkCardRecognizer:async function(e){return e.mbWasmModule.newRecognizer("BlinkCardRecognizer")},createRecognizerRunner:ve,createSuccessFrameGrabberRecognizer:Te,detectWasmFeatures:async function(){const e=[Ie(),xe(),De(),ye(),Ae()];if(!(await Promise.all(e)).every(Boolean))throw new Error("Browser doesn't meet minimum requirements!");return await je()?await ze()?d.AdvancedWithThreads:d.Advanced:d.Basic},detectWasmType:async function(){const e=await je(),t=await ze();return e?t?d.AdvancedWithThreads:d.Advanced:d.Basic},frameCaptureErrors:Q,getCameraDevices:K,isAndroidDevice:X,isBrowserSupported:re,isIOSDevice:B,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:()=>X()||B(),isSafari:fe,licenseErrors:U,loadWasmModule:Ce,localSdkErrors:G,obtainNewServerPermission:ge,sdkErrors:Y,selectCamera:q,unlockWasmSDK:async function(e,t,i,r){const o=r.initializeWithLicenseKey(e,i,t);switch(o.unlockResult){case le.Invalid:return{error:new f({...U.licenseInvalid,message:o.licenseError},{type:ce.LicenseTokenStateInvalid})};case le.Valid:return{error:null,showOverlay:(a=o.isTrial,s=o.allowRemoveDemoOverlay,n=o.allowRemoveProductionOverlay,!(a&&s||!a&&n))};case le.RequiresServerPermission:{const e=await ge(o,r);switch(e.status){case de.Ok:return{error:null,lease:e.lease};case de.NetworkError:{let t="";return e.networkErrorDescription&&(t=" "+e.networkErrorDescription),{error:new f({...U.licenseNetworkError,message:"There has been a network error while obtaining the server permission!"+t},{type:ce.NetworkError})}}case de.RemoteLock:return{error:new f(U.licenseRemoteLocked,{type:ce.RemoteLock}),lease:e.lease};case de.PermissionExpired:return{error:new f(U.licensePermissionExpired,{type:ce.PermissionExpired}),lease:e.lease};case de.PayloadCorrupted:return{error:new f(U.licensePayloadCorrupted,{type:ce.PayloadCorrupted}),lease:e.lease};case de.PayloadSignatureVerificationFailed:return{error:new f(U.licensePayloadVerificationFailed,{type:ce.PayloadSignatureVerificationFailed}),lease:e.lease};case de.IncorrectTokenState:return{error:new f(U.licenseTokenStateIncorrect,{type:ce.IncorrectTokenState}),lease:e.lease}}}}var a,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:P});class Pe{constructor(e){this.sdk=e}}var We;!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"}(We||(We={}));const Re={BlinkCardRecognizer:"createBlinkCardRecognizer"};var Ve,Fe,Xe,Be,He;!function(e){e.SingleSide="SingleSide",e.MultiSide="MultiSide"}(Ve||(Ve={})),function(e){e.First="First",e.Second="Second"}(Fe||(Fe={})),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"}(Xe||(Xe={})),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"}(He||(He={}));const Je=new Map([[He.AdjustAngle,2500],[He.Default,500],[He.Done,300],[He.DoneAll,400],[He.Flip,4e3],[He.WrongSide,1500],[He.MoveCloser,2500],[He.MoveFarther,2500]]);var Ke,qe,_e;!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"}(Ke||(Ke={})),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"}(qe||(qe={})),function(e){e.BrowserNotSupported="Browser is not supported!",e.LicenseError="Something is wrong with the license.",e.SdkLoadFailed="Failed to load SDK!"}(_e||(_e={}));const $e={browserNotSupported:{code:qe.BrowserNotSupported,message:_e.BrowserNotSupported},licenseError:{code:qe.LicenseError,message:_e.LicenseError},sdkLoadFailed:{code:qe.SdkLoadFailed,message:_e.SdkLoadFailed}};class et{constructor(){this.cancelInitiatedFromOutside=!1,this.showOverlay=!1,this.isFrontSuccessFrame=!1,this.lastDetectionStatus=he.Failed,this.eventEmitter$=document.createElement("a")}delete(){var e;null===(e=this.sdk)||void 0===e||e.delete()}initialize(e,t){const i=new pe(e);return i.allowHelloMessage=t.allowHelloMessage,i.engineLocation=t.engineLocation,i.workerLocation=t.workerLocation,t.wasmType&&(i.wasmType=t.wasmType),new Promise((e=>{Ce(i).then((t=>{this.sdk=t,this.showOverlay=t.showOverlay,e(new Pe(this.sdk))})).catch((t=>{e(new f($e.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:Xe.Preparing}),this.cancelInitiatedFromOutside=!1,this.eventEmitter$.addEventListener("terminate",(async()=>{var e,t,o,a,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),r)try{await r.delete()}catch(e){}for(const e of i)e&&(null===(o=e.recognizer)||void 0===o?void 0:o.objectHandle)>-1&&(null===(s=(a=e.recognizer).delete)||void 0===s||s.call(a))}));const i=await this.createRecognizers(e.recognizers,e.recognizerOptions,e.successFrame),r=await this.createRecognizerRunner(i);try{this.videoRecognizer=await Ne.createVideoRecognizerFromCameraStream(e.cameraFeed,r,e.cameraId),t({status:Xe.Ready}),await this.videoRecognizer.setVideoRecognitionMode(me.Recognition),this.videoRecognizer.setOnFrameProcessed((e=>{window.setTimeout((()=>{this.lastDetectionStatus=he.Failed}),0);const i=this.lastDetectionStatus===he.Failed;switch(this.lastDetectionStatus){case he.CameraTooFar:t({status:Xe.DetectionStatusCameraTooHigh});break;case he.FallbackSuccess:t({status:Xe.DetectionStatusFallbackSuccess});break;case he.DocumentPartiallyVisible:t({status:Xe.DetectionStatusPartial});break;case he.CameraAngleTooSteep:t({status:Xe.DetectionStatusCameraAtAngle});break;case he.CameraTooClose:t({status:Xe.DetectionStatusCameraTooNear});break;case he.DocumentTooCloseToCameraEdge:t({status:Xe.DetectionStatusDocumentTooCloseToEdge})}if(!i)return this.isFrontSuccessFrame?(t({status:Xe.OnFirstSideResult}),void(this.isFrontSuccessFrame=!1)):void t(e.processingStatus!==Ye.ScanningWrongSide?{status:Xe.DetectionStatusSuccess}