@microblink/blinkid-in-browser-sdk
Version:
A simple ID scanning library for WebAssembly-enabled browsers.
9 lines (8 loc) • 481 kB
JavaScript
import{r as e,c as t,h as i,H as s,g as o}from"./p-4d18f253.js";
/*! ****************************************************************************
Copyright (c) Microblink. All rights reserved.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
***************************************************************************** */let r=0;class a{constructor(e){this.action=e,this.messageID=function(){const e=r;return r+=1,e}()}}class n extends a{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.initialMemory=e.initialMemory,this.blinkIDVariant=e.blinkIdVariant,this.numberOfWorkers=e.numberOfWorkers}}var c,l,M,d,h;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"}(c||(c={}));class g extends a{constructor(e,t){super(g.action),this.className=e,this.params=t}}g.action="createNewNativeObject";class u extends a{constructor(e,t,i){super(u.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}u.action="createRecognizerRunner";class N extends a{constructor(e,t){super(N.action),this.recognizerHandles=e,this.allowMultipleResults=t}}N.action="reconfigureRecognizerRunner";class A extends a{constructor(){super(A.action)}}A.action="deleteRecognizerRunner";class D extends a{constructor(e,t,i){super(D.action),this.objectHandle=e,this.methodName=t,this.params=i}}D.action="invokeObject";class b extends a{constructor(e){super(b.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}b.action="processImage";class I extends a{constructor(e){super(I.action),this.hardReset=e}}I.action="resetRecognizers";class m{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1}}class p extends a{constructor(e){super(p.action),this.registeredMetadataCallbacks=e}}p.action="registerMetadataCallbacks";class f extends a{constructor(e){super(f.action),this.detectionOnlyMode=e}}f.action="setDetectionOnly";class y extends a{constructor(e){super(y.action),this.cameraPreviewMirrored=e}}y.action="setCameraPreviewMirrored";class j extends a{constructor(e){super(j.action),this.userId=e}}j.action="getProductIntegrationInfo";class x extends a{constructor(e){super(x.action),this.pingProxyUrl=e}}x.action="setPingProxyUrl";class C extends a{constructor(e){super(C.action),this.data=e}}C.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"}(l||(l={})),function(e){e.Basic="BASIC",e.Advanced="ADVANCED",e.AdvancedWithThreads="ADVANCED_WITH_THREADS"}(M||(M={}));class z extends Error{constructor(e,t){if(super(),!e.code||!e.message)throw new Error("Instance of SDKError is required to have code and message.");if(this.message=e.message,this.code=e.code,e instanceof L&&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 L{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 T(t):t}}class T{constructor(e){this.message=e.message,this.name=e.name,this.stack=e.stack}}!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"}(d||(d={})),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."}(h||(h={}));const E={feedMissing:{message:h.VIDEO_RECOGNIZER_FEED_MISSING,code:d.VIDEO_RECOGNIZER_FEED_MISSING},recognizersResetFailure:{message:h.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE,code:d.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE},feedPaused:{message:h.VIDEO_RECOGNIZER_FEED_PAUSED,code:d.VIDEO_RECOGNIZER_FEED_PAUSED},playRequestInterrupted:{message:h.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED,code:d.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED},videoFeedNotPaused:{message:h.VIDEO_RECOGNIZER_FEED_NOT_PAUSED,code:d.VIDEO_RECOGNIZER_FEED_NOT_PAUSED},videoFeedReleased:{message:h.VIDEO_RECOGNIZER_FEED_RELEASED,code:d.VIDEO_RECOGNIZER_FEED_RELEASED},mediaDevicesUnsupported:{code:d.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED,message:h.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED},cameraMissing:{code:d.VIDEO_RECOGNIZER_CAMERA_MISSING,message:h.VIDEO_RECOGNIZER_CAMERA_MISSING},cameraNotAllowed:{code:d.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED,message:h.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED},elementMissing:{message:h.VIDEO_RECOGNIZER_ELEMENT_MISSING,code:d.VIDEO_RECOGNIZER_ELEMENT_MISSING}},w={wasmSettingsMissing:{message:h.SDK_WASM_SETTINGS_MISSING,code:d.SDK_WASM_SETTINGS_MISSING},licenseKeyMissing:{message:h.SDK_LICENSE_KEY_MISSING,code:d.SDK_LICENSE_KEY_MISSING},wasmModuleNameMissing:{message:h.SDK_WASM_MODULE_NAME_MISSING,code:d.SDK_WASM_MODULE_NAME_MISSING},engineLocationInvalid:{message:h.SDK_ENGINE_LOCATION_INVALID,code:d.SDK_ENGINE_LOCATION_INVALID},workerLocationInvalid:{message:h.SDK_WORKER_LOCATION_INVALID,code:d.SDK_WORKER_LOCATION_INVALID},missing:{message:h.SDK_MISSING,code:d.SDK_MISSING},recognizersMissing:{message:h.SDK_RECOGNIZERS_MISSING,code:d.SDK_RECOGNIZERS_MISSING}},v={svgUnsupported:{message:h.FRAME_CAPTURE_SVG_UNSUPPORTED,code:d.FRAME_CAPTURE_SVG_UNSUPPORTED},canvasMissing:{message:h.FRAME_CAPTURE_CANVAS_MISSING,code:d.FRAME_CAPTURE_CANVAS_MISSING}},O={licenseTokenStateIncorrect:{code:d.LICENSE_UNLOCK_ERROR,message:h.LICENSE_TOKEN_STATE_INCORRECT},licensePayloadVerificationFailed:{code:d.LICENSE_UNLOCK_ERROR,message:h.LICENSE_PAYLOAD_VERIFICATION_FAILED},licensePayloadCorrupted:{code:d.LICENSE_UNLOCK_ERROR,message:h.LICENSE_PAYLOAD_CORRUPTED},licensePermissionExpired:{code:d.LICENSE_UNLOCK_ERROR,message:h.LICENSE_PERMISSION_EXPIRED},licenseRemoteLocked:{code:d.LICENSE_UNLOCK_ERROR,message:h.LICENSE_REMOTE_LOCKED},licenseNetworkError:{code:d.LICENSE_UNLOCK_ERROR},licenseInvalid:{code:d.LICENSE_UNLOCK_ERROR}},S={runnerMissing:{message:h.LOCAL_SDK_RUNNER_MISSING,code:d.LOCAL_SDK_RUNNER_MISSING},runnerEmpty:{message:h.LOCAL_SDK_RUNNER_EMPTY,code:d.LOCAL_SDK_RUNNER_EMPTY}},k={imageProcessFailure:{message:h.WORKER_IMAGE_PROCESS_FAILURE,code:d.WORKER_IMAGE_PROCESS_FAILURE},objectInvokeFailure:{message:h.WORKER_OBJECT_INVOKE_FAILURE,code:d.WORKER_OBJECT_INVOKE_FAILURE},runnerDeleteFailure:{message:h.WORKER_RUNNER_DELETE_FAILURE,code:d.WORKER_RUNNER_DELETE_FAILURE},runnerDeleted:{message:h.WORKER_RUNNER_DELETED,code:d.WORKER_RUNNER_DELETED},runnerReconfigureFailure:{message:h.WORKER_RUNNER_RECONFIGURE_FAILURE,code:d.WORKER_RUNNER_RECONFIGURE_FAILURE},runnerMissing:{message:h.WORKER_RUNNER_MISSING,code:d.WORKER_RUNNER_MISSING},runnerCreationFailure:{message:h.WORKER_RUNNER_CREATION_FAILURE,code:d.WORKER_RUNNER_CREATION_FAILURE},runnerExists:{message:h.WORKER_RUNNER_EXISTS,code:d.WORKER_RUNNER_EXISTS},recognizerCreationFailure:{message:h.WORKER_RECOGNIZER_CREATION_FAILURE,code:d.WORKER_RECOGNIZER_CREATION_FAILURE},functionInvokeFailure:{message:h.WORKER_FUNCTION_INVOKE_FAILURE,code:d.WORKER_FUNCTION_INVOKE_FAILURE},wasmInitMissing:{message:h.WORKER_WASM_INIT_MISSING,code:d.WORKER_WASM_INIT_MISSING},wasmLoadFailure:{message:h.WORKER_WASM_LOAD_FAILURE,code:d.WORKER_WASM_LOAD_FAILURE},handleUndefined:{message:h.WORKER_HANDLE_UNDEFINED,code:d.WORKER_HANDLE_UNDEFINED},integrationInfoFailure:{message:h.WORKER_INTEGRATION_INFO_FAILURE,code:d.WORKER_INTEGRATION_INFO_FAILURE}},Y={invalidProxyUrl:{message:h.INVALID_PING_PROXY_URL,code:d.INVALID_PING_PROXY_URL},permissionNotGranted:{message:h.PING_PROXY_PERMISSION_NOT_GRANTED,code:d.PING_PROXY_PERMISSION_NOT_GRANTED},dataKeysAmountExceeded:{message:h.PING_DATA_KEYS_AMOUNT_EXCEEDED,code:d.PING_DATA_KEYS_AMOUNT_EXCEEDED},dataKeyLengthExceeded:{message:h.PING_DATA_KEY_LENGTH_EXCEEDED,code:d.PING_DATA_KEY_LENGTH_EXCEEDED},dataValueLengthExceeded:{message:h.PING_DATA_VALUE_LENGTH_EXCEEDED,code:d.PING_DATA_VALUE_LENGTH_EXCEEDED}};function R(e,t){return i=>{const s=i;s.success?e():t("string"==typeof s.error||null===s.error?s.error:new z(s.error))}}function U(e,t){return i=>{const s=i;s.success?e(i):t("string"==typeof s.error||null===s.error?s.error:new z(s.error))}}class Q{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 D(this.objectHandle,"currentSettings",[]),s=U((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,s)}))}toSignedJSON(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());const i=new D(this.objectHandle,"toSignedJSON",[]),s=U((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,s)}))}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const s of t){const t=e[s];"function"==typeof t&&(this.callbacks.set(s,t),e[s]={parameter:{recognizerHandle:this.objectHandle,callbackName:s},type:c.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 s=new D(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:c.RecognizerSettings}]),o=R(t,i);this.wasmSDKWorker.postMessage(s,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 D(this.objectHandle,"getResult",[]),s=U((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,s)}))}delete(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());this.clearAllCallbacks();const i=new D(this.objectHandle,"delete",[]),s=R((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(i,s)}))}}function P(e){const t=new m;return t.onDebugText=!!e.onDebugText,t.onDetectionFailed=!!e.onDetectionFailed,t.onPointsDetection=!!e.onPointsDetection,t.onQuadDetection=!!e.onQuadDetection,t.onFirstSideResult=!!e.onFirstSideResult,t}class Z{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 s=new b(e),o=U((e=>{t(e.recognitionState)}),i);this.wasmSDKWorker.postTransferrableMessage(s,o)}))}reconfigureRecognizers(e,t){return new Promise(((i,s)=>{if(this.deleted)return void s("Recognizer runner is deleted. It cannot be used anymore!");const o=G(e),r=new N(o,t),a=R(i,s);this.wasmSDKWorker.postMessage(r,a),this.recognizers=e}))}setMetadataCallbacks(e){return new Promise(((t,i)=>{const s=new p(P(e)),o=R(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(s,e,o)}))}resetRecognizers(e){return new Promise(((t,i)=>{const s=new I(e),o=R(t,i);this.wasmSDKWorker.postMessage(s,o)}))}setDetectionOnlyMode(e){return new Promise(((t,i)=>{const s=new f(e),o=R(t,i);this.wasmSDKWorker.postMessage(s,o)}))}setPingProxyUrl(e){if(!function(e){return/^https:\/\/[^\/]+(?::\d+)?\/?$/.test(e)}(e))throw new z(Y.invalidProxyUrl);return new Promise(((t,i)=>{const s=new x(e),o=R(t,i);this.wasmSDKWorker.postMessage(s,o)}))}setPingData(e){return new Promise(((t,i)=>{const s=new C(e),o=R(t,i);this.wasmSDKWorker.postMessage(s,o)}))}setCameraPreviewMirrored(e){return new Promise(((t,i)=>{const s=new y(e),o=R(t,i);this.wasmSDKWorker.postMessage(s,o)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const i=new A,s=R((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(i,s)}))}}function G(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class V{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise(((s,o)=>{const r=G(e),a=new u(r,t,P(i)),n=R((()=>{s(new Z(this.wasmSDKWorker,e))}),o);this.wasmSDKWorker.postMessageAndRegisterCallbacks(a,i,n)}))}newRecognizer(e,...t){return new Promise(((i,s)=>{const o=new g(e,function(e){const t=[];for(let i of e){let e=c.Any;i instanceof Q&&(e=c.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),r=U((t=>{const s=new Q(this.wasmSDKWorker,e,t.objectHandle);i(s)}),s);this.wasmSDKWorker.postMessage(o,r)}))}}class W{constructor(e,t,i,s){this.eventHandlers={},this.metadataCallbacks={},this.loadedWasmType=M.Basic,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{s("Problem during initialization of worker file!")},this.mbWasmModule=new V(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),s=U((t=>{e(t.result)}),t);this.postMessage(i,s)}))}handleWorkerEvent(e){if("isCallbackMessage"in e.data){const t=e.data;switch(t.callbackType){case l.onDebugText:"function"==typeof this.metadataCallbacks.onDebugText&&this.metadataCallbacks.onDebugText(t.callbackParameters[0]);break;case l.onDetectionFailed:"function"==typeof this.metadataCallbacks.onDetectionFailed&&this.metadataCallbacks.onDetectionFailed();break;case l.onPointsDetection:"function"==typeof this.metadataCallbacks.onPointsDetection&&this.metadataCallbacks.onPointsDetection(t.callbackParameters[0]);break;case l.onQuadDetection:"function"==typeof this.metadataCallbacks.onQuadDetection&&this.metadataCallbacks.onQuadDetection(t.callbackParameters[0]);break;case l.onFirstSideResult:"function"==typeof this.metadataCallbacks.onFirstSideResult&&this.metadataCallbacks.onFirstSideResult();break;case l.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: ${l[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(((s,o)=>{const r=new W(e,t.loadProgressCallback,i,o),a=new n(t,i),c=U((e=>{const t=e;r.showOverlay=t.showOverlay,r.loadedWasmType=t.wasmType,s(r)}),(e=>{r&&"function"==typeof r.delete&&r.delete(),o(e)}));r.postMessage(a,c)}))}}var B;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(B||(B={}));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","बैक"],F=["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"],X=["후면 카메라","後置相機","Задна камера","後置鏡頭","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"],J=()=>!!navigator.userAgent.match(/Android/i),K=()=>!!navigator.userAgent.match(/iPhone/i);function q(e){const t=e.toLowerCase();return H.some((e=>t.includes(e)))}class _{constructor(e,t,i){this.deviceId=e.deviceId,this.facing=t,this.groupId=e.groupId,this.label=i||e.label}}async function $(){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 s=i.filter((e=>"videoinput"===e.kind));let o=0,r=0;for(const i of s)if(q(i.label)){let e;o++,J()&&(e=`Back camera ${o}`),t.push(new _(i,B.BackFacingCamera,e))}else{let t;r++,J()&&(t=`Front camera ${r}`),e.push(new _(i,B.FrontFacingCamera,t))}return{frontCameras:e,backCameras:t}}async function ee(e,t){const{frontCameras:i,backCameras:s}=await $();if(!i.length&&!s.length)return null;if(e){let t;return t=i.find((t=>t.deviceId===e)),t||(t=s.find((t=>t.deviceId===e))),t||null}let o=null;if(K()&&t===B.BackFacingCamera){let e=s.find((e=>F.includes(e.label)));e||(e=s.find((e=>X.includes(e.label)))),e&&(o=e)}else if(J()&&t===B.BackFacingCamera){let e={deviceId:"",score:-1};const t=(e,t)=>{let i=0;return e&&i++,t&&i++,i};for(const i of s){const s=await navigator.mediaDevices.getUserMedia({video:{deviceId:i.deviceId,width:1920,height:1080}});if("getCapabilities"in s.getVideoTracks()[0]){const o=s.getVideoTracks()[0].getCapabilities(),r=Boolean(o.torch),a=o.focusMode?.includes("single-shot"),n=t(r,a);n>e.score&&(e={deviceId:i.deviceId,score:n})}te(s)}o=s.find((t=>t.deviceId===e.deviceId))||null}if(null===o){let e=s.length>0?s:i;t===B.BackFacingCamera&&s.length>0&&(e=s),t===B.FrontFacingCamera&&i.length>0&&(e=i),e=e.sort(((e,t)=>e.label.localeCompare(t.label)));let o=e.length-1;const r=e.map((e=>{const t=RegExp(/\b([0-9]+)MP?\b/,"i").exec(e.label);return null!==t?parseInt(t[1],10):NaN}));return r.some((e=>isNaN(e)))||(o=r.lastIndexOf(Math.max(...r))),e[o]}return o}const te=e=>{const t=e.getTracks();for(const e of t)e.stop()};async function ie(e,t,i=B.BackFacingCamera){const s={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};""===e.deviceId?s.video.facingMode={ideal:i===B.BackFacingCamera?"environment":"user"}:s.video.deviceId={exact:e.deviceId};const o=await navigator.mediaDevices.getUserMedia(s);t.controls=!1,t.srcObject=o;let r=!1;return e.facing===B.FrontFacingCamera&&(r=!0),r}var se,oe,re;function ae(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){return!1}return!1}let ne,ce;!function(e){e[e.RotatedLeft90=0]="RotatedLeft90",e[e.NoRotation=1]="NoRotation",e[e.RotatedRight90=2]="RotatedRight90",e[e.Rotated180=3]="Rotated180"}(se||(se={})),function(e){e[e.Empty=0]="Empty",e[e.Uncertain=1]="Uncertain",e[e.Valid=2]="Valid",e[e.StageValid=3]="StageValid"}(oe||(oe={})),function(e){e[e.Front=0]="Front",e[e.Back=1]="Back"}(re||(re={}));class le{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 Me(e){let t,i,s=!1;if(e instanceof HTMLVideoElement)t=e.videoWidth,i=e.videoHeight,s=!0;else if(e instanceof HTMLImageElement)t=e.naturalWidth,i=e.naturalHeight;else{if(e instanceof SVGImageElement)throw new z(v.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),ce=ce||ne.getContext("2d",{willReadFrequently:!0}),!ce)throw new z(v.canvasMissing);ce.drawImage(e,0,0,ne.width,ne.height);const o=ce.getImageData(0,0,ne.width,ne.height);return new le(o,se.NoRotation,s)}var de,he,ge,ue;function Ne(e){return{licenseId:e.licenseId,licensee:e.licensee,applicationIds:e.applicationIds,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}async function Ae(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(Ne(e))});if(i.ok){const e=(await i.text()).toString();return t.submitServerPermission(e)}return{status:ge.NetworkError,lease:0,networkErrorDescription:`Server responded with status ${i.status}`}}catch(e){return{status:ge.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"}(de||(de={})),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"}(he||(he={})),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"}(ge||(ge={})),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"}(ue||(ue={}));class De 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 s=new Map;let o=0,r=0;const a=[],n=i?function(){const i=Date.now();if(a.length<e)return a.push(i),0;const s=a.shift()+t;return i>=s?(a.push(i),0):(a.push(s),s-i)}:function(){const i=Date.now();return i-o>t?(r=1,o=i,0):(r<e?r++:(o+=t,r=1),o-i)};return e=>{const t=function(...i){if(!t.isEnabled)return(async()=>e.apply(this,i))();let o;return new Promise(((t,r)=>{o=setTimeout((()=>{t(e.apply(this,i)),s.delete(o)}),n()),s.set(o,r)}))};return t.abort=()=>{for(const e of s.keys())clearTimeout(e),s.get(e)(new De);s.clear(),a.splice(0,a.length)},t.isEnabled=!0,Object.defineProperty(t,"queueSize",{get:()=>s.size}),t}}({limit:1,interval:Math.round(1/15*1e3),strict:!0});var Ie;!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(Ie||(Ie={}));class me{constructor(e,t,i=!1,s=null){this.deviceId=null,this.recognitionCancelRequested=!1,this.recognitionPauseRequested=!1,this.recognitionTimeoutMs=2e4,this.timeoutStartedAt=0,this.currentTimeoutCount=0,this.videoRecognitionMode=Ie.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===Ie.DetectionTest;await this.recognizerRunner.setDetectionOnlyMode(t)},this.startRecognition=async(e,t=2e4)=>{try{await this.videoElement.play()}catch(e){throw new Error(h.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED)}this.recognitionPauseRequested=!1,this.recognitionCancelRequested=!1,this.clearTimeout(),this.recognitionTimeoutMs=t,this.onScanningDone=e,await this.throttledQueueFrame()},this.resumeRecognition=async e=>{if(e)try{await this.resetRecognizers(!0)}catch(e){throw new z(E.recognizersResetFailure)}try{await this.videoElement.play()}catch(e){throw new Error(h.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 ie(e,this.videoElement,B.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=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=Me(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===Ie.DetectionTest||this.videoRecognitionMode===Ie.RecognitionTest)return await this.recognizerRunner.resetRecognizers(!0),this.clearTimeout(),void this.throttledQueueFrame();switch(t){case oe.Valid:return this.clearTimeout(),void("function"==typeof this.onScanningDone&&this.onScanningDone(t));case oe.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 oe.StageValid:case oe.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=s,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,s=B.BackFacingCamera){if(!(e&&e instanceof HTMLVideoElement))throw new z(E.elementMissing);if(!navigator.mediaDevices.getUserMedia)throw new z(E.mediaDevicesUnsupported);const o=await ee(i,s);if(!o)throw new z(E.cameraMissing);const r=await ie(o,e,s);return await t.setPingData({selectedCamera:o.label}),new me(e,t,r,o.deviceId)}static createVideoRecognizerFromVideoPath(e,t,i){const s=new me(t,i);return t.src=e,t.currentTime=0,t.onended=()=>{s.cancelRecognition()},s}}class pe{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 z(w.licenseKeyMissing);this.licenseKey=e}}const fe=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])),ye=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])),je=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),xe=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])),Ce=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])),ze=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]));function Le(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}async function Te(){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!Le()&&"Worker"in self}function Ee(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))}async function we(e){return new Promise(((t,i)=>{if(!e||"object"!=typeof e)return void i(new z(w.wasmSettingsMissing));if("string"!=typeof e.licenseKey)return void i(new z(w.licenseKeyMissing));if(!e.wasmModuleName)return void i(new z(w.wasmModuleNameMissing));if("string"!=typeof e.engineLocation)return void i(new z(w.engineLocationInvalid));if("string"!=typeof e.workerLocation)return void i(new z(w.workerLocationInvalid));const s=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=Ee(),localStorage.setItem("mb-user-id",e)),e}catch(e){return Ee()}}();try{const o=`/resources/${e.wasmModuleName}.worker.min.js`,r=window.location.origin+o,a=e.workerLocation||r;e.allowHelloMessage&&console.log("Worker location is:",a);const n=new Worker(a);W.createWasmWorker(n,e,s).then((e=>{t(e)}),i)}catch(e){i(e)}}))}async function ve(e,t,i=!1,s={}){if("object"!=typeof e)throw new z(w.missing);if("object"!=typeof t||t.length<1)throw new z(w.recognizersMissing);return e.mbWasmModule.createRecognizerRunner(t,i,s)}var Oe,Se,ke,Ye,Re,Ue,Qe,Pe,Ze,Ge,Ve,We,Be,He,Fe,Xe,Je;!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"}(Oe||(Oe={})),function(e){e[e.None=0]="None",e[e.ImageOnly=1]="ImageOnly",e[e.ResultFieldsOnly=2]="ResultFieldsOnly",e[e.FullResult=3]="FullResult"}(Se||(Se={}));class Ke{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"}(ke||(ke={}));class qe{constructor(e=0,t=0,i=0,s=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(s),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=s}checkExtensionFactor(e){if(e>1||e<-1)throw new Error("Extension factor must be in range [-1.0, 1.0]")}}function _e(e){if(e<100||e>400)throw new 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"}(Re||(Re={}));class $e{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]="ARMENIA",e[e.ARUBA=115]="ARUBA",e[e.BAILIWICK_OF_GUERNSEY=116]="BAILIWICK_OF_GUERNSEY",e[e.BAILIWICK_OF_JERSEY=117]="BAILIWICK_OF_JERSEY",e[e.BARBADOS=118]="BARBADOS",e[e.BELARUS=119]="BELARUS",e[e.BELIZE=120]="BELIZE",e[e.BENIN=121]="BENIN",e[e.BHUTAN=122]="BHUTAN",e[e.BONAIRE_SAINT_EUSTATIUS_AND_SABA=123]="BONAIRE_SAINT_EUSTATIUS_AND_SABA",e[e.BOTSWANA=124]="BOTSWANA",e[e.BOUVET_ISLAND=125]="BOUVET_ISLAND",e[e.BRITISH_INDIAN_OCEAN_TERRITORY=126]="BRITISH_INDIAN_OCEAN_TERRITORY",e[e.BURKINA_FASO=127]="BURKINA_FASO",e[e.BURUNDI=128]="BURUNDI",e[e.CAMEROON=129]="CAMEROON",e[e.CAPE_VERDE=130]="CAPE_VERDE",e[e.CARIBBEAN_NETHERLANDS=131]="CARIBBEAN_NETHERLANDS",e[e.CAYMAN_ISLANDS=132]="CAYMAN_ISLANDS",e[e.CENTRAL_AFRICAN_REPUBLIC=133]="CENTRAL_AFRICAN_REPUBLIC",e[e.CHAD=134]="CHAD",e[e.CHRISTMAS_ISLAND=135]="CHRISTMAS_ISLAND",e[e.COCOS_ISLANDS=136]="COCOS_ISLANDS",e[e.COMOROS=137]="COMOROS",e[e.CONGO=138]="CONGO",e[e.COOK_ISLANDS=139]="COOK_ISLANDS",e[e.CUBA=140]="CUBA",e[e.CURACAO=141]="CURACAO",e[e.DEMOCRATIC_REPUBLIC_OF_THE_CONGO=142]="DEMOCRATIC_REPUBLIC_OF_THE_CONGO",e[e.DJIBOUTI=143]="DJIBOUTI",e[e.DOMINICA=144]="DOMINICA",e[e.EAST_TIMOR=145]="EAST_TIMOR",e[e.EQUATORIAL_GUINEA=146]="EQUATORIAL_GUINEA",e[e.ERITREA=147]="ERITREA",e[e.ETHIOPIA=148]="ETHIOPIA",e[e.FALKLAND_ISLANDS=149]="FALKLAND_ISLANDS",e[e.FAROE_ISLANDS=150]="FAROE_ISLANDS",e[e.FEDERATED_STATES_OF_MICRONESIA=151]="FEDERATED_STATES_OF_MICRONESIA",e[e.FIJI=152]="FIJI",e[e.FRENCH_GUIANA=153]="FRENCH_GUIANA",e[e.FRENCH_POLYNESIA=154]="FRENCH_POLYNESIA",e[e.FRENCH_SOUTHERN_TERRITORIES=155]="FRENCH_SOUTHERN_TERRITORIES",e[e.GABON=156]="GABON",e[e.GAMBIA=157]="GAMBIA",e[e.GIBRALTAR=158]="GIBRALTAR",e[e.GREENLAND=159]="GREENLAND",e[e.GRENADA=160]="GRENADA",e[e.GUADELOUPE=161]="GUADELOUPE",e[e.GUAM=162]="GUAM",e[e.GUINEA=163]="GUINEA",e[e.GUINEA_BISSAU=164]="GUINEA_BISSAU",e[e.GUYANA=165]="GUYANA",e[e.HEAR