UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 61.7 kB
(function(){function e(e){return typeof e==`object`&&!!e}function t(t){if(typeof t==`string`)return t;if(e(t)){if(typeof t.message==`string`)return t.message}else if(typeof t?.toString==`function`)return t.toString();return`unknown error`}(function(e){return e.Body=`body`,e.Footnote=`footnote`,e})({});let n=function(e){return e.Start=`start`,e.Center=`center`,e.End=`end`,e}({});(function(e){return e.Normal=`normal`,e.Wider=`wider`,e.FitText=`fitText`,e})({}),function(e){return e.Normal=`normal`,e.Taller=`taller`,e}({}),function(e){return e.Square=`square`,e.Rounded=`rounded`,e}({});let r=function(e){return e.None=`none`,e.Check=`check`,e.ExclamationMark=`exclamationMark`,e}({}),i=function(e){return e.Top=`top`,e.Center=`center`,e.AboveViewFinder=`aboveViewFinder`,e.BelowViewFinder=`belowViewFinder`,e}({});(function(e){return e.AboveViewFinder=`aboveViewFinder`,e.BelowViewFinder=`belowViewFinder`,e})({}),function(e){return e.BlackOnWhite=`blackOnWhite`,e.WhiteOnBlack=`whiteOnBlack`,e.Transparent=`transparent`,e}({}),function(e){return e.Success=`success`,e.Error=`error`,e.Warning=`warning`,e.Info=`info`,e.Notification=`notification`,e}({}),function(e){return e[e.Ocr=0]=`Ocr`,e[e.HideLogo=1]=`HideLogo`,e[e.ShowTestLicenseMessage=2]=`ShowTestLicenseMessage`,e[e.AugmentedReality=5]=`AugmentedReality`,e[e.ActivityPingStatsAddon=8]=`ActivityPingStatsAddon`,e[e.ActivityPing=9]=`ActivityPing`,e[e.Registration=10]=`Registration`,e[e.Parser=11]=`Parser`,e[e.BarcodeCapture=14]=`BarcodeCapture`,e[e.Analytics=17]=`Analytics`,e[e.AnalyticsBatchMode=18]=`AnalyticsBatchMode`,e[e.AnalyticsScanContent=19]=`AnalyticsScanContent`,e[e.AnalyticsOnlineVerification=20]=`AnalyticsOnlineVerification`,e[e.SparkScan=21]=`SparkScan`,e[e.AamvaIdBarcodeVerification=22]=`AamvaIdBarcodeVerification`,e[e.MappingForTracking=23]=`MappingForTracking`,e[e.BarcodeFind=24]=`BarcodeFind`,e[e.MandatoryRegistration=25]=`MandatoryRegistration`,e[e.FeatureTracking=26]=`FeatureTracking`,e[e.IdCaptureViz=27]=`IdCaptureViz`,e[e.IdCaptureMrz=28]=`IdCaptureMrz`,e[e.IdCaptureBarcode=29]=`IdCaptureBarcode`,e[e.BarcodeSelectionAimToScan=30]=`BarcodeSelectionAimToScan`,e[e.BarcodeSelectionTapToScan=31]=`BarcodeSelectionTapToScan`,e[e.BarcodeCount=32]=`BarcodeCount`,e[e.BarcodePick=33]=`BarcodePick`,e[e.IdVerificationDataComparison=34]=`IdVerificationDataComparison`,e[e.SmartLabelBarcode=35]=`SmartLabelBarcode`,e[e.SmartLabelText=36]=`SmartLabelText`,e[e.VoidedIdDetection=37]=`VoidedIdDetection`,e[e.BarcodeArFull=38]=`BarcodeArFull`,e[e.BarcodeSequence=39]=`BarcodeSequence`,e}({});let a;(function(e){e.Level=function(e){return e.Debug=`debug`,e.Info=`info`,e.Warn=`warn`,e.Error=`error`,e.Quiet=`quiet`,e}({});let t=new Map([[`debug`,1],[`info`,2],[`warn`,3],[`error`,4],[`quiet`,5]]),n=`debug`;function r(e){n=e}e.setLevel=r;function i(e,...r){if(!(t.get(n)>t.get(e)))switch(e){case`debug`:console.debug(...r);break;case`info`:console.log(...r);break;case`warn`:console.warn(...r);break;case`error`:console.error(...r);break;default:break}}e.log=i;function a(...e){i(`warn`,...e)}e.warn=a;function o(...e){i(`debug`,...e)}e.debug=o;function s(...e){i(`info`,...e)}e.info=s;function c(...e){i(`error`,...e)}e.error=c})(a||={});var o=class e extends Error{constructor(t){super(t.message),Object.setPrototypeOf(this,e.prototype),this.name=t.name}toString(){return`${this.name}: ${this.message}`}};function s(e){return/^https?:\/\/(?:[^./]*\.)*cdn.jsdelivr.net\//.test(e)?{result:!0,cdnBaseURL:`https://cdn.jsdelivr.net/npm/`}:/^https?:\/\/(?:[^./]*\.)*unpkg.com\//.test(e)?{result:!0,cdnBaseURL:`https://unpkg.com/`}:{result:!1,cdnBaseURL:``}}function c(e){let t=/@scandit\/web-datacapture-[a-z]+/i.exec(e);return t?t[0]:null}function l(e,t,n){let r=t,i=s(r);if(i.result){let t=c(r);t!=null&&(r=`${i.cdnBaseURL}${t}@${e}/sdc-lib/`)}let a=n.replace(`.wasm`,``);return i.result?{jsURI:`${r}${a}.js`,wasmURI:`${r}${a}.wasm`}:{jsURI:`${r}${a}.js?v=${e}`,wasmURI:`${r}${a}.wasm?v=${e}`}}var u=class{constructor(){this.promise=new Promise((e,t)=>{this.reject=t,this.resolve=e})}};let d;(function(e){function t(){let e=`8.5.0`;if(e==null)throw new o({name:`Invalid library version`,message:`Library version is not defined or empty.`});return e}e.sdkVersion=t})(d||={});let f={};function p(e){return[...new Uint8Array(e)].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join(``)}async function*m(e){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}async function h(e){let t=[],n=0,r=0;for await(let r of m(e))t.push(r),n+=r.length;let i=new Uint8Array(n);for(let e of t)i.set(e,r),r+=e.length;return i.buffer}(function(e){return e.VALID=`VALID`,e.INVALID=`INVALID`,e.NOT_VERIFIABLE=`NOT_VERIFIABLE`,e})({});async function g(e,t,n){if(typeof crypto.subtle.digest!=`function`)return a.log(a.Level.Warn,`Insecure context (see https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts): The hash of the Scandit Data Capture library WASM file found at ${n} could not be verified`),`NOT_VERIFIABLE`;try{let r=e instanceof Promise?await e:e,i=p(await crypto.subtle.digest(`SHA-256`,r));return t==null?(a.log(a.Level.Warn,`The library hash is not defined or empty, cannot correctly verify integrity.`),`NOT_VERIFIABLE`):i===t?(a.log(a.Level.Debug,`Data Capture library WASM integrity found at ${n} has been verified correctly.`),`VALID`):(a.log(a.Level.Warn,`The Scandit Data Capture library WASM file found at ${n} seems invalid: expected file hash doesn't match (received: ${i}, expected: ${t}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),`INVALID`)}catch(e){return a.log(a.Level.Warn,`Wasm response could not be verified`,e),`NOT_VERIFIABLE`}}let _=new Map([[`br`,4.4],[`gzip`,2.9],[`none`,1]]);function v(e){let t=`content-encoding`;if(e==null||e.get(t)==null)return _.get(`none`);let n=new Set((e.get(t)??``).split(`,`).map(e=>e.trim()));for(let[e,t]of _)if(n.has(e))return t;return _.get(`none`)}function y(e){if(e==null)return 0;let t=v(e)??1,n=Number.parseInt(e.get(`content-length`)??`0`,10);return Number.isNaN(n)?0:Math.floor(n*t*100)/100}function b(e){let{pathname:t}=new URL(e);for(let[e,n]of Object.entries(f))if(t.endsWith(e))return n.bytes;return 0}function x(e){f=e}let S=(e,t)=>{let n=y(t);return n===0?b(e):n};function C(e,t,n,{onProgress:r,onError:i,onComplete:o}){if(!t.body)return[t];let s=S(e,t.headers),c=0,l=0;if(typeof TransformStream>`u`)return a.warn(`TransformStream is not supported in this environment. Progress tracking will be disabled.`),[t];let[u,d]=n?t.body.tee():[t.body],f=u.pipeThrough(new TransformStream({async transform(t,n){try{c+=t.length,l=Number((c/s*100).toFixed(2)),s>0&&t.length>0&&l<100?r?.({percentage:l,loadedBytes:c,privateUri:e}):s===0&&t.length>0&&r?.({percentage:null,loadedBytes:c,privateUri:e}),n.enqueue(t)}catch(e){n.error(e),i?.({error:e})}},flush(t){r?.({percentage:100,loadedBytes:c,privateUri:e}),o?.({percentage:100,loadedBytes:c,privateUri:e}),t.terminate()}}));return[new Response(f,{headers:new Headers(t.headers),status:t.status,statusText:t.statusText}),d]}async function w({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,onComplete:i,onError:a,referredOrigin:o}){let s=await fetch(e,{referrerPolicy:`origin`,referrer:o??``});if(!s.ok)throw Error(`HTTP status code is not ok: ${s.status}, ${s.statusText}`);let[c,l]=C(e,s,n,{onProgress:r,onError:a,onComplete:i});return l!=null&&g(h(l),t,e),c}function T({wasmURI:e,expectedHash:t,verifyResponseHash:n,progressCallback:r,successCallback:i,errorCallback:o,importObject:s,referredOrigin:c}){async function l(l){try{let a=await w({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,referredOrigin:c}),o=await(l??a).arrayBuffer(),u=await globalThis.WebAssembly.instantiate(o,s);i(u.instance,u.module)}catch(t){a.log(a.Level.Error,t),a.log(a.Level.Error,`Couldn't instantiate Scandit SDK DataCapture library at ${e}, did you configure the path for it correctly?`),o?.(t)}}async function u(){let o;try{o=await w({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,referredOrigin:c});let a=await globalThis.WebAssembly.instantiateStreaming(o,s);i(a.instance,a.module)}catch(e){a.log(a.Level.Warn,e),a.log(a.Level.Warn,`WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)`),l(o?.bodyUsed===!0?void 0:o)}}typeof globalThis.WebAssembly.instantiateStreaming==`function`?u():l()}async function E(e,t,n,r){return new Promise((i,a)=>{e().then(i).catch(o=>{let s=t*2;if(s>n){a(o);return}r(o),globalThis.setTimeout(()=>{E(e,s,n,r).then(i).catch(a)},t)})})}function D(e){var t;let n=`unknown`;if((t=e.href)!=null&&t.startsWith(`blob:null/`))n=`localhost`;else{let t=e.pathname?.length>1&&!e.pathname.startsWith(`/`);n=new URL(t?e.pathname:e.origin).hostname}return n.startsWith(`[`)&&n.endsWith(`]`)?(n=n.slice(1,-1),n):(/^(\d{1,3}\.){3}\d{1,3}$/.test(n)&&(n=n.split(`.`).map(e=>Number.parseInt(e,10).toString()).join(`.`)),n)}async function ee(e){let t;try{let n=new Promise((n,r)=>{t=setTimeout(()=>{a.debug(`IndexedDB database is blocked (timed out after ${e}ms). If you are running a Debug wasm build, things are slower and the timeout can be configured via IndexedDBBlockedTimeoutMs in localStorage (requires page reload).`),r(new o({name:`BlockedIndexedDB`,message:`IndexedDB database is blocked`}))},e)}),r=new Promise((e,t)=>{FS.syncfs(!0,n=>{n==null?e():t(n)})});await Promise.race([r,n])}finally{t!==void 0&&clearTimeout(t)}}async function te(e){try{FS.mkdir(e.writableDataPath)}catch(e){if(e.code!==`EEXIST`)throw e}return FS.mount(IDBFS,{autoPersist:!0},e.writableDataPath),ee(e.indexedDBTimeoutMs)}async function O(e,t){function n(e){try{return new URL(e,self.location.href).origin!==self.location.origin}catch(t){return a.log(a.Level.Warn,`Could not determine origin for WASM JS URL "${e}": ${t instanceof Error?t.message:String(t)}. Defaulting to same-origin path.`),!1}}function r(t){a.log(a.Level.Warn,t),a.log(a.Level.Warn,`Couldn't retrieve Scandit Data Capture library at ${e}, retrying...`)}try{if(n(e)){let t=await E(async()=>{let t=await fetch(e,{mode:`cors`,credentials:`omit`});if(!t.ok)throw Error(`Failed to load WASM JS script: ${e} (status ${t.status})`);let n=await t.blob();return/javascript|ecmascript/i.test(n.type)?n:new Blob([n],{type:`application/javascript`})},250,4e3,r),n=URL.createObjectURL(t);try{await importScripts(n)}finally{URL.revokeObjectURL(n)}self.Module.mainScriptUrlOrBlob=t}else await E(async()=>importScripts(e),250,4e3,r),self.Module.mainScriptUrlOrBlob=e;let i=globalThis.SDC_WASM_JS_VERSION;return i!==t&&a.log(a.Level.Warn,`The Scandit Data Capture library JS file found at ${e} seems invalid: expected version doesn't match (received: ${i}, expected: ${t}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(e){return a.log(a.Level.Error,e),!1}}function k(e,t,n){let r=t*n,i=new Uint8ClampedArray(r*4),a=new Uint32Array(i.buffer);for(let t=0;t<r;t++){let n=e[t];a[t]=4278190080|n<<16|n<<8|n}return i}var A=class{constructor(e,t){this.workerFunctions=e,this.options=t,this.imageIdCounter=0,this.conversions=new Map}convertToJpeg(e,t){let n=this.imageIdCounter++,r=new u;this.conversions.set(n,r);let i=e.toBitmap();return this.workerFunctions.postMessage({type:`convertToJPEG`,imageId:n,width:e.getWidth(),height:e.getHeight(),data:i,planes:e.getPlanes(),orientation:t,quality:this.options.quality},Array.from(new Set([i.buffer]))),r.promise}convertToBitmap(e){return{data:e.toBitmap(),byteOrder:1}}onConvertToJPEGResult(e,t){let n=this.conversions.get(e);n?(n.resolve(t),this.conversions.delete(e)):a.warn(`ImageConverterForwarder: Conversion for imageId ${e} not found in Map`)}},j=class{constructor(e){this.options=e}get quality(){return this.options.quality}async convertToJpeg(e,t){try{let{width:n,height:r,planes:i}=this.validateAndExtractImageData(e);this.prepareCanvas(n,r);let a=this.processImageData(e,i,n,r);return await this.convertToJpegBytes(a,t)}catch(e){throw a.warn(`Failed to convert image to JPEG: ${e}`),e instanceof Error?e:Error(`Failed to convert image to JPEG`)}}convertToBitmap(e){return{data:e.toBitmap(),byteOrder:1}}validateAndExtractImageData(e){let t=e.getWidth(),n=e.getHeight(),r=e.getPlanes();if(t<=0||n<=0)throw a.warn(`Invalid image dimensions: ${t}x${n}`),Error(`Invalid image dimensions: ${t}x${n}`);if(!r||r.length===0)throw a.warn(`ImageBuffer has no planes`),Error(`ImageBuffer has no planes`);return{width:t,height:n,planes:r}}prepareCanvas(e,t){if(!this.ensureCanvas(e,t))throw Error(`Failed to create OffscreenCanvas`);if(!this.canvas||!this.context)throw Error(`Canvas or context not properly initialized`)}processImageData(e,t,n,r){let i=this.createImageDataFromBuffer(e,t,n,r);if(i===null)throw Error(`Failed to create ImageData`);return this.validateImageData(i,n,r),i}validateImageData(e,t,n){if(e.width!==t||e.height!==n)throw a.warn(`ImageData dimensions mismatch: expected ${t}x${n}, got ${e.width}x${e.height}`),Error(`ImageData dimensions mismatch`);if(!e.data||e.data.length!==t*n*4)throw a.warn(`ImageData has invalid data length: expected ${t*n*4}, got ${e.data?.length||0}`),Error(`ImageData has invalid data length`)}async convertToJpegBytes(e,t){if(!this.context||!this.canvas)throw Error(`Canvas or context not available`);try{this.context.putImageData(e,0,0)}catch(e){throw a.warn(`Failed to put image data on canvas: ${e}`),Error(`Failed to put image data on canvas: ${e}`)}let n=t===0?this.canvas:this.applyRotation(this.canvas,t),r;try{r=await this.canvasToBlob(n)}catch(e){throw a.warn(`Failed to convert canvas to blob: ${e}`),Error(`Failed to convert canvas to blob: ${e}`)}if(!r||r.size===0)throw a.warn(`Canvas convertToBlob returned empty or null blob`),Error(`Failed to create JPEG blob`);let i;try{i=await r.arrayBuffer()}catch(e){throw a.warn(`Failed to get array buffer from blob: ${e}`),Error(`Failed to get array buffer from blob: ${e}`)}if(!i||i.byteLength===0)throw a.warn(`Blob arrayBuffer returned empty or null buffer`),Error(`Failed to get array buffer from blob`);return new Uint8Array(i)}ensureCanvas(e,t){try{return(!this.canvas||this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas=this.getNewCanvas(e,t),this.context=this.canvas.getContext(`2d`)),this.context!==null}catch(e){return a.warn(`Failed to create HTMLCanvasElement`,e),!1}}createImageDataFromBuffer(e,t,n,r){let i=new Set(t.map(e=>e.channel));try{if(this.isYUVFormat(i)){let t=e.toBitmap();return!t||t.length!==n*r*4?(a.warn(`Invalid bitmap data from toBitmap(): expected ${n*r*4} bytes, got ${t?.length||0}`),null):new ImageData(new Uint8ClampedArray(t),n,r)}if(this.isRGBAFormat(i))return this.createImageDataFromRGBAPlanes(t,n,r);if(this.isRGBFormat(i))return this.createImageDataFromRGBPlanes(t,n,r);if(this.isGrayscaleFormat(i))return this.createImageDataFromGrayscalePlanes(t,n,r);a.warn(`Unknown image format with channels: ${Array.from(i).join(`, `)}, falling back to toBitmap()`);let o=e.toBitmap();if(!o||o.length===0)return a.warn(`toBitmap() returned empty or null data`),null;let s=o.length/(n*r);return s===4?new ImageData(new Uint8ClampedArray(o),n,r):(a.warn(`Unsupported format: ${s} bytes per pixel`),null)}catch(e){return a.warn(`Failed to create ImageData: ${e}`),null}}isYUVFormat(e){return e.has(0)&&e.has(1)&&e.has(2)}isRGBAFormat(e){return e.has(3)&&e.has(4)&&e.has(5)&&e.has(6)}isRGBFormat(e){return e.has(3)&&e.has(4)&&e.has(5)&&!e.has(6)}isGrayscaleFormat(e){return e.has(0)&&!e.has(1)&&!e.has(2)}createImageDataFromRGBAPlanes(e,t,n){let r=e.find(e=>e.channel===3),i=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5),s=e.find(e=>e.channel===6);if(!r||!i||!o||!s)return a.warn(`Missing RGBA planes`),null;let c=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let a=(e*t+n)*4;c[a]=this.getPixelFromPlane(r,n,e),c[a+1]=this.getPixelFromPlane(i,n,e),c[a+2]=this.getPixelFromPlane(o,n,e),c[a+3]=this.getPixelFromPlane(s,n,e)}return new ImageData(c,t,n)}createImageDataFromRGBPlanes(e,t,n){let r=e.find(e=>e.channel===3),i=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5);if(!r||!i||!o)return a.warn(`Missing RGB planes`),null;let s=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let a=(e*t+n)*4;s[a]=this.getPixelFromPlane(r,n,e),s[a+1]=this.getPixelFromPlane(i,n,e),s[a+2]=this.getPixelFromPlane(o,n,e),s[a+3]=255}return new ImageData(s,t,n)}createImageDataFromGrayscalePlanes(e,t,n){let r=e.find(e=>e.channel===0);if(!r)return a.warn(`Missing Y plane for grayscale`),null;let i=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let a=(e*t+n)*4,o=this.getPixelFromPlane(r,n,e);i[a]=o,i[a+1]=o,i[a+2]=o,i[a+3]=255}return new ImageData(i,t,n)}getPixelFromPlane(e,t,n){let r=Math.floor(t/(e.subsamplingX||1)),i=Math.floor(n/(e.subsamplingY||1)),a=e.rowStride,o=e.pixelStride,s=i*a+r*o,c=e.data;return s<c.length?c[s]:0}applyRotation(e,t){let n=t*Math.PI/180,r=t===90||t===270||t===-90||t===-270,i=r?e.height:e.width,a=r?e.width:e.height,o=this.getNewCanvas(i,a),s=o.getContext(`2d`);if(!s)throw Error(`Failed to get 2D context for rotated canvas`);return s.translate(i/2,a/2),s.rotate(n),s.translate(-e.width/2,-e.height/2),s.drawImage(e,0,0),o}};j.JPEG_IMAGE_MIME_TYPE=`image/jpeg`;var ne=class extends j{getNewCanvas(e,t){return new OffscreenCanvas(e,t)}canvasToBlob(e){return e.convertToBlob({type:j.JPEG_IMAGE_MIME_TYPE,quality:this.options.quality})}},re=class{constructor(e){this.viewInfo=null,this.viewInfo=this.cloneViewInfo(e)}isSame(e){return this.viewInfo==null&&e==null?!0:this.viewInfo==null&&e!=null||this.viewInfo!=null&&e==null?!1:this.viewInfo.width===e.width&&this.viewInfo.height===e.height&&this.viewInfo.orientation===e.orientation&&this.viewInfo.viewFinderRect.origin.x===e.viewFinderRect.origin.x&&this.viewInfo.viewFinderRect.origin.y===e.viewFinderRect.origin.y&&this.viewInfo.viewFinderRect.size.width===e.viewFinderRect.size.width&&this.viewInfo.viewFinderRect.size.height===e.viewFinderRect.size.height}update(e){this.viewInfo=this.cloneViewInfo(e)}cloneViewInfo(e){return e?{...e,viewFinderRect:{origin:{...e.viewFinderRect.origin},size:{...e.viewFinderRect.size}}}:null}},M=class e{constructor(e,t){this.hintPresenterV2=null,this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL=5,this.redrawInterval=1e3/30,this.redrawRequests=[],this._isDrawLoopRunning=!1,this.frameDataPool=new Map,this.lastFrameColorType=`RGBA`,this.lastFrameId=null,this.poorMansBenchmarkLogs=!1,this.writableDataPathStandard=`/scandit_sync_folder`,this.resourceFilesSubfolder=`resources`,this.performanceMetricsReporterTimer=void 0,this.lastMetricsReportTime=0,this.metricsReportInterval=1e3,this.performanceMetrics={frameDataPoolSize:0,cameraOutputFrames:0,redrawRequestsCount:0,actualRedrawsCount:0,frameProcessingStartedCount:0,frameProcessedCount:0,frameSkippedCount:0},this.frameProcessingStartedCount=0,this.frameProcessingFinishedCount=0,this.gestureListener=null,this.webPlatformHintPresenter=null,this.deviceInstance=null,this.deviceInfo=null,this.lastViewInfo=new re(null),this.lastFrameProcessingStartedCount=0,this.lastFrameProcessingFinishedCount=0,this.moduleHandler=e,this.workerFunctions=t,this._loadProgressCallback=this._loadProgressCallback.bind(this),x(this.getWasmMetadata())}get Module(){return this.moduleHandler.get()}set isDrawLoopRunning(e){this._isDrawLoopRunning=e,!e&&typeof this.loopTimeoutId==`number`&&(clearTimeout(this.loopTimeoutId),this.loopTimeoutId=void 0)}get isDrawLoopRunning(){return this._isDrawLoopRunning}prepareFrameForListener(e){let t=this.lastFrameId;if(this.frameDataPool.size>=this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL){let e=this.frameDataPool.keys().next().value;e!=null&&this.frameDataPool.delete(e)}let n=e.getFrameData(),r=new Uint8ClampedArray(n);this.frameDataPool.set(t,{data:r,colorType:this.lastFrameColorType,frameId:t,width:e.getWidth(),height:e.getHeight()});let i=this.lastUsedModuleMirrorAxis==null?!1:this.lastUsedModuleMirrorAxis!==this.Module.Axis.None;return{frameId:t,width:e.getWidth(),height:e.getHeight(),isFrameSourceMirrored:i,colorType:this.lastFrameColorType}}createContext(e){var t,n,r,i;let a=this.getModeDeserializers(),o=D(location);(o===`localhost`||o===`127.0.0.1`)&&navigator.userAgent.includes(`Electron`)&&e.appName!=null&&(o+=`-${e.appName}`),this.parentDomain=e.parentDomain,this.contextDeserializer=new this.Module.DataCaptureContextDeserializer(this.writableDataPath,e.deviceId,e.context.deviceModelName,o,this.parentDomain,a,e.delayedRegistration,e.highEndBlurryRecognition,this.resourcePath);let s=this.contextDeserializer.contextFromJson(JSON.stringify(e.context));if(s==null){let e=this.contextDeserializer.getLastError();throw Error(`Could not create the context: ${e}`)}let c=s.getView();this.context=s.getContext(),s.delete(),this.setupDeviceInterface(e.isTablet,e.batteryInfo);let l=this.Module.DataCaptureContextListener.extend(`DataCaptureContextListener`,{didChangeStatus:(e,t)=>{this.contextDidChangeStatus(JSON.parse(t.toJson())),e.delete()},didStartObservingContext:e=>{this.didStartObservingContext(),e.delete()},didStopObservingContext:e=>{e.delete()}}),u=this.Module.DataCaptureContextFrameListener.extend(`DataCaptureContextFrameListener`,{onObservationStarted:e=>{e.delete()},onObservationStopped:e=>{e.delete()},onFrameProcessingStarted:(e,t)=>{this.workerFunctions.postMessage({type:`onFrameProcessingStarted`}),t.delete(),e.delete()},onFrameProcessingFinished:(e,t)=>{this.workerFunctions.postMessage({type:`onFrameProcessingFinished`}),t.delete(),e.delete()},onFrameSkipped:(e,t)=>{this.workerFunctions.postMessage({type:`onFrameSkipped`}),t.delete(),e.delete()}}),d=this.Module.GestureRecognizer.extend(`GestureRecognizer`,{setGestureListener:(e,t)=>{var n;(n=this.gestureListener)==null||n.delete(),this.gestureListener=e.clone(),e.delete()}});(t=this.gestureRecognizer)==null||t.delete(),this.gestureRecognizer=new d;let f=new l;this.context.addListener(f),f.delete();let p=new u;this.context.addFrameListener(p),p.delete(),this.setView(c),(n=this.view)==null||n.setGestureRecognizer(this.gestureRecognizer);let m=this.Module.PlatformHintPresenter.extend(`PlatformHintPresenter`,{setHintPresenter:e=>{e.delete()},showToast:e=>{this.workerFunctions.postMessage({type:`showToast`,payload:JSON.parse(e)})},hideToast:e=>{this.workerFunctions.postMessage({type:`hideToast`,payload:JSON.parse(e)})},showGuidance:e=>{this.workerFunctions.postMessage({type:`showGuidance`,payload:JSON.parse(e)})},hideGuidance:e=>{this.workerFunctions.postMessage({type:`hideGuidance`,payload:JSON.parse(e)})},startUpdateTimer:e=>{this.workerFunctions.postMessage({type:`startUpdateTimer`,payload:{duration:{unit:`ms`,value:e}}})},stopUpdateTimer:()=>{this.workerFunctions.postMessage({type:`stopUpdateTimer`})}});if((r=this.hintPresenterV2)==null||r.delete(),this.hintPresenterV2=null,(i=this.webPlatformHintPresenter)==null||i.delete(),this.webPlatformHintPresenter=null,this.webPlatformHintPresenter=new m,this.view){var h;this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter),(h=this.view)==null||h.setHintPresenterV2(this.hintPresenterV2)}this.webImageConverterInstance=this.getImageConverterInstance({quality:1}),this.Module.ImageConverter.setInstance(this.webImageConverterInstance)}convertToJPEGResult(e,t){this.webImageConverterInstance instanceof A&&this.webImageConverterInstance.onConvertToJPEGResult(e,t)}getImageConverterInstance(e){return this.workerFunctions.getOffscreenCanvas()==null?new A(this.workerFunctions,e):new ne(e)}onTap(e){var t;(t=this.gestureListener)==null||t.onTap(JSON.stringify(e))}hintPresenterV2Update(){var e;(e=this.hintPresenterV2)==null||e.update()}startReportingPerformanceMetrics(){this.performanceMetricsReporterTimer??(this.lastMetricsReportTime=performance.now(),this.scheduleMetricsReporting())}scheduleMetricsReporting(){this.performanceMetricsReporterTimer=setTimeout(()=>{this.checkAndReportMetrics()},100)}checkAndReportMetrics(){let e=performance.now();e-this.lastMetricsReportTime>=this.metricsReportInterval&&(this.reportPerformanceMetrics(),this.performanceMetrics.cameraOutputFrames=0,this.performanceMetrics.redrawRequestsCount=0,this.performanceMetrics.actualRedrawsCount=0,this.lastMetricsReportTime=e),this._isDrawLoopRunning&&this.scheduleMetricsReporting()}async reportPerformanceMetrics(){let e=this.frameProcessingStartedCount-this.lastFrameProcessingStartedCount,t=this.frameProcessingFinishedCount-this.lastFrameProcessingFinishedCount;this.lastFrameProcessingStartedCount=this.frameProcessingStartedCount,this.lastFrameProcessingFinishedCount=this.frameProcessingFinishedCount;let n={cameraOutputFrames:this.performanceMetrics.cameraOutputFrames,redrawRequestsCount:this.performanceMetrics.redrawRequestsCount,actualRedrawsCount:this.performanceMetrics.actualRedrawsCount,frameDataPoolSize:this.performanceMetrics.frameDataPoolSize,frameProcessingStartedCount:e,frameProcessedCount:t,frameSkippedCount:this.performanceMetrics.frameSkippedCount};this.workerFunctions.postMessage({type:`performanceMetricsReport`,payload:n})}deleteFrameData(e){this.frameDataPool.delete(e)}dispose(){var e,t,n,r,i;this.context.dispose(),this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.cleanupMetricsReporting(),(e=this.gestureRecognizer)==null||e.delete(),this.gestureRecognizer=null,(t=this.gestureListener)==null||t.delete(),this.gestureListener=null,(n=this.hintPresenterV2)==null||n.delete(),this.hintPresenterV2=null,(r=this.webPlatformHintPresenter)==null||r.delete(),this.webPlatformHintPresenter=null,(i=this.deviceInstance)==null||i.delete(),this.deviceInstance=null,this.deviceInfo=null}cleanupMetricsReporting(){this.performanceMetricsReporterTimer!=null&&(typeof this.performanceMetricsReporterTimer==`number`?cancelAnimationFrame(this.performanceMetricsReporterTimer):clearTimeout(this.performanceMetricsReporterTimer),this.performanceMetricsReporterTimer=void 0)}flushAnalytics(){this.context.flushAnalytics()}extractCentaurusLicense(t){return{payload:{centaurus:{licenseKey:this.Module.LicenseUtils[e.get3dPartyLicenseKeyMethodName](t)}}}}getModeDeserializers(){return new this.Module.VectorDataCaptureModeDeserializer}loadLibrary(e){return this.libraryLoadingPromise??=this.setup(e),this.libraryLoadingPromise}processFrame(e){var t;if(this.context==null)return a.debug(`[processFrame] Context is null, returning frame without processing`),{payload:e,transferables:[e.data.buffer]};this.lastFrameId=e.frameId;let n=e.data,r=e.colorType===`GRAYSCALE`?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;this.lastFrameColorType=e.colorType===`GRAYSCALE`?`GRAYSCALE`:`RGBA`;let i=this.Module.allocateUint8Array(n.byteLength);return this.Module.HEAPU8.set(n,i),(t=this.imageFrameSource)==null||t.outputFrame(i,e.width,e.height,r),{payload:e,transferables:[e.data.buffer]}}reportCameraProperties(e){this.context.setCameraProperties(e.deviceId,e.isFrontFacing,e.hasAutofocus)}requestFrameData(e){let t=this.frameDataPool.get(e);if(t==null)return{payload:{data:null,frameId:null,colorType:null}};if(t.data.buffer.byteLength===0)return this.frameDataPool.delete(e),{payload:{data:null,frameId:null,colorType:null}};let n=t.data;t.colorType===`GRAYSCALE`&&(n=k(t.data,t.width,t.height));let r={payload:{data:n,frameId:t.frameId,colorType:t.colorType},transferables:[n.buffer]};return this.frameDataPool.delete(e),r}scheduleRedraw(e,t){this.addRedrawRequest(t),this.isDrawLoopRunning||this.startDrawLoop(e)}sendViewRefreshCommands(e){this.workerFunctions.postMessage({type:`draw`,payload:e},[e.buffer])}setFrameSource(e,t){var n;this.lastUsedModuleMirrorAxis=this.mapMirrorAxisOnModule(e),(n=this.imageFrameSource)==null||n.delete(),this.imageFrameSource=new this.Module.ImageBufferFrameSource(this.lastUsedModuleMirrorAxis,t,0),this.context.setFrameSource(this.imageFrameSource)}startDrawLoop(e){this.isDrawLoopRunning=!0;let t=e=>this.redrawRequests.length>0&&this.redrawRequests[0]<=e,n=e=>{for(;this.redrawRequests.length>0&&this.redrawRequests[0]<=e;)this.redrawRequests.shift()},r=()=>{this.loopTimeoutId=setTimeout(()=>{if(!this.isDrawLoopRunning)return;let i=performance.now();if(t(i)){n(i),e.draw();let t=e.getDrawCommands();this.sendViewRefreshCommands(new Uint8Array(t))}r()},this.redrawInterval)};r()}updateContext(e){if(this.context!=null&&this.contextDeserializer!=null){e.view!=null&&!e.view.visible&&this.context.flushAnalytics();let t=this.onBeforeUpdateContextHook(e),n=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(t.context));if(n==null){let e=this.contextDeserializer.getLastError();throw Error(`Could not update the context: ${e}`)}this.context.delete(),this.context=n.getContext();let r=n.getView();n.delete(),r!=null&&t.view!=null&&(r.setViewSize(t.view.width,t.view.height,t.view.orientation),r.draw()),!this.hintPresenterV2&&this.webPlatformHintPresenter&&(this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter)),r!=null&&this.hintPresenterV2&&r.setHintPresenterV2(this.hintPresenterV2),this.gestureRecognizer!=null&&r?.setGestureRecognizer(this.gestureRecognizer),this.setView(r),this.notifyMainThreadOnViewInfoChanged(r),a.debug(`context updated`,t)}}notifyMainThreadOnViewInfoChanged(e){let t=this.getViewInfo(e);this.lastViewInfo.isSame(t)||(this.lastViewInfo.update(t),this.workerFunctions.postMessage({type:`viewSizeChanged`,payload:t}))}getViewInfo(e){if(e!=null)try{let t=JSON.parse(e.getViewInfo());if(t!=null){let e=this.getOrientationFromNumber(t.orientation);return{...t,orientation:e}}}catch(e){a.error(`Failed to get view size`,e)}return null}getOrientationFromNumber(e){switch(e){case 90:return`landscapeRight`;case 180:return`portraitUpsideDown`;case 270:return`landscapeLeft`;default:return`portrait`}}onBeforeUpdateContextHook(e){return e}onDocumentVisibilityChange(e){e===`hidden`&&this.context.flushAnalytics()}isFeatureSupported(e){return{payload:{supported:this.context.isFeatureSupported(e)}}}getViewfinderInfo(){return{payload:{isDisplayingViewfinder:this.view?.isDisplayingViewfinder()??!1,rect:JSON.parse(this.view.getViewfinderRect())}}}getOpenSourceSoftwareLicenseInfo(){return{payload:{licenseText:this.Module.OpenSourceSoftwareLicenseInfo.getLicenseText()}}}getWasmDynamicLibraries(e){return this.getWasmSideModuleFileName()==null?[]:[`${e.replace(/\/[^/]*$/,`/`)}${this.getWasmSideModuleFileName()}`]}getWasmCoreExpectedHash(e,t){return t?e?`f3b70ded9c443ff8a2fe946abb79139d5867d6ab3bfd6f2ed7ca39d0a6739733`:`c1c8b83bae31dfdd1e9428f50b354ad5e8059ea5e0c48fbebc9347b76f0bdaa5`:e?`1885e04f079c149c51b82f399d4de9d4a26c6e873485f1b79054041381f64cdd`:``}getWasmCoreFileName(e,t){return t?e?`scandit-datacapture-sdk-barcode-simd-pthreads.wasm`:`scandit-datacapture-sdk-barcode-pthreads.wasm`:e?`scandit-datacapture-sdk-barcode-simd.wasm`:``}getWasmMetadata(){return{"scandit-datacapture-sdk-barcode-pthreads.wasm":{bytes:7456647},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:7414515},"scandit-datacapture-sdk-barcode.wasm":{bytes:7520530},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:7464843}}}getWasmSideModuleFileName(){return``}_loadProgressCallback(e){this.workerFunctions.postMessage({type:`loadLibraryProgress`,payload:e})}addRedrawRequest(e){this.redrawRequests.push(Math.round(performance.now())+e),this.redrawRequests.sort((e,t)=>e-t)}contextDidChangeStatus(e){e.code===260?e.message=e.message.replace(`domain name`,`domain name (${D(location)})`):e.code===265&&(e.message=e.message.replace(`domain name`,`domain name (${this.parentDomain})`)),this.workerFunctions.postMessage({type:`contextDidChangeStatus`,payload:e})}didStartObservingContext(){this.workerFunctions.postMessage({type:`didStartObservingContext`})}mapMirrorAxisOnModule(e){switch(e){case`None`:return this.Module.Axis.None;case`X`:return this.Module.Axis.X;case`Y`:return this.Module.Axis.Y;default:return this.Module.Axis.None}}setView(e){this.view=e,this.setViewRefreshHandler(e),e??(this.isDrawLoopRunning=!1,this.sendViewRefreshCommands(new Uint8Array([])))}addNativeOverlay(e){a.warn(`addNativeOverlay has not been implemented for this module`,e)}removeNativeOverlay(e){a.warn(`removeNativeOverlay has not been implemented for this module`,e)}setViewRefreshHandler(e){if(e==null||e.isViewRefreshHandlerSet)return;let t=new(this.Module.NeedsRedrawDelegate.extend(`NeedsRedrawDelegate`,{setNeedsRedrawIn:this.scheduleRedraw.bind(this,e)}));e.setNeedsRedrawDelegate(t),e.isViewRefreshHandlerSet=!0}setupDataDecoding(){let e=this.moduleHandler.get(),t=e.DataDecoding.extend(`DataDecoding`,{decode(e,t){try{let n=JSON.parse(t),r=[];for(let t of n){let n=new TextDecoder(t.ianaName,{fatal:!0});r.push(n.decode(e.slice(t.startIndex,t.endIndex)))}return r.join(``)}catch{return``}}});e.setDataDecoding(new t)}getBatteryData(){var e;let t=(e=this.deviceInfo)==null||(e=e.batteryInfo)==null?void 0:e.percentage;if(t!=null)return{percentage:t}}isTablet(){return this.deviceInfo?.isTablet??!1}setupDeviceInterface(e,t){this.deviceInfo={isTablet:e,batteryInfo:t};let n=this.moduleHandler.get(),r=n.DeviceInterface.extend(`DeviceInterface`,{getBatteryData:this.getBatteryData.bind(this),isTablet:this.isTablet.bind(this)});this.deviceInstance=new r,n.DeviceHolder.setCurrentDevice(this.deviceInstance)}updateBatteryInfo(e){this.deviceInfo&&(this.deviceInfo.batteryInfo=e)}start(e,t,n){e&&t&&(this.setupDataDecoding(),this.moduleHandler.get().callMain(),this.moduleHandler.get().__emscripten_proxy_main===void 0&&n())}getWritableDataPath(e){return e==null?this.writableDataPathStandard:(a.debug(`IndexedDB database name override in use to recover from blocked standard database: ${e}`),e)}numOfMBToPages(e){return Math.ceil(1024*e*1024/64/1024)}async setup({libraryLocation:e,locationPath:t,writableDataPathOverride:n,indexedDBTimeoutMs:r,verifyResponseHash:i,referredOrigin:s,fixedWasmMemory:c,simdSupport:f,threadsSupport:p}){let m=!1,h=!1;this.writableDataPath=this.getWritableDataPath(n),this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,globalThis.path=t;let{resolve:g,reject:_,promise:v}=new u,y=d.sdkVersion();if(y===``)throw new o({name:`Invalid library version`,message:`Library version is not defined or empty, cannot generate proper path to library files.`});let{jsURI:b,wasmURI:x}=l(y,e,this.getWasmCoreFileName(f,p)),S={instantiateWasm:(e,t)=>(T({importObject:e,wasmURI:x,expectedHash:this.getWasmCoreExpectedHash(f,p),verifyResponseHash:i,successCallback:t,progressCallback:this._loadProgressCallback,errorCallback:e=>{_(e)},referredOrigin:s}),{})},C=c===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(c),maximum:this.numOfMBToPages(300),shared:p});return C!==null&&a.log(a.Level.Debug,`Fixed wasmMemory set`,C),this.moduleHandler.set({...C?{wasmMemory:C}:{},mainScriptUrlOrBlob:b,canvas:this.workerFunctions.getOffscreenCanvas()??{getContext:()=>null},...S,dynamicLibraries:this.getWasmDynamicLibraries(x),locateFile:t=>e+t,noInitialRun:!0,preRun:[async()=>{try{await te({writableDataPath:this.writableDataPath,indexedDBTimeoutMs:r})}catch(e){if(e.name===`BlockedIndexedDB`){_(e.toString());return}a.log(a.Level.Debug,`No IndexedDB support, some data will not be persisted:`,e)}h=!0,this.start(h,m,g)}],onMainComplete:()=>{if([m,h].includes(!1)){a.log(a.Level.Warn,{runtimeLoaded:m,fileSystemSynced:h},`Both runtimeLoaded and fileSystemSynced should be true when calling onMainComplete`),_(`onMainComplete has been called but runtime or file system was not ready.`);return}g()},onRuntimeInitialized:()=>{m=!0,this.start(h,m,g)},print:e=>{a.info(e)}}),await O(b,y)||_(`Couldn't retrieve Scandit Data Capture library at ${b}, did you configure the path for it correctly?`),v}};M.get3dPartyLicenseKeyMethodName=atob(`Z2V0QmxpbmtJZExpY2Vuc2VLZXk=`);function N(e){console.warn(`Reached unexpected case`,e)}function P(e){return typeof e==`object`&&!!e&&e.document==null&&`addEventListener`in e&&typeof e.importScripts==`function`}var F=class{constructor(e){if(typeof e!=`function`)throw TypeError(`FinalizationRegistry callback must be a function`)}register(e,t,n){}unregister(e){return!1}};function I(e){e.FinalizationRegistry===void 0&&(e.FinalizationRegistry=F)}var L=class{constructor(e,t){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=e,this.dataCaptureInstance=new M(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),P(e)&&(I(e),this.listenToMessages())}listenToMessages(){this.workerSelf.addEventListener(`message`,this.onMessageListener),this.workerSelf.addEventListener(`error`,e=>{a.log(a.Level.Error,e)}),this.workerSelf.addEventListener(`messageerror`,e=>{a.log(a.Level.Error,e)})}postMessage(e,t){this.workerSelf.postMessage(e,t??[])}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas==`function`}hasPayload(t){return e(t)&&`payload`in t}hasTransferables(t){return e(t)&&Array.isArray(t.transferables)}async respondWith(e,n,r){let i=null,a;try{a=r(),a instanceof Promise&&(a=await a)}catch(e){a=void 0,i=t(e)}let o={type:`workerTaskId`,command:e,id:n,payload:this.hasPayload(a)?a.payload:void 0};i!=null&&(o.error=i),this.postMessage(o,this.hasTransferables(a)?a.transferables:[])}onMessage(e){switch(e.data.command){case`loadLibrary`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:t.libraryLocation,locationPath:t.locationPath,referredOrigin:t.referredOrigin,writableDataPathOverride:t.writableDataPathOverride,threadsSupport:t.threadsSupport,simdSupport:t.simdSupport,verifyResponseHash:t.verifyResponseHash,fixedWasmMemory:t.fixedWasmMemory,indexedDBTimeoutMs:t.indexedDBTimeoutMs}))}break;case`onTap`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.onTap(t.point)})}break;case`hintPresenterV2update`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update()})}break;case`createContext`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.createContext({context:t.context,deviceId:t.deviceId,delayedRegistration:t.delayedRegistration,highEndBlurryRecognition:t.highEndBlurryRecognition,appName:t.appName,parentDomain:t.parentDomain,isTablet:t.isTablet,batteryInfo:t.batteryInfo}))}break;case`setFrameSource`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.setFrameSource(t.mirrorAxis,t.isCameraFrameSource))}break;case`processFrame`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.processFrame({data:t.data,frameId:t.frameId,width:t.width,height:t.height,colorType:t.colorType}))}break;case`requestFrameData`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.requestFrameData(t.frameId))}break;case`deleteFrameData`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.deleteFrameData(t.frameId)})}break;case`updateContext`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.updateContext(t))}break;case`dispose`:this.respondWith(e.data.command,e.data.id,()=>this.dataCaptureInstance.dispose());break;case`flushAnalytics`:this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.flushAnalytics()});break;case`reportCameraProperties`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.reportCameraProperties(t))}break;case`setLogLevel`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{a.setLevel(t.level)})}break;case`updateBatteryInfo`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.updateBatteryInfo(t.batteryInfo)})}break;case`extractCentaurusLicense`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.extractCentaurusLicense(t.licenseKey))}break;case`documentVisibility`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(t.state)})}break;case`isFeatureSupported`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.isFeatureSupported(t.feature))}break;case`getViewfinderInfo`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.getViewfinderInfo())}break;case`getOpenSourceSoftwareLicenseInfo`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo())}break;case`addNativeOverlay`:this.dataCaptureInstance.addNativeOverlay(e);break;case`removeNativeOverlay`:this.dataCaptureInstance.removeNativeOverlay(e);break;case`convertToJPEGResult`:{let{data:t}=e;this.dataCaptureInstance.convertToJPEGResult(t.imageId,t.result)}break;default:return N(e.data),!1}return!0}},R=class{constructor(e,t,n){this.barcodeAr=null,this.coreEngine=e,this.Module=t,this.workerFunctions=n}async forSettings(e){this.barcodeAr?.delete(),this.barcodeAr=new this.Module.BarcodeAr(this.coreEngine.context,JSON.stringify(e));let t=this.Module.BarcodeArListener.extend(`BarcodeArListener`,{didUpdateSession:(e,t,n)=>{let r=this.coreEngine.prepareFrameForListener(n);this.workerFunctions.postMessage({type:`barcodeArDidUpdateSession`,payload:{session:JSON.parse(t.toJson()),frameData:r}}),e.delete(),t.delete(),n.delete()}});this.barcodeAr.addListener(new t,1),this.Module.addBarcodeArToContext(this.coreEngine.context,this.barcodeAr)}start(){this.barcodeAr?.start()}pause(){this.barcodeAr?.pause()}stop(){this.barcodeAr?.stop()}setEnabled(e){this.barcodeAr?.setEnabled(e)}async removeMode(){this.barcodeAr!=null&&this.Module.removeBarcodeArFromContext(this.coreEngine.context,this.barcodeAr)}applySettings(e){this.barcodeAr?.applySettings(JSON.stringify(e))}},z=class{constructor(e,t,n){this.trackingListenerSet=!1,this.coreEngine=e,this.Module=t,this.workerFunctions=n,this.setup()}barcodeBatchDidUpdateSession(e){this.workerFunctions.postMessage({type:`barcodeBatchDidUpdateSession`,payload:JSON.parse(e.toJson())})}getBatchDeserializer(){return this.barcodeBatchDeserializer}setup(){let e=this.Module.BarcodeBatchListener.extend(`BarcodeTrackingListener`,{didUpdateSession:(e,t,n)=>{this.barcodeBatchDidUpdateSession(t),e.delete(),t.delete(),n.delete()},onTrackedBarcodeTapped:(e,t)=>{this.onTrackedBarcodeTapped(t),e.delete(),t.delete()}}),t=this.Module.BarcodeBatchDeserializerListener.extend(`BarcodeTrackingDeserializerListener`,{onModeDeserializationFinished:(t,n,r)=>{this.trackingListenerSet||=(n.addListener(new e,1),!0),t.delete(),n.delete(),r.delete()},onModeDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationFinished(e,t,n){e.delete(),t.delete(),n.delete()}});this.barcodeBatchDeserializer=new this.Module.BarcodeBatchDeserializer,this.barcodeBatchDeserializer.setListener(new t)}onTrackedBarcodeTapped(e){this.workerFunctions.postMessage({type:`didTapTrackedBarcode`,payload:JSON.parse(e.toJson())})}},B=class{constructor(e,t,n){this.captureListenerSet=!1,this.coreEngine=e,this.Module=t,this.workerFunctions=n,this.setup()}barcodeCaptureDidUpdateSession(e){this.workerFunctions.postMessage({type:`barcodeCaptureDidUpdateSession`,payload:JSON.parse(e.toJson())})}barcodeBatchDidUpdateSession(e){this.workerFunctions.postMessage({type:`barcodeBatchDidUpdateSession`,payload:JSON.parse(e.toJson())})}getCaptureDeserializer(){return this.barcodeCaptureDeserializer}getTrackingDeserializer(){return this.barcodeBatchDeserializer}setup(){let e=this.Module.BarcodeCaptureListener.extend(`BarcodeCaptureListener`,{didScan:(e,t,n)=>{this.barcodeCaptureDidScan(t,n),e.delete(),n.delete(),t.delete()},didUpdateSession:(e,t,n)=>{this.barcodeCaptureDidUpdateSession(t),e.delete(),n.delete(),t.delete()}}),t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.successFeedback()}}),n=new e,r=new t,i=this.Module.BarcodeCaptureDeserializerListener.extend(`BarcodeCaptureDeserializerListener`,{onModeDeserializationFinished:(e,t,i)=>{t.addListener(n,1),t.setSuccessFeedback(r),e.delete(),t.delete(),i.delete()},onModeDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationFinished(e,t,n){e.delete(),t.delete(),n.delete()}});this.barcodeCaptureDeserializer=new this.Module.BarcodeCaptureDeserializer,this.barcodeCaptureDeserializer.setListener(new i)}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}barcodeCaptureDidScan(e,t){let n=this.coreEngine.prepareFrameForListener(t);this.workerFunctions.postMessage({type:`barcodeCaptureDidScan`,payload:{session:JSON.parse(e.toJson()),frameData:n}})}};function V(e){return e.charAt(0).toUpperCase()+e.slice(1)}function H(e){return e}var U=class{constructor(e,t,a){this.barcodeFind=null,this.basicOverlay=null,this.transparentGuidanceHintStyle={backgroundColor:`00000000`,cornerRadius:4,fitToText:!1,isAnimatedToView:!1,textAlignment:n.Center,hintIcon:r.None,hintAnchor:i.Center,hintAnchorOffset:0,horizontalMargin:0,iconColor:`00000000`,lineHeight:-1,maxLines:1,maxWidthFraction:.8,textColor:`ffffffff`,textSize:15,textWeight:600},this.customerTransformation=H,this.coreEngine=e,this.Module=t,this.workerFunctions=a}async forSettings(e){this.barcodeFind?.delete(),this.barcodeFind=new this.Module.BarcodeFind(this.coreEngine.context,JSON.stringify(e));let t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.listUpdatedFeedback()}}),n=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.barcodeFindFeedback()}}),r=this.Module.BarcodeFindTransformer.extend(`BarcodeFindTransformer`,{transformBarcodeData:e=>this.customerTransformation(e)}),i=this.Module.BarcodeFindListener.extend(`BarcodeFindListener`,{didUpdateSession:(e,t,n)=>{let r=this.coreEngine.prepareFrameForListener(n);this.workerFunctions.postMessage({type:`barcodeFindDidUpdateSession`,payload:{session:JSON.parse(t.toJson()),frameData:r}}),e.delete(),t.delete(),n.delete()},onSearchPaused:e=>{let t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));this.workerFunctions.postMessage({type:`barcodeFindSearchPaused`,payload:{foundItems:t}})},onSearchStopped:e=>{let t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));this.workerFunctions.postMessage({type:`barcodeFindSearchStopped`,payload:{foundItems:t}})},onSearchStarted:()=>{this.workerFunctions.postMessage({type:`barcodeFindSearchStarted`,payload:{}})}});this.barcodeFind.setBarcodeFindTransformer(new r),this.barcodeFind.addListener(new i,1),this.barcodeFind.setItemListUpdatedFeedback(new t),this.barcodeFind.setFeedback(new n),this.Module.addBarcodeFindToContext(this.coreEngine.context,this.barcodeFind)}barcodeFindFeedback(){this.workerFunctions.postMessage({type:`barcodeFindFeedback`,payload:{}})}start(){this.barcodeFind?.start()}stop(){this.barcodeFind?.stop()}pause(){this.barcodeFind?.pause()}setEnabled(e){this.barcodeFind?.setEnabled(e)}setItemList(e){this.barcodeFind?.setItemList(JSON.stringify(e))}async removeMode(){this.barcodeFind!=null&&this.Module.removeBarcodeFindFromContext(this.coreEngine.context,this.barcodeFind)}addBasicOverlay(){this.basicOverlay?.delete(),this.basicOverlay=null,this.barcodeFind!=null&&(this.basicOverlay=new this.Module.BarcodeFindBasicOverlay(this.barcodeFind)),this.coreEngine.view!=null&&this.basicOverlay!=null&&(this.basicOverlay.setGuidanceHandler(this.createWebFindGuidanceHandler()),this.Module.addBarcodeFindBasicOverlayToView(this.coreEngine.view,this.basicOverlay))}removeBasicOverlay(){this.coreEngine.view!=null&&this.basicOverlay!=null&&this.Module.removeBarcodeFindBasicOverlayFromView(this.coreEngine.view,this.basicOverlay)}async applySettings(e){this.barcodeFind?.applySettings(JSON.stringify(e))}updateBasicOverlay(e){let t=Object.entries(e).filter(([e,t])=>e!==`type`);for(let[e,n]of t){let t=`set${V(e)}`;this.basicOverlay!=null&&typeof this.basicOverlay[t]==`function`&&n!=null&&this.basicOverlay[t](n)}}setTransformerFunction(e){this.customerTransformation=e??H}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}listUpdatedFeedback(){this.workerFunctions.postMessage({type:`barcodeFindListUpdatedFeedback`,payload:{}})}setToast(e,t){let n=this.coreEngine.hintPresenterV2;e?n?.showToast(JSON.stringify(t)):n?.hideToast(t.tag)}setGuidance(e,t,n){let r={tag:n,text:t,hintStyle:this.transparentGuidanceHintStyle};this.workerFunctions.postMessage({type:e?`showGuidance`:`hideGuidance`,payload:r})}createWebFindGuidanceHandler(){return new(this.Module.BarcodeFindGuidanceHandler.extend(`BarcodeFindGuidanceHandler`,{setInitialGuidance:(e,t)=>{this.setGuidance(e,t,`InitialGuidance`)},setMoveCloserGuidance:(e,t)=>{this.setGuidance(!1,t,`InitialGuidance`),this.setGuidance(e,t,`MoveCloserGuidance`)},setTapShutterToPause:(e,t)=>{this.setGuidance(!1,t,`InitialGuidance`),this.setGuidance(e,t,`TapShutterToPause`)},setTapShutterToResume:(e,t)=>{this.setGuidance(!1,t,`InitialGuidance`),this.setGuidance(e,t,`TapShutterResume`)}}))}},W=class{constructor(e){this.subscribers=new Set,this.property={key:e,value:null}}addSubscriber(e){this.subscribers.add(e),e.onPropertyChanged?.(this.property)}removeSubscriber(e){this.subscribers.delete(e)}setProperty(e){if(this.property.value!==e.value){this.property={key:this.property.key,value:e.value};for(let e of this.subscribers)e.onPropertyChanged?.(this.property)}}};let G={torch_state:new W(`torch_state`),scanning_mode:new W(`scanning_mode`),sound_enabled:new W(`sound_enabled`),haptic_enabled:new W(`haptic_enabled`),session_stop_reason:new W(`session_stop_reason`),camera_position:new W(`camera_position`)};var K=class{getBehaviorSubject(e){return G[e]}},q=class{constructor(e,t,n){this.captureListenerSet=!1,this.propertyPushSource=new K,this.coreEngine=e,this.Module=t,this.workerFunctions=n,this.setup()}sparkScanDidUpdateSession(e){this.workerFunctions.postMessage({type:`sparkScanDidUpdateSessio