@microblink/blinkid-in-browser-sdk
Version:
A simple ID scanning library for WebAssembly-enabled browsers.
9 lines (8 loc) • 471 kB
JavaScript
import{r as e,c as t,h as i,H as o,g as s}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 y extends a{constructor(e){super(y.action),this.detectionOnlyMode=e}}y.action="setDetectionOnly";class j extends a{constructor(e){super(j.action),this.cameraPreviewMirrored=e}}j.action="setCameraPreviewMirrored";class f extends a{constructor(e){super(f.action),this.userId=e}}f.action="getProductIntegrationInfo";class x extends a{constructor(e){super(x.action),this.pingProxyUrl=e}}x.action="setPingProxyUrl",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,"details"in e){if("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 C{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"}(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."}(h||(h={}));const L={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}},T={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}},w={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}},E={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}},v={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}},O={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}},S={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}};function k(e,t){return i=>{const o=i;o.success?e():t("string"==typeof o.error||null===o.error?o.error:new z(o.error))}}function Y(e,t){return i=>{const o=i;o.success?e(i):t("string"==typeof o.error||null===o.error?o.error:new z(o.error))}}class R{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",[]),o=Y((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,o)}))}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",[]),o=Y((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,o)}))}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const o of t){const t=e[o];"function"==typeof t&&(this.callbacks.set(o,t),e[o]={parameter:{recognizerHandle:this.objectHandle,callbackName:o},type: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 o=new D(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:c.RecognizerSettings}]),s=k(t,i);this.wasmSDKWorker.postMessage(o,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(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());const i=new D(this.objectHandle,"getResult",[]),o=Y((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,o)}))}delete(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());this.clearAllCallbacks();const i=new D(this.objectHandle,"delete",[]),o=k((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(i,o)}))}}function U(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 Q{constructor(e,t){this.deleted=!1,this.wasmSDKWorker=e,this.recognizers=t}processImage(e){return new Promise(((t,i)=>{if(this.deleted)return void i("Recognizer runner is deleted. It cannot be used anymore!");const o=new b(e),s=Y((e=>{t(e.recognitionState)}),i);this.wasmSDKWorker.postTransferrableMessage(o,s)}))}reconfigureRecognizers(e,t){return new Promise(((i,o)=>{if(this.deleted)return void o("Recognizer runner is deleted. It cannot be used anymore!");const s=Z(e),r=new N(s,t),a=k(i,o);this.wasmSDKWorker.postMessage(r,a),this.recognizers=e}))}setMetadataCallbacks(e){return new Promise(((t,i)=>{const o=new p(U(e)),s=k(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(o,e,s)}))}resetRecognizers(e){return new Promise(((t,i)=>{const o=new I(e),s=k(t,i);this.wasmSDKWorker.postMessage(o,s)}))}setDetectionOnlyMode(e){return new Promise(((t,i)=>{const o=new y(e),s=k(t,i);this.wasmSDKWorker.postMessage(o,s)}))}setPingProxyUrl(e){if(!function(e){return/^https:\/\/[^\/]+(?::\d+)?\/?$/.test(e)}(e))throw new z(S.invalidProxyUrl);return new Promise(((t,i)=>{const o=new x(e),s=k(t,i);this.wasmSDKWorker.postMessage(o,s)}))}setCameraPreviewMirrored(e){return new Promise(((t,i)=>{const o=new j(e),s=k(t,i);this.wasmSDKWorker.postMessage(o,s)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const i=new A,o=k((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(i,o)}))}}function Z(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class P{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise(((o,s)=>{const r=Z(e),a=new u(r,t,U(i)),n=k((()=>{o(new Q(this.wasmSDKWorker,e))}),s);this.wasmSDKWorker.postMessageAndRegisterCallbacks(a,i,n)}))}newRecognizer(e,...t){return new Promise(((i,o)=>{const s=new g(e,function(e){const t=[];for(let i of e){let e=c.Any;i instanceof R&&(e=c.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),r=Y((t=>{const o=new R(this.wasmSDKWorker,e,t.objectHandle);i(o)}),o);this.wasmSDKWorker.postMessage(s,r)}))}}class G{constructor(e,t,i,o){this.eventHandlers={},this.metadataCallbacks={},this.loadedWasmType=M.Basic,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{o("Problem during initialization of worker file!")},this.mbWasmModule=new P(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 f(this.userId),o=Y((t=>{e(t.result)}),t);this.postMessage(i,o)}))}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(((o,s)=>{const r=new G(e,t.loadProgressCallback,i,s),a=new n(t,i),c=Y((e=>{const t=e;r.showOverlay=t.showOverlay,r.loadedWasmType=t.wasmType,o(r)}),(e=>{r&&"function"==typeof r.delete&&r.delete(),s(e)}));r.postMessage(a,c)}))}}var V;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(V||(V={}));const W=["rear","back","rück","arrière","trasera","trás","traseira","posteriore","后面","後面","背面","后置","後置","背置","задней","الخلفية","후","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"],H=["후면 카메라","後置相機","Задна камера","後置鏡頭","Camera mặt sau","Hátoldali kamera","Cámara trasera","Back Camera","Kamera på baksidan","Πίσω κάμερα","Bagsidekamera","Zadná kamera","Fotocamera (posteriore)","Câmara traseira","מצלמה אחורית","Takakamera","Rückkamera","Caméra arrière","Zadní fotoaparát","Артқы камера","Tylny aparat","बैक कैमरा","Hátsó kamera","Camera aan achterzijde","Kamera Belakang","Câmera Traseira","Stražnja kamera","الكاميرا الخلفية","Càmera posterior","Fotocamera posteriore","Càmera del darrere","กล้องด้านหลัง","Cameră spate","Kamera, bagside","背面カメラ","Задня камера","Arka Kamera","后置相机","Камера на задней панели","后置镜头","Kamera bak","Задняя камера","Aparat tylny","Kamera på baksiden","Câmera de Trás"],X=()=>!!navigator.userAgent.match(/Android/i),F=()=>!!navigator.userAgent.match(/iPhone/i);function J(e){const t=e.toLowerCase();return W.some((e=>t.includes(e)))}class K{constructor(e,t,i){this.deviceId=e.deviceId,this.facing=t,this.groupId=e.groupId,this.label=i||e.label}}async function q(){const e=[],t=[];let i=await navigator.mediaDevices.enumerateDevices();if(i.filter((e=>"videoinput"===e.kind)).every((e=>""===e.label))){const e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});i=await navigator.mediaDevices.enumerateDevices(),e.getTracks().forEach((e=>e.stop()))}const o=i.filter((e=>"videoinput"===e.kind));let s=0,r=0;for(const i of o)if(J(i.label)){let e;s++,X()&&(e=`Back camera ${s}`),t.push(new K(i,V.BackFacingCamera,e))}else{let t;r++,X()&&(t=`Front camera ${r}`),e.push(new K(i,V.FrontFacingCamera,t))}return{frontCameras:e,backCameras:t}}async function _(e,t){const{frontCameras:i,backCameras:o}=await q();if(!i.length&&!o.length)return null;if(e){let t;return t=i.find((t=>t.deviceId===e)),t||(t=o.find((t=>t.deviceId===e))),t||null}let s=null;if(F()&&t===V.BackFacingCamera){let e=o.find((e=>B.includes(e.label)));e||(e=o.find((e=>H.includes(e.label)))),e&&(s=e)}else if(X()&&t===V.BackFacingCamera){let e={deviceId:"",score:-1};const t=(e,t)=>{let i=0;return e&&i++,t&&i++,i};for(const i of o){const o=await navigator.mediaDevices.getUserMedia({video:{deviceId:i.deviceId,width:1920,height:1080}});if("getCapabilities"in o.getVideoTracks()[0]){const s=o.getVideoTracks()[0].getCapabilities(),r=Boolean(s.torch),a=s.focusMode?.includes("single-shot"),n=t(r,a);n>e.score&&(e={deviceId:i.deviceId,score:n})}$(o)}s=o.find((t=>t.deviceId===e.deviceId))||null}if(null===s){let e=o.length>0?o:i;t===V.BackFacingCamera&&o.length>0&&(e=o),t===V.FrontFacingCamera&&i.length>0&&(e=i),e=e.sort(((e,t)=>e.label.localeCompare(t.label)));let s=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)))||(s=r.lastIndexOf(Math.max(...r))),e[s]}return s}const $=e=>{const t=e.getTracks();for(const e of t)e.stop()};async function ee(e,t,i=V.BackFacingCamera){const o={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};""===e.deviceId?o.video.facingMode={ideal:i===V.BackFacingCamera?"environment":"user"}:o.video.deviceId={exact:e.deviceId};const s=await navigator.mediaDevices.getUserMedia(o);t.controls=!1,t.srcObject=s;let r=!1;return e.facing===V.FrontFacingCamera&&(r=!0),r}var te,ie,oe;function se(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){return!1}return!1}let re,ae;!function(e){e[e.RotatedLeft90=0]="RotatedLeft90",e[e.NoRotation=1]="NoRotation",e[e.RotatedRight90=2]="RotatedRight90",e[e.Rotated180=3]="Rotated180"}(te||(te={})),function(e){e[e.Empty=0]="Empty",e[e.Uncertain=1]="Uncertain",e[e.Valid=2]="Valid",e[e.StageValid=3]="StageValid"}(ie||(ie={})),function(e){e[e.Front=0]="Front",e[e.Back=1]="Back"}(oe||(oe={}));class ne{constructor(e,t,i){this.imageData={data:e.data,width:e.width,height:e.height,colorSpace:e.colorSpace},this.orientation=t,this.videoFrame=i}}function ce(e){let t,i,o=!1;if(e instanceof HTMLVideoElement)t=e.videoWidth,i=e.videoHeight,o=!0;else if(e instanceof HTMLImageElement)t=e.naturalWidth,i=e.naturalHeight;else{if(e instanceof SVGImageElement)throw new z(w.svgUnsupported);e instanceof VideoFrame?(t=e.displayWidth,i=e.displayHeight):(t=e.width,i=e.height)}if(re=re||document.createElement("canvas"),re.width!==t&&re.height!==i&&(re.width=t,re.height=i),ae=ae||re.getContext("2d",{willReadFrequently:!0}),!ae)throw new z(w.canvasMissing);ae.drawImage(e,0,0,re.width,re.height);const s=ae.getImageData(0,0,re.width,re.height);return new ne(s,te.NoRotation,o)}var le,Me,de,he;function ge(e){return{licenseId:e.licenseId,licensee:e.licensee,applicationIds:e.applicationIds,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}async function ue(e,t){try{const i=await fetch("https://baltazar.microblink.com/api/v2/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(ge(e))});if(i.ok){const e=(await i.text()).toString();return t.submitServerPermission(e)}return{status:de.NetworkError,lease:0,networkErrorDescription:`Server responded with status ${i.status}`}}catch(e){return{status:de.NetworkError,lease:0,networkErrorDescription:`Unexpected error: ${JSON.stringify(e)}`}}}!function(e){e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid"}(le||(le={})),function(e){e.LicenseTokenStateInvalid="LICENSE_TOKEN_STATE_INVALID",e.NetworkError="NETWORK_ERROR",e.RemoteLock="REMOTE_LOCK",e.PermissionExpired="PERMISSION_EXPIRED",e.PayloadCorrupted="PAYLOAD_CORRUPTED",e.PayloadSignatureVerificationFailed="PAYLOAD_SIGNATURE_VERIFICATION_FAILED",e.IncorrectTokenState="INCORRECT_TOKEN_STATE"}(Me||(Me={})),function(e){e[e.Ok=0]="Ok",e[e.NetworkError=1]="NetworkError",e[e.RemoteLock=2]="RemoteLock",e[e.PermissionExpired=3]="PermissionExpired",e[e.PayloadCorrupted=4]="PayloadCorrupted",e[e.PayloadSignatureVerificationFailed=5]="PayloadSignatureVerificationFailed",e[e.IncorrectTokenState=6]="IncorrectTokenState"}(de||(de={})),function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success",e[e.CameraTooFar=2]="CameraTooFar",e[e.CameraTooClose=3]="CameraTooClose",e[e.CameraAngleTooSteep=4]="CameraAngleTooSteep",e[e.DocumentTooCloseToCameraEdge=5]="DocumentTooCloseToCameraEdge",e[e.DocumentPartiallyVisible=6]="DocumentPartiallyVisible",e[e.FallbackSuccess=7]="FallbackSuccess"}(he||(he={}));class Ne extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}}const Ae=function({limit:e,interval:t,strict:i}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=new Map;let s=0,r=0;const a=[],n=i?function(){const i=Date.now();if(a.length<e)return a.push(i),0;const o=a.shift()+t;return i>=o?(a.push(i),0):(a.push(o),o-i)}:function(){const i=Date.now();return i-s>t?(r=1,s=i,0):(r<e?r++:(s+=t,r=1),s-i)};return e=>{const t=function(...i){if(!t.isEnabled)return(async()=>e.apply(this,i))();let s;return new Promise(((t,r)=>{s=setTimeout((()=>{t(e.apply(this,i)),o.delete(s)}),n()),o.set(s,r)}))};return t.abort=()=>{for(const e of o.keys())clearTimeout(e),o.get(e)(new Ne);o.clear(),a.splice(0,a.length)},t.isEnabled=!0,Object.defineProperty(t,"queueSize",{get:()=>o.size}),t}}({limit:1,interval:Math.round(1/15*1e3),strict:!0});var De;!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(De||(De={}));class be{constructor(e,t,i=!1,o=null){this.deviceId=null,this.recognitionCancelRequested=!1,this.recognitionPauseRequested=!1,this.recognitionTimeoutMs=2e4,this.timeoutStartedAt=0,this.currentTimeoutCount=0,this.videoRecognitionMode=De.Recognition,this.onScanningDone=null,this.onFrameProcessed=null,this.cameraFlipped=!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===De.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(L.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 ee(e,this.videoElement,V.BackFacingCamera),await this.resumeRecognition(!0)},this.queueFrame=()=>new Promise((e=>{this.frameCallback((()=>{this.recognitionLoop().then((()=>e()))}))})),this.throttledQueueFrame=Ae(this.queueFrame),this.recognitionLoop=async()=>{if(this.recognitionPauseRequested)return;if(this.recognitionCancelRequested)return this.clearTimeout(),await this.resetRecognizers(!0),this.onScanningDone=null,void(this.recognitionCancelRequested=!1);const e=ce(this.videoElement);await new Promise((e=>setTimeout(e,0)));const t=await this.recognizerRunner.processImage(e),i=await this.recognizerRunner.recognizers[0].getResult();if("function"==typeof this.onFrameProcessed&&this.onFrameProcessed(i,e.imageData),this.videoRecognitionMode===De.DetectionTest||this.videoRecognitionMode===De.RecognitionTest)return await this.recognizerRunner.resetRecognizers(!0),this.clearTimeout(),void this.throttledQueueFrame();switch(t){case ie.Valid:return this.clearTimeout(),void("function"==typeof this.onScanningDone&&this.onScanningDone(t));case ie.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 ie.StageValid:case ie.Empty:return this.clearTimeout(),void this.throttledQueueFrame()}},this.clearTimeout=()=>{this.currentTimeoutCount=0,this.timeoutStartedAt=0},this.releaseVideoFeed=()=>{this.videoElement&&null!==this.videoElement.srcObject&&this.videoElement.srcObject instanceof MediaStream&&(this.videoElement.srcObject.getTracks().forEach((e=>e.stop())),this.videoElement.srcObject=null)},this.videoElement=e,this.recognizerRunner=t,this.cameraFlipped=i,this.deviceId=o,this.frameCallback="requestVideoFrameCallback"in HTMLVideoElement.prototype?this.videoElement.requestVideoFrameCallback.bind(this.videoElement):window.requestAnimationFrame.bind(window),this.handleFlippingVideo(),this.videoElement.setAttribute("playsinline",""),this.videoElement.setAttribute("mute","")}static async createVideoRecognizerFromCameraStream(e,t,i=null,o=V.BackFacingCamera){if(!(e&&e instanceof HTMLVideoElement))throw new z(L.elementMissing);if(!navigator.mediaDevices.getUserMedia)throw new z(L.mediaDevicesUnsupported);const s=await _(i,o);if(!s)throw new z(L.cameraMissing);const r=await ee(s,e,o);return new be(e,t,r,s.deviceId)}static createVideoRecognizerFromVideoPath(e,t,i){const o=new be(t,i);return t.src=e,t.currentTime=0,t.onended=()=>{o.cancelRecognition()},o}}class Ie{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(T.licenseKeyMissing);this.licenseKey=e}}const me=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])),pe=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])),ye=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),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,12,1,10,0,67,0,0,0,0,252,0,26,11])),fe=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])),xe=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 ze(){return/iOS|iPhone|iPad|iPod/i.test(navigator.userAgent)}async function Ce(){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!ze()&&"Worker"in self}function Le(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))}async function Te(e){return new Promise(((t,i)=>{if(!e||"object"!=typeof e)return void i(new z(T.wasmSettingsMissing));if("string"!=typeof e.licenseKey)return void i(new z(T.licenseKeyMissing));if(!e.wasmModuleName)return void i(new z(T.wasmModuleNameMissing));if("string"!=typeof e.engineLocation)return void i(new z(T.engineLocationInvalid));if("string"!=typeof e.workerLocation)return void i(new z(T.workerLocationInvalid));const o=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=Le(),localStorage.setItem("mb-user-id",e)),e}catch(e){return Le()}}();try{const s=`/resources/${e.wasmModuleName}.worker.min.js`,r=window.location.origin+s,a=e.workerLocation||r;e.allowHelloMessage&&console.log("Worker location is:",a);const n=new Worker(a);G.createWasmWorker(n,e,o).then((e=>{t(e)}),i)}catch(e){i(e)}}))}async function we(e,t,i=!1,o={}){if("object"!=typeof e)throw new z(T.missing);if("object"!=typeof t||t.length<1)throw new z(T.recognizersMissing);return e.mbWasmModule.createRecognizerRunner(t,i,o)}var Ee,ve,Oe,Se,ke,Ye,Re,Ue,Qe,Ze,Pe,Ge,Ve,We,Be;!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"}(Ee||(Ee={})),function(e){e[e.None=0]="None",e[e.ImageOnly=1]="ImageOnly",e[e.ResultFieldsOnly=2]="ResultFieldsOnly",e[e.FullResult=3]="FullResult"}(ve||(ve={}));class He{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"}(Oe||(Oe={}));class Xe{constructor(e=0,t=0,i=0,o=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(o),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=o}checkExtensionFactor(e){if(e>1||e<-1)throw new Error("Extension factor must be in range [-1.0, 1.0]")}}function Fe(e){if(e<100||e>400)throw new Error("DPI must be from interval [100, 400]")}!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"}(Se||(Se={})),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.HEARD_ISLAND_AND_MCDONALD_ISLANDS=166]="HEARD_ISLAND_AND_MCDONALD_ISLANDS",e[e.IRAN=167]="IRAN",e[e.IRAQ=168]="IRAQ",e[e.ISLE_OF_MAN=169]="ISLE_OF_MAN",e[e.IVORY_COAST=170]="IVORY_COAST",e[e.JAMAICA=171]="JAMAICA",e[e.KIRIBATI=172]="KIRIBATI",e[e.KYRGYZSTAN=173]="KYRGYZSTAN",e[e.LAOS=174]="LAOS",e[e.LEBANON=175]="LEBANON",e[e.LESOTHO=176]="LESOTHO",e[e.LIBERIA=177]="LIBERIA",e[e.LIBYA=178]="LIBYA",e[e.LIECHTENSTEIN=179]="LIECHTENSTEIN",e[e.MACAU=180]="MACAU",e[e.MADAGASCAR=181]="MADAGASCAR",e[e.MALAWI=182]="MALAWI",e[e.MALI=183]="MALI",e[e.MARSHALL_ISLANDS=184]="MARSHALL_ISLANDS",e[e.MARTINIQUE=185]="MARTINIQUE",e[e.MAURITANIA=186]="MAURITANIA",e[e.MAYOTTE=187]="MAYOTTE",e[e.MOLDOVA=188]="MOLDOVA",e[e.MONACO=189]="MONACO",e[e.MONGOLIA=190]="MONGOLIA",e[e.MONTSERRAT=191]="MONTSERRAT",e[e.MOZAMBIQUE=192]="MOZAMBIQUE",e[e.MYANMAR=193]="MYANMAR",e[e.NAMIBIA=194]="NAMIBIA",e[e.NAURU=195]="NAURU",e[e.NEPAL=196]="NEPAL",e[e.NEW_CALEDONIA=197]="NEW_CALEDONIA",e[e.NIGER=198]="NIGER",e[e.NIUE=199]="NIUE",e[e.NORFOLK_ISLAND=200]="NORFOLK_ISLAND",e[e.NORTHERN_CYPRUS=201]="NORTHERN_CYPRUS",e[e.NORTHERN_MARIANA_ISLANDS=202]="NORTHERN_MARIANA_ISLANDS",e[e.NORTH_KOREA=203]="NORTH_KOREA",e[e.NORTH_MACEDONIA=204]="NORTH_MACEDONIA",e[e.PALAU=205]="PALAU",e[e.PALESTINE=206]="PALESTINE",e[e.PAPUA_NEW_GUINEA=207]="PAPUA_NEW_GUINEA",e[e.PITCAIRN=208]="PITCAIRN",e[e.REUNION=209]="REUNION",e[e.RWANDA=210]="RWANDA",e[e.SAINT_BARTHELEMY=211]="SAINT_BARTHELEMY",e[e.SAINT_HELENA_ASCENSION_AND_TRISTIAN_DA_CUNHA=212]="SAINT_HELENA_ASCENSION_AND_TRISTIAN_DA_CUNHA",e[e.SAINT_KITTS_AND_NEVIS=213]="SAINT_