import { scanImageData } from 'zbar.wasm'

if (typeof importScripts === "function") {
  self.addEventListener('message', async e => {
    const symbols = await scanImageData(e.data.imageData)
    self.postMessage({
      response: symbols.map((sym, n) => ({
        index: n,
        typeName: sym.typeName,
        value: sym.decode(),
        points: sym.points,
      }))
    })
  })
}