@scandit/web-datacapture-label 8.6.0-beta.1 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ declare class LabelCaptureWorkerManager extends DataCaptureLoader {
11
11
  private _handshake?;
12
12
  get dataCaptureWorker(): DataCaptureWorker;
13
13
  get name(): string;
14
- initializeNativeHandles(): Promise<void>;
14
+ initializeNativeHandles(forceRefresh?: boolean): Promise<void>;
15
15
  protected createDataCaptureWorker(): Promise<DataCaptureWorker>;
16
16
  static create(options: DataCaptureLoaderOptions): Promise<LabelCaptureWorkerManager>;
17
17
  workerCommand<C extends DataCaptureActionMessageKey>(command: C, payload: WorkerCommandPayload<C>, transferables?: Transferable[]): Promise<any>;
@@ -1 +1 @@
1
- import{t as e}from"../LabelCaptureWorkerManager-AJWX-5XC.js";export{e as LabelCaptureWorkerManager};
1
+ import{t as e}from"../LabelCaptureWorkerManager-iwl00EZR.js";export{e as LabelCaptureWorkerManager};
@@ -1 +1 @@
1
- import{nativeImplementationRegistry as e}from"./NativeImplementationRegistry.js";import{DataCaptureEngine as t}from"@scandit/web-datacapture-core/build/js/worker/index.js";var n=class extends t{constructor(e,t){super(e,t)}getModeDeserializers(){return super.getModeDeserializers()}dispose(){e.clear(),super.dispose()}getWasmSideModuleFileName(){return``}getWasmCoreFileName(e,t){return t?e?`scandit-datacapture-sdk-label-simd-pthreads.wasm`:`scandit-datacapture-sdk-label-pthreads.wasm`:e?`scandit-datacapture-sdk-label-simd.wasm`:`scandit-datacapture-sdk-label.wasm`}getWasmCoreExpectedHash(e,t){return t?e?`4b125c7c0eff3d86cb9cf486fc565715d5ed4ef8b3a55d92d2644821ff2c5153`:`90134fae783b4bfa7099e10f8ce794b36ce0e65b09c8768e1c371759d49a125e`:e?`d281ceffa4089a1bc17134ea2ca3c1240ed065d791afb7161d6ac6d52cb65a0c`:`95c96f880ed773e8eed9c597d708af0bc62225eb75814915a247e238a3c68668`}onBeforeUpdateContextHook(e){var t;return((t=e.context.view)==null?void 0:t.overlays)!=null&&(e.context.view.overlays=void 0),e}addNativeOverlay(t){if(!this.view)throw Error(`View is not set`);let n=t.data.overlayHandle,r=e.get(n).asDataCaptureOverlay();this.view.addOverlay(r),r.delete()}removeNativeOverlay(t){if(!this.view)throw Error(`View is not set`);let n=t.data.overlayHandle,r=e.get(n).asDataCaptureOverlay();this.view.removeOverlay(r),r.delete()}getWasmMetadata(){return{"scandit-datacapture-sdk-label-pthreads.wasm":{bytes:8459392},"scandit-datacapture-sdk-label-simd-pthreads.wasm":{bytes:8411528},"scandit-datacapture-sdk-label-simd.wasm":{bytes:8496347},"scandit-datacapture-sdk-label.wasm":{bytes:8558663}}}};export{n as DataCaptureEngine};
1
+ import{nativeImplementationRegistry as e}from"./NativeImplementationRegistry.js";import{DataCaptureEngine as t}from"@scandit/web-datacapture-core/build/js/worker/index.js";var n=class extends t{constructor(e,t){super(e,t)}getModeDeserializers(){return super.getModeDeserializers()}dispose(){e.clear(),super.dispose()}getWasmSideModuleFileName(){return``}getWasmCoreFileName(e,t){return t?e?`scandit-datacapture-sdk-label-simd-pthreads.wasm`:`scandit-datacapture-sdk-label-pthreads.wasm`:e?`scandit-datacapture-sdk-label-simd.wasm`:`scandit-datacapture-sdk-label.wasm`}getWasmCoreExpectedHash(e,t){return t?e?`c97306a4180ebe777d304bdbae442d7d172ceb01195e9c43ab97c702696067fc`:`75ec45015587ddeda3f399e64a1d0bfdcfdd739489d13caf5a40cc64233cec17`:e?`455de5ed9f71b7ce7b34e6996f54ff1faec12898f135b93239275974ef39ad98`:`f3a0d316966e0009ab5448abbd4db2ae4fb6df2921a290f7b66db29db37ed7dd`}onBeforeUpdateContextHook(e){var t;return((t=e.context.view)==null?void 0:t.overlays)!=null&&(e.context.view.overlays=void 0),e}addNativeOverlay(t){if(!this.view)throw Error(`View is not set`);let n=t.data.overlayHandle,r=e.get(n).asDataCaptureOverlay();this.view.addOverlay(r),r.delete()}removeNativeOverlay(t){if(!this.view)throw Error(`View is not set`);let n=t.data.overlayHandle,r=e.get(n).asDataCaptureOverlay();this.view.removeOverlay(r),r.delete()}getWasmMetadata(){return{"scandit-datacapture-sdk-label-pthreads.wasm":{bytes:8462565},"scandit-datacapture-sdk-label-simd-pthreads.wasm":{bytes:8414690},"scandit-datacapture-sdk-label-simd.wasm":{bytes:8499568},"scandit-datacapture-sdk-label.wasm":{bytes:8561900}}}};export{n as DataCaptureEngine};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scandit/web-datacapture-label",
3
- "version": "8.6.0-beta.1",
3
+ "version": "8.6.0",
4
4
  "description": "Scandit Data Capture SDK for the Web",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "sideEffects": false,
@@ -86,8 +86,8 @@
86
86
  "sdc-lib/"
87
87
  ],
88
88
  "peerDependencies": {
89
- "@scandit/web-datacapture-barcode": "8.6.0-beta.1",
90
- "@scandit/web-datacapture-core": "8.6.0-beta.1"
89
+ "@scandit/web-datacapture-barcode": "8.6.0",
90
+ "@scandit/web-datacapture-core": "8.6.0"
91
91
  },
