UNPKG

@microblink/blinkid-in-browser-sdk

Version:

A simple ID scanning library for WebAssembly-enabled browsers.

9 lines (8 loc) 71.3 kB
/*! **************************************************************************** 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 e=0;class t{constructor(t){this.action=t,this.messageID=function(){const t=e;return e+=1,t}()}}class i extends t{constructor(e,t){super(i.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.initialMemory=e.initialMemory,this.blinkIDVariant=e.blinkIdVariant,this.numberOfWorkers=e.numberOfWorkers}}var a,n,s;i.action="init",function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback"}(a||(a={}));class r extends t{constructor(e,t){super(r.action),this.className=e,this.params=t}}r.action="createNewNativeObject";class o extends t{constructor(e,t,i){super(o.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}o.action="createRecognizerRunner";class A extends t{constructor(e,t){super(A.action),this.recognizerHandles=e,this.allowMultipleResults=t}}A.action="reconfigureRecognizerRunner";class E extends t{constructor(){super(E.action)}}E.action="deleteRecognizerRunner";class I extends t{constructor(e,t,i){super(I.action),this.objectHandle=e,this.methodName=t,this.params=i}}I.action="invokeObject";class R extends t{constructor(e){super(R.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}R.action="processImage";class N extends t{constructor(e){super(N.action),this.hardReset=e}}N.action="resetRecognizers";class c{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1}}class _ extends t{constructor(e){super(_.action),this.registeredMetadataCallbacks=e}}_.action="registerMetadataCallbacks";class l extends t{constructor(e){super(l.action),this.detectionOnlyMode=e}}l.action="setDetectionOnly";class S extends t{constructor(e){super(S.action),this.cameraPreviewMirrored=e}}S.action="setCameraPreviewMirrored";class O extends t{constructor(e){super(O.action),this.userId=e}}O.action="getProductIntegrationInfo";class d extends t{constructor(e){super(d.action),this.pingProxyUrl=e}}d.action="setPingProxyUrl";class D extends t{constructor(e){super(D.action),this.data=e}}D.action="setPingData",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.recognizerCallback=5]="recognizerCallback"}(n||(n={})),function(e){e.Basic="BASIC",e.Advanced="ADVANCED",e.AdvancedWithThreads="ADVANCED_WITH_THREADS"}(s||(s={}));class C extends Error{constructor(e,t){if(super(),!e.code||!e.message)throw Error("Instance of SDKError is required to have code and message.");if(this.message=e.message,this.code=e.code,e instanceof u&&e.details&&"message"in e.details){const t=Error(e.details.message);"stack"in e.details&&(t.stack=e.details.stack),this.details=t}else this.details=t}}class u{constructor(e,t){if(!e.code||!e.message)throw 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 T(t):t}}class T{constructor(e){this.message=e.message,this.name=e.name,this.stack=e.stack}}var m,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",e.INVALID_PING_PROXY_URL="INVALID_PROXY_URL",e.PING_PROXY_PERMISSION_NOT_GRANTED="PING_PROXY_PERMISSION_NOT_GRANTED",e.PING_DATA_KEYS_AMOUNT_EXCEEDED="PING_DATA_KEYS_AMOUNT_EXCEEDED",e.PING_DATA_KEY_LENGTH_EXCEEDED="PING_DATA_KEY_LENGTH_EXCEEDED",e.PING_DATA_VALUE_LENGTH_EXCEEDED="PING_DATA_VALUE_LENGTH_EXCEEDED"}(m||(m={})),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!",e.INVALID_PING_PROXY_URL="Provided ping proxy URL is not a valid secure URL in format 'https://{host}:{port?}'.",e.PING_PROXY_PERMISSION_NOT_GRANTED="Allow ping proxy permission not found in license.",e.PING_DATA_KEYS_AMOUNT_EXCEEDED="Maximum number of ping data keys exceeded.",e.PING_DATA_KEY_LENGTH_EXCEEDED="Ping data key is too long.",e.PING_DATA_VALUE_LENGTH_EXCEEDED="Ping data value is too long."}(L||(L={}));const U={feedMissing:{message:L.VIDEO_RECOGNIZER_FEED_MISSING,code:m.VIDEO_RECOGNIZER_FEED_MISSING},recognizersResetFailure:{message:L.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE,code:m.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE},feedPaused:{message:L.VIDEO_RECOGNIZER_FEED_PAUSED,code:m.VIDEO_RECOGNIZER_FEED_PAUSED},playRequestInterrupted:{message:L.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED,code:m.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED},videoFeedNotPaused:{message:L.VIDEO_RECOGNIZER_FEED_NOT_PAUSED,code:m.VIDEO_RECOGNIZER_FEED_NOT_PAUSED},videoFeedReleased:{message:L.VIDEO_RECOGNIZER_FEED_RELEASED,code:m.VIDEO_RECOGNIZER_FEED_RELEASED},mediaDevicesUnsupported:{code:m.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED,message:L.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED},cameraMissing:{code:m.VIDEO_RECOGNIZER_CAMERA_MISSING,message:L.VIDEO_RECOGNIZER_CAMERA_MISSING},cameraNotAllowed:{code:m.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED,message:L.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED},elementMissing:{message:L.VIDEO_RECOGNIZER_ELEMENT_MISSING,code:m.VIDEO_RECOGNIZER_ELEMENT_MISSING}},g={wasmSettingsMissing:{message:L.SDK_WASM_SETTINGS_MISSING,code:m.SDK_WASM_SETTINGS_MISSING},licenseKeyMissing:{message:L.SDK_LICENSE_KEY_MISSING,code:m.SDK_LICENSE_KEY_MISSING},wasmModuleNameMissing:{message:L.SDK_WASM_MODULE_NAME_MISSING,code:m.SDK_WASM_MODULE_NAME_MISSING},engineLocationInvalid:{message:L.SDK_ENGINE_LOCATION_INVALID,code:m.SDK_ENGINE_LOCATION_INVALID},workerLocationInvalid:{message:L.SDK_WORKER_LOCATION_INVALID,code:m.SDK_WORKER_LOCATION_INVALID},missing:{message:L.SDK_MISSING,code:m.SDK_MISSING},recognizersMissing:{message:L.SDK_RECOGNIZERS_MISSING,code:m.SDK_RECOGNIZERS_MISSING}},h={svgUnsupported:{message:L.FRAME_CAPTURE_SVG_UNSUPPORTED,code:m.FRAME_CAPTURE_SVG_UNSUPPORTED},canvasMissing:{message:L.FRAME_CAPTURE_CANVAS_MISSING,code:m.FRAME_CAPTURE_CANVAS_MISSING}},M={licenseTokenStateIncorrect:{code:m.LICENSE_UNLOCK_ERROR,message:L.LICENSE_TOKEN_STATE_INCORRECT},licensePayloadVerificationFailed:{code:m.LICENSE_UNLOCK_ERROR,message:L.LICENSE_PAYLOAD_VERIFICATION_FAILED},licensePayloadCorrupted:{code:m.LICENSE_UNLOCK_ERROR,message:L.LICENSE_PAYLOAD_CORRUPTED},licensePermissionExpired:{code:m.LICENSE_UNLOCK_ERROR,message:L.LICENSE_PERMISSION_EXPIRED},licenseRemoteLocked:{code:m.LICENSE_UNLOCK_ERROR,message:L.LICENSE_REMOTE_LOCKED},licenseNetworkError:{code:m.LICENSE_UNLOCK_ERROR},licenseInvalid:{code:m.LICENSE_UNLOCK_ERROR}},P={runnerMissing:{message:L.LOCAL_SDK_RUNNER_MISSING,code:m.LOCAL_SDK_RUNNER_MISSING},runnerEmpty:{message:L.LOCAL_SDK_RUNNER_EMPTY,code:m.LOCAL_SDK_RUNNER_EMPTY}},G={imageProcessFailure:{message:L.WORKER_IMAGE_PROCESS_FAILURE,code:m.WORKER_IMAGE_PROCESS_FAILURE},objectInvokeFailure:{message:L.WORKER_OBJECT_INVOKE_FAILURE,code:m.WORKER_OBJECT_INVOKE_FAILURE},runnerDeleteFailure:{message:L.WORKER_RUNNER_DELETE_FAILURE,code:m.WORKER_RUNNER_DELETE_FAILURE},runnerDeleted:{message:L.WORKER_RUNNER_DELETED,code:m.WORKER_RUNNER_DELETED},runnerReconfigureFailure:{message:L.WORKER_RUNNER_RECONFIGURE_FAILURE,code:m.WORKER_RUNNER_RECONFIGURE_FAILURE},runnerMissing:{message:L.WORKER_RUNNER_MISSING,code:m.WORKER_RUNNER_MISSING},runnerCreationFailure:{message:L.WORKER_RUNNER_CREATION_FAILURE,code:m.WORKER_RUNNER_CREATION_FAILURE},runnerExists:{message:L.WORKER_RUNNER_EXISTS,code:m.WORKER_RUNNER_EXISTS},recognizerCreationFailure:{message:L.WORKER_RECOGNIZER_CREATION_FAILURE,code:m.WORKER_RECOGNIZER_CREATION_FAILURE},functionInvokeFailure:{message:L.WORKER_FUNCTION_INVOKE_FAILURE,code:m.WORKER_FUNCTION_INVOKE_FAILURE},wasmInitMissing:{message:L.WORKER_WASM_INIT_MISSING,code:m.WORKER_WASM_INIT_MISSING},wasmLoadFailure:{message:L.WORKER_WASM_LOAD_FAILURE,code:m.WORKER_WASM_LOAD_FAILURE},handleUndefined:{message:L.WORKER_HANDLE_UNDEFINED,code:m.WORKER_HANDLE_UNDEFINED},integrationInfoFailure:{message:L.WORKER_INTEGRATION_INFO_FAILURE,code:m.WORKER_INTEGRATION_INFO_FAILURE}},p={invalidProxyUrl:{message:L.INVALID_PING_PROXY_URL,code:m.INVALID_PING_PROXY_URL},permissionNotGranted:{message:L.PING_PROXY_PERMISSION_NOT_GRANTED,code:m.PING_PROXY_PERMISSION_NOT_GRANTED},dataKeysAmountExceeded:{message:L.PING_DATA_KEYS_AMOUNT_EXCEEDED,code:m.PING_DATA_KEYS_AMOUNT_EXCEEDED},dataKeyLengthExceeded:{message:L.PING_DATA_KEY_LENGTH_EXCEEDED,code:m.PING_DATA_KEY_LENGTH_EXCEEDED},dataValueLengthExceeded:{message:L.PING_DATA_VALUE_LENGTH_EXCEEDED,code:m.PING_DATA_VALUE_LENGTH_EXCEEDED}};function F(e,t){return i=>{const a=i;a.success?e():t("string"==typeof a.error||null===a.error?a.error:new C(a.error))}}function f(e,t){return i=>{const a=i;a.success?e(i):t("string"==typeof a.error||null===a.error?a.error:new C(a.error))}}class K{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(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const i=new I(this.objectHandle,"currentSettings",[]),a=f((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,a)}))}toSignedJSON(){return new Promise(((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const i=new I(this.objectHandle,"toSignedJSON",[]),a=f((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,a)}))}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const n of t){const t=e[n];if("function"==typeof t){this.callbacks.set(n,t);e[n]={parameter:{recognizerHandle:this.objectHandle,callbackName:n},type:a.Callback},i=!0}}return i&&this.wasmSDKWorker.registerRecognizerCallbacks(this.objectHandle,this),e}updateSettings(e){return new Promise(((t,i)=>{if(0>this.objectHandle)return void i("Invalid object handle: "+this.objectHandle);const n=new I(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:a.RecognizerSettings}]),s=F(t,i);this.wasmSDKWorker.postMessage(n,s)}))}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(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const i=new I(this.objectHandle,"getResult",[]),a=f((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,a)}))}delete(){return new Promise(((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);this.clearAllCallbacks();const i=new I(this.objectHandle,"delete",[]),a=F((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(i,a)}))}}function b(e){const t=new c;return t.onDebugText=!!e.onDebugText,t.onDetectionFailed=!!e.onDetectionFailed,t.onPointsDetection=!!e.onPointsDetection,t.onQuadDetection=!!e.onQuadDetection,t.onFirstSideResult=!!e.onFirstSideResult,t}class w{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 a=new R(e),n=f((e=>{t(e.recognitionState)}),i);this.wasmSDKWorker.postTransferrableMessage(a,n)}))}reconfigureRecognizers(e,t){return new Promise(((i,a)=>{if(this.deleted)return void a("Recognizer runner is deleted. It cannot be used anymore!");const n=V(e),s=new A(n,t),r=F(i,a);this.wasmSDKWorker.postMessage(s,r),this.recognizers=e}))}setMetadataCallbacks(e){return new Promise(((t,i)=>{const a=new _(b(e)),n=F(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(a,e,n)}))}resetRecognizers(e){return new Promise(((t,i)=>{const a=new N(e),n=F(t,i);this.wasmSDKWorker.postMessage(a,n)}))}setDetectionOnlyMode(e){return new Promise(((t,i)=>{const a=new l(e),n=F(t,i);this.wasmSDKWorker.postMessage(a,n)}))}setPingProxyUrl(e){if(!function(e){return/^https:\/\/[^\/]+(?::\d+)?\/?$/.test(e)}(e))throw new C(p.invalidProxyUrl);return new Promise(((t,i)=>{const a=new d(e),n=F(t,i);this.wasmSDKWorker.postMessage(a,n)}))}setPingData(e){return new Promise(((t,i)=>{const a=new D(e),n=F(t,i);this.wasmSDKWorker.postMessage(a,n)}))}setCameraPreviewMirrored(e){return new Promise(((t,i)=>{const a=new S(e),n=F(t,i);this.wasmSDKWorker.postMessage(a,n)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const i=new E,a=F((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(i,a)}))}}function V(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class y{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise(((a,n)=>{const s=V(e),r=new o(s,t,b(i)),A=F((()=>{a(new w(this.wasmSDKWorker,e))}),n);this.wasmSDKWorker.postMessageAndRegisterCallbacks(r,i,A)}))}newRecognizer(e,...t){return new Promise(((i,n)=>{const s=new r(e,function(e){const t=[];for(let i of e){let e=a.Any;i instanceof K&&(e=a.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),o=f((t=>{const a=new K(this.wasmSDKWorker,e,t.objectHandle);i(a)}),n);this.wasmSDKWorker.postMessage(s,o)}))}}class W{constructor(e,t,i,a){this.eventHandlers={},this.metadataCallbacks={},this.loadedWasmType=s.Basic,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{a("Problem during initialization of worker file!")},this.mbWasmModule=new y(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 O(this.userId),a=f((t=>{e(t.result)}),t);this.postMessage(i,a)}))}handleWorkerEvent(e){if("isCallbackMessage"in e.data){const t=e.data;switch(t.callbackType){case n.onDebugText:"function"==typeof this.metadataCallbacks.onDebugText&&this.metadataCallbacks.onDebugText(t.callbackParameters[0]);break;case n.onDetectionFailed:"function"==typeof this.metadataCallbacks.onDetectionFailed&&this.metadataCallbacks.onDetectionFailed();break;case n.onPointsDetection:"function"==typeof this.metadataCallbacks.onPointsDetection&&this.metadataCallbacks.onPointsDetection(t.callbackParameters[0]);break;case n.onQuadDetection:"function"==typeof this.metadataCallbacks.onQuadDetection&&this.metadataCallbacks.onQuadDetection(t.callbackParameters[0]);break;case n.onFirstSideResult:"function"==typeof this.metadataCallbacks.onFirstSideResult&&this.metadataCallbacks.onFirstSideResult();break;case n.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 Error("Unknown callback type: "+n[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,a){return new Promise(((n,s)=>{const r=new W(e,t.loadProgressCallback,a,s),o=new i(t,a),A=f((e=>{const t=e;r.showOverlay=t.showOverlay,r.loadedWasmType=t.wasmType,n(r)}),(e=>{r&&"function"==typeof r.delete&&r.delete(),s(e)}));r.postMessage(o,A)}))}}var k;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(k||(k={}));const H=["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","बैक"],B=["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"],v=["후면 카메라","後置相機","Задна камера","後置鏡頭","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"],Y=()=>!!navigator.userAgent.match(/Android/i),Z=()=>!!navigator.userAgent.match(/iPhone/i),z=()=>Y()||Z();function x(e){const t=e.toLowerCase();return H.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 X(){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 a=i.filter((e=>"videoinput"===e.kind));let n=0,s=0;for(const i of a)if(x(i.label)){let e;n++,Y()&&(e="Back camera "+n),t.push(new J(i,k.BackFacingCamera,e))}else{let t;s++,Y()&&(t="Front camera "+s),e.push(new J(i,k.FrontFacingCamera,t))}return{frontCameras:e,backCameras:t}}async function j(e,t){const{frontCameras:i,backCameras:a}=await X();if(!i.length&&!a.length)return null;if(e){let t;return t=i.find((t=>t.deviceId===e)),t||(t=a.find((t=>t.deviceId===e))),t||null}let n=null;if(Z()&&t===k.BackFacingCamera){let e=a.find((e=>B.includes(e.label)));e||(e=a.find((e=>v.includes(e.label)))),e&&(n=e)}else if(Y()&&t===k.BackFacingCamera){let e={deviceId:"",score:-1};const t=(e,t)=>{let i=0;return e&&i++,t&&i++,i};for(const i of a){const a=await navigator.mediaDevices.getUserMedia({video:{deviceId:i.deviceId,width:1920,height:1080}});if("getCapabilities"in a.getVideoTracks()[0]){const n=a.getVideoTracks()[0].getCapabilities(),s=!!n.torch,r=n.focusMode?.includes("single-shot"),o=t(s,r);o>e.score&&(e={deviceId:i.deviceId,score:o})}Q(a)}n=a.find((t=>t.deviceId===e.deviceId))||null}if(null===n){let e=a.length>0?a:i;t===k.BackFacingCamera&&a.length>0&&(e=a),t===k.FrontFacingCamera&&i.length>0&&(e=i),e=e.sort(((e,t)=>e.label.localeCompare(t.label)));let n=e.length-1;const s=e.map((e=>{const t=RegExp(/\b([0-9]+)MP?\b/,"i").exec(e.label);return null!==t?parseInt(t[1],10):NaN}));return s.some((e=>isNaN(e)))||(n=s.lastIndexOf(Math.max(...s))),e[n]}return n}const Q=e=>{const t=e.getTracks();for(const e of t)e.stop()};async function q(e,t,i=k.BackFacingCamera){const a={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};if(""===e.deviceId){a.video.facingMode={ideal:i===k.BackFacingCamera?"environment":"user"}}else a.video.deviceId={exact:e.deviceId};const n=await navigator.mediaDevices.getUserMedia(a);t.controls=!1,t.srcObject=n;let s=!1;return e.facing===k.FrontFacingCamera&&(s=!0),s}var $,ee,te;function ie(){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}function ae(){const e=navigator.userAgent||navigator.vendor;return!!/(instagram|fbav|linkedinapp|twitter|micromessenger|whatsapp|tiktok)[/\s]?([\w.]*)/i.exec(e)}let ne,se;!function(e){e[e.RotatedLeft90=0]="RotatedLeft90",e[e.NoRotation=1]="NoRotation",e[e.RotatedRight90=2]="RotatedRight90",e[e.Rotated180=3]="Rotated180"}($||($={})),function(e){e[e.Empty=0]="Empty",e[e.Uncertain=1]="Uncertain",e[e.Valid=2]="Valid",e[e.StageValid=3]="StageValid"}(ee||(ee={})),function(e){e[e.Front=0]="Front",e[e.Back=1]="Back"}(te||(te={}));class re{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 oe(e){let t,i,a=!1;if(e instanceof HTMLVideoElement)t=e.videoWidth,i=e.videoHeight,a=!0;else if(e instanceof HTMLImageElement)t=e.naturalWidth,i=e.naturalHeight;else{if(e instanceof SVGImageElement)throw new C(h.svgUnsupported);e instanceof VideoFrame?(t=e.displayWidth,i=e.displayHeight):(t=e.width,i=e.height)}if(ne=ne||document.createElement("canvas"),ne.width!==t&&ne.height!==i&&(ne.width=t,ne.height=i),se=se||ne.getContext("2d",{willReadFrequently:!0}),!se)throw new C(h.canvasMissing);se.drawImage(e,0,0,ne.width,ne.height);const n=se.getImageData(0,0,ne.width,ne.height);return new re(n,$.NoRotation,a)}var Ae,Ee;!function(e){e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid"}(Ae||(Ae={})),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"}(Ee||(Ee={}));function Ie(e){return{licenseId:e.licenseId,licensee:e.licensee,applicationIds:e.applicationIds,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}var Re,Ne;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(Ie(e))});if(i.ok){const e=""+await i.text();return t.submitServerPermission(e)}return{status:Re.NetworkError,lease:0,networkErrorDescription:"Server responded with status "+i.status}}catch(e){return{status:Re.NetworkError,lease:0,networkErrorDescription:"Unexpected error: "+JSON.stringify(e)}}}async function _e(e,t,i,a){const n=a.initializeWithLicenseKey(e,i,t);switch(n.unlockResult){case Ae.Invalid:return{error:new C({...M.licenseInvalid,message:n.licenseError},{type:Ee.LicenseTokenStateInvalid})};case Ae.Valid:return{error:null,showOverlay:(s=n.isTrial,r=n.allowRemoveDemoOverlay,o=n.allowRemoveProductionOverlay,!(s&&r||!s&&o))};case Ae.RequiresServerPermission:{const e=await ce(n,a);switch(e.status){case Re.Ok:return{error:null,lease:e.lease};case Re.NetworkError:{let t="";return e.networkErrorDescription&&(t=" "+e.networkErrorDescription),{error:new C({...M.licenseNetworkError,message:"There has been a network error while obtaining the server permission!"+t},{type:Ee.NetworkError})}}case Re.RemoteLock:return{error:new C(M.licenseRemoteLocked,{type:Ee.RemoteLock}),lease:e.lease};case Re.PermissionExpired:return{error:new C(M.licensePermissionExpired,{type:Ee.PermissionExpired}),lease:e.lease};case Re.PayloadCorrupted:return{error:new C(M.licensePayloadCorrupted,{type:Ee.PayloadCorrupted}),lease:e.lease};case Re.PayloadSignatureVerificationFailed:return{error:new C(M.licensePayloadVerificationFailed,{type:Ee.PayloadSignatureVerificationFailed}),lease:e.lease};case Re.IncorrectTokenState:return{error:new C(M.licenseTokenStateIncorrect,{type:Ee.IncorrectTokenState}),lease:e.lease}}}}var s,r,o}!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"}(Re||(Re={})),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"}(Ne||(Ne={}));class le extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}}const Se=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 a=new Map;let n=0,s=0;const r=[],o=i?function(){const i=Date.now();if(e>r.length)return r.push(i),0;const a=r.shift()+t;return a>i?(r.push(a),a-i):(r.push(i),0)}:function(){const i=Date.now();return i-n>t?(s=1,n=i,0):(e>s?s++:(n+=t,s=1),n-i)};return e=>{const t=function(...i){if(!t.isEnabled)return(async()=>e.apply(this,i))();let n;return new Promise(((t,s)=>{n=setTimeout((()=>{t(e.apply(this,i)),a.delete(n)}),o()),a.set(n,s)}))};return t.abort=()=>{for(const e of a.keys())clearTimeout(e),a.get(e)(new le);a.clear(),r.splice(0,r.length)},t.isEnabled=!0,Object.defineProperty(t,"queueSize",{get:()=>a.size}),t}}({limit:1,interval:67,strict:!0});var Oe;!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(Oe||(Oe={}));class de{constructor(e,t,i=!1,a=null){this.deviceId=null,this.recognitionCancelRequested=!1,this.recognitionPauseRequested=!1,this.recognitionTimeoutMs=2e4,this.timeoutStartedAt=0,this.currentTimeoutCount=0,this.videoRecognitionMode=Oe.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===Oe.DetectionTest;await this.recognizerRunner.setDetectionOnlyMode(t)},this.startRecognition=async(e,t=2e4)=>{try{await this.videoElement.play()}catch(e){throw Error(L.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 C(U.recognizersResetFailure)}try{await this.videoElement.play()}catch(e){throw Error(L.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,k.BackFacingCamera),await this.recognizerRunner.setPingData({selectedCamera:e.label}),await this.resumeRecognition(!0)},this.queueFrame=()=>new Promise((e=>{this.frameCallback((()=>{this.recognitionLoop().then((()=>e()))}))})),this.throttledQueueFrame=Se(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=oe(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===Oe.DetectionTest||this.videoRecognitionMode===Oe.RecognitionTest)return await this.recognizerRunner.resetRecognizers(!0),this.clearTimeout(),void this.throttledQueueFrame();switch(t){case ee.Valid:return this.clearTimeout(),void("function"==typeof this.onScanningDone&&this.onScanningDone(t));case ee.Uncertain:{const e=performance.now();return 0===this.timeoutStartedAt&&(this.timeoutStartedAt=e),this.currentTimeoutCount=e-this.timeoutStartedAt,this.recognitionTimeoutMs>this.currentTimeoutCount?void this.throttledQueueFrame():(this.clearTimeout(),void("function"==typeof this.onScanningDone&&this.onScanningDone(t)))}case ee.StageValid:case ee.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=a,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,a=k.BackFacingCamera){if(!(e&&e instanceof HTMLVideoElement))throw new C(U.elementMissing);if(!navigator.mediaDevices.getUserMedia)throw new C(U.mediaDevicesUnsupported);const n=await j(i,a);if(!n)throw new C(U.cameraMissing);const s=await q(n,e,a);return await t.setPingData({selectedCamera:n.label}),new de(e,t,s,n.deviceId)}static createVideoRecognizerFromVideoPath(e,t,i){const a=new de(t,i);return t.src=e,t.currentTime=0,t.onended=()=>{a.cancelRecognition()},a}}class De{constructor(e){if(this.allowHelloMessage=!0,this.engineLocation="",this.workerLocation="",this.wasmType=null,this.numberOfWorkers=null,this.loadProgressCallback=null,this.wasmModuleName="BlinkIDWasmSDK",!e)throw new C(g.licenseKeyMissing);this.licenseKey=e}}const Ce=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])),ue=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])),Te=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])),me=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])),Le=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])),Ue=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 ge(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}function he(){return/iOS|iPhone|iPad|iPod/i.test(navigator.userAgent)}async function Me(){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!ge()&&"Worker"in self}async function Pe(){const e=[ue(),Te(),Ce(),me(),Le()];if(!(await Promise.all(e)).every(Boolean))throw Error("Browser doesn't meet minimum requirements!");if(!await Ue())return s.Basic;return await Me()?s.AdvancedWithThreads:s.Advanced}async function Ge(){const e=await Ue(),t=await Me();return e?t?s.AdvancedWithThreads:s.Advanced:s.Basic}function pe(e){let t="";return t=e.wasmType===s.AdvancedWithThreads?"advanced-threads":e.wasmType===s.Advanced?"advanced":"basic",`${e.blinkIDVariant}/${t}`}function Fe(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))}async function fe(e){return new Promise(((t,i)=>{if(!e||"object"!=typeof e)return void i(new C(g.wasmSettingsMissing));if("string"!=typeof e.licenseKey)return void i(new C(g.licenseKeyMissing));if(!e.wasmModuleName)return void i(new C(g.wasmModuleNameMissing));if("string"!=typeof e.engineLocation)return void i(new C(g.engineLocationInvalid));if("string"!=typeof e.workerLocation)return void i(new C(g.workerLocationInvalid));const a=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=Fe(),localStorage.setItem("mb-user-id",e)),e}catch(e){return Fe()}}();try{const n=`/resources/${e.wasmModuleName}.worker.min.js`,s=window.location.origin+n,r=e.workerLocation||s;e.allowHelloMessage&&console.log("Worker location is:",r);const o=new Worker(r);W.createWasmWorker(o,e,a).then((e=>{t(e)}),i)}catch(e){i(e)}}))}async function Ke(e,t,i=!1,a={}){if("object"!=typeof e)throw new C(g.missing);if("object"!=typeof t||1>t.length)throw new C(g.recognizersMissing);return e.mbWasmModule.createRecognizerRunner(t,i,a)}var be,we,Ve,ye,We,ke,He,Be,ve,Ye,Ze,ze,xe,Je,Xe,je,Qe;!function(e){e[e.NONE=0]="NONE",e[e.QR_CODE=1]="QR_CODE",e[e.DATA_MATRIX=2]="DATA_MATRIX",e[e.UPC_E=3]="UPC_E",e[e.UPC_A=4]="UPC_A",e[e.EAN_8=5]="EAN_8",e[e.EAN_13=6]="EAN_13",e[e.CODE_128=7]="CODE_128",e[e.CODE_39=8]="CODE_39",e[e.ITF=9]="ITF",e[e.AZTEC_BARCODE=10]="AZTEC_BARCODE",e[e.PDF417_BARCODE=11]="PDF417_BARCODE"}(be||(be={})),function(e){e[e.None=0]="None",e[e.ImageOnly=1]="ImageOnly",e[e.ResultFieldsOnly=2]="ResultFieldsOnly",e[e.FullResult=3]="FullResult"}(we||(we={}));class qe{constructor(){this.enableMrzId=!0,this.enableMrzPassport=!0,this.enableMrzVisa=!0,this.enablePhotoId=!0,this.enableBarcodeId=!0,this.enableFullDocumentRecognition=!0}}!function(e){e[e.Strict=0]="Strict",e[e.Normal=1]="Normal",e[e.Relaxed=2]="Relaxed"}(Ve||(Ve={}));class $e{constructor(e=0,t=0,i=0,a=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(a),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=a}checkExtensionFactor(e){if(e>1||-1>e)throw Error("Extension factor must be in range [-1.0, 1.0]")}}function et(e){if(100>e||e>400)throw Error("DPI must be from interval [100, 400]")}!function(e){e[e.Latin=0]="Latin",e[e.Arabic=1]="Arabic",e[e.Cyrillic=2]="Cyrillic",e[e.Greek=3]="Greek",e[e.Count=4]="Count"}(ye||(ye={})),function(e){e[e.DocumentType=0]="DocumentType",e[e.StandardVersionNumber=1]="StandardVersionNumber",e[e.CustomerFamilyName=2]="CustomerFamilyName",e[e.CustomerFirstName=3]="CustomerFirstName",e[e.CustomerFullName=4]="CustomerFullName",e[e.DateOfBirth=5]="DateOfBirth",e[e.Sex=6]="Sex",e[e.EyeColor=7]="EyeColor",e[e.AddressStreet=8]="AddressStreet",e[e.AddressCity=9]="AddressCity",e[e.AddressJurisdictionCode=10]="AddressJurisdictionCode",e[e.AddressPostalCode=11]="AddressPostalCode",e[e.FullAddress=12]="FullAddress",e[e.Height=13]="Height",e[e.HeightIn=14]="HeightIn",e[e.HeightCm=15]="HeightCm",e[e.CustomerMiddleName=16]="CustomerMiddleName",e[e.HairColor=17]="HairColor",e[e.NameSuffix=18]="NameSuffix",e[e.AKAFullName=19]="AKAFullName",e[e.AKAFamilyName=20]="AKAFamilyName",e[e.AKAGivenName=21]="AKAGivenName",e[e.AKASuffixName=22]="AKASuffixName",e[e.WeightRange=23]="WeightRange",e[e.WeightPounds=24]="WeightPounds",e[e.WeightKilograms=25]="WeightKilograms",e[e.CustomerIdNumber=26]="CustomerIdNumber",e[e.FamilyNameTruncation=27]="FamilyNameTruncation",e[e.FirstNameTruncation=28]="FirstNameTruncation",e[e.MiddleNameTruncation=29]="MiddleNameTruncation",e[e.PlaceOfBirth=30]="PlaceOfBirth",e[e.AddressStreet2=31]="AddressStreet2",e[e.RaceEthnicity=32]="RaceEthnicity",e[e.NamePrefix=33]="NamePrefix",e[e.CountryIdentification=34]="CountryIdentification",e[e.ResidenceStreetAddress=35]="ResidenceStreetAddress",e[e.ResidenceStreetAddress2=36]="ResidenceStreetAddress2",e[e.ResidenceCity=37]="ResidenceCity",e[e.ResidenceJurisdictionCode=38]="ResidenceJurisdictionCode",e[e.ResidencePostalCode=39]="ResidencePostalCode",e[e.ResidenceFullAddress=40]="ResidenceFullAddress",e[e.Under18=41]="Under18",e[e.Under19=42]="Under19",e[e.Under21=43]="Under21",e[e.SocialSecurityNumber=44]="SocialSecurityNumber",e[e.AKASocialSecurityNumber=45]="AKASocialSecurityNumber",e[e.AKAMiddleName=46]="AKAMiddleName",e[e.AKAPrefixName=47]="AKAPrefixName",e[e.OrganDonor=48]="OrganDonor",e[e.Veteran=49]="Veteran",e[e.AKADateOfBirth=50]="AKADateOfBirth",e[e.IssuerIdentificationNumber=51]="IssuerIdentificationNumber",e[e.DocumentExpirationDate=52]="DocumentExpirationDate",e[e.JurisdictionVersionNumber=53]="JurisdictionVersionNumber",e[e.JurisdictionVehicleClass=54]="JurisdictionVehicleClass",e[e.JurisdictionRestrictionCodes=55]="JurisdictionRestrictionCodes",e[e.JurisdictionEndorsementCodes=56]="JurisdictionEndorsementCodes",e[e.DocumentIssueDate=57]="DocumentIssueDate",e[e.FederalCommercialVehicleCodes=58]="FederalCommercialVehicleCodes",e[e.IssuingJurisdiction=59]="IssuingJurisdiction",e[e.StandardVehicleClassification=60]="StandardVehicleClassification",e[e.IssuingJurisdictionName=61]="IssuingJurisdictionName",e[e.StandardEndorsementCode=62]="StandardEndorsementCode",e[e.StandardRestrictionCode=63]="StandardRestrictionCode",e[e.JurisdictionVehicleClassificationDescription=64]="JurisdictionVehicleClassificationDescription",e[e.JurisdictionEndorsmentCodeDescription=65]="JurisdictionEndorsmentCodeDescription",e[e.JurisdictionRestrictionCodeDescription=66]="JurisdictionRestrictionCodeDescription",e[e.InventoryControlNumber=67]="InventoryControlNumber",e[e.CardRevisionDate=68]="CardRevisionDate",e[e.DocumentDiscriminator=69]="DocumentDiscriminator",e[e.LimitedDurationDocument=70]="LimitedDurationDocument",e[e.AuditInformation=71]="AuditInformation",e[e.ComplianceType=72]="ComplianceType",e[e.IssueTimestamp=73]="IssueTimestamp",e[e.PermitExpirationDate=74]="PermitExpirationDate",e[e.PermitIdentifier=75]="PermitIdentifier",e[e.PermitIssueDate=76]="PermitIssueDate",e[e.NumberOfDuplicates=77]="NumberOfDuplicates",e[e.HAZMATExpirationDate=78]="HAZMATExpirationDate",e[e.MedicalIndicator=79]="MedicalIndicator",e[e.NonResident=80]="NonResident",e[e.UniqueCustomerId=81]="UniqueCustomerId",e[e.DataDiscriminator=82]="DataDiscriminator",e[e.DocumentExpirationMonth=83]="DocumentExpirationMonth",e[e.DocumentNonexpiring=84]="DocumentNonexpiring",e[e.SecurityVersion=85]="SecurityVersion",e[e.Count=86]="Count"}(We||(We={}));class tt{constructor(){this.country=null,this.region=null,this.type=null}}!function(e){e[e.NONE=0]="NONE",e[e.ALBANIA=1]="ALBANIA",e[e.ALGERIA=2]="ALGERIA",e[e.ARGENTINA=3]="ARGENTINA",e[e.AUSTRALIA=4]="AUSTRALIA",e[e.AUSTRIA=5]="AUSTRIA",e[e.AZERBAIJAN=6]="AZERBAIJAN",e[e.BAHRAIN=7]="BAHRAIN",e[e.BANGLADESH=8]="BANGLADESH",e[e.BELGIUM=9]="BELGIUM",e[e.BOSNIA_AND_HERZEGOVINA=10]="BOSNIA_AND_HERZEGOVINA",e[e.BRUNEI=11]="BRUNEI",e[e.BULGARIA=12]="BULGARIA",e[e.CAMBODIA=13]="CAMBODIA",e[e.CANADA=14]="CANADA",e[e.CHILE=15]="CHILE",e[e.COLOMBIA=16]="COLOMBIA",e[e.COSTA_RICA=17]="COSTA_RICA",e[e.CROATIA=18]="CROATIA",e[e.CYPRUS=19]="CYPRUS",e[e.CZECHIA=20]="CZECHIA",e[e.DENMARK=21]="DENMARK",e[e.DOMINICAN_REPUBLIC=22]="DOMINICAN_REPUBLIC",e[e.EGYPT=23]="EGYPT",e[e.ESTONIA=24]="ESTONIA",e[e.FINLAND=25]="FINLAND",e[e.FRANCE=26]="FRANCE",e[e.GEORGIA=27]="GEORGIA",e[e.GERMANY=28]="GERMANY",e[e.GHANA=29]="GHANA",e[e.GREECE=30]="GREECE",e[e.GUATEMALA=31]="GUATEMALA",e[e.HONG_KONG=32]="HONG_KONG",e[e.HUNGARY=33]="HUNGARY",e[e.INDIA=34]="INDIA",e[e.INDONESIA=35]="INDONESIA",e[e.IRELAND=36]="IRELAND",e[e.ISRAEL=37]="ISRAEL",e[e.ITALY=38]="ITALY",e[e.JORDAN=39]="JORDAN",e[e.KAZAKHSTAN=40]="KAZAKHSTAN",e[e.KENYA=41]="KENYA",e[e.KOSOVO=42]="KOSOVO",e[e.KUWAIT=43]="KUWAIT",e[e.LATVIA=44]="LATVIA",e[e.LITHUANIA=45]="LITHUANIA",e[e.MALAYSIA=46]="MALAYSIA",e[e.MALDIVES=47]="MALDIVES",e[e.MALTA=48]="MALTA",e[e.MAURITIUS=49]="MAURITIUS",e[e.MEXICO=50]="MEXICO",e[e.MOROCCO=51]="MOROCCO",e[e.NETHERLANDS=52]="NETHERLANDS",e[e.NEW_ZEALAND=53]="NEW_ZEALAND",e[e.NIGERIA=54]="NIGERIA",e[e.PAKISTAN=55]="PAKISTAN",e[e.PANAMA=56]="PANAMA",e[e.PARAGUAY=57]="PARAGUAY",e[e.PHILIPPINES=58]="PHILIPPINES",e[e.POLAND=59]="POLAND",e[e.PORTUGAL=60]="PORTUGAL",e[e.PUERTO_RICO=61]="PUERTO_RICO",e[e.QATAR=62]="QATAR",e[e.ROMANIA=63]="ROMANIA",e[e.RUSSIA=64]="RUSSIA",e[e.SAUDI_ARABIA=65]="SAUDI_ARABIA",e[e.SERBIA=66]="SERBIA",e[e.SINGAPORE=67]="SINGAPORE",e[e.SLOVAKIA=68]="SLOVAKIA",e[e.SLOVENIA=69]="SLOVENIA",e[e.SOUTH_AFRICA=70]="SOUTH_AFRICA",e[e.SPAIN=71]="SPAIN",e[e.SWEDEN=72]="SWEDEN",e[e.SWITZERLAND=73]="SWITZERLAND",e[e.TAIWAN=74]="TAIWAN",e[e.THAILAND=75]="THAILAND",e[e.TUNISIA=76]="TUNISIA",e[e.TURKEY=77]="TURKEY",e[e.UAE=78]="UAE",e[e.UGANDA=79]="UGANDA",e[e.UK=80]="UK",e[e.UKRAINE=81]="UKRAINE",e[e.USA=82]="USA",e[e.VIETNAM=83]="VIETNAM",e[e.BRAZIL=84]="BRAZIL",e[e.NORWAY=85]="NORWAY",e[e.OMAN=86]="OMAN",e[e.ECUADOR=87]="ECUADOR",e[e.EL_SALVADOR=88]="EL_SALVADOR",e[e.SRI_LANKA=89]="SRI_LANKA",e[e.PERU=90]="PERU",e[e.URUGUAY=91]="URUGUAY",e[e.BAHAMAS=92]="BAHAMAS",e[e.BERMUDA=93]="BERMUDA",e[e.BOLIVIA=94]="BOLIVIA",e[e.CHINA=95]="CHINA",e[e.EUROPEAN_UNION=96]="EUROPEAN_UNION",e[e.HAITI=97]="HAITI",e[e.HONDURAS=98]="HONDURAS",e[e.ICELAND=99]="ICELAND",e[e.JAPAN=100]="JAPAN",e[e.LUXEMBOURG=101]="LUXEMBOURG",e[e.MONTENEGRO=102]="MONTENEGRO",e[e.NICARAGUA=103]="NICARAGUA",e[e.SOUTH_KOREA=104]="SOUTH_KOREA",e[e.VENEZUELA=105]="VENEZUELA",e[e.AFGHANISTAN=106]="AFGHANISTAN",e[e.ALAND_ISLANDS=107]="ALAND_ISLANDS",e[e.AMERICAN_SAMOA=108]="AMERICAN_SAMOA",e[e.ANDORRA=109]="ANDORRA",e[e.ANGOLA=110]="ANGOLA",e[e.ANGUILLA=111]="ANGUILLA",e[e.ANTARCTICA=112]="ANTARCTICA",e[e.ANTIGUA_AND_BARBUDA=113]="ANTIGUA_AND_BARBUDA",e[e.ARMENIA=114]="ARMENI