UNPKG

@microblink/blinkid-in-browser-sdk

Version:

A simple ID scanning library for WebAssembly-enabled browsers.

38 lines (33 loc) 208 kB
import{r as e,c as t,h as i,H as r,g as o}from"./p-2ec4d5b3.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. ***************************************************************************** */ /*! ***************************************************************************** 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 s(e,t,i,r){return new(i||(i=Promise))((function(o,s){function a(e){try{M(r.next(e))}catch(e){s(e)}}function n(e){try{M(r.throw(e))}catch(e){s(e)}}function M(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,n)}M((r=r.apply(e,t||[])).next())}))}let a=0;class n{constructor(e){this.action=e,this.messageID=function(){const e=a;return a+=1,e}()}}class M extends n{constructor(e,t){super(M.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}}var c,l,N,g,D;M.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 I extends n{constructor(e,t){super(I.action),this.className=e,this.params=t}}I.action="createNewNativeObject";class u extends n{constructor(e,t,i){super(u.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=i}}u.action="createRecognizerRunner";class d extends n{constructor(e,t){super(d.action),this.recognizerHandles=e,this.allowMultipleResults=t}}d.action="reconfigureRecognizerRunner";class h extends n{constructor(){super(h.action)}}h.action="deleteRecognizerRunner";class j extends n{constructor(e,t,i){super(j.action),this.objectHandle=e,this.methodName=t,this.params=i}}j.action="invokeObject";class A extends n{constructor(e){super(A.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}A.action="processImage";class z extends n{constructor(e){super(z.action),this.hardReset=e}}z.action="resetRecognizers";class T{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1,this.onGlare=!1}}class y extends n{constructor(e){super(y.action),this.registeredMetadataCallbacks=e}}y.action="registerMetadataCallbacks";class m extends n{constructor(e){super(m.action),this.detectionOnlyMode=e}}m.action="setDetectionOnly";class O extends n{constructor(e){super(O.action),this.callbackNonEmpty=e}}O.action="setClearTimeoutCallback";class b extends n{constructor(e){super(b.action),this.cameraPreviewMirrored=e}}function x(e,t){return i=>{const r=i;r.success?e():t(r.error)}}function C(e,t){return i=>{const r=i;r.success?e(i):t(r.error)}}b.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"}(l||(l={}));class p{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 j(this.objectHandle,"currentSettings",[]),r=C((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,r)}))}clearAllCallbacks(){this.callbacks.clear(),this.wasmSDKWorker.unregisterRecognizerCallbacks(this.objectHandle)}removeFunctions(e){this.clearAllCallbacks();const t=Object.keys(e);let i=!1;for(const r of t){const t=e[r];"function"==typeof t&&(this.callbacks.set(r,t),e[r]={parameter:{recognizerHandle:this.objectHandle,callbackName:r},type: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 r=new j(this.objectHandle,"updateSettings",[{parameter:this.removeFunctions(e),type:c.RecognizerSettings}]),o=x(t,i);this.wasmSDKWorker.postMessage(r,o)}))}invokeCallback(e,t){const i=this.callbacks.get(e);void 0!==i?i(...t):console.warn("Cannot find callback",e)}getResult(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());const i=new j(this.objectHandle,"getResult",[]),r=C((t=>{e(t.result)}),t);this.wasmSDKWorker.postMessage(i,r)}))}delete(){return new Promise(((e,t)=>{if(this.objectHandle<0)return void t("Invalid object handle: "+this.objectHandle.toString());this.clearAllCallbacks();const i=new j(this.objectHandle,"delete",[]),r=x((()=>{this.objectHandle=-1,e()}),t);this.wasmSDKWorker.postMessage(i,r)}))}}function L(e){const t=new T;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 E{constructor(e){this.deleted=!1,this.wasmSDKWorker=e}processImage(e){return new Promise(((t,i)=>{if(this.deleted)return void i("Recognizer runner is deleted. It cannot be used anymore!");const r=new A(e),o=C((e=>{t(e.recognitionState)}),i);this.wasmSDKWorker.postTransferrableMessage(r,o)}))}reconfigureRecognizers(e,t){return new Promise(((i,r)=>{if(this.deleted)return void r("Recognizer runner is deleted. It cannot be used anymore!");const o=w(e),s=new d(o,t),a=x(i,r);this.wasmSDKWorker.postMessage(s,a)}))}setMetadataCallbacks(e){return new Promise(((t,i)=>{const r=new y(L(e)),o=x(t,i);this.wasmSDKWorker.postMessageAndRegisterCallbacks(r,e,o)}))}resetRecognizers(e){return new Promise(((t,i)=>{const r=new z(e),o=x(t,i);this.wasmSDKWorker.postMessage(r,o)}))}setDetectionOnlyMode(e){return new Promise(((t,i)=>{const r=new m(e),o=x(t,i);this.wasmSDKWorker.postMessage(r,o)}))}setClearTimeoutCallback(e){return new Promise(((t,i)=>{const r=new O(null!==e),o=x(t,i);this.wasmSDKWorker.registerClearTimeoutCallback(e),this.wasmSDKWorker.postMessage(r,o)}))}setCameraPreviewMirrored(e){return new Promise(((t,i)=>{const r=new b(e),o=x(t,i);this.wasmSDKWorker.postMessage(r,o)}))}delete(){return this.deleted?Promise.reject("Recognizer runner is already deleted."):new Promise(((e,t)=>{const i=new h,r=x((()=>{this.deleted=!0,e()}),t);this.wasmSDKWorker.postMessage(i,r)}))}}function w(e){const t=[];for(const i of e)t.push(i.getRemoteObjectHandle());return t}class S{constructor(e){this.wasmSDKWorker=e}createRecognizerRunner(e,t=!1,i={}){return new Promise(((r,o)=>{const s=w(e),a=new u(s,t,L(i)),n=x((()=>{r(new E(this.wasmSDKWorker))}),o);this.wasmSDKWorker.postMessageAndRegisterCallbacks(a,i,n)}))}newRecognizer(e,...t){return new Promise(((i,r)=>{const o=new I(e,function(e){const t=[];for(let i of e){let e=c.Any;i instanceof p&&(e=c.Recognizer,i=i.getRemoteObjectHandle()),t.push({parameter:i,type:e})}return t}(t)),s=C((t=>{const r=new p(this.wasmSDKWorker,e,t.objectHandle);i(r)}),r);this.wasmSDKWorker.postMessage(o,s)}))}}class k{constructor(e,t,i){this.eventHandlers={},this.metadataCallbacks={},this.clearTimeoutCallback=null,this.mbWasmWorker=e,this.mbWasmWorker.onmessage=e=>{this.handleWorkerEvent(e)},this.mbWasmWorker.onerror=()=>{i("Problem during initialization of worker file!")},this.mbWasmModule=new S(this),this.loadCallback=t,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,i){this.eventHandlers[e.messageID]=i,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)}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.clearTimeoutCallback:this.clearTimeoutCallback&&"function"==typeof this.clearTimeoutCallback.onClearTimeout&&this.clearTimeoutCallback.onClearTimeout();break;case l.onGlare:"function"==typeof this.metadataCallbacks.onGlare&&this.metadataCallbacks.onGlare(t.callbackParameters[0]);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){const t=e.data;"function"==typeof this.loadCallback&&this.loadCallback(t.progress)}else{const t=e.data,i=this.eventHandlers[t.messageID];delete this.eventHandlers[t.messageID],i(t)}}static createWasmWorker(e,t,i){return s(this,void 0,void 0,(function*(){return new Promise(((r,o)=>{const s=new k(e,t.loadProgressCallback,o),a=new M(t,i),n=C((e=>{s.showOverlay=e.showOverlay,r(s)}),o);s.postMessage(a,n)}))}))}}let f;!function(e){e[e.RotatedLeft90=0]="RotatedLeft90",e[e.NoRotation=1]="NoRotation",e[e.RotatedRight90=2]="RotatedRight90",e[e.Rotated180=3]="Rotated180"}(N||(N={})),function(e){e[e.Empty=0]="Empty",e[e.Uncertain=1]="Uncertain",e[e.Valid=2]="Valid",e[e.StageValid=3]="StageValid"}(g||(g={})),function(e){e[e.Fail=0]="Fail",e[e.Success=1]="Success",e[e.CameraTooHigh=2]="CameraTooHigh",e[e.FallbackSuccess=3]="FallbackSuccess",e[e.Partial=4]="Partial",e[e.CameraAtAngle=5]="CameraAtAngle",e[e.CameraTooNear=6]="CameraTooNear",e[e.DocumentTooCloseToEdge=7]="DocumentTooCloseToEdge"}(D||(D={}));class U{constructor(e,t,i){this.imageData=e,this.orientation=t,this.videoFrame=i}}function R(e){let t,i,r=!1;if(e instanceof HTMLVideoElement)t=e.videoWidth,i=e.videoHeight,r=!0;else if(e instanceof HTMLImageElement)t=e.naturalWidth,i=e.naturalHeight;else{if(e instanceof SVGImageElement)throw new Error("Recognition of SVG elements not supported!");t=e.width,i=e.height}f=f||document.createElement("canvas"),f.width=t,f.height=i;const o=f.getContext("2d");if(!o)throw new Error("Could not get canvas 2d context!");o.drawImage(e,0,0,f.width,f.height);const s=o.getImageData(0,0,f.width,f.height);return new U(s,N.NoRotation,r)}var Q,v,Y;!function(e){e[e.BackFacingCamera=0]="BackFacingCamera",e[e.FrontFacingCamera=1]="FrontFacingCamera"}(Q||(Q={})),function(e){e.MediaDevicesNotSupported="MediaDevicesNotSupported",e.CameraNotFound="CameraNotFound",e.CameraNotAllowed="CameraNotAllowed",e.CameraInUse="CameraInUse",e.CameraNotAvailable="CameraNotAvailable",e.VideoElementNotProvided="VideoElementNotProvided"}(v||(v={}));class _ extends Error{constructor(e,...t){super(...t),this.reason=e,this.name="VideoRecognizerError"}}!function(e){e[e.Recognition=0]="Recognition",e[e.RecognitionTest=1]="RecognitionTest",e[e.DetectionTest=2]="DetectionTest"}(Y||(Y={}));class Z{constructor(e,t,i=!1,r=!1){this.videoFeed=null,this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.recognitionTimeoutMs=15e3,this.timeoutID=0,this.videoRecognitionMode=Y.Recognition,this.onScanningDone=null,this.allowManualVideoPlayout=!1,this.cameraFlipped=!1,this.videoFeed=e,this.recognizerRunner=t,this.cameraFlipped=i,r&&(this.allowManualVideoPlayout=r)}static createVideoRecognizerFromCameraStream(e,t,i=null,r=Q.BackFacingCamera){return s(this,void 0,void 0,(function*(){return new Promise(((o,a)=>s(this,void 0,void 0,(function*(){if(e&&e instanceof Element)if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)try{const n=yield function(e,t){return s(this,void 0,void 0,(function*(){const i=[],r=[];{let e=yield navigator.mediaDevices.enumerateDevices();if(e.filter((e=>"videoinput"===e.kind)).every((e=>""===e.label))){const t=yield navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});e=yield navigator.mediaDevices.enumerateDevices(),t.getTracks().forEach((e=>e.stop()))}const t=e.filter((e=>"videoinput"===e.kind));for(const e of t)W(e.label)?r.push(new P(e,Q.BackFacingCamera)):i.push(new P(e,Q.FrontFacingCamera))}if(i.length>0||r.length>0){let o=r.length>0?r:i;t===Q.BackFacingCamera&&r.length>0&&(o=r),t===Q.FrontFacingCamera&&i.length>0&&(o=i),o=o.sort(((e,t)=>e.label.localeCompare(t.label)));{let t=0;const s=o.map((e=>{const t=RegExp(/\b([0-9]+)MP?\b/,"i").exec(e.label);return null!==t?parseInt(t[1],10):NaN}));if(s.some((e=>isNaN(e)))||(t=s.lastIndexOf(Math.max(...s))),e){let t=null;return t=i.filter((t=>t.deviceId===e))[0],t||(t=r.filter((t=>t.deviceId===e))[0]),t||null}return o[t]}}return null}))}(i,r);if(null===n)return void a(new _(v.CameraNotFound));const M={audio:!1,video:{width:{min:640,ideal:1920,max:1920},height:{min:480,ideal:1080,max:1080}}};""===n.deviceId?M.video.facingMode={ideal:r===Q.BackFacingCamera?"environment":"user"}:M.video.deviceId={exact:n.deviceId};const c=yield navigator.mediaDevices.getUserMedia(M);e.controls=!1,e.srcObject=c;let l=!1;n.facing===Q.FrontFacingCamera&&(e.style.transform="scaleX(-1)",l=!0),yield t.setCameraPreviewMirrored(l),o(new Z(e,t,l))}catch(e){let t=v.CameraInUse;switch(e.name){case"NotFoundError":case"OverconstrainedError":t=v.CameraNotFound;break;case"NotAllowedError":case"SecurityError":t=v.CameraNotAllowed;break;case"AbortError":case"NotReadableError":t=v.CameraNotAvailable;break;case"TypeError":throw e}a(new _(t,e.message))}else a(new _(v.MediaDevicesNotSupported));else a(new _(v.VideoElementNotProvided,"Video element, i.e. camera feed is not provided!"))}))))}))}static createVideoRecognizerFromVideoPath(e,t,i){return s(this,void 0,void 0,(function*(){return new Promise((r=>{t.src=e,t.currentTime=0,t.onended=()=>{o.cancelRecognition()};const o=new Z(t,i);r(o)}))}))}flipCamera(){return s(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))}))}setVideoRecognitionMode(e){return s(this,void 0,void 0,(function*(){this.videoRecognitionMode=e;const t=this.videoRecognitionMode===Y.DetectionTest;yield this.recognizerRunner.setDetectionOnlyMode(t)}))}startRecognition(e,t=15e3){if(null===this.videoFeed)throw new Error("The associated video feed has been released!");if(!this.videoFeed.paused)throw new Error("The associated video feed is not paused. Use resumeRecognition instead!");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()),(e=>{if(!this.allowManualVideoPlayout)throw console.warn("Native error",e),new Error("The play() request was interrupted or prevented by browser security rules!");this.videoFeed&&(this.videoFeed.controls=!0,this.videoFeed.addEventListener("play",(()=>this.playPauseEvent())),this.videoFeed.addEventListener("pause",(()=>this.playPauseEvent())))}))}recognize(e=15e3){return s(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{try{this.startRecognition((e=>{this.pauseVideoFeed(),t(e)}),e)}catch(e){i(e)}}))}))}cancelRecognition(){this.cancelled=!0}pauseVideoFeed(){this.pauseRecognition(),this.videoFeed&&this.videoFeed.pause()}pauseRecognition(){this.recognitionPaused=!0}resetRecognizers(e){return s(this,void 0,void 0,(function*(){yield this.recognizerRunner.resetRecognizers(e)}))}getRecognizerRunner(){return this.recognizerRunner}resumeRecognition(e){if(this.cancelled=!1,this.timedOut=!1,this.recognitionPaused=!1,this.videoFeed&&this.videoFeed.paused)throw new Error("Cannot resume recognition while video feed is paused! Use recognize or startRecognition");setTimeout((()=>{e?this.resetRecognizers(!0).then((()=>{this.recognitionLoop()})).catch((()=>{throw new Error("Could not reset recognizers!")})):this.recognitionLoop()}),1)}releaseVideoFeed(){null!==this.videoFeed&&(null!==this.videoFeed.srcObject&&(this.videoFeed.paused||this.cancelRecognition(),this.videoFeed.srcObject.getTracks().forEach((e=>e.stop())),this.videoFeed.srcObject=null),this.videoFeed=null)}playPauseEvent(){this.videoFeed&&this.videoFeed.paused?this.cancelRecognition():this.resumeRecognition(!0)}recognitionLoop(){return s(this,void 0,void 0,(function*(){if(!this.videoFeed)throw new Error("Missing video feed!");const e=R(this.videoFeed),t=yield this.recognizerRunner.processImage(e);t===g.Valid||this.cancelled||this.timedOut?this.videoRecognitionMode===Y.Recognition||this.cancelled?(this.clearTimeout(),this.onScanningDone&&this.onScanningDone(t)):(yield this.recognizerRunner.resetRecognizers(!0),this.clearTimeout()):t===g.Uncertain?0===this.timeoutID&&(this.timeoutID=window.setTimeout((()=>{this.timedOut=!0}),this.recognitionTimeoutMs)):t===g.StageValid&&this.clearTimeout(),this.recognitionPaused||setTimeout((()=>{this.recognitionLoop()}),1)}))}clearTimeout(){this.timeoutID>0&&(window.clearTimeout(this.timeoutID),this.timeoutID=0)}}const G=["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 W(e){const t=e.toLowerCase();return G.some((e=>t.includes(e)))}class P{constructor(e,t){this.deviceId=e.deviceId,this.facing=t,this.groupId=e.groupId,this.label=e.label}}class F{constructor(e){if(this.allowHelloMessage=!0,this.engineLocation="",this.loadProgressCallback=null,this.wasmModuleName="BlinkIDWasmSDK",!e)throw new Error("Missing license key!");this.licenseKey=e}}function B(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))}function V(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){return!1}return!1}function H(e){return s(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{if(!e||"object"!=typeof e)return void i("Missing WASM load settings!");if("string"!=typeof e.licenseKey)return void i("Missing license key!");if(!e.wasmModuleName)return void i("Missing WASM module name!");if("string"!=typeof e.engineLocation)return void i("Setting property 'engineLocation' must be a string!");const r=function(){try{let e=localStorage.getItem("mb-user-id");return null===e&&(e=B(),localStorage.setItem("mb-user-id",e)),e}catch(e){return B()}}();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,r){return new(s||(s=Promise))((function(n,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((r=r.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 r extends s{constructor(e,t){super(r.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}}var n,i,o,a;r.action="init",function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback"}(n||(n={}));class c extends s{constructor(e,t){super(c.action),this.funcName=e,this.params=t}}c.action="invokeFunction";class l extends s{constructor(e,t){super(l.action),this.className=e,this.params=t}}l.action="createNewNativeObject";class u extends s{constructor(e,t,s){super(u.action),this.recognizerHandles=e,this.allowMultipleResults=t,this.registeredMetadataCallbacks=s}}u.action="createRecognizerRunner";class h extends s{constructor(e,t){super(h.action),this.recognizerHandles=e,this.allowMultipleResults=t}}h.action="reconfigureRecognizerRunner";class d extends s{constructor(){super(d.action)}}d.action="deleteRecognizerRunner";class g extends s{constructor(e,t,s){super(g.action),this.objectHandle=e,this.methodName=t,this.params=s}}g.action="invokeObject";class m extends s{constructor(e){super(m.action),this.frame=e}getTransferrables(){return[this.frame.imageData.data.buffer]}}m.action="processImage";class f extends s{constructor(e){super(f.action),this.hardReset=e}}f.action="resetRecognizers";class p extends s{constructor(e){super(p.action),this.registeredMetadataCallbacks=e}}p.action="registerMetadataCallbacks";class R extends s{constructor(e){super(R.action),this.detectionOnlyMode=e}}R.action="setDetectionOnly";class b extends s{constructor(e){super(b.action),this.callbackNonEmpty=e}}b.action="setClearTimeoutCallback";class k extends s{constructor(e){super(k.action),this.cameraPreviewMirrored=e}}k.action="setCameraPreviewMirrored";class y{constructor(e,t,s){this.success=!0,this.error=null,this.messageID=e,this.success=t,this.error=s}}class w{constructor(e,t,s){this.success=!0,this.showOverlay=!0,this.messageID=e,this.showOverlay=s}}class v extends y{constructor(e,t){super(e,!0,null),this.result=t}}class C extends y{constructor(e,t){super(e,!0,null),this.objectHandle=t}}class z extends y{constructor(e,t){super(e,!0,null),this.recognitionState=t}}class E{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 M{constructor(e,t){this.isCallbackMessage=!0,this.callbackType=e,this.callbackParameters=t}}function I(e,t){return t=t||"",""===(e=e||"")?t:e.endsWith("/")?t.startsWith("/")?e+t.substring(1):e+t:t.startsWith("/")?e+t:e+"/"+t}!function(e){e[e.Invalid=0]="Invalid",e[e.RequiresServerPermission=1]="RequiresServerPermission",e[e.Valid=2]="Valid"}(o||(o={})),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"}(a||(a={}));class S{constructor(e,t){this.code="UNLOCK_LICENSE_ERROR",this.message=null,this.type=e,t&&(this.message=t)}}function x(e){return{licenseId:e.licenseId,licensee:e.licensee,packageName:e.packageName,platform:"Browser",sdkName:e.sdkName,sdkVersion:e.sdkVersion}}var T;function P(t,s){return e(this,void 0,void 0,(function*(){try{const e=yield fetch("https://baltazar.microblink.com/api/v1/status/check",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-cache",body:JSON.stringify(x(t))});if(e.ok){const t=""+(yield e.text());return s.submitServerPermission(t)}return{status:T.NetworkError,lease:0,networkErrorDescription:"Server responded with status "+e.status}}catch(e){return{status:T.NetworkError,lease:0,networkErrorDescription:"Unexpected error: "+JSON.stringify(e)}}}))}!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"}(T||(T={}));new class{constructor(){this.context=self,this.wasmModule=null,this.nativeRecognizerRunner=null,this.objects={},this.nextObjectHandle=0,this.metadataCallbacks={},this.clearTimeoutCallback=null,this.context.onmessage=e=>{const t=e.data;switch(t.action){case r.action:this.processInitMessage(t);break;case c.action:this.processInvokeFunction(t);break;case l.action:this.processCreateNewRecognizer(t);break;case g.action:this.processInvokeObject(t);break;case u.action:this.processCreateRecognizerRunner(t);break;case h.action:this.processReconfigureRecognizerRunner(t);break;case d.action:this.processDeleteRecognizerRunner(t);break;case m.action:this.processImage(t);break;case f.action:this.resetRecognizers(t);break;case R.action:this.setDetectionOnly(t);break;case k.action:this.setCameraPreviewMirrored(t);break;case p.action:this.registerMetadataCallbacks(t);break;case b.action:this.registerClearTimeoutCallback(t);break;default:throw Error("Unknown message action: "+JSON.stringify(t.action))}}}getNextObjectHandle(){const e=this.nextObjectHandle;return this.nextObjectHandle=this.nextObjectHandle+1,e}notifyError(e,t){this.context.postMessage(new y(e.messageID,!1,t))}notifySuccess(e){this.context.postMessage(new y(e.messageID,!0,null))}notifyInitSuccess(e,t){this.context.postMessage(new w(e.messageID,!0,t))}unwrapParameters(e){const t=[];for(const s of e.params){let r=s.parameter;s.type===n.Recognizer?(r=this.objects[r],void 0===r&&this.notifyError(e,"Cannot find object with handle: undefined")):s.type===n.RecognizerSettings&&(r=this.restoreFunctions(r)),t.push(r)}return t}restoreFunctions(e){const t=Object.keys(e);for(const s of t){const t=e[s];"object"==typeof t&&null!==t&&"parameter"in t&&"type"in t&&t.type===n.Callback&&(e[s]=(...e)=>{const s=new M(i.recognizerCallback,[t.parameter].concat(e));this.context.postMessage(s)})}return e}scanForTransferrables(e){if("object"==typeof e){const t=Object.keys(e),s=[];for(const r of t){const t=e[r];t instanceof ImageData?s.push(t.data.buffer):t instanceof Uint8Array?s.push(t.buffer):null!==t&&"object"==typeof t&&s.push(...this.scanForTransferrables(t))}return s}return[]}registerHeartBeat(e){this.unregisterHeartBeat(),this.lease=e;let t=e-Math.floor(Date.now()/1e3);t>120?t-=120:t/=2,this.inFlightHeartBeatTimeoutId=setTimeout(()=>{this.obtainNewServerPermission(!0)},1e3*t)}unregisterHeartBeat(){this.lease&&delete this.lease,this.inFlightHeartBeatTimeoutId&&(clearTimeout(this.inFlightHeartBeatTimeoutId),delete this.inFlightHeartBeatTimeoutId)}obtainNewServerPermission(t){return e(this,void 0,void 0,(function*(){if(this.wasmModule){const e=this.wasmModule.getActiveLicenseTokenInfo(),s=yield P(e,this.wasmModule);switch(s.status){case T.Ok:case T.RemoteLock:this.registerHeartBeat(s.lease);break;case T.NetworkError:case T.PayloadSignatureVerificationFailed:case T.PayloadCorrupted:t?(console.warn("Problem with obtaining server permission. Will attempt in 10 seconds "+T[s.status]),this.inFlightHeartBeatTimeoutId=setTimeout(()=>{this.obtainNewServerPermission(!1)},1e4)):console.error("Problem with obtaining server permission. "+T[s.status]);break;case T.IncorrectTokenState:case T.PermissionExpired:console.error("Internal error: "+T[s.status])}return s.status}return console.error("Internal inconsistency! Wasm module not initialized where it's expected to be!"),T.IncorrectTokenState}))}willSoonExpire(){if(this.lease){if(this.wasmModule.getActiveLicenseTokenInfo().unlockResult===o.Valid){const e=Math.floor(Date.now()/1e3);return 30>this.lease-e}return!0}return!1}processInitMessage(t){let s={locateFile:e=>I(""===t.engineLocation?self.location.origin:t.engineLocation,e)};t.registerLoadCallback&&(s=Object.assign(s,{setStatus:e=>{const t=new E(function(e){if("Running..."===e)return 100;if(0===e.length)return 0;const t=/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/.exec(e);if(t){return 100*parseInt(t[2])/parseInt(t[4])}return NaN}(e));this.context.postMessage(t)}}));try{const r=""===t.engineLocation?self.location.origin:t.engineLocation,n=I(r,t.wasmModuleName+".js");importScripts(n);(0,self[t.wasmModuleName])(s).then(s=>e(this,void 0,void 0,(function*(){const r=yield function(t,s,r,n){return e(this,void 0,void 0,(function*(){const e=n.initializeWithLicenseKey(t,r,s);switch(e.unlockResult){case o.Invalid:return{error:new S(a.LicenseTokenStateInvalid,e.licenseError)};case o.Valid:return{error:null,showOverlay:(i=e.isTrial,c=e.allowRemoveDemoOverlay,l=e.allowRemoveProductionOverlay,!(i&&c||!i&&l))};case o.RequiresServerPermission:{const t=yield P(e,n);switch(t.status){case T.Ok:return{error:null,lease:t.lease};case T.NetworkError:{let e="";return t.networkErrorDescription&&(e=" "+t.networkErrorDescription),{error:new S(a.NetworkError,"There has been a network error while obtaining the server permission!"+e)}}case T.RemoteLock:return{error:new S(a.RemoteLock,"Provided license key has been remotely locked.Please contact support for more information!"),lease:t.lease};case T.PermissionExpired:return{error:new S(a.PermissionExpired,"Internal error (server permission expired)"),lease:t.lease};case T.PayloadCorrupted:return{error:new S(a.PayloadCorrupted,"Server permission payload is corrupted!"),lease:t.lease};case T.PayloadSignatureVerificationFailed:return{error:new S(a.PayloadSignatureVerificationFailed,"Failed to verify server permission's digital signature!"),lease:t.lease};case T.IncorrectTokenState:return{error:new S(a.IncorrectTokenState,"Internal error (Incorrect token state)"),lease:t.lease}}}}var i,c,l}))}(t.licenseKey,t.allowHelloMessage,t.userId,s);null===r.error?(this.wasmModule=s,r.lease?this.registerHeartBeat(r.lease):this.unregisterHeartBeat(),this.notifyInitSuccess(t,!!r.showOverlay)):this.notifyError(t,r.error)})),e=>{this.notifyError(t,e)})}catch(e){this.notifyError(t,e)}}processInvokeFunction(e){if(null===this.wasmModule)return void this.notifyError(e,"WASM module is not initialized!");const t=e.funcName,s=this.unwrapParameters(e);try{const r=this.wasmModule[t](...s);this.context.postMessage(new v(e.messageID,r))}catch(t){this.notifyError(e,t)}}processCreateNewRecognizer(e){if(null===this.wasmModule)return void this.notifyError(e,"WASM module is not initialized!");const t=e.className,s=this.unwrapParameters(e);try{const r=new this.wasmModule[t](...s),n=this.getNextObjectHandle();this.objects[n]=r,this.context.postMessage(new C(e.messageID,n))}catch(t){this.notifyError(e,t)}}getRecognizers(e){const t=[];for(const s of e){t.push(this.objects[s])}return t}processCreateRecognizerRunner(t){return e(this,void 0,void 0,(function*(){if(null===this.wasmModule)this.notifyError(t,"WASM module is not initialized!");else if(null!==this.nativeRecognizerRunner)this.notifyError(t,"Recognizer runner is already created! Multiple instances are not allowed!");else{this.setupMetadataCallbacks(t.registeredMetadataCallbacks);try{if(this.willSoonExpire()){const e=yield this.obtainNewServerPermission(!1);if(e!==T.Ok){const s=T[e];return void this.notifyError(t,new S(a[s],"Cannot initialize recognizers because of invalid server permission: "+s))}}const e=this.getRecognizers(t.recognizerHandles);this.nativeRecognizerRunner=new this.wasmModule.RecognizerRunner(e,t.allowMultipleResults,this.metadataCallbacks),this.notifySuccess(t)}catch(e){this.notifyError(t,e)}}}))}processReconfigureRecognizerRunner(e){if(null===this.wasmModule)this.notifyError(e,"WASM module is not initialized!");else if(null===this.nativeRecognizerRunner)this.notifyError(e,"Recognizer runner is not created! There is nothing to reconfigure!");else try{const t=this.getRecognizers(e.recognizerHandles);this.nativeRecognizerRunner.reconfigureRecognizers(t,e.allowMultipleResults),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}}processDeleteRecognizerRunner(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.delete(),this.nativeRecognizerRunner=null,this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is already deleted!")}processInvokeObject(e){try{const t=e.objectHandle,s=e.methodName,r=this.unwrapParameters(e),n=this.objects[t];if(void 0===n)this.notifyError(e,"Cannot find object with handle: "+t);else{const i=n[s](...r),o=this.scanForTransferrables(i);"delete"===s&&delete this.objects[t],this.context.postMessage(new v(e.messageID,i),o)}}catch(t){this.notifyError(e,t)}}processImage(e){if(null!==this.nativeRecognizerRunner)try{const t=this.nativeRecognizerRunner.processImage(e.frame);this.context.postMessage(new z(e.messageID,t))}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}resetRecognizers(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.resetRecognizers(e.hardReset),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}setDetectionOnly(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.setDetectionOnlyMode(e.detectionOnlyMode),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}setCameraPreviewMirrored(e){if(null!==this.nativeRecognizerRunner)try{this.nativeRecognizerRunner.setCameraPreviewMirrored(e.cameraPreviewMirrored),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}setupMetadataCallbacks(e){e.onDebugText?this.metadataCallbacks.onDebugText=e=>{const t=new M(i.onDebugText,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onDebugText,e.onDetectionFailed?this.metadataCallbacks.onDetectionFailed=()=>{const e=new M(i.onDetectionFailed,[]);this.context.postMessage(e)}:delete this.metadataCallbacks.onDetectionFailed,e.onPointsDetection?this.metadataCallbacks.onPointsDetection=e=>{const t=new M(i.onPointsDetection,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onPointsDetection,e.onQuadDetection?this.metadataCallbacks.onQuadDetection=e=>{const t=new M(i.onQuadDetection,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onQuadDetection,e.onFirstSideResult?this.metadataCallbacks.onFirstSideResult=()=>{const e=new M(i.onFirstSideResult,[]);this.context.postMessage(e)}:delete this.metadataCallbacks.onFirstSideResult,e.onGlare?this.metadataCallbacks.onGlare=e=>{const t=new M(i.onGlare,[e]);this.context.postMessage(t)}:delete this.metadataCallbacks.onGlare}registerMetadataCallbacks(e){if(null!==this.nativeRecognizerRunner){this.setupMetadataCallbacks(e.registeredMetadataCallbacks);try{this.nativeRecognizerRunner.setJSDelegate(this.metadataCallbacks),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}registerClearTimeoutCallback(e){if(null!==this.nativeRecognizerRunner){this.clearTimeoutCallback=e.callbackNonEmpty?{onClearTimeout:()=>{const e=new M(i.clearTimeoutCallback,[]);this.context.postMessage(e)}}:null;try{this.nativeRecognizerRunner.setClearTimeoutCallback(this.clearTimeoutCallback),this.notifySuccess(e)}catch(t){this.notifyError(e,t)}}else this.notifyError(e,"Recognizer runner is not initialized! Cannot process image!")}}}(); `],{type:"application/javascript"}),s=URL.createObjectURL(o),a=new Worker(s);k.createWasmWorker(a,e,r).then((e=>{t(e)}),i)}catch(e){i(e)}}))}))}function J(e,t,i=!1,r={}){return s(this,void 0,void 0,(function*(){if("object"!=typeof e)throw new Error("SDK is not provided!");if("object"!=typeof t||t.length<1)throw new Error("To create RecognizerRunner at least 1 recognizer is required.");return e.mbWasmModule.createRecognizerRunner(t,i,r)}))}function X(e,t){return s(this,void 0,void 0,(function*(){const i=yield e.mbWasmModule.newRecognizer("SuccessFrameGrabberRecognizer",t);return i.wrappedRecognizer=t,i}))}var K,q,$,ee,te,ie,re,oe,se,ae,ne;!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"}(K||(K={})),function(e){e[e.None=0]="None",e[e.ImageOnly=1]="ImageOnly",e[e.ResultFieldsOnly=2]="ResultFieldsOnly",e[e.FullResult=3]="FullResult"}(q||(q={}));class Me{constructor(e=0,t=0,i=0,r=0){this.upFactor=0,this.downFactor=0,this.leftFactor=0,this.rightFactor=0,this.checkExtensionFactor(e),this.checkExtensionFactor(t),this.checkExtensionFactor(i),this.checkExtensionFactor(r),this.upFactor=e,this.downFactor=t,this.leftFactor=i,this.rightFactor=r}checkExtensionFactor(e){if(e>1||e<-1)throw new Error("Extension factor must be in range [-1.0, 1.0]")}}function ce(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"}($||($={})),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.RE