@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
6 lines • 65 kB
JavaScript
(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`}let n;(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})(n||={});var r=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 i(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 a(e){let t=/@scandit\/web-datacapture-[a-z]+/i.exec(e);return t?t[0]:null}function o(e,t,n){let r=t,o=i(r);if(o.result){let t=a(r);t!=null&&(r=`${o.cdnBaseURL}${t}@${e}/sdc-lib/`)}let s=n.replace(`.wasm`,``);return o.result?{jsURI:`${r}${s}.js`,wasmURI:`${r}${s}.wasm`}:{jsURI:`${r}${s}.js?v=${e}`,wasmURI:`${r}${s}.wasm?v=${e}`}}(function(e){return e[e.Free=0]=`Free`,e[e.Writing=1]=`Writing`,e[e.Ready=2]=`Ready`,e[e.Processing=3]=`Processing`,e})({});var s=class e{constructor(e,t,n,r){this.getHeapBuffer=e,this.memAddressSlotByteLength=t,this.stateBuffer=n,this.addressBuffer=r,this._staleAddressDetected=!1}static create(t){let n=new Int32Array(new SharedArrayBuffer(t.memAddressSlotCount*Int32Array.BYTES_PER_ELEMENT)),r=new Uint32Array(new SharedArrayBuffer(t.memAddressSlotCount*Uint32Array.BYTES_PER_ELEMENT));for(let e=0;e<t.memAddressSlotCount;e++)Atomics.store(r,e,t.allocateUint8Array(t.memAddressSlotByteLength));return new e(t.getHeapBuffer,t.memAddressSlotByteLength,n,r)}static attach(t){return new e(()=>t.heapBuffer,t.memAddressSlotByteLength,new Int32Array(t.stateSharedBuffer),new Uint32Array(t.addressSharedBuffer))}get hasStaleAddresses(){return this._staleAddressDetected}get memAddressSlotCount(){return this.stateBuffer.length}get buffers(){return{stateSharedBuffer:this.stateBuffer.buffer,addressSharedBuffer:this.addressBuffer.buffer,heapBuffer:this.getHeapBuffer(),memAddressSlotByteLength:this.memAddressSlotByteLength}}viewFor(e){return new Uint8ClampedArray(this.getHeapBuffer(),e,this.memAddressSlotByteLength)}claimFreeMemAddressSlot(){for(let e=0;e<this.stateBuffer.length;e++)if(Atomics.compareExchange(this.stateBuffer,e,0,1)===0){let t=Atomics.load(this.addressBuffer,e);return t+this.memAddressSlotByteLength>this.getHeapBuffer().byteLength?(this._staleAddressDetected=!0,this.abandon(e),null):{index:e,address:t,view:this.viewFor(t)}}return null}markReady(e){let t=Atomics.compareExchange(this.stateBuffer,e,1,2);if(t!==1)throw Error(`SharedFrameMemAddressSlotPool: cannot mark memAddressSlot ${e} ready from state ${t}`)}abandon(e){let t=Atomics.compareExchange(this.stateBuffer,e,1,0);if(t!==1)throw Error(`SharedFrameMemAddressSlotPool: cannot abandon memAddressSlot ${e} from state ${t}`)}beginProcessing(e){if(Atomics.compareExchange(this.stateBuffer,e,2,3)!==2)return null;let t=Atomics.load(this.addressBuffer,e);return{index:e,address:t,view:this.viewFor(t)}}release(e,t){let n=Atomics.load(this.stateBuffer,e);if(n!==3)throw Error(`SharedFrameMemAddressSlotPool: cannot release memAddressSlot ${e} from state ${n}`);for(let n=0;n<this.addressBuffer.length;n++)if(Atomics.load(this.addressBuffer,n)===t)throw Error(`SharedFrameMemAddressSlotPool: replacement address ${t} for memAddressSlot ${e} is already in use by memAddressSlot ${n} — addresses must never be reused`);Atomics.store(this.addressBuffer,e,t),Atomics.store(this.stateBuffer,e,0)}dispose(e){for(let t=0;t<this.addressBuffer.length;t++)e(Atomics.load(this.addressBuffer,t))}},c=class{constructor(){this.promise=new Promise((e,t)=>{this.reject=t,this.resolve=e})}};let l;(function(e){function t(){return`8.6.0`}e.sdkVersion=t})(l||={});let u={};function d(e){return[...new Uint8Array(e)].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join(``)}async function*f(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 p(e){let t=[],n=0,r=0;for await(let r of f(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 m(e,t,r){if(typeof crypto.subtle.digest!=`function`)return n.log(n.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 ${r} could not be verified`),`NOT_VERIFIABLE`;try{let i=e instanceof Promise?await e:e,a=d(await crypto.subtle.digest(`SHA-256`,i));return t==null?(n.log(n.Level.Warn,`The library hash is not defined or empty, cannot correctly verify integrity.`),`NOT_VERIFIABLE`):a===t?(n.log(n.Level.Debug,`Data Capture library WASM integrity found at ${r} has been verified correctly.`),`VALID`):(n.log(n.Level.Warn,`The Scandit Data Capture library WASM file found at ${r} seems invalid: expected file hash doesn't match (received: ${a}, expected: ${t}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),`INVALID`)}catch(e){return n.log(n.Level.Warn,`Wasm response could not be verified`,e),`NOT_VERIFIABLE`}}let h=new Map([[`br`,4.4],[`gzip`,2.9],[`none`,1]]);function g(e){let t=`content-encoding`;if(e==null||e.get(t)==null)return h.get(`none`);let n=new Set((e.get(t)??``).split(`,`).map(e=>e.trim()));for(let[e,t]of h)if(n.has(e))return t;return h.get(`none`)}function _(e){if(e==null)return 0;let t=g(e)??1,n=Number.parseInt(e.get(`content-length`)??`0`,10);return Number.isNaN(n)?0:Math.floor(n*t*100)/100}function v(e){let{pathname:t}=new URL(e);for(let[e,n]of Object.entries(u))if(t.endsWith(e))return n.bytes;return 0}function y(e){u=e}let b=(e,t)=>{let n=_(t);return n===0?v(e):n};function x(e,t,r,{onProgress:i,onError:a,onComplete:o}){if(!t.body)return[t];let s=b(e,t.headers),c=0,l=0;if(typeof TransformStream>`u`)return n.warn(`TransformStream is not supported in this environment. Progress tracking will be disabled.`),[t];let[u,d]=r?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?i?.({percentage:l,loadedBytes:c,privateUri:e}):s===0&&t.length>0&&i?.({percentage:null,loadedBytes:c,privateUri:e}),n.enqueue(t)}catch(e){n.error(e),a?.({error:e})}},flush(t){i?.({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 S({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]=x(e,s,n,{onProgress:r,onError:a,onComplete:i});return l!=null&&m(p(l),t,e),c}function C({wasmURI:e,expectedHash:t,verifyResponseHash:r,progressCallback:i,successCallback:a,errorCallback:o,importObject:s,referredOrigin:c}){async function l(l){try{let n=await S({wasmURI:e,expectedHash:t,verifyResponseHash:r,onProgress:i,referredOrigin:c}),o=await(l??n).arrayBuffer(),u=await globalThis.WebAssembly.instantiate(o,s);a(u.instance,u.module)}catch(t){n.log(n.Level.Error,t),n.log(n.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 S({wasmURI:e,expectedHash:t,verifyResponseHash:r,onProgress:i,referredOrigin:c});let n=await globalThis.WebAssembly.instantiateStreaming(o,s);a(n.instance,n.module)}catch(e){n.log(n.Level.Warn,e),n.log(n.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 w(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(()=>{w(e,s,n,r).then(i).catch(a)},t)})})}function T(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 E(e){let t;try{let i=new Promise((i,a)=>{t=setTimeout(()=>{n.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).`),a(new r({name:`BlockedIndexedDB`,message:`IndexedDB database is blocked`}))},e)}),a=new Promise((e,t)=>{FS.syncfs(!0,n=>{n==null?e():t(n)})});await Promise.race([a,i])}finally{t!==void 0&&clearTimeout(t)}}async function ee(e){try{FS.mkdir(e.writableDataPath)}catch(e){if(e.code!==`EEXIST`)throw e}return FS.mount(IDBFS,{autoPersist:!0},e.writableDataPath),E(e.indexedDBTimeoutMs)}async function D(e,t){function r(e){try{return new URL(e,self.location.href).origin!==self.location.origin}catch(t){return n.log(n.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 i(t){n.log(n.Level.Warn,t),n.log(n.Level.Warn,`Couldn't retrieve Scandit Data Capture library at ${e}, retrying...`)}try{if(r(e)){let t=await w(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,i),n=URL.createObjectURL(t);try{await importScripts(n)}finally{URL.revokeObjectURL(n)}self.Module.mainScriptUrlOrBlob=t}else await w(async()=>importScripts(e),250,4e3,i),self.Module.mainScriptUrlOrBlob=e;let a=globalThis.SDC_WASM_JS_VERSION;return a!==t&&n.log(n.Level.Warn,`The Scandit Data Capture library JS file found at ${e} seems invalid: expected version doesn't match (received: ${a}, expected: ${t}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(e){return n.log(n.Level.Error,e),!1}}function O(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 k=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 c;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 r=this.conversions.get(e);r?(r.resolve(t),this.conversions.delete(e)):n.warn(`ImageConverterForwarder: Conversion for imageId ${e} not found in Map`)}},A=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 n.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(),r=e.getHeight(),i=e.getPlanes();if(t<=0||r<=0)throw n.warn(`Invalid image dimensions: ${t}x${r}`),Error(`Invalid image dimensions: ${t}x${r}`);if(!i||i.length===0)throw n.warn(`ImageBuffer has no planes`),Error(`ImageBuffer has no planes`);return{width:t,height:r,planes:i}}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,r){if(e.width!==t||e.height!==r)throw n.warn(`ImageData dimensions mismatch: expected ${t}x${r}, got ${e.width}x${e.height}`),Error(`ImageData dimensions mismatch`);if(!e.data||e.data.length!==t*r*4)throw n.warn(`ImageData has invalid data length: expected ${t*r*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 n.warn(`Failed to put image data on canvas: ${e}`),Error(`Failed to put image data on canvas: ${e}`)}let r=t===0?this.canvas:this.applyRotation(this.canvas,t),i;try{i=await this.canvasToBlob(r)}catch(e){throw n.warn(`Failed to convert canvas to blob: ${e}`),Error(`Failed to convert canvas to blob: ${e}`)}if(!i||i.size===0)throw n.warn(`Canvas convertToBlob returned empty or null blob`),Error(`Failed to create JPEG blob`);let a;try{a=await i.arrayBuffer()}catch(e){throw n.warn(`Failed to get array buffer from blob: ${e}`),Error(`Failed to get array buffer from blob: ${e}`)}if(!a||a.byteLength===0)throw n.warn(`Blob arrayBuffer returned empty or null buffer`),Error(`Failed to get array buffer from blob`);return new Uint8Array(a)}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 n.warn(`Failed to create HTMLCanvasElement`,e),!1}}createImageDataFromBuffer(e,t,r,i){let a=new Set(t.map(e=>e.channel));try{if(this.isYUVFormat(a)){let t=e.toBitmap();return!t||t.length!==r*i*4?(n.warn(`Invalid bitmap data from toBitmap(): expected ${r*i*4} bytes, got ${t?.length||0}`),null):new ImageData(new Uint8ClampedArray(t),r,i)}if(this.isRGBAFormat(a))return this.createImageDataFromRGBAPlanes(t,r,i);if(this.isRGBFormat(a))return this.createImageDataFromRGBPlanes(t,r,i);if(this.isGrayscaleFormat(a))return this.createImageDataFromGrayscalePlanes(t,r,i);n.warn(`Unknown image format with channels: ${Array.from(a).join(`, `)}, falling back to toBitmap()`);let o=e.toBitmap();if(!o||o.length===0)return n.warn(`toBitmap() returned empty or null data`),null;let s=o.length/(r*i);return s===4?new ImageData(new Uint8ClampedArray(o),r,i):(n.warn(`Unsupported format: ${s} bytes per pixel`),null)}catch(e){return n.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,r){let i=e.find(e=>e.channel===3),a=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5),s=e.find(e=>e.channel===6);if(!i||!a||!o||!s)return n.warn(`Missing RGBA planes`),null;let c=new Uint8ClampedArray(t*r*4);for(let e=0;e<r;e++)for(let n=0;n<t;n++){let r=(e*t+n)*4;c[r]=this.getPixelFromPlane(i,n,e),c[r+1]=this.getPixelFromPlane(a,n,e),c[r+2]=this.getPixelFromPlane(o,n,e),c[r+3]=this.getPixelFromPlane(s,n,e)}return new ImageData(c,t,r)}createImageDataFromRGBPlanes(e,t,r){let i=e.find(e=>e.channel===3),a=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5);if(!i||!a||!o)return n.warn(`Missing RGB planes`),null;let s=new Uint8ClampedArray(t*r*4);for(let e=0;e<r;e++)for(let n=0;n<t;n++){let r=(e*t+n)*4;s[r]=this.getPixelFromPlane(i,n,e),s[r+1]=this.getPixelFromPlane(a,n,e),s[r+2]=this.getPixelFromPlane(o,n,e),s[r+3]=255}return new ImageData(s,t,r)}createImageDataFromGrayscalePlanes(e,t,r){let i=e.find(e=>e.channel===0);if(!i)return n.warn(`Missing Y plane for grayscale`),null;let a=new Uint8ClampedArray(t*r*4);for(let e=0;e<r;e++)for(let n=0;n<t;n++){let r=(e*t+n)*4,o=this.getPixelFromPlane(i,n,e);a[r]=o,a[r+1]=o,a[r+2]=o,a[r+3]=255}return new ImageData(a,t,r)}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}};A.JPEG_IMAGE_MIME_TYPE=`image/jpeg`;var te=class extends A{getNewCanvas(e,t){return new OffscreenCanvas(e,t)}canvasToBlob(e){return e.convertToBlob({type:A.JPEG_IMAGE_MIME_TYPE,quality:this.options.quality})}},ne=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}},j=class e{constructor(e,t){this.hintPresenterV2=null,this.threadsSupport=!0,this.insufficientMultithreadingReported=!1,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,frameHandoffTotalMicros:0,frameHandoffCount:0},this.frameProcessingStartedCount=0,this.frameProcessingFinishedCount=0,this.gestureListener=null,this.webPlatformHintPresenter=null,this.deviceInstance=null,this.deviceInfo=null,this.lastViewInfo=new ne(null),this.lastFrameProcessingStartedCount=0,this.lastFrameProcessingFinishedCount=0,this.moduleHandler=e,this.workerFunctions=t,this._loadProgressCallback=this._loadProgressCallback.bind(this),y(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&&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=T(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.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(),this.insufficientMultithreadingReported=!1,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 k&&this.webImageConverterInstance.onConvertToJPEGResult(e,t)}getImageConverterInstance(e){return this.workerFunctions.getOffscreenCanvas()==null?new k(this.workerFunctions,e):new te(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.performanceMetrics.frameHandoffTotalMicros=0,this.performanceMetrics.frameHandoffCount=0,this.lastMetricsReportTime=e),this._isDrawLoopRunning?this.scheduleMetricsReporting():this.performanceMetricsReporterTimer=void 0}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,frameHandoffTotalMicros:this.performanceMetrics.frameHandoffTotalMicros,frameHandoffCount:this.performanceMetrics.frameHandoffCount};this.workerFunctions.postMessage({type:`performanceMetricsReport`,payload:n})}deleteFrameData(e){this.frameDataPool.delete(e)}dispose(){var e,t,n,r,i,a;this.context.dispose(),(e=this.sharedFrameMemAddressSlotPool)==null||e.dispose(e=>this.Module.deleteUint8Array(e)),this.sharedFrameMemAddressSlotPool=void 0,this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.cleanupMetricsReporting(),(t=this.gestureRecognizer)==null||t.delete(),this.gestureRecognizer=null,(n=this.gestureListener)==null||n.delete(),this.gestureListener=null,(r=this.hintPresenterV2)==null||r.delete(),this.hintPresenterV2=null,(i=this.webPlatformHintPresenter)==null||i.delete(),this.webPlatformHintPresenter=null,(a=this.deviceInstance)==null||a.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()}reportInsufficientMultithreadingIfNeeded(e){if(this.threadsSupport||this.insufficientMultithreadingReported)return;this.insufficientMultithreadingReported=!0;let t=new this.Module.InsufficientMultithreadingAnalyticsData(e);this.Module.InsufficientMultithreadingAnalyticsHelper.storeAnalyticsEvent(this.context,t),t.delete()}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 n.debug(`[processFrame] Context is null, returning frame without processing`),{payload:e,transferables:[e.data.buffer]};this.lastFrameId=e.frameId;let r=e.data,i=e.colorType===`GRAYSCALE`?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;this.lastFrameColorType=e.colorType===`GRAYSCALE`?`GRAYSCALE`:`RGBA`;let a=this.Module.allocateUint8Array(r.byteLength);return this.Module.HEAPU8.set(r,a),(t=this.imageFrameSource)==null||t.outputFrame(a,e.width,e.height,i),{payload:e,transferables:[e.data.buffer]}}negotiateSharedFramePath(e){var t;return this.Module.HEAPU8.buffer instanceof SharedArrayBuffer?((t=this.sharedFrameMemAddressSlotPool)==null||t.dispose(e=>this.Module.deleteUint8Array(e)),this.sharedFrameMemAddressSlotPool=s.create({memAddressSlotCount:e.memAddressSlotCount,memAddressSlotByteLength:e.memAddressSlotByteLength,allocateUint8Array:e=>this.Module.allocateUint8Array(e),getHeapBuffer:()=>this.Module.HEAPU8.buffer}),{payload:this.sharedFrameMemAddressSlotPool.buffers}):{payload:null}}processFrameFromMemAddressSlot(e){var t;if(this.context==null||this.sharedFrameMemAddressSlotPool==null)return;let n=this.sharedFrameMemAddressSlotPool.beginProcessing(e.memAddressSlotIndex);if(n==null)return;this.lastFrameId=e.frameId,this.lastFrameColorType=e.colorType===`GRAYSCALE`?`GRAYSCALE`:`RGBA`;let r=e.colorType===`GRAYSCALE`?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;(t=this.imageFrameSource)==null||t.outputFrame(n.address,e.width,e.height,r);let i=this.Module.allocateUint8Array(this.sharedFrameMemAddressSlotPool.buffers.memAddressSlotByteLength);this.sharedFrameMemAddressSlotPool.release(n.index,i)}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=O(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),r=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(t.context));if(r==null){let e=this.contextDeserializer.getLastError();throw Error(`Could not update the context: ${e}`)}this.context.delete(),this.context=r.getContext(),this.insufficientMultithreadingReported=!1;let i=r.getView();r.delete(),i!=null&&t.view!=null&&(i.setViewSize(t.view.width,t.view.height,t.view.orientation),i.draw()),!this.hintPresenterV2&&this.webPlatformHintPresenter&&(this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter)),i!=null&&this.hintPresenterV2&&i.setHintPresenterV2(this.hintPresenterV2),this.gestureRecognizer!=null&&i?.setGestureRecognizer(this.gestureRecognizer),this.setView(i),this.notifyMainThreadOnViewInfoChanged(i),n.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){n.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?`c8f403533e1c4422e7dbd309975f1b6796d317ec9423c8e3b3fb92e51d8710b3`:`75610fc67d4be5f4fc7389a642f08edeac85c1729229944783d877bfb31081c6`:e?`baebc48ef54d8e530217c124128de3256924b94e24c15639df896f5de72082fe`:``}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:7733852},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:7685873},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:7743614},"scandit-datacapture-sdk-barcode.wasm":{bytes:7805987}}}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 (${T(location)})`):e.code===265?e.message=e.message.replace(`domain name`,`domain name (${this.parentDomain})`):e.code===28&&(e.message+=` Resource files were expected at "${this.resourcePath}". This can be caused by a version mismatch, e.g. a browser or CDN cache still holding files from a previous SDK version. Please ensure the correct Scandit Data Capture resource files (with correct version) are retrieved.`),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){n.warn(`addNativeOverlay has not been implemented for this module`,e)}removeNativeOverlay(e){n.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:(n.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:i,indexedDBTimeoutMs:a,verifyResponseHash:s,referredOrigin:u,fixedWasmMemory:d,simdSupport:f,threadsSupport:p}){let m=!1,h=!1;this.threadsSupport=p,this.writableDataPath=this.getWritableDataPath(i),this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,globalThis.path=t;let{resolve:g,reject:_,promise:v}=new c,y=l.sdkVersion();if(y===``)throw new r({name:`Invalid library version`,message:`Library version is not defined or empty, cannot generate proper path to library files.`});let{jsURI:b,wasmURI:x}=o(y,e,this.getWasmCoreFileName(f,p)),S={instantiateWasm:(e,t)=>(C({importObject:e,wasmURI:x,expectedHash:this.getWasmCoreExpectedHash(f,p),verifyResponseHash:s,successCallback:t,progressCallback:this._loadProgressCallback,errorCallback:e=>{_(e)},referredOrigin:u}),{})},w=d===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(d),maximum:this.numOfMBToPages(300),shared:p});return w!==null&&n.log(n.Level.Debug,`Fixed wasmMemory set`,w),this.moduleHandler.set({...w?{wasmMemory:w}:{},mainScriptUrlOrBlob:b,canvas:this.workerFunctions.getOffscreenCanvas()??{getContext:()=>null},...S,dynamicLibraries:this.getWasmDynamicLibraries(x),locateFile:t=>e+t,noInitialRun:!0,preRun:[async()=>{try{await ee({writableDataPath:this.writableDataPath,indexedDBTimeoutMs:a})}catch(e){if(e.name===`BlockedIndexedDB`){_(e.toString());return}n.log(n.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)){n.log(n.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=>{n.info(e)}}),await D(b,y)||_(`Couldn't retrieve Scandit Data Capture library at ${b}, did you configure the path for it correctly?`),v}};j.get3dPartyLicenseKeyMethodName=atob(`Z2V0QmxpbmtJZExpY2Vuc2VLZXk=`);function M(e){console.warn(`Reached unexpected case`,e)}function N(e){return typeof e==`object`&&!!e&&e.document==null&&`addEventListener`in e&&typeof e.importScripts==`function`}var P=class{constructor(e){if(typeof e!=`function`)throw TypeError(`FinalizationRegistry callback must be a function`)}register(e,t,n){}unregister(e){return!1}};function F(e){e.FinalizationRegistry===void 0&&(e.FinalizationRegistry=P)}var I=class{constructor(e,t){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=e,this.dataCaptureInstance=new j(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),N(e)&&(F(e),this.listenToMessages())}listenToMessages(){this.workerSelf.addEventListener(`message`,this.onMessageListener),this.workerSelf.addEventListener(`error`,e=>{n.log(n.Level.Error,e)}),this.workerSelf.addEventListener(`messageerror`,e=>{n.log(n.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,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`negotiateSharedFramePath`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.negotiateSharedFramePath({memAddressSlotByteLength:t.memAddressSlotByteLength,memAddressSlotCount:t.memAddressSlotCount}))}break;case`processFrameFromMemAddressSlot`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.processFrameFromMemAddressSlot({memAddressSlotIndex:t.memAddressSlotIndex,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,()=>{n.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 M(e.data),!1}return!0}},L=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.toJsonIgnoringLicense()),frameData:r}}),e.delete(),t.delete(),n.delete()}});this.barcodeAr.addListener(new t,1),this.Module.addBarcodeArToContext(this.coreEngine.context,this.barcodeAr),this.coreEngine.reportInsufficientMultithreadingIfNeeded(`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))}},R=class{constructor(e,t,n){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=new(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)=>{n.addListener(e,1),this.coreEngine.reportInsufficientMultithreadingIfNeeded(`BarcodeBatch`),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())})}},z=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 B(e){return e.charAt(0).toUpperCase()+e.slice(1)}function V(e){return e}var H=class{constructor(e,t,n){this.barcodeFind=null,this.basicOverlay=null,this.transparentGuidanceHintStyle={backgroundColor:`00000000`,cornerRadius:4,fitToText:!1,isAnimatedToView:!1,textAlignment:`center`,hintIcon:`none`,hintAnchor:`center`,hintAnchorOffset:0,horizontalMargin:0,iconColor:`00000000`,lineHeight:-1,maxLines:1,maxWidthFraction:.8,textColor:`ffffffff`,textSize:15,textWeight:600},this.customerTransformation=V,this.coreEngine=e,this.Module=t,this.workerFunctions=n}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.toJsonIgnoringLicense()),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),this.coreEngine.reportInsufficientMultithreadingIfNeeded(`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${B(e)}`;this.basicOverlay!=null&&typeof this.basicOverlay[t]==`function`&&n!=null&&this.basicOverlay[t](n)}}setTransformerFunction(e){this.customerTransformation=e??V}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`)}}))}},U=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 W={torch_state:new U(`torch_state`),scanning_mode:new U(`scanning_mode`),sound_enabled:new U(`sound_enabled`),haptic_enabled:new U(`haptic_enabled`),session_stop_reason:new U(`session_stop_reason`),camera_position:new U(`camera_position`)};var G=class{getBehaviorSubject(e){return W[e]}},K=class{constructor(e,t,n){this.captureListenerSet=!1,this.propertyPushSource=new G,this.coreEngine=e,this.Module=t,this.workerFunctions=n,this.setup()}sparkScanDidUpdateSession(e){this.workerFunctions.postMessage({type:`sparkScanDidUpdateSession`,payload:JSON.parse(e.toJson())})}getSparkScanDeserializer(){return this.sparkScanDeserializer}setup(){let e=this.Module.SparkScanListener.extend(`SparkScanListener`,{didScan:(e,t,n)=>{this.sparkScanDidScan(t,n),e.delete(),t.delete(),n.delete()},didUpdateSession:(e,t,n)=>{this.sparkScanDidUpdateSession(t),e.delete(),t.delete(),n.delete()}}),t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.successFeedback()}}),n=this.Module.SparkScanDeserializerListener.extend(`SparkScanDeserializerListener`,{onModeDeserializationFinished:(n,r,i)=>{if(!this.captureListenerSet){r.addListener(new e,1),r.setSuccessFeedback(new t),r.setPropertyPushSource(this.propertyPushSource);let n=new(this.Module.SparkScanViewHandlerDelegate.extend(`SparkScanViewHandlerDelegate`,{onSwitchedAwayFromSmartScanSelection:()=>{this.workerFunctions.postMessage({type:`sparkScanSwitchedAwayFromSmartScanSelection`})},onSwitchedToSmartScanSelection:()=>{this.workerFunctions.postMessage({type:`sparkScanSwitchedToSmartScanSelection`})},enableHapticWhenOverlapping:()=>{},onStateTransition:()=>{},resetAllTimers:()=>{}})),i=r.getStateMachine();i.setViewHandlerDelegate(n),n.delete(),i.delete(),this.sparkScan=r.clone(),this.captureListenerSet=!0}this.coreEngine.reportInsufficientMultithreadingIfNeeded(`SparkScan`),n.delete(),i.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()},onOverlayDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onOverlayDeserializationFinished:(e,t,n)=>{this.sparkScanOverlay?.delete(),this.sparkScanOverlay=t,e.delete(),n.delete()}});this.sparkScanDeserializer=new this.Module.SparkScanDeserializer,this.sparkScanDeserializer.setListener(new n)}emitErrorFeedback(e){this.sparkScanOverlay?.onErrorFeedbackEmitted(e)}overlayReadyForDraw(){this.sparkScanOverlay?.onReadyForNewData()}discardEnqueuedData(){this.sparkScanOverlay?.discardEnqueuedData()}analyticsManagerPropertyChanged(e){this.propertyPushSource.getBehaviorSubject(e.key).setProperty(e)}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}selectItemWithSmartScanSelection(){this.sparkScan?.selectItemWithSmartScanSelectionAsync()}async removeMode(){this.captureListenerSet=!1,this.sparkScan?.delete(),this.sparkScan=void 0,this.sparkScanOverlay?.delete(),this.sparkScanOverlay=void 0}sparkScanDidScan(e,t){let n=this.coreEngine.prepareFrameForListener(t);this.workerFunctions.postMessage({type:`sparkScanDidScan`,payload:{session:JSON.parse(e.toJson()),frameData:n}})}},q=class extends j{constructor(e,t){super(e,t)}getModeDeserializers(){this.barcodeCaptureMode=new z(this,this.Module,this.workerFunctions),this.barcodeBatchMode=new R(this,this.Module,this.workerFunctions),this.sparkScanMode=new K(this,this.Module,this.workerFunctions),this.barcodeFindMode=new H(this,this.Module,this.workerFunctions),this.barcodeArMode=new L(this,this.Module,this.workerFunctions);let e=super.getModeDeserializers();return e.push_back(this.barcodeCaptureMode.getCaptureDeserializer()),e.push_back(this.barcodeBatchMode.getBatchDeserializer()),e.push_back(this.sparkScanMode.getSparkScanDeserializer()),e}getWasmSideModuleFileName(){return``}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`:`scandit-datacapture-sdk-barcode.wasm`}getWasmCoreExpectedHash(e,t){return t?e?`c8f403533e1c4422e7dbd309975f1b6796d317ec9423c8e3b3fb92e51d8710b3`:`75610fc67d4be5f4fc7389a642f08edeac85c1729229944783d877bfb31081c6`:e?`baebc48ef54d8e530217c124128de3256924b94e24c15639df896f5de72082fe`:`be725293860b2d90d1bd2a79a03b8970526dcc2bd9b62c60bb0bfa4e442495cb`}getWasmMetadata(){return{"scandit-datacapture-sdk-barcode-pthreads.wasm":{bytes:7733852},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:7685873},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:7743614},"scandit-datacapture-sdk-barcode.wasm":{bytes:7805987}}}};function re(e){return(e=>/^[$A-Z_a-z][\w$]*\s*\(.*\)\s*\{/.test(e)&&!e.startsWith(`function`))(e)?`function ${e}`:e}let J=[`fetch`,`XMLHttpRequest`,`eval`,`Function`,`self`,`globalThis`,`Module`,`importScripts`,`this`,`console`,`window`,`document`,`import`,`Worker`,`ServiceWorker`,`with`,`Reflect`,`Proxy`],Y=[`constructor`,`__proto__`];function X(e,t){let n=t+2,r=e.length;for(;n<r&&!(e[n]===`*`&&n+1<r&&e[n+1]===`/`);)n++;return Math.min(r,n+2)}function ie(e,t){let n=t+2,r=e.length;for(;n<r&&e[n]!==`
`&&e[n]!==`\r`;)n++;return n}function Z(e,t,n){let r=t+1,i=e.length;for(;r<i&&e[r]!==n&&e[r]!==`
`&&e[r]!==`\r`;)r+=e[r]===`\\`&&r+1<i?2:1;return r<i&&e[r]===n?r+1:r}function ae(e){let t=``,n=0,r=e.length;for(;n<r;){let i=e[n],a=n+1<r?e[n+1]:``;if(i===`/`&&a===`*`){n=X(e,n);continue}if(i===`/`&&a===`/`){n=ie(e,n);continue}if(i===`'`||i===`"`){t+=i+i,n=Z(e,n,i);continue}if(i==="`"){let r=Q(e,n);t+=r.text,n=r.next;continue}t+=i,n++}return t}function Q(e,t){let n=t+1,r=e.length,i=[];for(;n<r&&e[n]!=="`";){if(e[n]===`\\`&&n+1<r){n+=2;continue}if(e[n]===`$`&&n+1<r&&e[n+1]===`{`){let t=n+2,r=oe(e,t);i.push(e.substring(t,r)),n=r+1;continue}n++}return{text:i.length===0?"``":`\`\`+(${i.join(`)+(`)})`,next:Math.min(r,n+1)}}function oe(e,t){let n=1,r=t,i=e.length;for(;r<i&&n>0;){let t=e[r];if(t===`{`)n++,r++;else if(t===`}`){if(n--,n===0)return r;r++}else t===`'`||t===`"`?r=Z(e,r,t):t==="`"?r=Q(e,r).next:t===`\\`&&r+1<i?r+=2:r++}return Math.min(i,r)}let se=/(['"`])((?:\\.|(?!\1).)*)\1\s*\+\s*(['"`])((?:\\.|(?!\3).)*)\3/g;function ce(e){let t,n=e;do t=n,n=t.replace(se,(e,t,n,r,i)=>`'${n}${i}'`);while(n!==t);return n}let le=[`getPrototypeOf`],ue=/^[$A-Z_a-z][\w$]*$/,de=/^-?\d+(?:\.\d+)?$/,fe=/^(?:""|''|``(?:\+\([^()]*\))*)$/,pe=new Set([`return`,`throw`,`typeof`,`void`,`delete`,`new`,`in`,`of`,`instanceof`,`await`,`yield`,`case`]);function $(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return!1;let r=e[n];if(r===`)`||r===`]`)return!0;if(!/[\w$]/.test(r))return!1;let i=n+1;for(;n>=0&&/[\w$]/.test(e[n]);)n--;let a=e.substring(n+1,i);return!pe.has(a)}function me(e,t){let n=e.length,r=1,i=t+1;for(;i<n&&r>0;)e[i]===`[`?r++:e[i]===`]`&&r--,r>0&&i++;return i}function he(e){return e===``||ue.test(e)||de.test(e)||fe.test(e)}function ge(e){let t=e.length,n=0;for(;n<t;){if(e[n]!==`[`||!$(e,n)){n++;continue}let t=me(e,n);if(!he(e.substring(n+1,t).trim()))return!0;n=t+1}return!1}function _e(e){let t=ce(e),n=ae(t);for(let e of J)if(RegExp(`\\b${e}\\b`).test(n))return!0;for(let e of[...J,...Y])if(RegExp(`\\[\\s*(['"\`])${e}\\1\\s*\\]`).test(t))return!0;for(let e of Y)if(RegExp(`\\.\\s*${e}\\b`).test(n))return!0;for(let e of le)if(RegExp(`\\.\\s*${e}\\b`).test(n))return!0;return!!ge(n)}function ve(e){if(e==null)return null;let t=re(e);if(_e(t))throw Error(`Function should be pure. Shouldn't introduce side effects, or rely on global scope`);let n=new Set([`eval`,`this`,`import`,`with`]),r=`'use strict';
return (function (${J.filter(e=>!n.has(e)).join(`,`)}) {
return (${t});
})();`;try{return Function(r)()}catch{return null}}new class extends I{constructor(e,t){super(e,t),this.dataCaptureInstance=new q(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)})}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`sparkScanEmitErrorFeedback`:{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.sparkScanMode.emitErrorFeedback(t.shouldRemoveBrush)}),!0}case`sparkScanOverlayReadyForDraw`:{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.sparkScanMode.overlayReadyForDraw()}),!0}case`sparkScanOverlayDiscardEnqueuedData`:{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.sparkScanMode.discardEnqueuedData()}),!0}case`sparkScanAnalyticsManagerPropertyChanged`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.sparkScanMode.analyticsManagerPropertyChanged(t.property)}),!0}case`sparkScanSelectItemWithSmartScanSelection`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.sparkScanMode.selectItemWithSmartScanSelection()}),!0}case`sparkScanModeRemove`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.sparkScanMode.removeMode()),!0}case`barcodeFindForSettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeFindMode.forSettings(t.settings)),!0}case`barcodeFindModeRemove`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeFindMode.removeMode()),!0}case`barcodeFindSearchStart`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.start()}),!0;case`barcodeFindSearchPause`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.pause()}),!0;case`barcodeFindSearchStop`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.stop()}),!0;case`barcodeFindSetItemList`:{let{data:t}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.setItemList(t.itemList)}),!0}case`barcodeFindSetEnabled`:{let{data:t}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.setEnabled(t.enabled)}),!0}case`barcodeFindApplySettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeFindMode.applySettings(t.settings)),!0}case`barcodeFindAddBasicOverlay`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeFindMode.addBasicOverlay()}),!0}case`barcodeFindRemoveBasicOverlay`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeFindMode.removeBasicOverlay()}),!0}case`barcodeFindUpdateBasicOverlay`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeFindMode.updateBasicOverlay(t.jsonOverlay)}),!0}case`barcodeFindSetTransformerFunction`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{let e=ve(t.functionAsString);this.dataCaptureInstance.barcodeFindMode.setTransformerFunction(e)}),!0}case`barcodeArForSettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeArMode.forSettings(t.settings)),!0}case`barcodeArModeRemove`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeArMode.removeMode()),!0}case`barcodeArSearchStart`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.start()}),!0;case`barcodeArSearchPause`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.pause()}),!0;case`barcodeArSearchStop`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.stop()}),!0;case`barcodeArSetEnabled`:{let{data:t}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.setEnabled(t.enabled)}),!0}case`barcodeArApplySettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeArMode.applySettings(t.settings)}),!0}default:return super.onMessage(e)}}}(globalThis,{get:()=>globalThis.Module,set:e=>{globalThis.Module=e}})})();