92
92
  "dependencies": {
93
93
  "@types/emscripten": "1.41.5"
@@ -0,0 +1 @@
1
+ (function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}};function n(e){return typeof e==`object`&&!!e}function r(e){if(typeof e==`string`)return e;if(n(e)){if(typeof e.message==`string`)return e.message}else if(typeof e?.toString==`function`)return e.toString();return`unknown error`}let i;(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})(i||={});var a=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 o(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 s(e){let t=/@scandit\/web-datacapture-[a-z]+/i.exec(e);return t?t[0]:null}function c(e,t,n){let r=t,i=o(r);if(i.result){let t=s(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}`}}(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 l=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))}},u=class{constructor(){this.promise=new Promise((e,t)=>{this.reject=t,this.resolve=e})}};let d;(function(e){function t(){return`8.6.0`}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 i.log(i.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,a=p(await crypto.subtle.digest(`SHA-256`,r));return t==null?(i.log(i.Level.Warn,`The library hash is not defined or empty, cannot correctly verify integrity.`),`NOT_VERIFIABLE`):a===t?(i.log(i.Level.Debug,`Data Capture library WASM integrity found at ${n} has been verified correctly.`),`VALID`):(i.log(i.Level.Warn,`The Scandit Data Capture library WASM file found at ${n} 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 i.log(i.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:a,onComplete:o}){if(!t.body)return[t];let s=S(e,t.headers),c=0,l=0;if(typeof TransformStream>`u`)return i.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),a?.({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 ee({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 te({wasmURI:e,expectedHash:t,verifyResponseHash:n,progressCallback:r,successCallback:a,errorCallback:o,importObject:s,referredOrigin:c}){async function l(l){try{let i=await ee({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,referredOrigin:c}),o=await(l??i).arrayBuffer(),u=await globalThis.WebAssembly.instantiate(o,s);a(u.instance,u.module)}catch(t){i.log(i.Level.Error,t),i.log(i.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 ee({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,referredOrigin:c});let i=await globalThis.WebAssembly.instantiateStreaming(o,s);a(i.instance,i.module)}catch(e){i.log(i.Level.Warn,e),i.log(i.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 ne(e){let t;try{let n=new Promise((n,r)=>{t=setTimeout(()=>{i.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 a({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 re(e){try{FS.mkdir(e.writableDataPath)}catch(e){if(e.code!==`EEXIST`)throw e}return FS.mount(IDBFS,{autoPersist:!0},e.writableDataPath),ne(e.indexedDBTimeoutMs)}async function ie(e,t){function n(e){try{return new URL(e,self.location.href).origin!==self.location.origin}catch(t){return i.log(i.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){i.log(i.Level.Warn,t),i.log(i.Level.Warn,`Couldn't retrieve Scandit Data Capture library at ${e}, retrying...`)}try{if(n(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,r),n=URL.createObjectURL(t);try{await importScripts(n)}finally{URL.revokeObjectURL(n)}self.Module.mainScriptUrlOrBlob=t}else await w(async()=>importScripts(e),250,4e3,r),self.Module.mainScriptUrlOrBlob=e;let a=globalThis.SDC_WASM_JS_VERSION;return a!==t&&i.log(i.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 i.log(i.Level.Error,e),!1}}function ae(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 E=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)):i.warn(`ImageConverterForwarder: Conversion for imageId ${e} not found in Map`)}},D=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 i.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 i.warn(`Invalid image dimensions: ${t}x${n}`),Error(`Invalid image dimensions: ${t}x${n}`);if(!r||r.length===0)throw i.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 i.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 i.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 i.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 i.warn(`Failed to convert canvas to blob: ${e}`),Error(`Failed to convert canvas to blob: ${e}`)}if(!r||r.size===0)throw i.warn(`Canvas convertToBlob returned empty or null blob`),Error(`Failed to create JPEG blob`);let a;try{a=await r.arrayBuffer()}catch(e){throw i.warn(`Failed to get array buffer from blob: ${e}`),Error(`Failed to get array buffer from blob: ${e}`)}if(!a||a.byteLength===0)throw i.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 i.warn(`Failed to create HTMLCanvasElement`,e),!1}}createImageDataFromBuffer(e,t,n,r){let a=new Set(t.map(e=>e.channel));try{if(this.isYUVFormat(a)){let t=e.toBitmap();return!t||t.length!==n*r*4?(i.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(a))return this.createImageDataFromRGBAPlanes(t,n,r);if(this.isRGBFormat(a))return this.createImageDataFromRGBPlanes(t,n,r);if(this.isGrayscaleFormat(a))return this.createImageDataFromGrayscalePlanes(t,n,r);i.warn(`Unknown image format with channels: ${Array.from(a).join(`, `)}, falling back to toBitmap()`);let o=e.toBitmap();if(!o||o.length===0)return i.warn(`toBitmap() returned empty or null data`),null;let s=o.length/(n*r);return s===4?new ImageData(new Uint8ClampedArray(o),n,r):(i.warn(`Unsupported format: ${s} bytes per pixel`),null)}catch(e){return i.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),a=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5),s=e.find(e=>e.channel===6);if(!r||!a||!o||!s)return i.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 i=(e*t+n)*4;c[i]=this.getPixelFromPlane(r,n,e),c[i+1]=this.getPixelFromPlane(a,n,e),c[i+2]=this.getPixelFromPlane(o,n,e),c[i+3]=this.getPixelFromPlane(s,n,e)}return new ImageData(c,t,n)}createImageDataFromRGBPlanes(e,t,n){let r=e.find(e=>e.channel===3),a=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5);if(!r||!a||!o)return i.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 i=(e*t+n)*4;s[i]=this.getPixelFromPlane(r,n,e),s[i+1]=this.getPixelFromPlane(a,n,e),s[i+2]=this.getPixelFromPlane(o,n,e),s[i+3]=255}return new ImageData(s,t,n)}createImageDataFromGrayscalePlanes(e,t,n){let r=e.find(e=>e.channel===0);if(!r)return i.warn(`Missing Y plane for grayscale`),null;let a=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let i=(e*t+n)*4,o=this.getPixelFromPlane(r,n,e);a[i]=o,a[i+1]=o,a[i+2]=o,a[i+3]=255}return new ImageData(a,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}};D.JPEG_IMAGE_MIME_TYPE=`image/jpeg`;var oe=class extends D{getNewCanvas(e,t){return new OffscreenCanvas(e,t)}canvasToBlob(e){return e.convertToBlob({type:D.JPEG_IMAGE_MIME_TYPE,quality:this.options.quality})}},se=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}},O=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 se(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&&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 E&&this.webImageConverterInstance.onConvertToJPEGResult(e,t)}getImageConverterInstance(e){return this.workerFunctions.getOffscreenCanvas()==null?new E(this.workerFunctions,e):new oe(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 i.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 a=this.Module.allocateUint8Array(n.byteLength);return this.Module.HEAPU8.set(n,a),(t=this.imageFrameSource)==null||t.outputFrame(a,e.width,e.height,r),{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=l.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=ae(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(),this.insufficientMultithreadingReported=!1;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),i.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){i.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?`c97306a4180ebe777d304bdbae442d7d172ceb01195e9c43ab97c702696067fc`:`75ec45015587ddeda3f399e64a1d0bfdcfdd739489d13caf5a40cc64233cec17`:e?`455de5ed9f71b7ce7b34e6996f54ff1faec12898f135b93239275974ef39ad98`:``}getWasmCoreFileName(e,t){return t?e?`scandit-datacapture-sdk-label-simd-pthreads.wasm`:`scandit-datacapture-sdk-label-pthreads.wasm`:e?`scandit-datacapture-sdk-label-simd.wasm`:``}getWasmMetadata(){return{"scandit-datacapture-sdk-label-pthreads.wasm":{bytes:8462565},"scandit-datacapture-sdk-label-simd-pthreads.wasm":{bytes:8414690},"scandit-datacapture-sdk-label-simd.wasm":{bytes:8499568},"scandit-datacapture-sdk-label.wasm":{bytes:8561900}}}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){i.warn(`addNativeOverlay has not been implemented for this module`,e)}removeNativeOverlay(e){i.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:(i.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:o,referredOrigin:s,fixedWasmMemory:l,simdSupport:f,threadsSupport:p}){let m=!1,h=!1;this.threadsSupport=p,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 a({name:`Invalid library version`,message:`Library version is not defined or empty, cannot generate proper path to library files.`});let{jsURI:b,wasmURI:x}=c(y,e,this.getWasmCoreFileName(f,p)),S={instantiateWasm:(e,t)=>(te({importObject:e,wasmURI:x,expectedHash:this.getWasmCoreExpectedHash(f,p),verifyResponseHash:o,successCallback:t,progressCallback:this._loadProgressCallback,errorCallback:e=>{_(e)},referredOrigin:s}),{})},C=l===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(l),maximum:this.numOfMBToPages(300),shared:p});return C!==null&&i.log(i.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 re({writableDataPath:this.writableDataPath,indexedDBTimeoutMs:r})}catch(e){if(e.name===`BlockedIndexedDB`){_(e.toString());return}i.log(i.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)){i.log(i.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=>{i.info(e)}}),await ie(b,y)||_(`Couldn't retrieve Scandit Data Capture library at ${b}, did you configure the path for it correctly?`),v}};O.get3dPartyLicenseKeyMethodName=atob(`Z2V0QmxpbmtJZExpY2Vuc2VLZXk=`);function ce(e){console.warn(`Reached unexpected case`,e)}function le(e){return typeof e==`object`&&!!e&&e.document==null&&`addEventListener`in e&&typeof e.importScripts==`function`}var ue=class{constructor(e){if(typeof e!=`function`)throw TypeError(`FinalizationRegistry callback must be a function`)}register(e,t,n){}unregister(e){return!1}};function de(e){e.FinalizationRegistry===void 0&&(e.FinalizationRegistry=ue)}var fe=class{constructor(e,t){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=e,this.dataCaptureInstance=new O(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),le(e)&&(de(e),this.listenToMessages())}listenToMessages(){this.workerSelf.addEventListener(`message`,this.onMessageListener),this.workerSelf.addEventListener(`error`,e=>{i.log(i.Level.Error,e)}),this.workerSelf.addEventListener(`messageerror`,e=>{i.log(i.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(e){return n(e)&&`payload`in e}hasTransferables(e){return n(e)&&Array.isArray(e.transferables)}async respondWith(e,t,n){let i=null,a;try{a=n(),a instanceof Promise&&(a=await a)}catch(e){a=void 0,i=r(e)}let o={type:`workerTaskId`,command:e,id:t,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,()=>{i.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 ce(e.data),!1}return!0}};let k=new class{constructor(){this.idToNativeImplMap=new Map,this.nativeImplToHandleMap=new WeakMap,this.id=0}allocateHandle(e){return{type:`nativeProxyHandle`,className:e,id:this.id++}}set(e,t){this.idToNativeImplMap.set(e.id,t),this.nativeImplToHandleMap.set(t,e)}get(e){let t=this.idToNativeImplMap.get(e.id);if(t==null)throw Error(`No native implementation for handle ${e.className}#${e.id}`);return t}has(e){return this.idToNativeImplMap.has(e.id)}delete(e){let t=this.idToNativeImplMap.get(e.id);t!=null&&(this.idToNativeImplMap.delete(e.id),this.nativeImplToHandleMap.delete(t))}handleForNativeImplementation(e){return this.nativeImplToHandleMap.get(e)}register(e,t){let n=this.handleForNativeImplementation(t);return n??(n=this.allocateHandle(e),this.set(n,t)),n}clear(){this.idToNativeImplMap.forEach((e,t)=>{this.idToNativeImplMap.delete(t),this.nativeImplToHandleMap.delete(e)}),this.id=0}};var pe=class extends O{constructor(e,t){super(e,t)}getModeDeserializers(){return super.getModeDeserializers()}dispose(){k.clear(),super.dispose()}getWasmSideModuleFileName(){return``}getWasmCoreFileName(e,t){return t?e?`scandit-datacapture-sdk-label-simd-pthreads.wasm`:`scandit-datacapture-sdk-label-pthreads.wasm`:e?`scandit-datacapture-sdk-label-simd.wasm`:`scandit-datacapture-sdk-label.wasm`}getWasmCoreExpectedHash(e,t){return t?e?`c97306a4180ebe777d304bdbae442d7d172ceb01195e9c43ab97c702696067fc`:`75ec45015587ddeda3f399e64a1d0bfdcfdd739489d13caf5a40cc64233cec17`:e?`455de5ed9f71b7ce7b34e6996f54ff1faec12898f135b93239275974ef39ad98`:`f3a0d316966e0009ab5448abbd4db2ae4fb6df2921a290f7b66db29db37ed7dd`}onBeforeUpdateContextHook(e){return e.context.view?.overlays!=null&&(e.context.view.overlays=void 0),e}addNativeOverlay(e){if(!this.view)throw Error(`View is not set`);let t=e.data.overlayHandle,n=k.get(t).asDataCaptureOverlay();this.view.addOverlay(n),n.delete()}removeNativeOverlay(e){if(!this.view)throw Error(`View is not set`);let t=e.data.overlayHandle,n=k.get(t).asDataCaptureOverlay();this.view.removeOverlay(n),n.delete()}getWasmMetadata(){return{"scandit-datacapture-sdk-label-pthreads.wasm":{bytes:8462565},"scandit-datacapture-sdk-label-simd-pthreads.wasm":{bytes:8414690},"scandit-datacapture-sdk-label-simd.wasm":{bytes:8499568},"scandit-datacapture-sdk-label.wasm":{bytes:8561900}}}};function me(e){return typeof e==`object`&&!!e&&e.type===`nativeProxyHandle`}function he(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`result`||t===`error`}function ge(e){return typeof e==`object`&&!!e&&typeof e.then==`function`&&!(e instanceof Promise)}function A(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e.constructor;return t!==void 0&&t!==Object}function j(e){if(me(e))return k.get(e);if(Array.isArray(e))return e.map(j);if(typeof e==`object`&&e&&e.constructor===Object){let t={};for(let[n,r]of Object.entries(e))t[n]=j(r);return t}return e}function _e(e,t){return new Promise((n,r)=>{e.then({run:e=>{e?n(e):r(Error(t))}})})}function M(e,t){if(he(e)){if(e.type===`error`)throw Error(String(e.error));return M(e.result,t)}return Array.isArray(e)?e.map(e=>M(e,t)):A(e)?k.register(t,e):e}function ve(e,t,n,r){let i=r.module[e];if(i==null)throw Error(`Unknown native class: ${e}`);let a=n[0];if(A(a)){let e=a[t];if(typeof e==`function`)return{fn:e,receiver:a,args:n.slice(1)}}let o=i[t];if(typeof o==`function`)return{fn:o,receiver:i,args:n};throw Error(`Method not found: ${e}.${t}`)}function ye(e){let t=e.split(`.`);if(t.length!==2||!t[0]||!t[1])throw Error(`Invalid native call command: "${e}" (expected "ClassName.methodName")`);return[t[0],t[1]]}async function be(e,t){let{command:n,args:r}=e;try{let[e,i]=ye(n),{fn:a,receiver:o,args:s}=ve(e,i,r.map(j),t),c=a.apply(o,s);return i.endsWith(`Wrapped`)&&ge(c)?c=await _e(c,`${n} failed`):c instanceof Promise&&(c=await c),M(c,e)}catch(e){throw e instanceof Error&&!e.message.startsWith(`${n}:`)&&(e.message=`${n}: ${e.message}`),e}}function xe(e){return e.includes(`.`)}function Se(e){return{off:0,auto:1,on:2}[e]}var N=class{get Module(){return Le.Module}impl(e){return k.get(e)}},Ce=new class extends N{async getName(e){return this.impl(e).getName()}async isOptional(e){return this.impl(e).isOptional()}async setOptional(e,t){throw Error(`This method must be implemented manually.`)}async getValueRegexes(e){return this.impl(e).getPatterns()}async setValueRegexes(e,t){throw Error(`This method must be implemented manually.`)}async getHiddenProperties(e){throw Error(`This method must be implemented manually.`)}async setHiddenProperties(e,t){throw Error(`This method must be implemented manually.`)}async getLocation(e){throw Error(`This method must be implemented manually.`)}async setLocation(e,t){throw Error(`This method must be implemented manually.`)}async getAnchorRegexes(e){throw Error(`This method must be implemented manually.`)}async setAnchorRegexes(e,t){throw Error(`This method must be implemented manually.`)}async getNumberOfMandatoryInstances(e){return this.impl(e).getNumberOfMandatoryInstances()}async setNumberOfMandatoryInstances(e,t){throw Error(`This method must be implemented manually.`)}},P=new class extends N{async create(e,t){let n=this.Module.LabelDefinition.create(e,t.map(e=>Ce.impl(e)));return k.register(`LabelDefinition`,n)}async getName(e){return this.impl(e).getName()}async getFieldDefinitions(e){return this.impl(e).getFieldDefinitions()}async createVinLabelDefinition(e){let t=this.Module.LabelDefinition.createVinLabelDefinition(e);return k.register(`LabelDefinition`,t)}async createPriceCaptureDefinition(e){let t=this.Module.LabelDefinition.createPriceCaptureDefinition(e);return k.register(`LabelDefinition`,t)}async getHiddenProperties(e){return this.impl(e).getHiddenProperties()}async setHiddenProperties(e,t){this.impl(e).setHiddenProperties(t)}async setAdaptiveRecognitionMode(e,t){let n=this.impl(e),r=Se(t);n.setAdaptiveRecognitionMode(r)}},we=class{canHandle(e){return e.startsWith(`labelCaptureBuild`)}async handle(e){let{data:t}=e;switch(t.command){case`labelCaptureBuildVinLabelDefinition`:{let e=await P.createVinLabelDefinition(t.payload.name);t.payload.adaptiveRecognitionMode!==void 0&&await P.setAdaptiveRecognitionMode(e,t.payload.adaptiveRecognitionMode);let n=P.impl(e),r=n.getHiddenProperties(),i=n.getFieldDefinitions().map(e=>({name:e.getName(),patterns:e.getPatterns(),isOptional:e.isOptional(),numberOfMandatoryInstances:e.getNumberOfMandatoryInstances()??null}));return{payload:{handle:e,name:n.getName(),hiddenProperties:r,fields:i}}}case`labelCaptureBuildPriceCaptureDefinition`:{let e=await P.createPriceCaptureDefinition(t.payload.name);t.payload.adaptiveRecognitionMode!==void 0&&await P.setAdaptiveRecognitionMode(e,t.payload.adaptiveRecognitionMode);let n=P.impl(e),r=n.getHiddenProperties(),i=n.getFieldDefinitions().map(e=>({name:e.getName(),patterns:e.getPatterns(),isOptional:e.isOptional(),numberOfMandatoryInstances:e.getNumberOfMandatoryInstances()??null}));return{payload:{handle:e,name:n.getName(),hiddenProperties:r,fields:i}}}}}},F,I=t((()=>{F=class e{constructor(e){this.hexadecimalString=e}get redComponent(){return this.hexadecimalString.slice(0,2)}get greenComponent(){return this.hexadecimalString.slice(2,4)}get blueComponent(){return this.hexadecimalString.slice(4,6)}get alphaComponent(){return this.hexadecimalString.slice(6,8)}get red(){return e.hexToNumber(this.redComponent)}get green(){return e.hexToNumber(this.greenComponent)}get blue(){return e.hexToNumber(this.blueComponent)}get alpha(){return e.hexToNumber(this.alphaComponent)}static fromHex(t){return new e(e.normalizeHex(t))}static fromRGBA(t,n,r,i=1){let a=[t,n,r,e.normalizeAlpha(i)].reduce((t,n)=>t+e.numberToHex(n),``);return new e(a)}static areEquals(e,t){return e==null||t==null?!1:e.hexadecimalString===t.hexadecimalString}static hexToNumber(e){return Number.parseInt(e,16)}static fromJSON(t){return e.fromHex(t)}static numberToHex(e){let t=Math.round(e).toString(16);return t.length===1&&(t=`0${t}`),t.toUpperCase()}static normalizeHex(e){let t=e;return t.startsWith(`#`)&&(t=t.slice(1)),t.length<6&&(t=[...t].map(e=>e+e).join(``)),t.length===6&&(t+=`FF`),t.toUpperCase()}static normalizeAlpha(e){return e>0&&e<=1?255*e:e}withAlpha(t){let n=this.hexadecimalString.slice(0,6)+e.numberToHex(e.normalizeAlpha(t));return e.fromHex(n)}toJSON(){return this.hexadecimalString}}}));I();let L={fillColor:F.fromJSON(`#00000000`),strokeColor:F.fromJSON(`#00000000`),strokeWidth:0};var R=class e{constructor(e=L.fillColor,t=L.strokeColor,n=L.strokeWidth){this.fill={color:e},this.stroke={color:t,width:n}}static get transparent(){let t=F.fromRGBA(255,255,255,0);return new e(t,t,0)}get fillColor(){return this.fill.color}get strokeColor(){return this.stroke.color}get strokeWidth(){return this.stroke.width}clone(){return new e(this.fillColor,this.strokeColor,this.strokeWidth)}static areEquals(e,t){return e==null||t==null?!1:F.areEquals(e.fill.color,t.fill.color)&&F.areEquals(e.stroke.color,t.stroke.color)&&e.stroke.width===t.stroke.width}toJSONObject(){return{fill:{color:this.fillColor.toJSON()},stroke:{width:this.strokeWidth,color:this.strokeColor.toJSON()}}}static fromJSONObject(t){return new e(F.fromJSON(t.fill.color),F.fromJSON(t.stroke.color),t.stroke.width)}};let z=function(e){return e.Pixel=`pixel`,e.Fraction=`fraction`,e}({});I();function B(e){return F.fromRGBA(e.r*255,e.g*255,e.b*255,e.a*255)}function V(e){return{r:e.red/255,g:e.green/255,b:e.blue/255,a:e.alpha/255}}function H(e){return R.fromJSONObject({fill:{color:B(e.fillColor).toJSON()},stroke:{color:B(e.strokeColor).toJSON(),width:e.strokeWidth}})}function U(e){let t=e instanceof R?e:R.fromJSONObject(e);return{fillColor:V(t.fillColor),strokeColor:V(t.strokeColor),strokeWidth:t.strokeWidth}}let Te={[z.Pixel]:0,[z.Fraction]:2};z.Pixel,z.Fraction,z.Pixel;function W(e){let t=Te[e.unit];return{value:e.value,unit:t}}var G=new class extends N{create(){let e=this.Module.AimerViewfinder.create();return k.register(`AimerViewfinder`,e)}async setFrameColor(e,t){this.impl(e).setFrameColor(t)}async getFrameColor(e){return this.impl(e).getFrameColor()}async setDotColor(e,t){this.impl(e).setDotColor(t)}async getDotColor(e){return this.impl(e).getDotColor()}async getDotColorDefault(){return this.Module.AimerViewfinder.getDotColorDefault()}async getFrameColorDefault(){return this.Module.AimerViewfinder.getFrameColorDefault()}},K=new class extends N{create(){let e=this.Module.NoViewfinder.create();return k.register(`NoViewfinder`,e)}},q=new class extends N{create(e){let t=this.Module.RectangularViewfinderAnimation.create(e);return k.register(`RectangularViewfinderAnimation`,t)}async isLooping(e){return this.impl(e).isLooping()}async toJson(e){return this.impl(e).toJson()}getNativeImplementation(e){return this.impl(e)}},J=new class extends N{create(){let e=this.Module.RectangularViewfinder.create();return k.register(`RectangularViewfinder`,e)}createForStyles(e,t){let n=this.Module.RectangularViewfinder.createForStyles(e,t);return k.register(`RectangularViewfinder`,n)}async setWidthAndHeight(e,t,n){this.impl(e).setWidthAndHeight(t,n)}async setWidthAndAspectRatio(e,t,n){this.impl(e).setWidthAndAspectRatio(t,n)}async setHeightAndAspectRatio(e,t,n){this.impl(e).setHeightAndAspectRatio(t,n)}async setShorterDimensionAndAspectRatio(e,t,n){this.impl(e).setShorterDimensionAndAspectRatio(t,n)}async getSizeWithUnitAndAspect(e){return this.impl(e).getSizeWithUnitAndAspect()}async setColor(e,t){this.impl(e).setColor(t)}async getColor(e){return this.impl(e).getColor()}async setDisabledColor(e,t){this.impl(e).setDisabledColor(t)}async getDisabledColor(e){return this.impl(e).getDisabledColor()}async getStyle(e){return this.impl(e).getStyle()}async setAnimation(e,t){this.impl(e).setAnimation(t)}async getAnimation(e){return this.impl(e).getAnimation()}async setDimming(e,t){this.impl(e).setDimming(t)}async getDimming(e){return this.impl(e).getDimming()}async setDisabledDimming(e,t){this.impl(e).setDisabledDimming(t)}async getDisabledDimming(e){return this.impl(e).getDisabledDimming()}async getLineStyle(e){return this.impl(e).getLineStyle()}};I();async function Ee(e){if(e.type===`rectangular`){let t=J.createForStyles(+(e.style===`rounded`),+(e.lineStyle===`light`)),n=[];e.size.width&&e.size.height?n.push(J.setWidthAndHeight(t,W(e.size.width),W(e.size.height))):e.size.width&&e.size.aspect?n.push(J.setWidthAndAspectRatio(t,W(e.size.width),e.size.aspect)):e.size.height&&e.size.aspect&&n.push(J.setHeightAndAspectRatio(t,W(e.size.height),e.size.aspect)),n.push(J.setColor(t,V(F.fromJSON(e.color)))),n.push(J.setDisabledColor(t,V(F.fromJSON(e.disabledColor)))),n.push(J.setDimming(t,e.dimming));let r=q.create(e.animation?.looping??!1);return n.push(J.setAnimation(t,q.getNativeImplementation(r))),await Promise.all(n),J.impl(t)}if(e.type===`aimer`){let t=G.create(),n=[];return n.push(G.setFrameColor(t,V(F.fromJSON(e.frameColor)))),n.push(G.setDotColor(t,V(F.fromJSON(e.dotColor)))),await Promise.all(n),G.impl(t)}return K.impl(K.create())}var Y=new class extends N{async create(e){let t=k.get(e),n=this.Module.LabelCaptureBasicOverlay.create(t);return k.register(`LabelCaptureBasicOverlay`,n)}async setDefaultFieldBrush(e,t,n){this.impl(e).setDefaultFieldBrush(t,n)}async getDefaultFieldBrush(e,t){return this.impl(e).getDefaultFieldBrush(t)}async setDefaultLabelBrush(e,t){this.impl(e).setDefaultLabelBrush(t)}async getDefaultLabelBrush(e){return this.impl(e).getDefaultLabelBrush()}async setBrushForField(e,t,n,r){this.impl(e).setBrushForField(t,n,r)}async setBrushForLabel(e,t,n){this.impl(e).setBrushForLabel(t,n)}async setListener(e,t){this.impl(e).setListener(t)}async getListener(e){return this.impl(e).getListener()}async setShouldShowScanAreaGuides(e,t){this.impl(e).setShouldShowScanAreaGuides(t)}async getShouldShowScanAreaGuides(e){return this.impl(e).getShouldShowScanAreaGuides()}async getViewfinder(e){return this.impl(e).getViewfinder()}async setViewfinder(e,t){this.impl(e).setViewfinder(t)}async asDataCaptureOverlay(e){return this.impl(e).asDataCaptureOverlay()}},De=class{constructor(e){this.workerMain=e,this.labelBrushMap=new Map,this.fieldBrushMap=new Map,this.pendingFieldBrushObjects=new Map,this.pendingLabelBrushObjects=new Map,this.overlayListenerAdded=!1,this.labelCaptureBasicOverlayListener={onLabelTapped:(e,t)=>{this.workerMain.postCallbackMessage({type:`labelCaptureBasicOverlayOnLabelTapped`,payload:{labelJSON:JSON.parse(t.toJson())}})},brushForField:(e,t,n)=>{let r=this.getFieldIdentifier(n,t);return this.pendingFieldBrushObjects.set(r,{field:t,label:n}),this.workerMain.postCallbackMessage({type:`labelCaptureBasicOverlayBrushForField`,payload:{fieldJSON:JSON.parse(t.toJson()),labelJSON:JSON.parse(n.toJson())}}),this.getBrushForField(n,t)},brushForLabel:(e,t)=>{let n=this.getLabelIdentifier(t);return this.pendingLabelBrushObjects.set(n,{label:t}),this.workerMain.postCallbackMessage({type:`labelCaptureBasicOverlayBrushForLabel`,payload:{labelJSON:JSON.parse(t.toJson())}}),this.getBrushForLabel(t)}}}canHandle(e){return e.startsWith(`labelCaptureBasicOverlay`)}async handle(e){let{data:t}=e;switch(t.command){case`labelCaptureBasicOverlayForLabelCapture`:return{payload:await Y.create(t.payload.labelCaptureHandle)};case`labelCaptureBasicOverlaySetDefaultFieldBrush`:Y.setDefaultFieldBrush(t.payload.labelCaptureBasicOverlayHandle,t.payload.labelFieldState,t.payload.brush?U(t.payload.brush):void 0);break;case`labelCaptureBasicOverlayGetDefaultFieldBrush`:{let e=await Y.getDefaultFieldBrush(t.payload.labelCaptureBasicOverlayHandle,t.payload.labelFieldState);return{payload:e?H(e):void 0}}case`labelCaptureBasicOverlaySetDefaultLabelBrush`:Y.setDefaultLabelBrush(t.payload.labelCaptureBasicOverlayHandle,t.payload.brush?U(t.payload.brush):void 0);break;case`labelCaptureBasicOverlayGetDefaultLabelBrush`:{let e=await Y.getDefaultLabelBrush(t.payload.labelCaptureBasicOverlayHandle);return{payload:e?H(e):void 0}}case`labelCaptureBasicOverlaySetBrushForField`:{let{brush:e,fieldJSON:n,labelCaptureBasicOverlayHandle:r,labelJSON:i}=t.payload;if(this.overlayListenerAdded){let t=this.getFieldIdentifierFromJSON(i,n),r=e?U(e):void 0;r?this.fieldBrushMap.set(t,r):this.fieldBrushMap.delete(t);let a=this.pendingFieldBrushObjects.get(t);a&&this.overlayHandle&&(this.pendingFieldBrushObjects.delete(t),await Y.setBrushForField(this.overlayHandle,r,a.field,a.label));break}await Y.setBrushForField(r,e?U(e):void 0,n,i);break}case`labelCaptureBasicOverlaySetBrushForLabel`:{let{brush:e,labelCaptureBasicOverlayHandle:n,labelJSON:r}=t.payload;if(this.overlayListenerAdded){let t=this.getLabelIdentifierFromJSON(r),n=e?U(e):void 0;n?this.labelBrushMap.set(t,n):this.labelBrushMap.delete(t);let i=this.pendingLabelBrushObjects.get(t);i&&this.overlayHandle&&(this.pendingLabelBrushObjects.delete(t),await Y.setBrushForLabel(this.overlayHandle,n,i.label));break}await Y.setBrushForLabel(n,e?U(e):void 0,r);break}case`labelCaptureBasicOverlaySetListener`:this.overlayHandle=t.payload.labelCaptureBasicOverlayHandle,await Y.setListener(t.payload.labelCaptureBasicOverlayHandle,this.labelCaptureBasicOverlayListener),this.overlayListenerAdded=!0;break;case`labelCaptureBasicOverlaySetShouldShowScanAreaGuides`:await Y.setShouldShowScanAreaGuides(t.payload.labelCaptureBasicOverlayHandle,t.payload.show);break;case`labelCaptureBasicOverlayGetShouldShowScanAreaGuides`:return{payload:await Y.getShouldShowScanAreaGuides(t.payload.labelCaptureBasicOverlayHandle)};case`labelCaptureBasicOverlayGetViewfinder`:return{payload:await Y.getViewfinder(t.payload.labelCaptureBasicOverlayHandle)};case`labelCaptureBasicOverlayUpdateViewfinder`:{let e=await Ee(t.payload.viewfinderJSON);await Y.setViewfinder(t.payload.labelCaptureBasicOverlayHandle,e);break}}}getBrushForField(e,t){let n=this.getFieldIdentifier(e,t);return this.fieldBrushMap.get(n)}getBrushForLabel(e){let t=this.getLabelIdentifier(e);return this.labelBrushMap.get(t)}getFieldIdentifier(e,t){return`${e.getTrackingId()}-${t.getName()}-${t.getText()??``}`}getFieldIdentifierFromJSON(e,t){return`${e.trackingId}-${t.name}-${t.text??``}`}getLabelIdentifier(e){return e.getTrackingId()}getLabelIdentifierFromJSON(e){return e.trackingId}};function Oe(e){return{receipt:0,"shipping-label":1}[e]}let ke={0:`fedex`,1:`ups`,2:`usps`,3:`dhl`,4:`dpd`,5:`gls`,6:`tnt`,7:`amazon-logistics`,8:`ontrac`,9:`royal-mail`,10:`parcelforce`,11:`evri`,12:`yodel`,13:`chronopost`,14:`colissimo`,15:`mondial-relay`,16:`poste-italiane`,17:`brt`,18:`sda`,19:`hermes`,20:`austrian-post`,21:`swiss-post`,22:`postnl`,23:`bpost`,24:`postnord`,25:`correos`,26:`seur`,27:`inpost`,28:`other`,29:`not-available`};function Ae(e){return ke[e]}var je=class{constructor(e){this.workerMain=e}onProcessingStarted(){this.workerMain.postCallbackMessage({type:`receiptScanningListenerOnProcessingStarted`})}onReceiptScanned(e){this.workerMain.postCallbackMessage({type:`receiptScanningListenerOnReceiptScanned`,payload:{result:{storeName:e.storeName,storeCity:e.storeCity,storeAddress:e.storeAddress,date:e.date,time:e.time,paymentPreTaxTotal:e.paymentPreTaxTotal,paymentTax:e.paymentTax,paymentTotal:e.paymentTotal,loyaltyNumber:e.loyaltyNumber,lineItems:e.lineItems.map(e=>({name:e.name,unitPrice:e.unitPrice,discount:e.discount,quantity:e.quantity,totalPrice:e.totalPrice}))}}})}onReceiptScanningFailed(){this.workerMain.postCallbackMessage({type:`receiptScanningListenerOnReceiptScanningFailed`})}onShippingLabelScanned(e){this.workerMain.postCallbackMessage({type:`receiptScanningListenerOnShippingLabelScanned`,payload:{result:{barcodes:e.barcodes.map(e=>JSON.parse(e.toJson())),trackingId:e.trackingId,receiverFullName:e.receiverFullName,receiverCompany:e.receiverCompany??null,receiverStreet:e.receiverStreet,receiverCity:e.receiverCity,receiverState:e.receiverState??null,receiverPostalCode:e.receiverPostalCode,receiverCountry:e.receiverCountry??null,carrier:Ae(e.carrier)}}})}onShippingLabelScanningFailed(){this.workerMain.postCallbackMessage({type:`receiptScanningListenerOnShippingLabelScanningFailed`})}},Me=class{constructor(e){this.workerMain=e,this.adaptiveRecognitionListener=new je(this.workerMain)}canHandle(e){return e.startsWith(`receiptScanning`)}async handle(e){let{data:t}=e;switch(t.command){case`receiptScanningHandlerStartFlow`:{let e=k.get(t.payload.labelCaptureHandle).adaptiveRecognitionHandler();e.setResultType(Oe(t.payload.resultType)),e.startFlow();break}case`receiptScanningHandlerFinishFlow`:k.get(t.payload.labelCaptureHandle).adaptiveRecognitionHandler().finishFlow();break;case`receiptScanningHandlerAddListener`:k.get(t.payload.labelCaptureHandle).adaptiveRecognitionHandler().addListener(this.adaptiveRecognitionListener);break;case`receiptScanningHandlerRemoveListener`:k.get(t.payload.labelCaptureHandle).adaptiveRecognitionHandler().removeListener(this.adaptiveRecognitionListener);break}}};function Ne(e){return{[z.Fraction]:2,[z.Pixel]:0}[e]}function X(e){return{value:e.value,unit:Ne(e.unit)}}let Z=e=>e.result!=null&&e.error==null;var Q=new class extends N{async loadFromString(e){let t=this.Module.LabelCaptureSettings.loadFromString(e);if(!Z(t))throw Error(t.error);let n=t.result;return k.register(`LabelCaptureSettings`,n)}async createFromLabelDefinitions(e){let t=this.Module.LabelCaptureSettings.createFromLabelDefinitions(e.map(e=>P.impl(e)));if(!Z(t))throw Error(t.error);let n=t.result;return k.register(`LabelCaptureSettings`,n)}async create(e,t,n){let r=this.Module.LabelCaptureSettings.create(e.map(e=>P.impl(e)),t,n);if(!Z(r))throw Error(r.error);let i=r.result;return k.register(`LabelCaptureSettings`,i)}async setLocationSelection(e,t){this.impl(e).setLocationSelection(t)}async getLocationSelection(e){throw Error(`This method must be implemented manually.`)}async getLicenseKey(e){return this.impl(e).getLicenseKey()}async setLicenseKey(e,t){this.impl(e).setLicenseKey(t)}async getLicensee(e){return this.impl(e).getLicensee()}async setLicensee(e,t){this.impl(e).setLicensee(t)}async getIntProperty(e,t){return this.impl(e).getIntProperty(t)}async setIntProperty(e,t,n){this.impl(e).setIntProperty(t,n)}async getBlueprintJson(e){return this.impl(e).getBlueprintJson()}},Pe=class{constructor(e){this.workerMain=e}canHandle(e){return e.startsWith(`labelCaptureSettings`)}async handle(e){let{data:t}=e;switch(t.command){case`labelCaptureSettingsGetLocationSelection`:{let e=await Q.impl(t.payload.settingsHandle).getLocationSelection();return{payload:e?JSON.parse(e.toJson()):void 0}}case`labelCaptureSettingsSetLocationSelection`:if(t.payload.locationSelection.type===`rectangular`){let e=t.payload.locationSelection,n=this.workerMain.Module.RectangularLocationSelection.create();if(e.size.width&&e.size.aspect){let t=X(e.size.width);n.setWidthAndAspectRatio(t,e.size.aspect)}if(e.size.height&&e.size.aspect){let t=X(e.size.height);n.setHeightAndAspectRatio(t,e.size.aspect)}if(e.size.width&&e.size.height){let t=X(e.size.width),r=X(e.size.height);n.setWidthAndHeight(t,r)}Q.impl(t.payload.settingsHandle).setLocationSelection(n)}break}}},Fe=class{constructor(e){this.workerMain=e}onFieldsScanned(e){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnFieldsScanned`,payload:{fields:e.map(e=>({labelField:JSON.parse(e.getLabelField().toJson()),valid:e.isValid(),isProcessingInCloud:e.isProcessingInCloud()}))}})}onScanTimeout(){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnScanTimeout`})}onLabelIsMissingRequiredField(e){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnLabelIsMissingRequiredField`,payload:{fields:e.map(e=>({labelField:JSON.parse(e.getLabelField().toJson()),valid:e.isValid(),isProcessingInCloud:e.isProcessingInCloud()}))}})}onManualInput(e,t,n){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnManualInput`,payload:{field:{labelField:JSON.parse(e.getLabelField().toJson()),valid:e.isValid(),isProcessingInCloud:e.isProcessingInCloud()},oldValue:t,newValue:n}})}onCloudBackupServiceStarted(){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnCloudBackupServiceStarted`})}onCloudBackupServiceStopped(){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnCloudBackupServiceStopped`})}onStateChanged(e){this.workerMain.postCallbackMessage({type:`validationFlowListenerOnStateChanged`,payload:{state:e}})}onResultUpdate(e,t,n){let r=n?this.workerMain.dataCaptureInstance.prepareFrameForListener(n):void 0;this.workerMain.postCallbackMessage({type:`validationFlowListenerOnResultUpdate`,payload:{updateType:e.type,fields:t.map(e=>({labelField:JSON.parse(e.getLabelField().toJson()),valid:e.isValid(),isProcessingInCloud:e.isProcessingInCloud()})),data:r}}),n?.delete()}};let $=e=>k.get(e);var Ie=class{constructor(e){this.workerMain=e,this.cloudBackupFeedback=null,this.validationFlowListener=new Fe(this.workerMain)}getOrCreateCloudBackupFeedback(){if(!this.cloudBackupFeedback){let e=this.workerMain.Module.Feedback.extend(`Feedback`,{emit:()=>{this.workerMain.postCallbackMessage({type:`validationFlowFeedbackForCloudBackupEmit`})}});this.cloudBackupFeedback=new e}return this.cloudBackupFeedback}canHandle(e){return e.startsWith(`validationFlow`)}async handle(e){let{data:t}=e;switch(t.command){case`validationFlowHandlerCreate`:{let e=$(t.payload.labelCaptureHandle).validationFlowHandler();return e.addListener(this.validationFlowListener),e.setFeedbackForCloudBackup(this.getOrCreateCloudBackupFeedback()),{payload:t.payload.labelCaptureHandle}}case`validationFlowHandlerStartCompleteLabelScan`:$(t.payload.labelCaptureHandle).validationFlowHandler().startCompleteLabelScan(t.payload.labelName);break;case`validationFlowHandlerStartPartialLabelScan`:$(t.payload.labelCaptureHandle).validationFlowHandler().startPartialLabelScan(t.payload.targets);break;case`validationFlowHandlerUpdateFieldValue`:return{payload:$(t.payload.labelCaptureHandle).validationFlowHandler().updateFieldValue(t.payload.target,t.payload.value)};case`validationFlowHandlerFinishFlow`:{let e=$(t.payload.labelCaptureHandle).validationFlowHandler().finishFlow();return e.type===`error`?{payload:e}:{payload:{type:`result`,result:e.result.map(e=>({labelField:JSON.parse(e.getLabelField().toJson()),valid:e.isValid()}))}}}case`validationFlowHandlerPauseScan`:$(t.payload.labelCaptureHandle).validationFlowHandler().pauseScan();break;case`validationFlowHandlerResumeScan`:$(t.payload.labelCaptureHandle).validationFlowHandler().resumeScan();break;case`validationFlowHandlerReset`:$(t.payload.labelCaptureHandle).validationFlowHandler().reset();break;case`validationFlowHandlerGetValidationFlowFields`:return{payload:$(t.payload.labelCaptureHandle).validationFlowHandler().validationFlowFields().map(e=>({labelField:JSON.parse(e.getLabelField().toJson()),valid:e.isValid(),isProcessingInCloud:e.isProcessingInCloud()}))};case`validationFlowHandlerCancelCloudBackupTaskForField`:$(t.payload.labelCaptureHandle).validationFlowHandler().cancelCloudBackupTaskForField(t.payload.fieldName);break;case`validationFlowHandlerUncancelCloudBackupTaskForField`:$(t.payload.labelCaptureHandle).validationFlowHandler().uncancelCloudBackupTaskForField(t.payload.fieldName);break;case`validationFlowHandlerClearAllFields`:$(t.payload.labelCaptureHandle).validationFlowHandler().clearAllFields();break}}};let Le=new class extends fe{constructor(e,t){super(e,t),this.dataCaptureInstance=new pe(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),this.fieldBuilderHandler=new we,this.settingsHandler=new Pe(this),this.labelCaptureBasicOverlayHandler=new De(this),this.validationFlowHandler=new Ie(this),this.adaptiveRecognitionHandler=new Me(this)}get Module(){return this.dataCaptureInstance.Module}async respondWith(e,t,n){let i=null,a;try{a=n(),a instanceof Promise&&(a=await a)}catch(e){a=void 0,i=r(e)}let o={type:`workerTaskId`,command:e,id:t,payload:this.hasPayload(a)?a.payload:void 0};i!=null&&(o.error=i),this.postMessage(o,this.hasTransferables(a)?a.transferables:[])}postCallbackMessage(e,t){this.postMessage(e,t)}onMessage(e){let t=e.data.command;if(t==null)return super.onMessage(e);if(xe(t)){let n=e;return this.respondWith(t,n.data.id,async()=>({payload:await be(n.data,{module:this.Module})})),!0}return t===`initializeNativeHandles`?(this.respondWith(t,e.data.id,()=>({payload:{contextHandle:k.register(`DataCaptureContext`,this.dataCaptureInstance.context),listenerHandle:k.register(`LabelCaptureListener`,this)}})),!0):this.fieldBuilderHandler.canHandle(t)?(this.respondWith(t,e.data.id,()=>this.fieldBuilderHandler.handle(e)),!0):this.settingsHandler.canHandle(t)?(this.respondWith(t,e.data.id,()=>this.settingsHandler.handle(e)),!0):this.labelCaptureBasicOverlayHandler.canHandle(t)?(this.respondWith(t,e.data.id,()=>this.labelCaptureBasicOverlayHandler.handle(e)),!0):this.validationFlowHandler.canHandle(t)?(this.respondWith(t,e.data.id,()=>this.validationFlowHandler.handle(e)),!0):this.adaptiveRecognitionHandler.canHandle(t)?(this.respondWith(t,e.data.id,()=>this.adaptiveRecognitionHandler.handle(e)),!0):t===`addNativeOverlay`?(this.respondWith(t,e.data.id,async()=>{this.dataCaptureInstance.addNativeOverlay(e)}),!0):t===`removeNativeOverlay`?(this.respondWith(t,e.data.id,async()=>{this.dataCaptureInstance.removeNativeOverlay(e)}),!0):super.onMessage(e)}onObservationStarted(){this.dataCaptureInstance.reportInsufficientMultithreadingIfNeeded(`LabelCapture`),this.postCallbackMessage({type:`labelCaptureOnObservationStarted`})}onObservationStopped(){this.postCallbackMessage({type:`labelCaptureOnObservationStopped`})}onSessionUpdated(e,t,n){this.postCallbackMessage({type:`labelCaptureOnSessionUpdated`,payload:{session:JSON.parse(t.toJson()),data:this.dataCaptureInstance.prepareFrameForListener(n)}}),n.delete()}}(globalThis,{get:()=>globalThis.Module,set:e=>{globalThis.Module=e}});return e.workerInstance=Le,e})({});