@microblink/blinkinput-in-browser-sdk
Version:
A simple barcode scanning library for WebAssembly-enabled browsers.
37 lines (32 loc) • 68 kB
JavaScript
/*! ****************************************************************************
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.
***************************************************************************** */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BlinkInputSDK={})}(this,(function(e){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function t(e,t,r,s){return new(r||(r=Promise))((function(o,i){function n(e){try{c(s.next(e))}catch(e){i(e)}}function a(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,a)}c((s=s.apply(e,t||[])).next())}))}let r=0;class s{constructor(e){this.action=e,this.messageID=function(){const e=r;return r+=1,e}()}}class o extends s{constructor(e,t){super(o.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.numberOfWorkers=e.numberOfWorkers}}var i,n,a;o.action="init",function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback"}(i||(i={}));class c extends s{constructor(e,t){super(c.action),this.className=e,this.params=t}}c.action="createNewNativeObject";class E extends s{constructor(e,t,r){super(E.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=r}}E.action="createRecognizerRunner";class d extends s{constructor(e,t){super(d.action),this.recognizerHandles=e,this.allowMultipleResults=t}}d.action="reconfigureRecognizerRunner";class l extends s{constructor(){super(l.action)}}l.action="deleteRecognizerRunner";class R extends s{constructor(e,t,r){super(R.action),this.objectHandle=e,this.methodName=t,this.params=r}}R.action="invokeObject";class u extends s{constructor(e){super(u.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}u.action="processImage";class _ extends s{constructor(e){super(_.action),this.hardReset=e}}_.action="resetRecognizers";class I{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1,this.onGlare=!1}}class m extends s{constructor(e){super(m.action),this.registeredMetadataCallbacks=e}}m.action="registerMetadataCallbacks";class N extends s{constructor(e){super(N.action),this.detectionOnlyMode=e}}N.action="setDetectionOnly";class S extends s{constructor(e){super(S.action),this.callbackNonEmpty=e}}S.action="setClearTimeoutCallback";class g extends s{constructor(e){super(g.action),this.cameraPreviewMirrored=e}}g.action="setCameraPreviewMirrored",function(e){e[e.onDebugText=0]="onDebugText",e[e.onDetectionFailed=1]="onDetectionFailed",e[e.onQuadDetection=2]="onQuadDetection",e[e.onPointsDetection=3]="onPointsDetection",e[e.onFirstSideResult=4]="onFirstSideResult",e[e.clearTimeoutCallback=5]="clearTimeoutCallback",e[e.onGlare=6]="onGlare",e[e.recognizerCallback=7]="recognizerCallback"}(n||(n={})),(a=e.WasmType||(e.WasmType={})).Basic="BASIC",a.Advanced="ADVANCED",a.AdvancedWithThreads="ADVANCED_WITH_THREADS";function h(e,t){return r=>{const s=r;s.success?e():t(s.error)}}function C(e,t){return r=>{const s=r;s.success?e(r):t(s.error)}}class O{constructor(e,t,r){this.wasmSDKWorker=e,this.objectHandle=r,this.recognizerName=t,this.callbacks=new Map}getRemoteObjectHandle(){return this.objectHandle}currentSettings(){return new Promise(((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const r=new R(this.objectHandle,"currentSettings",[]),s=C((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(r,s)}))}toJSON(){return Promise.resolve(null)}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let r=!1;for(const s of t){const t=e[s];if("function"==typeof t){this.callbacks.set(s,t);e[s]={parameter:{recognizerHandle:this.objectHandle,callbackName:s},type:i.Callback},r=!0}}return r&&this.wasmSDKWorker.registerRecognizerCallbacks(this.objectHandle,this),e}updateSettings(e){return new Promise(((t,r)=>{if(0>this.objectHandle)return void r("Invalid object handle: "+this.objectHandle);const s=new R(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:i.RecognizerSettings}]),o=h(t,r);this.wasmSDKWorker.postMessage(s,o)}))}invokeCallback(e,t){const r=this.callbacks.get(e);void 0!==r?r(...t):console.warn("Cannot find callback",e)}getResult(){return new Promise(((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);const r=new R(this.objectHandle,"getResult",[]),s=C((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(r,s)}))}delete(){return new Promise(((e,t)=>{if(0>this.objectHandle)return void t("Invalid object handle: "+this.objectHandle);this.clearAllCallbacks();const r=new R(this.objectHandle,"delete",[]),s=h((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(r,s)}))}}function D(e){const t=new I;return t.onDebugText=!!e.onDebugText,t.onDetectionFailed=!!e.onDetectionFailed,t.onPointsDetection=!!e.onPointsDetection,t.onQuadDetection=!!e.onQuadDetection,t.onFirstSideResult=!!e.onFirstSideResult,t.onGlare=!!e.onGlare,t}class A{constructor(e){this.deleted=!1,this.wasmSDKWorker=e}processImage(e){return new Promise(((t,r)=>{if(this.deleted)return void r("Recognizer runner is deleted. It cannot be used anymore!");const s=new u(e),o=C((e=>{t(e.recognitionState)}),r);this.wasmSDKWorker.postTransferrableMessage(s,o)}))}reconfigureRecognizers(e,t){return new Promise(((r,s)=>{if(this.deleted)return void s("Recognizer runner is deleted. It cannot be used anymore!");const o=M(e),i=new d(o,t),n=h(r,s);this.wasmSDKWorker.postMessage(i,n)}))}setMetadataCallbacks(e){return new Promise(((t,r)=>{const s=new m(D(e)),o=h(t,r);this.wasmSDKWorker.postMessageAndRegisterCallbacks(s,e,o)}))}resetRecognizers(e){return new Promise(((t,r)=>{const s=new _(e),o=h(t,r);this.wasmSDKWorker.postMessage(s,o)}))}setDetectionOnlyMode(e){return new Promise(((t,r)=>{const s=new N(e),o=h(t,r);this.wasmSDKWorker.postMessage(s,o)}))}setClearTimeoutCallback(e){return new Promise(((t,r)=>{const s=new S(null!==e),o=h(t,r);this.wasmSDKWorker.registerClearTimeoutCallback(e),this.wasmSDKWorker.postMessage(s,o)}))}setCameraPreviewMirrored(e){return new Promise(((t,r)=>{const s=new g(e),o=h(t,r);this.wasmSDKWorker.postMessage(s,o)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const r=new l,s=h((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(r,s)}))}}function M(e){const t=[];for(const r of e)t.push(r.getRemoteObjectHandle());return t}class p{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,r={}){return new Promise(((s,o)=>{const i=M(e),n=new E(i,t,D(r)),a=h((()=>{s(new A(this.wasmSDKWorker))}),o);this.wasmSDKWorker.postMessageAndRegisterCallbacks(n,r,a)}))}newRecognizer(e,...t){return new Promise(((r,s)=>{const o=new c(e,function(e){const t=[];for(let r of e){let e=i.Any;r instanceof O&&(e=i.Recognizer,r=r.getRemoteObjectHandle()),t.push({parameter:r,type:e})}return t}(t)),n=C((t=>{const s=new O(this.wasmSDKWorker,e,t.objectHandle);r(s)}),s);this.wasmSDKWorker.postMessage(o,n)}))}}class T{constructor(t,r,s){this.eventHandlers={},this.metadataCallbacks={},this.clearTimeoutCallback=null,this.loadedWasmType=e.WasmType.Basic,this.mbWasmWorker=t,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{s("Problem during initialization of worker file!")},this.mbWasmModule=new p(this),this.loadCallback=r,this.recognizersWithCallbacks=new Map,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,r){this.eventHandlers[e.messageID]=r,this.metadataCallbacks=t,this.mbWasmWorker.postMessage(e)}registerClearTimeoutCallback(e){this.clearTimeoutCallback=e}registerRecognizerCallbacks(e,t){this.recognizersWithCallbacks.set(e,t)}unregisterRecognizerCallbacks(e){this.recognizersWithCallbacks.delete(e)}delete(){this.mbWasmWorker.terminate()}handleWorkerEvent(e){if("isCallbackMessage"in e.data){const t=e.data;switch(t.callbackType){case n.onDebugText:"function"==typeof this.metadataCallbacks.onDebugText&&this.metadataCallbacks.onDebugText(t.callbackParameters[0]);break;case n.onDetectionFailed:"function"==typeof this.metadataCallbacks.onDetectionFailed&&this.metadataCallbacks.onDetectionFailed();break;case n.onPointsDetection:"function"==typeof this.metadataCallbacks.onPointsDetection&&this.metadataCallbacks.onPointsDetection(t.callbackParameters[0]);break;case n.onQuadDetection:"function"==typeof this.metadataCallbacks.onQuadDetection&&this.metadataCallbacks.onQuadDetection(t.callbackParameters[0]);break;case n.onFirstSideResult:"function"==typeof this.metadataCallbacks.onFirstSideResult&&this.metadataCallbacks.onFirstSideResult();break;case n.clearTimeoutCallback:this.clearTimeoutCallback&&"function"==typeof this.clearTimeoutCallback.onClearTimeout&&this.clearTimeoutCallback.onClearTimeout();break;case n.onGlare:"function"==typeof this.metadataCallbacks.onGlare&&this.metadataCallbacks.onGlare(t.callbackParameters[0]);break;case n.recognizerCallback:{const e=t.callbackParameters.shift(),r=this.recognizersWithCallbacks.get(e.recognizerHandle);void 0!==r?r.invokeCallback(e.callbackName,t.callbackParameters):console.warn("Cannot find recognizer to deliver callback message. Maybe it's destroyed?",e);break}default:throw Error("Unknown callback type: "+n[t.callbackType])}}else if("isLoadProgressMessage"in e.data){const t=e.data;"function"==typeof this.loadCallback&&this.loadCallback(t.progress)}else{const t=e.data,r=this.eventHandlers[t.messageID];delete this.eventHandlers[t.messageID],r(t)}}static createWasmWorker(e,r,s){return t(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{const n=new T(e,r.loadProgressCallback,i),a=new o(r,s),c=C((e=>{const r=e;n.showOverlay=r.showOverlay,n.loadedWasmType=r.wasmType,t(n)}),(e=>{n&&"function"==typeof n.delete&&n.delete(),i(e)}));n.postMessage(a,c)}))}))}}class v{constructor(e,t){if(!e.code||!e.message)throw Error("Instance of SDKError is required to have code and message.");this.message=e.message,this.code=e.code,this.details=t}}var b,f;(b=e.ErrorCodes||(e.ErrorCodes={})).WORKER_WASM_LOAD_FAILURE="WORKER_WASM_LOAD_FAILURE",b.WORKER_WASM_INIT_MISSING="WORKER_WASM_INIT_MISSING",b.WORKER_FUNCTION_INVOKE_FAILURE="WORKER_FUNCTION_INVOKE_FAILURE",b.WORKER_RECOGNIZER_CREATION_FAILURE="WORKER_RECOGNIZER_CREATION_FAILURE",b.WORKER_RUNNER_EXISTS="WORKER_RUNNER_EXISTS",b.WORKER_RUNNER_CREATION_FAILURE="WORKER_RUNNER_CREATION_FAILURE",b.WORKER_RUNNER_MISSING="WORKER_RUNNER_MISSING",b.WORKER_RUNNER_RECONFIGURE_FAILURE="WORKER_RUNNER_RECONFIGURE_FAILURE",b.WORKER_RUNNER_DELETED="WORKER_RUNNER_DELETED",b.WORKER_RUNNER_DELETE_FAILURE="WORKER_RUNNER_DELETE_FAILURE",b.WORKER_OBJECT_INVOKE_FAILURE="WORKER_OBJECT_INVOKE_FAILURE",b.WORKER_IMAGE_PROCESS_FAILURE="WORKER_IMAGE_PROCESS_FAILURE",b.WORKER_HANDLE_UNDEFINED="WORKER_HANDLE_UNDEFINED",b.WORKER_MESSAGE_ACTION_UNKNOWN="WORKER_MESSAGE_ACTION_UNKNOWN",b.WORKER_LICENSE_UNLOCK_ERROR="WORKER_LICENSE_UNLOCK_ERROR",b.LOCAL_SDK_RUNNER_MISSING="LOCAL_SDK_RUNNER_MISSING",b.LOCAL_SDK_RUNNER_EMPTY="LOCAL_SDK_RUNNER_EMPTY",b.LICENSE_UNLOCK_ERROR="LICENSE_UNLOCK_ERROR",b.FRAME_CAPTURE_SVG_UNSUPPORTED="FRAME_CAPTURE_SVG_UNSUPPORTED",b.FRAME_CAPTURE_CANVAS_MISSING="FRAME_CAPTURE_CANVAS_MISSING",b.SDK_WASM_SETTINGS_MISSING="SDK_WASM_SETTINGS_MISSING",b.SDK_LICENSE_KEY_MISSING="SDK_LICENSE_KEY_MISSING",b.SDK_WASM_MODULE_NAME_MISSING="SDK_WASM_MODULE_NAME_MISSING",b.SDK_ENGINE_LOCATION_INVALID="SDK_ENGINE_LOCATION_INVALID",b.SDK_MISSING="SDK_MISSING",b.SDK_RECOGNIZERS_MISSING="SDK_RECOGNIZERS_MISSING",b.VIDEO_RECOGNIZER_ELEMENT_MISSING="VIDEO_RECOGNIZER_ELEMENT_MISSING",b.VIDEO_RECOGNIZER_CAMERA_MISSING="VIDEO_RECOGNIZER_CAMERA_MISSING",b.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED="VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED",b.VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE="VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE",b.VIDEO_RECOGNIZER_CAMERA_IN_USE="VIDEO_RECOGNIZER_CAMERA_IN_USE",b.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED="VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED",b.VIDEO_RECOGNIZER_FEED_RELEASED="VIDEO_RECOGNIZER_FEED_RELEASED",b.VIDEO_RECOGNIZER_FEED_NOT_PAUSED="VIDEO_RECOGNIZER_FEED_NOT_PAUSED",b.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED="VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED",b.VIDEO_RECOGNIZER_FEED_PAUSED="VIDEO_RECOGNIZER_FEED_PAUSED",b.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE="VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE",b.VIDEO_RECOGNIZER_FEED_MISSING="VIDEO_RECOGNIZER_FEED_MISSING",(f=e.ErrorMessages||(e.ErrorMessages={})).WORKER_HANDLE_UNDEFINED="Cannot find object with handle: undefined",f.WORKER_WASM_LOAD_FAILURE="Failed to load WASM in web worker!",f.WORKER_WASM_INIT_MISSING="WASM module is not initialized!",f.WORKER_FUNCTION_INVOKE_FAILURE="Failed to invoke function!",f.WORKER_RECOGNIZER_CREATION_FAILURE="Failed to create new recognizer!",f.WORKER_RUNNER_EXISTS="Recognizer runner is already created! Multiple instances are not allowed!",f.WORKER_RUNNER_CREATION_FAILURE="Failed to create new recognizer runner!",f.WORKER_RUNNER_MISSING="Recognizer runner is not created! There is nothing to reconfigure!",f.WORKER_RUNNER_RECONFIGURE_FAILURE="Failed to reconfigure recognizer runner!",f.WORKER_RUNNER_DELETED="Recognizer runner is already deleted!",f.WORKER_RUNNER_DELETE_FAILURE="Failed to delete recognizer runner!",f.WORKER_OBJECT_INVOKE_FAILURE="Failed to invoke object!",f.WORKER_IMAGE_PROCESS_FAILURE="Recognizer runner is not initialized! Cannot process image!",f.LOCAL_SDK_RUNNER_MISSING="Property nativeRecognizerRunner is not available!",f.LOCAL_SDK_RUNNER_EMPTY="Native RecognizerRunner cannot be empty!",f.LICENSE_TOKEN_STATE_INCORRECT="Internal error (Incorrect token state)",f.LICENSE_PAYLOAD_VERIFICATION_FAILED="Failed to verify server permission's digital signature!",f.LICENSE_PAYLOAD_CORRUPTED="Server permission payload is corrupted!",f.LICENSE_PERMISSION_EXPIRED="Internal error (server permission expired)",f.LICENSE_REMOTE_LOCKED="Provided license key has been remotely locked. Please contact support for more information!",f.FRAME_CAPTURE_SVG_UNSUPPORTED="Recognition of SVG elements not supported!",f.FRAME_CAPTURE_CANVAS_MISSING="Could not get canvas 2d context!",f.SDK_WASM_SETTINGS_MISSING="Missing WASM load settings!",f.SDK_LICENSE_KEY_MISSING="Missing license key!",f.SDK_WASM_MODULE_NAME_MISSING="Missing WASM module name!",f.SDK_ENGINE_LOCATION_INVALID="Setting property 'engineLocation' must be a string!",f.SDK_MISSING="SDK is not provided!",f.SDK_RECOGNIZERS_MISSING="To create RecognizerRunner at least 1 recognizer is required.",f.VIDEO_RECOGNIZER_ELEMENT_MISSING="Video element, i.e. camera feed is not provided!",f.VIDEO_RECOGNIZER_CAMERA_MISSING="Camera not found!",f.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED="Camera not allowed!",f.VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE="Camera not available!",f.VIDEO_RECOGNIZER_CAMERA_IN_USE="Camera in use!",f.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED="Media devices not supported by browser.",f.VIDEO_RECOGNIZER_FEED_RELEASED="The associated video feed has been released!",f.VIDEO_RECOGNIZER_FEED_NOT_PAUSED="The associated video feed is not paused. Use resumeRecognition instead!",f.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED="The play() request was interrupted or prevented by browser security rules!",f.VIDEO_RECOGNIZER_FEED_PAUSED="Cannot resume recognition while video feed is paused! Use recognize or startRecognition",f.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE="Could not reset recognizers!",f.VIDEO_RECOGNIZER_FEED_MISSING="Missing video feed!";const F={feedMissing:{message:e.ErrorMessages.VIDEO_RECOGNIZER_FEED_MISSING,code:e.ErrorCodes.VIDEO_RECOGNIZER_FEED_MISSING},recognizersResetFailure:{message:e.ErrorMessages.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE,code:e.ErrorCodes.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE},feedPaused:{message:e.ErrorMessages.VIDEO_RECOGNIZER_FEED_PAUSED,code:e.ErrorCodes.VIDEO_RECOGNIZER_FEED_PAUSED},playRequestInterrupted:{message:e.ErrorMessages.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED,code:e.ErrorCodes.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED},videoFeedNotPaused:{message:e.ErrorMessages.VIDEO_RECOGNIZER_FEED_NOT_PAUSED,code:e.ErrorCodes.VIDEO_RECOGNIZER_FEED_NOT_PAUSED},videoFeedReleased:{message:e.ErrorMessages.VIDEO_RECOGNIZER_FEED_RELEASED,code:e.ErrorCodes.VIDEO_RECOGNIZER_FEED_RELEASED},mediaDevicesUnsupported:{code:e.ErrorCodes.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED,message:e.ErrorMessages.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED},cameraMissing:{code:e.ErrorCodes.VIDEO_RECOGNIZER_CAMERA_MISSING,message:e.ErrorMessages.VIDEO_RECOGNIZER_CAMERA_MISSING},elementMissing:{message:e.ErrorMessages.VIDEO_RECOGNIZER_ELEMENT_MISSING,code:e.ErrorCodes.VIDEO_RECOGNIZER_ELEMENT_MISSING}},w={wasmSettingsMissing:{message:e.ErrorMessages.SDK_WASM_SETTINGS_MISSING,code:e.ErrorCodes.SDK_WASM_SETTINGS_MISSING},licenseKeyMissing:{message:e.ErrorMessages.SDK_LICENSE_KEY_MISSING,code:e.ErrorCodes.SDK_LICENSE_KEY_MISSING},wasmModuleNameMissing:{message:e.ErrorMessages.SDK_WASM_MODULE_NAME_MISSING,code:e.ErrorCodes.SDK_WASM_MODULE_NAME_MISSING},engineLocationInvalid:{message:e.ErrorMessages.SDK_ENGINE_LOCATION_INVALID,code:e.ErrorCodes.SDK_ENGINE_LOCATION_INVALID},missing:{message:e.ErrorMessages.SDK_MISSING,code:e.ErrorCodes.SDK_MISSING},recognizersMissing:{message:e.ErrorMessages.SDK_RECOGNIZERS_MISSING,code:e.ErrorCodes.SDK_RECOGNIZERS_MISSING}},L={svgUnsupported:{message:e.ErrorMessages.FRAME_CAPTURE_SVG_UNSUPPORTED,code:e.ErrorCodes.FRAME_CAPTURE_SVG_UNSUPPORTED},canvasMissing:{message:e.ErrorMessages.FRAME_CAPTURE_CANVAS_MISSING,code:e.ErrorCodes.FRAME_CAPTURE_CANVAS_MISSING}},k={licenseTokenStateIncorrect:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR,message:e.ErrorMessages.LICENSE_TOKEN_STATE_INCORRECT},licensePayloadVerificationFailed:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR,message:e.ErrorMessages.LICENSE_PAYLOAD_VERIFICATION_FAILED},licensePayloadCorrupted:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR,message:e.ErrorMessages.LICENSE_PAYLOAD_CORRUPTED},licensePermissionExpired:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR,message:e.ErrorMessages.LICENSE_PERMISSION_EXPIRED},licenseRemoteLocked:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR,message:e.ErrorMessages.LICENSE_REMOTE_LOCKED},licenseNetworkError:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR},licenseInvalid:{code:e.ErrorCodes.LICENSE_UNLOCK_ERROR}},y={runnerMissing:{message:e.ErrorMessages.LOCAL_SDK_RUNNER_MISSING,code:e.ErrorCodes.LOCAL_SDK_RUNNER_MISSING},runnerEmpty:{message:e.ErrorMessages.LOCAL_SDK_RUNNER_EMPTY,code:e.ErrorCodes.LOCAL_SDK_RUNNER_EMPTY}},U={imageProcessFailure:{message:e.ErrorMessages.WORKER_IMAGE_PROCESS_FAILURE,code:e.ErrorCodes.WORKER_IMAGE_PROCESS_FAILURE},objectInvokeFailure:{message:e.ErrorMessages.WORKER_OBJECT_INVOKE_FAILURE,code:e.ErrorCodes.WORKER_OBJECT_INVOKE_FAILURE},runnerDeleteFailure:{message:e.ErrorMessages.WORKER_RUNNER_DELETE_FAILURE,code:e.ErrorCodes.WORKER_RUNNER_DELETE_FAILURE},runnerDeleted:{message:e.ErrorMessages.WORKER_RUNNER_DELETED,code:e.ErrorCodes.WORKER_RUNNER_DELETED},runnerReconfigureFailure:{message:e.ErrorMessages.WORKER_RUNNER_RECONFIGURE_FAILURE,code:e.ErrorCodes.WORKER_RUNNER_RECONFIGURE_FAILURE},runnerMissing:{message:e.ErrorMessages.WORKER_RUNNER_MISSING,code:e.ErrorCodes.WORKER_RUNNER_MISSING},runnerCreationFailure:{message:e.ErrorMessages.WORKER_RUNNER_CREATION_FAILURE,code:e.ErrorCodes.WORKER_RUNNER_CREATION_FAILURE},runnerExists:{message:e.ErrorMessages.WORKER_RUNNER_EXISTS,code:e.ErrorCodes.WORKER_RUNNER_EXISTS},recognizerCreationFailure:{message:e.ErrorMessages.WORKER_RECOGNIZER_CREATION_FAILURE,code:e.ErrorCodes.WORKER_RECOGNIZER_CREATION_FAILURE},functionInvokeFailure:{message:e.ErrorMessages.WORKER_FUNCTION_INVOKE_FAILURE,code:e.ErrorCodes.WORKER_FUNCTION_INVOKE_FAILURE},wasmInitMissing:{message:e.ErrorMessages.WORKER_WASM_INIT_MISSING,code:e.ErrorCodes.WORKER_WASM_INIT_MISSING},wasmLoadFailure:{message:e.ErrorMessages.WORKER_WASM_LOAD_FAILURE,code:e.ErrorCodes.WORKER_WASM_LOAD_FAILURE},handleUndefined:{message:e.ErrorMessages.WORKER_HANDLE_UNDEFINED,code:e.ErrorCodes.WORKER_HANDLE_UNDEFINED}};var P;(P=e.PreferredCameraType||(e.PreferredCameraType={}))[P.BackFacingCamera=0]="BackFacingCamera",P[P.FrontFacingCamera=1]="FrontFacingCamera";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","बैक"];function K(e){const t=e.toLowerCase();return W.some((e=>t.includes(e)))}class G{constructor(e,t){this.deviceId=e.deviceId,this.facing=t,this.groupId=e.groupId,this.label=e.label}}function V(){return t(this,void 0,void 0,(function*(){const t=[],r=[];{let s=yield navigator.mediaDevices.enumerateDevices();if(s.filter((e=>"videoinput"===e.kind)).every((e=>""===e.label))){const e=yield navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});s=yield navigator.mediaDevices.enumerateDevices(),e.getTracks().forEach((e=>e.stop()))}const o=s.filter((e=>"videoinput"===e.kind));for(const s of o)K(s.label)?r.push(new G(s,e.PreferredCameraType.BackFacingCamera)):t.push(new G(s,e.PreferredCameraType.FrontFacingCamera))}return{frontCameras:t,backCameras:r}}))}function z(r,s){return t(this,void 0,void 0,(function*(){const{frontCameras:t,backCameras:o}=yield V();if(t.length>0||o.length>0){let i=o.length>0?o:t;s===e.PreferredCameraType.BackFacingCamera&&o.length>0&&(i=o),s===e.PreferredCameraType.FrontFacingCamera&&t.length>0&&(i=t),i=i.sort(((e,t)=>e.label.localeCompare(t.label)));{let e=0;const s=i.map((e=>{const t=/\b([0-9]+)MP?\b/i.exec(e.label);return null!==t?parseInt(t[1],10):NaN}));if(s.some((e=>isNaN(e)))||(e=s.lastIndexOf(Math.max(...s))),r){let e=null;return e=t.filter((e=>e.deviceId===r))[0],e||(e=o.filter((e=>e.deviceId===r))[0]),e||null}return i[e]}}return null}))}function Z(r,s,o=e.PreferredCameraType.BackFacingCamera){return t(this,void 0,void 0,(function*(){const t={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};if(""===r.deviceId){t.video.facingMode={ideal:o===e.PreferredCameraType.BackFacingCamera?"environment":"user"}}else t.video.deviceId={exact:r.deviceId};const i=yield navigator.mediaDevices.getUserMedia(t);s.controls=!1,s.srcObject=i;let n=!1;return r.facing===e.PreferredCameraType.FrontFacingCamera&&(s.style.transform="scaleX(-1)",n=!0),n}))}function j(e){e&&null!==e.srcObject&&(e.srcObject.getTracks().forEach((e=>e.stop())),e.srcObject=null)}var H,x;let B;(H=e.ImageOrientation||(e.ImageOrientation={}))[H.RotatedLeft90=0]="RotatedLeft90",H[H.NoRotation=1]="NoRotation",H[H.RotatedRight90=2]="RotatedRight90",H[H.Rotated180=3]="Rotated180",(x=e.RecognizerResultState||(e.RecognizerResultState={}))[x.Empty=0]="Empty",x[x.Uncertain=1]="Uncertain",x[x.Valid=2]="Valid",x[x.StageValid=3]="StageValid";class Y{constructor(e,t,r){this.imageData=e,this.orientation=t,this.videoFrame=r}}function Q(t){let r,s,o=!1;if(t instanceof HTMLVideoElement)r=t.videoWidth,s=t.videoHeight,o=!0;else if(t instanceof HTMLImageElement)r=t.naturalWidth,s=t.naturalHeight;else{if(t instanceof SVGImageElement)throw new v(L.svgUnsupported);r=t.width,s=t.height}B=B||document.createElement("canvas"),B.width=r,B.height=s;const i=B.getContext("2d");if(!i)throw new v(L.canvasMissing);i.drawImage(t,0,0,B.width,B.height);const n=i.getImageData(0,0,B.width,B.height);return new Y(n,e.ImageOrientation.NoRotation,o)}var X,q;(X=e.LicenseTokenState||(e.LicenseTokenState={}))[X.Invalid=0]="Invalid",X[X.RequiresServerPermission=1]="RequiresServerPermission",X[X.Valid=2]="Valid",(q=e.LicenseErrorType||(e.LicenseErrorType={})).LicenseTokenStateInvalid="LICENSE_TOKEN_STATE_INVALID",q.NetworkError="NETWORK_ERROR",q.RemoteLock="REMOTE_LOCK",q.PermissionExpired="PERMISSION_EXPIRED",q.PayloadCorrupted="PAYLOAD_CORRUPTED",q.PayloadSignatureVerificationFailed="PAYLOAD_SIGNATURE_VERIFICATION_FAILED",q.IncorrectTokenState="INCORRECT_TOKEN_STATE";function J(e){return{licenseId:e.licenseId,licensee:e.licensee,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}var $,ee,te,re;function se(r,s){return t(this,void 0,void 0,(function*(){try{const t=yield fetch("https://baltazar.microblink.com/api/v1/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(J(r))});if(t.ok){const e=""+(yield t.text());return s.submitServerPermission(e)}return{status:e.ServerPermissionSubmitResultStatus.NetworkError,lease:0,networkErrorDescription:"Server responded with status "+t.status}}catch(t){return{status:e.ServerPermissionSubmitResultStatus.NetworkError,lease:0,networkErrorDescription:"Unexpected error: "+JSON.stringify(t)}}}))}($=e.ServerPermissionSubmitResultStatus||(e.ServerPermissionSubmitResultStatus={}))[$.Ok=0]="Ok",$[$.NetworkError=1]="NetworkError",$[$.RemoteLock=2]="RemoteLock",$[$.PermissionExpired=3]="PermissionExpired",$[$.PayloadCorrupted=4]="PayloadCorrupted",$[$.PayloadSignatureVerificationFailed=5]="PayloadSignatureVerificationFailed",$[$.IncorrectTokenState=6]="IncorrectTokenState",(ee=e.DetectionStatus||(e.DetectionStatus={}))[ee.Fail=0]="Fail",ee[ee.Success=1]="Success",ee[ee.CameraTooHigh=2]="CameraTooHigh",ee[ee.FallbackSuccess=3]="FallbackSuccess",ee[ee.Partial=4]="Partial",ee[ee.CameraAtAngle=5]="CameraAtAngle",ee[ee.CameraTooNear=6]="CameraTooNear",ee[ee.DocumentTooCloseToEdge=7]="DocumentTooCloseToEdge",(te=e.NotSupportedReason||(e.NotSupportedReason={})).MediaDevicesNotSupported="MediaDevicesNotSupported",te.CameraNotFound="CameraNotFound",te.CameraNotAllowed="CameraNotAllowed",te.CameraInUse="CameraInUse",te.CameraNotAvailable="CameraNotAvailable",te.VideoElementNotProvided="VideoElementNotProvided",(re=e.VideoRecognitionMode||(e.VideoRecognitionMode={}))[re.Recognition=0]="Recognition",re[re.RecognitionTest=1]="RecognitionTest",re[re.DetectionTest=2]="DetectionTest";class oe{constructor(t,r,s=!1,o=!1,i=null){this.deviceId=null,this.videoFeed=null,this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.recognitionTimeoutMs=2e4,this.timeoutID=0,this.videoRecognitionMode=e.VideoRecognitionMode.Recognition,this.onScanningDone=null,this.allowManualVideoPlayout=!1,this.cameraFlipped=!1,this.shouldReleaseVideoFeed=!1,this.videoFeed=t,this.recognizerRunner=r,this.cameraFlipped=s,this.allowManualVideoPlayout=o,this.deviceId=i}static createVideoRecognizerFromCameraStream(r,s,o=null,i=e.PreferredCameraType.BackFacingCamera){return t(this,void 0,void 0,(function*(){return new Promise(((n,a)=>t(this,void 0,void 0,(function*(){if(r&&r instanceof Element)if(navigator.mediaDevices&&void 0!==navigator.mediaDevices.getUserMedia)try{const t=yield z(o,i);if(null===t)return void a(new v(F.cameraMissing,{reason:e.NotSupportedReason.CameraNotFound}));const c=yield Z(t,r,i);yield s.setCameraPreviewMirrored(c),n(new oe(r,s,c,!1,t.deviceId))}catch(t){let r=e.NotSupportedReason.CameraInUse,s=e.ErrorCodes.VIDEO_RECOGNIZER_CAMERA_IN_USE;switch(t.name){case"NotFoundError":case"OverconstrainedError":r=e.NotSupportedReason.CameraNotFound,s=e.ErrorCodes.VIDEO_RECOGNIZER_CAMERA_MISSING;break;case"NotAllowedError":case"SecurityError":r=e.NotSupportedReason.CameraNotAllowed,s=e.ErrorCodes.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED;break;case"AbortError":case"NotReadableError":r=e.NotSupportedReason.CameraNotAvailable,s=e.ErrorCodes.VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE;break;case"TypeError":throw t}a(new v({message:t.message,code:s},{reason:r}))}else a(new v(F.mediaDevicesUnsupported,{reason:e.NotSupportedReason.MediaDevicesNotSupported}));else a(new v(F.elementMissing,{reason:e.NotSupportedReason.VideoElementNotProvided}))}))))}))}static createVideoRecognizerFromVideoPath(e,r,s){return t(this,void 0,void 0,(function*(){return new Promise((t=>{r.src=e,r.currentTime=0,r.onended=()=>{o.cancelRecognition()};const o=new oe(r,s);t(o)}))}))}flipCamera(){return t(this,void 0,void 0,(function*(){this.videoFeed&&(this.cameraFlipped?(this.videoFeed.style.transform="scaleX(1)",this.cameraFlipped=!1):(this.videoFeed.style.transform="scaleX(-1)",this.cameraFlipped=!0),yield this.recognizerRunner.setCameraPreviewMirrored(this.cameraFlipped))}))}isCameraFlipped(){return this.cameraFlipped}setVideoRecognitionMode(r){return t(this,void 0,void 0,(function*(){this.videoRecognitionMode=r;const t=this.videoRecognitionMode===e.VideoRecognitionMode.DetectionTest;yield this.recognizerRunner.setDetectionOnlyMode(t)}))}startRecognition(e,t=2e4){return new Promise(((r,s)=>{null!==this.videoFeed?this.videoFeed.paused?(this.cancelled=!1,this.recognitionPaused=!1,this.clearTimeout(),this.recognitionTimeoutMs=t,this.onScanningDone=e,this.recognizerRunner.setClearTimeoutCallback({onClearTimeout:()=>this.clearTimeout()}),this.videoFeed.play().then((()=>this.playPauseEvent().then((()=>r())).catch((e=>s(e)))),(e=>{this.allowManualVideoPlayout?this.videoFeed&&(this.videoFeed.controls=!0,this.videoFeed.addEventListener("play",(()=>{this.playPauseEvent().then().catch((e=>s(e)))})),this.videoFeed.addEventListener("pause",(()=>{this.playPauseEvent().then().catch((e=>s(e)))}))):s(new v(F.playRequestInterrupted,e))}))):s(new v(F.videoFeedNotPaused)):s(new v(F.videoFeedReleased))}))}recognize(e=2e4){return new Promise(((t,r)=>{try{this.startRecognition((e=>{this.pauseVideoFeed(),t(e)}),e).then().catch((e=>r(e)))}catch(e){r(e)}}))}cancelRecognition(){this.cancelled=!0}pauseVideoFeed(){this.pauseRecognition(),this.videoFeed&&this.videoFeed.pause()}pauseRecognition(){this.recognitionPaused=!0}resetRecognizers(e){return t(this,void 0,void 0,(function*(){yield this.recognizerRunner.resetRecognizers(e)}))}getRecognizerRunner(){return this.recognizerRunner}resumeRecognition(e){return new Promise(((t,r)=>{this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.videoFeed&&this.videoFeed.paused?r(new v(F.feedPaused)):setTimeout((()=>{e?this.resetRecognizers(!0).then((()=>{this.recognitionLoop().then((()=>t())).catch((e=>r(e)))})).catch((()=>{r(new v(F.recognizersResetFailure))})):this.recognitionLoop().then((()=>t())).catch((e=>r(e)))}),1)}))}releaseVideoFeed(){var e,t;this.videoFeed&&(null===(e=this.videoFeed)||void 0===e?void 0:e.readyState)>=(null===(t=this.videoFeed)||void 0===t?void 0:t.HAVE_CURRENT_DATA)?(this.videoFeed.paused||this.cancelRecognition(),j(this.videoFeed),this.videoFeed=null,this.shouldReleaseVideoFeed=!1):this.shouldReleaseVideoFeed=!0}changeCameraDevice(e){return new Promise(((t,r)=>{null!==this.videoFeed?(this.pauseRecognition(),j(this.videoFeed),Z(e,this.videoFeed).then((()=>{null!==this.videoFeed?this.videoFeed.play().then((()=>{this.resumeRecognition(!0),t()}),(e=>{this.allowManualVideoPlayout?this.videoFeed?this.videoFeed.controls=!0:r(new v(F.feedMissing)):r(new v(F.playRequestInterrupted,e))})):r(new v(F.feedMissing))})).catch((e=>r(e)))):r(new v(F.feedMissing))}))}playPauseEvent(){return new Promise(((e,t)=>{if(this.videoFeed&&this.videoFeed.paused)return this.cancelRecognition(),void e();this.resumeRecognition(!0).then((()=>e())).catch((e=>t(e)))}))}recognitionLoop(){return new Promise(((t,r)=>{if(!this.videoFeed)return void r(new v(F.feedMissing));if(this.shouldReleaseVideoFeed&&this.videoFeed.readyState>this.videoFeed.HAVE_CURRENT_DATA)return this.releaseVideoFeed(),void t();const s=Q(this.videoFeed);this.recognizerRunner.processImage(s).then((s=>{const o=()=>{this.recognitionPaused?t():setTimeout((()=>{this.recognitionLoop().then((()=>t())).catch((e=>r(e)))}),1)};if(s===e.RecognizerResultState.Valid||this.cancelled||this.timedOut){if(this.videoRecognitionMode!==e.VideoRecognitionMode.Recognition&&!this.cancelled)return void this.recognizerRunner.resetRecognizers(!0).then((()=>{this.clearTimeout(),o()})).catch((e=>r(e)));this.clearTimeout(),this.onScanningDone&&this.onScanningDone(s)}else{if(s===e.RecognizerResultState.Uncertain)return 0===this.timeoutID&&(this.timeoutID=window.setTimeout((()=>{this.timedOut=!0}),this.recognitionTimeoutMs)),void o();if(s===e.RecognizerResultState.StageValid)return this.clearTimeout(),void o()}o()})).catch((e=>r(e)))}))}clearTimeout(){this.timeoutID>0&&(window.clearTimeout(this.timeoutID),this.timeoutID=0)}}function ie(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))}var ne;(ne=e.BarcodeFormat||(e.BarcodeFormat={}))[ne.NONE=0]="NONE",ne[ne.QR_CODE=1]="QR_CODE",ne[ne.DATA_MATRIX=2]="DATA_MATRIX",ne[ne.UPC_E=3]="UPC_E",ne[ne.UPC_A=4]="UPC_A",ne[ne.EAN_8=5]="EAN_8",ne[ne.EAN_13=6]="EAN_13",ne[ne.CODE_128=7]="CODE_128",ne[ne.CODE_39=8]="CODE_39",ne[ne.ITF=9]="ITF",ne[ne.AZTEC_BARCODE=10]="AZTEC_BARCODE",ne[ne.PDF417_BARCODE=11]="PDF417_BARCODE";e.BarcodeRecognizerSettings=class{constructor(){this.shouldScanInverse=!1,this.slowerThoroughScan=!0,this.nullQuietZoneAllowed=!1,this.uncertainDecodingAllowed=!0,this.useAutoScale=!0,this.readCode39AsExtendedData=!1,this.scanCode128=!1,this.scanCode39=!1,this.scanEAN13=!1,this.scanEAN8=!1,this.scanITF=!1,this.scanPDF417=!1,this.scanQRCode=!1,this.scanUPCA=!1,this.scanUPCE=!1}},e.CapturedFrame=Y,e.SDKError=v,e.SelectedCamera=G,e.SimNumberRecognizerSettings=class{},e.VideoRecognizer=oe,e.VinRecognizerSettings=class{},e.WasmSDKLoadSettings=class{constructor(e){if(this.allowHelloMessage=!0,this.engineLocation="",this.wasmType=null,this.numberOfWorkers=null,this.loadProgressCallback=null,this.wasmModuleName="BlinkInputWasmSDK",!e)throw new v(w.licenseKeyMissing);this.licenseKey=e}},e.bindCameraToVideoFeed=Z,e.captureFrame=Q,e.clearVideoFeed=j,e.createBarcodeRecognizer=function(e){return t(this,void 0,void 0,(function*(){return e.mbWasmModule.newRecognizer("BarcodeRecognizer")}))},e.createRecognizerRunner=function(e,r,s=!1,o={}){return t(this,void 0,void 0,(function*(){if("object"!=typeof e)throw new v(w.missing);if("object"!=typeof r||1>r.length)throw new v(w.recognizersMissing);return e.mbWasmModule.createRecognizerRunner(r,s,o)}))},e.createSimNumberRecognizer=function(e){return t(this,void 0,void 0,(function*(){return e.mbWasmModule.newRecognizer("SimNumberRecognizer")}))},e.createSuccessFrameGrabberRecognizer=function(e,r){return t(this,void 0,void 0,(function*(){const t=yield e.mbWasmModule.newRecognizer("SuccessFrameGrabberRecognizer",r);return t.wrappedRecognizer=r,t}))},e.createVinRecognizer=function(e){return t(this,void 0,void 0,(function*(){return e.mbWasmModule.newRecognizer("VinRecognizer")}))},e.detectWasmType=function(r){return t(this,void 0,void 0,(function*(){const t=yield(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])))(),s=yield(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])))(),o=yield(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])))(),i=yield(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])))(),n=yield(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]));if(!(t&&s&&o&&i))return e.WasmType.Basic;if(!n)return e.WasmType.Advanced;try{return new Worker(r+"/Worker.test.js").terminate(),e.WasmType.AdvancedWithThreads}catch(t){return e.WasmType.Advanced}}))},e.frameCaptureErrors=L,e.getCameraDevices=V,e.isBrowserSupported=function(){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},e.isInAppBrowser=function(){const e=navigator.userAgent||navigator.vendor;return!!/(instagram|fbav|linkedinapp|twitter|micromessenger|whatsapp|tiktok)[/\s]?([\w.]*)/i.exec(e)},e.licenseErrors=k,e.loadWasmModule=function(e){return t(this,void 0,void 0,(function*(){return new Promise(((t,r)=>{if(!e||"object"!=typeof e)return void r(new v(w.wasmSettingsMissing));if("string"!=typeof e.licenseKey)return void r(new v(w.licenseKeyMissing));if(!e.wasmModuleName)return void r(new v(w.wasmModuleNameMissing));if("string"!=typeof e.engineLocation)return void r(new v(w.engineLocationInvalid));const s=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=ie(),localStorage.setItem("mb-user-id",e)),e}catch(e){return ie()}}();try{const o=new Blob([String.raw`!function(){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function e(e,t,s,n){return new(s||(s=Promise))((function(r,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))}let t=0;class s{constructor(e){this.action=e,this.messageID=function(){const e=t;return t+=1,e}()}}class n extends s{constructor(e,t){super(n.action),this.wasmModuleName=e.wasmModuleName,this.licenseKey=e.licenseKey,this.userId=t,this.registerLoadCallback=null!==e.loadProgressCallback,this.allowHelloMessage=e.allowHelloMessage,this.engineLocation=e.engineLocation,this.wasmType=e.wasmType,this.numberOfWorkers=e.numberOfWorkers}}var r,i;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"}(r||(r={}));class o extends s{constructor(e,t){super(o.action),this.funcName=e,this.params=t}}o.action="invokeFunction";class a extends s{constructor(e,t){super(a.action),this.className=e,this.params=t}}a.action="createNewNativeObject";class c extends s{constructor(e,t,s){super(c.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=s}}c.action="createRecognizerRunner";class E extends s{constructor(e,t){super(E.action),this.recognizerHandles=e,this.allowMultipleResults=t}}E.action="reconfigureRecognizerRunner";class R extends s{constructor(){super(R.action)}}R.action="deleteRecognizerRunner";class l extends s{constructor(e,t,s){super(l.action),this.objectHandle=e,this.methodName=t,this.params=s}}l.action="invokeObject";class _ extends s{constructor(e){super(_.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}_.action="processImage";class u extends s{constructor(e){super(u.action),this.hardReset=e}}u.action="resetRecognizers";class I extends s{constructor(e){super(I.action),this.registeredMetadataCallbacks=e}}I.action="registerMetadataCallbacks";class d extends s{constructor(e){super(d.action),this.detectionOnlyMode=e}}d.action="setDetectionOnly";class N extends s{constructor(e){super(N.action),this.callbackNonEmpty=e}}N.action="setClearTimeoutCallback";class O extends s{constructor(e){super(O.action),this.cameraPreviewMirrored=e}}O.action="setCameraPreviewMirrored";class h{constructor(e,t,s){this.success=!0,this.error=null,this.messageID=e,this.success=t,this.error=s}}class S{constructor(e,t,s,n){this.success=!0,this.showOverlay=!0,this.messageID=e,this.success=t,this.showOverlay=s,this.wasmType=n}}class g extends h{constructor(e,t){super(e,!0,null),this.result=t}}class C extends h{constructor(e,t){super(e,!0,null),this.objectHandle=t}}class m extends h{constructor(e,t){super(e,!0,null),this.recognitionState=t}}class A{constructor(e){this.isLoadProgressMessage=!0,this.progress=e}}!function(e){e[e.onDebugText=0]="onDebugText",e[e.onDetectionFailed=1]="onDetectionFailed",e[e.onQuadDetection=2]="onQuadDetection",e[e.onPointsDetection=3]="onPointsDetection",e[e.onFirstSideResult=4]="onFirstSideResult",e[e.clearTimeoutCallback=5]="clearTimeoutCallback",e[e.onGlare=6]="onGlare",e[e.recognizerCallback=7]="recognizerCallback"}(i||(i={}));class D{constructor(e,t){this.isCallbackMessage=!0,this.callbackType=e,this.callbackParameters=t}}function f(e,t){return t=t||"",""===(e=e||"")?t:e.endsWith("/")?t.startsWith("/")?e+t.substring(1):e+t:t.startsWith("/")?e+t:e+"/"+t}var M,L,y;function w(t){return e(this,void 0,void 0,(function*(){const e=yield(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])))(),s=yield(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])))(),n=yield(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])))(),r=yield(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])))(),i=yield(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]));if(!(e&&s&&n&&r))return M.Basic;if(!i)return M.Advanced;try{return new Worker(t+"/Worker.test.js").terminate(),M.AdvancedWithThreads}catch(e){return M.Advanced}}))}!function(e){e.Basic="BASIC",e.Advanced="ADVANCED",e.AdvancedWithThreads="ADVANCED_WITH_THREADS"}(M||(M={}));class T{constructor(e,t){if(!e.code||!e.message)throw Error("Instance of SDKError is required to have code and message.");this.message=e.message,this.code=e.code,this.details=t}}!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.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_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"}(L||(L={})),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.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_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!"}(y||(y={}));const p={licenseTokenStateIncorrect:{code:L.LICENSE_UNLOCK_ERROR,message:y.LICENSE_TOKEN_STATE_INCORRECT},licensePayloadVerificationFailed:{code:L.LICENSE_UNLOCK_ERROR,message:y.LICENSE_PAYLOAD_VERIFICATION_FAILED},licensePayloadCorrupted:{code:L.LICENSE_UNLOCK_ERROR,message:y.LICENSE_PAYLOAD_CORRUPTED},licensePermissionExpired:{code:L.LICENSE_UNLOCK_ERROR,m