@tbsoft-gmbh/signature-sdk 1.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/node-gyp-build/node-gyp-build.js","../node_modules/node-gyp-build/index.js","../node_modules/usb/tsc/usb/bindings.ts","../node_modules/usb/tsc/usb/endpoint.ts","../node_modules/usb/tsc/usb/interface.ts","../node_modules/usb/tsc/usb/capability.ts","../node_modules/usb/tsc/usb/device.ts","../node_modules/usb/tsc/usb/index.ts","../node_modules/usb/tsc/webusb/webusb-device.ts","../node_modules/usb/tsc/webusb/index.ts","../node_modules/usb/dist/usb/descriptors.js","../node_modules/usb/tsc/index.ts","../src/png-decode.ts","../src/driver-hid.ts","../src/usb-transport.ts","../src/hid-protocol.ts","../src/hid-display.ts","../src/font-8x13.ts","../src/hid-crypto.ts","../src/signature-renderer.ts","../src/assets-embedded.ts"],"sourcesContent":["var fs = require('fs')\nvar path = require('path')\nvar os = require('os')\n\n// Workaround to fix webpack's build warnings: 'the request of a dependency is an expression'\nvar runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require // eslint-disable-line\n\nvar vars = (process.config && process.config.variables) || {}\nvar prebuildsOnly = !!process.env.PREBUILDS_ONLY\nvar abi = process.versions.modules // TODO: support old node where this is undef\nvar runtime = isElectron() ? 'electron' : (isNwjs() ? 'node-webkit' : 'node')\n\nvar arch = process.env.npm_config_arch || os.arch()\nvar platform = process.env.npm_config_platform || os.platform()\nvar libc = process.env.LIBC || (isAlpine(platform) ? 'musl' : 'glibc')\nvar armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || ''\nvar uv = (process.versions.uv || '').split('.')[0]\n\nmodule.exports = load\n\nfunction load (dir) {\n return runtimeRequire(load.resolve(dir))\n}\n\nload.resolve = load.path = function (dir) {\n dir = path.resolve(dir || '.')\n\n try {\n var name = runtimeRequire(path.join(dir, 'package.json')).name.toUpperCase().replace(/-/g, '_')\n if (process.env[name + '_PREBUILD']) dir = process.env[name + '_PREBUILD']\n } catch (err) {}\n\n if (!prebuildsOnly) {\n var release = getFirst(path.join(dir, 'build/Release'), matchBuild)\n if (release) return release\n\n var debug = getFirst(path.join(dir, 'build/Debug'), matchBuild)\n if (debug) return debug\n }\n\n var prebuild = resolve(dir)\n if (prebuild) return prebuild\n\n var nearby = resolve(path.dirname(process.execPath))\n if (nearby) return nearby\n\n var target = [\n 'platform=' + platform,\n 'arch=' + arch,\n 'runtime=' + runtime,\n 'abi=' + abi,\n 'uv=' + uv,\n armv ? 'armv=' + armv : '',\n 'libc=' + libc,\n 'node=' + process.versions.node,\n process.versions.electron ? 'electron=' + process.versions.electron : '',\n typeof __webpack_require__ === 'function' ? 'webpack=true' : '' // eslint-disable-line\n ].filter(Boolean).join(' ')\n\n throw new Error('No native build was found for ' + target + '\\n loaded from: ' + dir + '\\n')\n\n function resolve (dir) {\n // Find matching \"prebuilds/<platform>-<arch>\" directory\n var tuples = readdirSync(path.join(dir, 'prebuilds')).map(parseTuple)\n var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0]\n if (!tuple) return\n\n // Find most specific flavor first\n var prebuilds = path.join(dir, 'prebuilds', tuple.name)\n var parsed = readdirSync(prebuilds).map(parseTags)\n var candidates = parsed.filter(matchTags(runtime, abi))\n var winner = candidates.sort(compareTags(runtime))[0]\n if (winner) return path.join(prebuilds, winner.file)\n }\n}\n\nfunction readdirSync (dir) {\n try {\n return fs.readdirSync(dir)\n } catch (err) {\n return []\n }\n}\n\nfunction getFirst (dir, filter) {\n var files = readdirSync(dir).filter(filter)\n return files[0] && path.join(dir, files[0])\n}\n\nfunction matchBuild (name) {\n return /\\.node$/.test(name)\n}\n\nfunction parseTuple (name) {\n // Example: darwin-x64+arm64\n var arr = name.split('-')\n if (arr.length !== 2) return\n\n var platform = arr[0]\n var architectures = arr[1].split('+')\n\n if (!platform) return\n if (!architectures.length) return\n if (!architectures.every(Boolean)) return\n\n return { name, platform, architectures }\n}\n\nfunction matchTuple (platform, arch) {\n return function (tuple) {\n if (tuple == null) return false\n if (tuple.platform !== platform) return false\n return tuple.architectures.includes(arch)\n }\n}\n\nfunction compareTuples (a, b) {\n // Prefer single-arch prebuilds over multi-arch\n return a.architectures.length - b.architectures.length\n}\n\nfunction parseTags (file) {\n var arr = file.split('.')\n var extension = arr.pop()\n var tags = { file: file, specificity: 0 }\n\n if (extension !== 'node') return\n\n for (var i = 0; i < arr.length; i++) {\n var tag = arr[i]\n\n if (tag === 'node' || tag === 'electron' || tag === 'node-webkit') {\n tags.runtime = tag\n } else if (tag === 'napi') {\n tags.napi = true\n } else if (tag.slice(0, 3) === 'abi') {\n tags.abi = tag.slice(3)\n } else if (tag.slice(0, 2) === 'uv') {\n tags.uv = tag.slice(2)\n } else if (tag.slice(0, 4) === 'armv') {\n tags.armv = tag.slice(4)\n } else if (tag === 'glibc' || tag === 'musl') {\n tags.libc = tag\n } else {\n continue\n }\n\n tags.specificity++\n }\n\n return tags\n}\n\nfunction matchTags (runtime, abi) {\n return function (tags) {\n if (tags == null) return false\n if (tags.runtime && tags.runtime !== runtime && !runtimeAgnostic(tags)) return false\n if (tags.abi && tags.abi !== abi && !tags.napi) return false\n if (tags.uv && tags.uv !== uv) return false\n if (tags.armv && tags.armv !== armv) return false\n if (tags.libc && tags.libc !== libc) return false\n\n return true\n }\n}\n\nfunction runtimeAgnostic (tags) {\n return tags.runtime === 'node' && tags.napi\n}\n\nfunction compareTags (runtime) {\n // Precedence: non-agnostic runtime, abi over napi, then by specificity.\n return function (a, b) {\n if (a.runtime !== b.runtime) {\n return a.runtime === runtime ? -1 : 1\n } else if (a.abi !== b.abi) {\n return a.abi ? -1 : 1\n } else if (a.specificity !== b.specificity) {\n return a.specificity > b.specificity ? -1 : 1\n } else {\n return 0\n }\n }\n}\n\nfunction isNwjs () {\n return !!(process.versions && process.versions.nw)\n}\n\nfunction isElectron () {\n if (process.versions && process.versions.electron) return true\n if (process.env.ELECTRON_RUN_AS_NODE) return true\n return typeof window !== 'undefined' && window.process && window.process.type === 'renderer'\n}\n\nfunction isAlpine (platform) {\n return platform === 'linux' && fs.existsSync('/etc/alpine-release')\n}\n\n// Exposed for unit tests\n// TODO: move to lib\nload.parseTags = parseTags\nload.matchTags = matchTags\nload.compareTags = compareTags\nload.parseTuple = parseTuple\nload.matchTuple = matchTuple\nload.compareTuples = compareTuples\n","const runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require // eslint-disable-line\nif (typeof runtimeRequire.addon === 'function') { // if the platform supports native resolving prefer that\n module.exports = runtimeRequire.addon.bind(runtimeRequire)\n} else { // else use the runtime version here\n module.exports = require('./node-gyp-build.js')\n}\n",null,null,null,null,null,null,null,null,"\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n//# sourceMappingURL=descriptors.js.map",null,"/**\r\n * Minimal PNG decoder using only Node.js built-in zlib.\r\n * Supports 8-bit RGB, RGBA, Grayscale, and Grayscale+Alpha PNGs.\r\n * No external dependencies.\r\n */\r\n\r\nimport zlib from \"zlib\";\r\n\r\nexport interface DecodedPng {\r\n width: number;\r\n height: number;\r\n channels: number; // 1=gray, 2=gray+alpha, 3=RGB, 4=RGBA\r\n data: Buffer; // Raw pixel data, row-major, channels interleaved\r\n}\r\n\r\nexport function decodePng(buf: Buffer): DecodedPng | null {\r\n // Verify PNG signature\r\n if (buf[0] !== 0x89 || buf[1] !== 0x50 || buf[2] !== 0x4E || buf[3] !== 0x47) {\r\n return null;\r\n }\r\n\r\n let offset = 8; // Skip signature\r\n let width = 0, height = 0, bitDepth = 0, colorType = 0;\r\n const idatChunks: Buffer[] = [];\r\n\r\n // Parse chunks\r\n while (offset < buf.length) {\r\n const chunkLen = buf.readUInt32BE(offset);\r\n const chunkType = buf.toString(\"ascii\", offset + 4, offset + 8);\r\n\r\n if (chunkType === \"IHDR\") {\r\n width = buf.readUInt32BE(offset + 8);\r\n height = buf.readUInt32BE(offset + 12);\r\n bitDepth = buf[offset + 16];\r\n colorType = buf[offset + 17];\r\n } else if (chunkType === \"IDAT\") {\r\n idatChunks.push(buf.slice(offset + 8, offset + 8 + chunkLen));\r\n } else if (chunkType === \"IEND\") {\r\n break;\r\n }\r\n\r\n offset += 12 + chunkLen; // 4 len + 4 type + data + 4 crc\r\n }\r\n\r\n if (width === 0 || height === 0 || idatChunks.length === 0) return null;\r\n\r\n // Determine channels from color type\r\n let channels: number;\r\n switch (colorType) {\r\n case 0: channels = 1; break; // Grayscale\r\n case 2: channels = 3; break; // RGB\r\n case 4: channels = 2; break; // Grayscale + Alpha\r\n case 6: channels = 4; break; // RGBA\r\n default: return null; // Indexed/other not supported\r\n }\r\n\r\n // Decompress IDAT data\r\n const compressed = Buffer.concat(idatChunks);\r\n let decompressed: Buffer;\r\n try {\r\n decompressed = zlib.inflateSync(compressed);\r\n } catch {\r\n return null;\r\n }\r\n\r\n // Apply PNG filtering (each row has a filter byte prefix)\r\n const bytesPerPixel = channels * (bitDepth / 8);\r\n const stride = width * bytesPerPixel;\r\n const pixels = Buffer.alloc(height * stride);\r\n\r\n let srcOffset = 0;\r\n for (let y = 0; y < height; y++) {\r\n const filterType = decompressed[srcOffset++];\r\n const rowStart = y * stride;\r\n const prevRowStart = (y - 1) * stride;\r\n\r\n for (let x = 0; x < stride; x++) {\r\n const raw = decompressed[srcOffset++];\r\n let value: number;\r\n\r\n switch (filterType) {\r\n case 0: // None\r\n value = raw;\r\n break;\r\n case 1: // Sub\r\n value = raw + (x >= bytesPerPixel ? pixels[rowStart + x - bytesPerPixel] : 0);\r\n break;\r\n case 2: // Up\r\n value = raw + (y > 0 ? pixels[prevRowStart + x] : 0);\r\n break;\r\n case 3: // Average\r\n const left = x >= bytesPerPixel ? pixels[rowStart + x - bytesPerPixel] : 0;\r\n const up = y > 0 ? pixels[prevRowStart + x] : 0;\r\n value = raw + Math.floor((left + up) / 2);\r\n break;\r\n case 4: // Paeth\r\n const a = x >= bytesPerPixel ? pixels[rowStart + x - bytesPerPixel] : 0;\r\n const b = y > 0 ? pixels[prevRowStart + x] : 0;\r\n const c = (x >= bytesPerPixel && y > 0) ? pixels[prevRowStart + x - bytesPerPixel] : 0;\r\n value = raw + paethPredictor(a, b, c);\r\n break;\r\n default:\r\n value = raw;\r\n }\r\n\r\n pixels[rowStart + x] = value & 0xFF;\r\n }\r\n }\r\n\r\n return { width, height, channels, data: pixels };\r\n}\r\n\r\nfunction paethPredictor(a: number, b: number, c: number): number {\r\n const p = a + b - c;\r\n const pa = Math.abs(p - a);\r\n const pb = Math.abs(p - b);\r\n const pc = Math.abs(p - c);\r\n if (pa <= pb && pa <= pc) return a;\r\n if (pb <= pc) return b;\r\n return c;\r\n}\r\n","/**\r\n * Cross-platform HID driver for Signotec signing pads.\r\n *\r\n * Uses direct USB HID communication via node-hid. Works on Windows, macOS, and Linux\r\n * without any native DLL/SO dependencies.\r\n *\r\n * Features:\r\n * - Device discovery with caching and validation\r\n * - Display rendering (text, buttons, PNG/BMP images)\r\n * - AES-256-CBC signature decryption for live coordinate data\r\n * - Software hotspot detection (cancel/retry/confirm buttons)\r\n * - Signature image rendering (PNG output)\r\n * - Flash standby image storage and restore (0x89/0x8A protocol)\r\n * - Configurable timeouts for USB-over-IP environments\r\n * - Automatic retry on failed commands\r\n * - Disconnect detection and session recovery\r\n * - Mutex to prevent concurrent signing sessions\r\n *\r\n * @module driver-hid\r\n */\r\n\r\nimport path from \"path\";\r\nimport fs from \"fs\";\r\nimport type {\r\n PadDriver,\r\n DeviceInfo,\r\n DriverConfig,\r\n Logger,\r\n SignatureCallbackHandlers,\r\n StartSignatureOptions,\r\n} from \"./types\";\r\nimport { HidProtocol, SIG_EVENT, type PadInfo } from \"./hid-protocol\";\r\nimport { DisplayRenderer, fontLineHeight } from \"./hid-display\";\r\nimport { SignatureDecryptor } from \"./hid-crypto\";\r\nimport { renderSignaturePng } from \"./signature-renderer\";\r\nimport { CANCEL_BMP, OK_BMP, RETRY_PNG } from \"./assets-embedded\";\r\n\r\n// ─── Constants ──────────────────────────────────────────────────────────────────\r\n\r\n/** Button hotspot areas on the pad display (matches Windows driver layout). */\r\nconst HOTSPOTS = [\r\n { id: 0, label: \"Cancel\", left: 8, top: 5, width: 85, height: 33 },\r\n { id: 1, label: \"Retry\", left: 115, top: 5, width: 85, height: 33 },\r\n { id: 2, label: \"Confirm\", left: 223, top: 5, width: 85, height: 33 },\r\n] as const;\r\n\r\n/** Sensor coordinate range (0-4096 for Sigma pads). */\r\nconst SENSOR_RANGE = 4096;\r\n\r\n/** Tap detection thresholds for software hotspot detection. */\r\nconst TAP = {\r\n MAX_POINTS: 200, // max pen-data events for a tap (~800ms at 250Hz)\r\n MAX_DURATION: 800, // max tap duration in ms\r\n MAX_DRIFT: 30, // max pen movement in display pixels\r\n} as const;\r\n\r\n/** Minimum signature image size to consider valid (bytes). */\r\nconst MIN_SIGNATURE_SIZE = 500;\r\n\r\n// ─── Helpers ────────────────────────────────────────────────────────────────────\r\n\r\n/** Convert sensor coordinates (0-4096) to display coordinates (0-320/0-160). */\r\nfunction sensorToDisplay(sx: number, sy: number, dw: number, dh: number): { x: number; y: number } {\r\n return {\r\n x: Math.round(sx * dw / SENSOR_RANGE),\r\n y: Math.round(sy * dh / SENSOR_RANGE),\r\n };\r\n}\r\n\r\ntype Point = { x: number; y: number; pressure?: number };\r\n\r\n// ─── Driver Factory ─────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Create a new Signotec HID driver instance.\r\n *\r\n * @param config - Optional configuration for timeouts, retries, and logging.\r\n * @returns PadDriver instance ready for use.\r\n *\r\n * @example\r\n * ```typescript\r\n * // Default configuration:\r\n * const driver = createHidDriver();\r\n *\r\n * // For slow USB-over-IP connections:\r\n * const driver = createHidDriver({\r\n * commandTimeout: 5000,\r\n * chunkDelayMs: 10,\r\n * maxRetries: 3,\r\n * });\r\n * ```\r\n */\r\nexport function createHidDriver(config?: DriverConfig): PadDriver {\r\n const log: Logger = config?.logger === null\r\n ? { info() {}, warn() {}, error() {} }\r\n : (config?.logger ?? console);\r\n\r\n const onDriverEvent = config?.onDriverEvent;\r\n\r\n /** Emit a structured driver event for external logging (Grafana/Loki etc.) */\r\n function emit(\r\n level: \"info\" | \"warn\" | \"error\",\r\n message: string,\r\n category: \"session\" | \"device\" | \"usb\" | \"display\" | \"signature\" | \"flash\",\r\n data?: Record<string, unknown>\r\n ): void {\r\n // Log to logger\r\n if (level === \"error\") log.error(`[${category}] ${message}`, data ?? \"\");\r\n else if (level === \"warn\") log.warn(`[${category}] ${message}`, data ?? \"\");\r\n else log.info(`[${category}] ${message}`, data ?? \"\");\r\n\r\n // Emit structured event\r\n onDriverEvent?.({\r\n level, message, category, data,\r\n timestamp: new Date().toISOString(),\r\n });\r\n }\r\n\r\n // ─── Session State ──────────────────────────────────────────────────────────\r\n\r\n let protocol: HidProtocol | null = null;\r\n let padInfo: PadInfo | null = null;\r\n let currentHandlers: SignatureCallbackHandlers | null = null;\r\n let currentSerialNo: string | null = null;\r\n let lastOptions: StartSignatureOptions | null = null;\r\n let lastDevicePath: string | null = null;\r\n\r\n // Signature capture\r\n let isCapturing = false;\r\n /** Promise-based mutex: serializes session access to prevent concurrent opens. */\r\n let sessionLock: Promise<void> = Promise.resolve();\r\n let decryptor: SignatureDecryptor | null = null;\r\n let currentStroke: Point[] = [];\r\n let allStrokes: Point[][] = [];\r\n let signatureEventCount = 0;\r\n\r\n // Tap detection\r\n let tapStartTime = 0;\r\n let tapStartPoint: { x: number; y: number } | null = null;\r\n let tapPointCount = 0;\r\n let tapMaxDrift = 0;\r\n\r\n // Reconnection\r\n let reconnectTimer: ReturnType<typeof setTimeout> | null = null;\r\n\r\n // Device cache\r\n let cachedDeviceList: DeviceInfo[] | null = null;\r\n let cacheTimestamp = 0;\r\n const CACHE_TTL = 2000; // 2 seconds\r\n\r\n // ─── Cleanup ────────────────────────────────────────────────────────────────\r\n\r\n /** Promise that resolves when cleanup is fully done (device handle released). */\r\n let cleanupPromise: Promise<void> = Promise.resolve();\r\n\r\n /**\r\n * Clean up the current signing session.\r\n * Stops signature, restores standby from flash, closes device.\r\n * Returns a Promise that resolves when the device is fully released.\r\n */\r\n function cleanup(): Promise<void> {\r\n if (reconnectTimer) {\r\n clearTimeout(reconnectTimer);\r\n reconnectTimer = null;\r\n }\r\n isCapturing = false;\r\n\r\n const prot = protocol;\r\n protocol = null;\r\n currentHandlers = null;\r\n currentSerialNo = null;\r\n decryptor = null;\r\n currentStroke = [];\r\n allStrokes = [];\r\n signatureEventCount = 0;\r\n tapStartPoint = null;\r\n tapPointCount = 0;\r\n tapMaxDrift = 0;\r\n if (!prot) {\r\n cleanupPromise = Promise.resolve();\r\n return cleanupPromise;\r\n }\r\n\r\n prot.onSignatureEvent(null);\r\n prot.onDisconnect(null);\r\n\r\n cleanupPromise = (async () => {\r\n try {\r\n if (prot.isConnected()) {\r\n await prot.stopSignature().catch(() => {});\r\n // Drain stale responses (device sends extra ACKs after stopping)\r\n await new Promise(r => setTimeout(r, 200));\r\n await prot.eraseDisplay().catch(() => {});\r\n // Drain stale ACK from eraseDisplay before showStandby\r\n await new Promise(r => setTimeout(r, 300));\r\n await prot.showStandbyFromFlash().catch(() => {});\r\n await new Promise(r => setTimeout(r, 100));\r\n }\r\n } catch (err) {\r\n emit(\"warn\", \"Error during cleanup: \" + (err as Error).message, \"session\");\r\n }\r\n try { prot.close(); } catch (err) {\r\n emit(\"warn\", \"Error closing device: \" + (err as Error).message, \"device\");\r\n }\r\n // Give the OS time to release the device handle\r\n // (macOS HID needs ~300ms; USB/libusb interface release is async)\r\n await new Promise(r => setTimeout(r, 500));\r\n })();\r\n\r\n return cleanupPromise;\r\n }\r\n\r\n // ─── Hotspot Detection ──────────────────────────────────────────────────────\r\n\r\n /** Check if display coordinates fall within a button hotspot area. */\r\n function checkHotspot(x: number, y: number): number | null {\r\n for (const hs of HOTSPOTS) {\r\n if (x >= hs.left && x <= hs.left + hs.width &&\r\n y >= hs.top && y <= hs.top + hs.height) {\r\n return hs.id;\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n // ─── Signature Event Handling ───────────────────────────────────────────────\r\n\r\n function handleSignatureEvent(type: number, data: Buffer): void {\r\n if (!isCapturing || !currentHandlers || !currentSerialNo || !decryptor) return;\r\n\r\n const dw = padInfo?.displayWidth || 320;\r\n const dh = padInfo?.displayHeight || 160;\r\n\r\n if (type === SIG_EVENT.PEN_DATA || type === SIG_EVENT.PEN_DATA_EXT) {\r\n signatureEventCount++;\r\n\r\n const point = decryptor.decryptEvent(data);\r\n if (!point) return;\r\n\r\n const display = sensorToDisplay(point.x, point.y, dw, dh);\r\n\r\n // Tap detection\r\n if (tapPointCount === 0) {\r\n tapStartTime = Date.now();\r\n tapStartPoint = { x: display.x, y: display.y };\r\n tapMaxDrift = 0;\r\n } else if (tapStartPoint) {\r\n const drift = Math.abs(display.x - tapStartPoint.x) + Math.abs(display.y - tapStartPoint.y);\r\n if (drift > tapMaxDrift) tapMaxDrift = drift;\r\n }\r\n tapPointCount++;\r\n\r\n // Only capture strokes in the signature area (below buttons)\r\n if (display.y > 39 && !point.penUp) {\r\n currentStroke.push({ x: point.x, y: point.y, pressure: point.pressure });\r\n // Scale sensor coordinates (0-4096) to DLL-compatible range\r\n // (X: 180-7800, Y: 1024-3455) so existing frontend components work unchanged\r\n const dllX = Math.round(180 + (point.x / SENSOR_RANGE) * 7620);\r\n const dllY = Math.round(1024 + (point.y / SENSOR_RANGE) * 2431);\r\n currentHandlers.onSignatureData(\"liveData\", {\r\n point: { x: dllX, y: dllY, pressure: point.pressure },\r\n serialNo: currentSerialNo,\r\n });\r\n }\r\n } else if (type === SIG_EVENT.PEN_UP) {\r\n // Check for button tap\r\n const tapDuration = Date.now() - tapStartTime;\r\n const isTap = tapPointCount > 0 &&\r\n tapPointCount < TAP.MAX_POINTS &&\r\n tapDuration < TAP.MAX_DURATION &&\r\n tapMaxDrift < TAP.MAX_DRIFT;\r\n\r\n if (isTap && tapStartPoint) {\r\n const hotspotId = checkHotspot(tapStartPoint.x, tapStartPoint.y);\r\n if (hotspotId !== null) {\r\n handleHotspotPress(hotspotId);\r\n }\r\n }\r\n\r\n // End current stroke\r\n if (currentStroke.length > 0) {\r\n allStrokes.push([...currentStroke]);\r\n currentStroke = [];\r\n }\r\n\r\n // Reset tap detection\r\n tapPointCount = 0;\r\n tapStartPoint = null;\r\n tapMaxDrift = 0;\r\n }\r\n }\r\n\r\n /** Handle a hotspot button press. */\r\n function handleHotspotPress(id: number): void {\r\n if (!currentHandlers || !currentSerialNo) return;\r\n\r\n switch (id) {\r\n case 0: // Cancel\r\n emit(\"info\", \"Cancel button pressed\", \"session\");\r\n isCapturing = false;\r\n currentHandlers.onUserEvent(\"cancel\", { serialNo: currentSerialNo });\r\n cleanup(); // starts async cleanup\r\n break;\r\n\r\n case 1: // Retry\r\n emit(\"info\", \"Retry button pressed\", \"session\");\r\n currentStroke = [];\r\n allStrokes = [];\r\n signatureEventCount = 0;\r\n decryptor?.resetIv();\r\n tapPointCount = 0;\r\n tapStartPoint = null;\r\n currentHandlers.onSignatureData(\"clear\", { serialNo: currentSerialNo });\r\n // Redraw UI and restart capture (mirrors initial startSigningProcess flow)\r\n if (protocol?.isConnected() && lastOptions) {\r\n isCapturing = false;\r\n (async () => {\r\n try {\r\n await protocol!.stopSignature();\r\n await protocol!.eraseDisplay();\r\n await new Promise(r => setTimeout(r, 200));\r\n await drawPadUI(lastOptions!);\r\n // Drain stale ACKs from image transfer before next command\r\n await new Promise(r => setTimeout(r, 200));\r\n await protocol!.setSignRect(8, 40, 300, 95);\r\n isCapturing = true;\r\n await protocol!.startSignature();\r\n } catch (err) {\r\n log.error(\"Error during retry:\", (err as Error).message);\r\n }\r\n })();\r\n }\r\n break;\r\n\r\n case 2: // Confirm\r\n emit(\"info\", \"Confirm button pressed\", \"session\");\r\n driver.confirmSignature();\r\n break;\r\n }\r\n }\r\n\r\n // ─── Disconnect & Recovery ──────────────────────────────────────────────────\r\n\r\n function handleDisconnect(): void {\r\n emit(\"warn\", \"Pad disconnected during signing\", \"usb\");\r\n isCapturing = false;\r\n\r\n if (lastDevicePath && currentHandlers) {\r\n attemptReconnect();\r\n }\r\n }\r\n\r\n function attemptReconnect(): void {\r\n if (reconnectTimer) return;\r\n\r\n const maxAttempts = config?.reconnectAttempts ?? 10;\r\n const interval = config?.reconnectIntervalMs ?? 2000;\r\n let attempts = 0;\r\n\r\n const tryReconnect = () => {\r\n attempts++;\r\n if (attempts > maxAttempts) {\r\n log.error(`Signotec pad reconnection failed after ${maxAttempts} attempts`);\r\n currentHandlers?.onUserEvent(\"cancel\", { serialNo: currentSerialNo || \"unknown\" });\r\n cleanup();\r\n return;\r\n }\r\n\r\n log.info(`Signotec reconnect attempt ${attempts}/${maxAttempts}...`);\r\n try {\r\n const prot = new HidProtocol(config);\r\n const devices = prot.listDevices();\r\n if (devices.length > 0) {\r\n log.info(\"Signotec pad reconnected - cancelling session (state lost)\");\r\n currentHandlers?.onUserEvent(\"cancel\", { serialNo: currentSerialNo || \"unknown\" });\r\n cleanup();\r\n return;\r\n }\r\n } catch (err) {\r\n log.warn(\"Reconnect probe error:\", (err as Error).message);\r\n }\r\n\r\n reconnectTimer = setTimeout(tryReconnect, interval);\r\n };\r\n\r\n reconnectTimer = setTimeout(tryReconnect, 1000);\r\n }\r\n\r\n // ─── Display Rendering ──────────────────────────────────────────────────────\r\n\r\n /**\r\n * Draw the signing UI on the pad display.\r\n * Includes: button bar (Cancel/Retry/OK), text content, signature line, footer.\r\n */\r\n async function drawPadUI(options: StartSignatureOptions): Promise<void> {\r\n if (!protocol || !padInfo) return;\r\n\r\n const w = padInfo.displayWidth;\r\n const h = padInfo.displayHeight;\r\n const renderer = new DisplayRenderer(w, h);\r\n renderer.clear();\r\n\r\n // Button bar at top (y: 0-38)\r\n for (const hs of HOTSPOTS) {\r\n renderer.fillRect(hs.left, hs.top, hs.width, hs.height, true);\r\n }\r\n // White text on black buttons (8x13 font fits perfectly in 33px button height)\r\n renderer.drawTextInverted(16, 12, \"Abbruch\", 1);\r\n renderer.drawTextInverted(124, 12, \"Neustart\", 1);\r\n renderer.drawTextInverted(251, 12, \"OK\", 1);\r\n\r\n // Body text - 8x13 font, clean 1px strokes\r\n const dd = options?.displayData;\r\n let textY = 40;\r\n const bodySpacing = 15;\r\n\r\n const drawBodyLine = (line: { label: string; content: string | number; fontSize?: number }) => {\r\n const fs = Math.max(1, Math.min(3, line.fontSize ?? 1));\r\n renderer.drawText(8, textY, `${line.label} ${line.content}`, fs);\r\n textY += bodySpacing;\r\n };\r\n\r\n if (dd?.body?.line1) drawBodyLine(dd.body.line1);\r\n if (dd?.body?.line2) drawBodyLine(dd.body.line2);\r\n if (dd?.body?.line3) drawBodyLine(dd.body.line3);\r\n if (dd?.body?.line4) drawBodyLine(dd.body.line4);\r\n\r\n // \"Unterschrift:\" bold + signature line (where drawing starts)\r\n renderer.drawText(8, 120, \"Unterschrift:\", 1, true);\r\n renderer.hLine(8, 135, w - 16);\r\n\r\n // Footer - right below line\r\n if (dd?.footer?.line1) {\r\n const fs = Math.max(1, Math.min(3, dd.footer.line1.fontSize ?? 1));\r\n renderer.drawText(8, 140, `${dd.footer.line1.label} ${dd.footer.line1.content}`, fs);\r\n }\r\n if (dd?.footer?.line2) {\r\n const fs = Math.max(1, Math.min(3, dd.footer.line2.fontSize ?? 1));\r\n renderer.drawText(203, 140, `${dd.footer.line2.label} ${dd.footer.line2.content}`, fs);\r\n }\r\n\r\n // Overlay embedded button images (no external files needed)\r\n try {\r\n renderer.drawImageData(8, 5, CANCEL_BMP);\r\n renderer.drawImageData(223, 5, OK_BMP);\r\n renderer.drawImageData(115, 5, RETRY_PNG);\r\n } catch (err) {\r\n log.warn(\"Could not render button images:\", (err as Error).message);\r\n }\r\n\r\n await renderer.sendToDevice(protocol);\r\n }\r\n\r\n // ─── Session Start (extracted for mutex wrapping) ──────────────────────────\r\n\r\n async function doStartSession(\r\n serialNo: string,\r\n handlers: SignatureCallbackHandlers,\r\n options: StartSignatureOptions\r\n ): Promise<void> {\r\n // Wait for any previous cleanup to fully complete (device handle released)\r\n await cleanupPromise;\r\n\r\n // If a session is active, clean it up first\r\n if (protocol?.isConnected()) {\r\n log.warn(\"Signotec: Previous session still active, cleaning up first\");\r\n await cleanup();\r\n }\r\n\r\n // Create protocol with config\r\n protocol = new HidProtocol(config);\r\n const devices = protocol.listDevices();\r\n if (devices.length === 0) {\r\n protocol = null;\r\n throw new Error(`No device with serialNo.: ${serialNo} was found.`);\r\n }\r\n\r\n const targetDevice = devices.find(d => d.serialNumber === serialNo) || devices[0];\r\n lastDevicePath = targetDevice.path;\r\n\r\n // Open device with retry (macOS needs time to release HID handles)\r\n const maxOpenRetries = 3;\r\n for (let attempt = 1; attempt <= maxOpenRetries; attempt++) {\r\n try {\r\n protocol.open(targetDevice.path);\r\n break;\r\n } catch (err) {\r\n if (attempt < maxOpenRetries) {\r\n log.warn(`Device open attempt ${attempt}/${maxOpenRetries} failed, retrying in 500ms...`);\r\n await new Promise(r => setTimeout(r, 500));\r\n } else {\r\n protocol = null;\r\n throw new Error(`Failed to open device after ${maxOpenRetries} attempts: ${(err as Error).message}`);\r\n }\r\n }\r\n }\r\n\r\n // Verify device is responsive\r\n const responsive = await protocol.isResponsive();\r\n if (!responsive) {\r\n protocol.close();\r\n protocol = null;\r\n throw new Error(\"Device is connected but not responding. Check USB connection.\");\r\n }\r\n\r\n // Set up event handlers\r\n protocol.onDisconnect(handleDisconnect);\r\n protocol.onSignatureEvent(handleSignatureEvent);\r\n\r\n currentHandlers = handlers;\r\n currentSerialNo = serialNo;\r\n lastOptions = options;\r\n currentStroke = [];\r\n allStrokes = [];\r\n signatureEventCount = 0;\r\n tapPointCount = 0;\r\n tapStartPoint = null;\r\n tapMaxDrift = 0;\r\n\r\n // Initialize AES decryptor\r\n decryptor = SignatureDecryptor.withDefaultKey();\r\n\r\n // Read device info\r\n padInfo = await protocol.getDeviceInfo();\r\n log.info(`Signotec pad: ${padInfo.serialNo} (${padInfo.displayWidth}x${padInfo.displayHeight})`);\r\n\r\n // Erase display\r\n const erased = await protocol.eraseDisplay();\r\n if (!erased) {\r\n await cleanup();\r\n throw new Error(\"Failed to erase display. Device may be unresponsive.\");\r\n }\r\n await new Promise(r => setTimeout(r, 300));\r\n\r\n // Draw signing UI\r\n await drawPadUI(options);\r\n await new Promise(r => setTimeout(r, 200));\r\n\r\n // Set signature rectangle\r\n await protocol.setSignRect(8, 40, 300, 95);\r\n\r\n // Start capture\r\n isCapturing = true;\r\n const started = await protocol.startSignature();\r\n if (!started) {\r\n await cleanup();\r\n throw new Error(\"Failed to start signature capture on device.\");\r\n }\r\n\r\n emit(\"info\", \"Signing session started\", \"session\", { serialNo: currentSerialNo });\r\n }\r\n\r\n // ─── Driver API ─────────────────────────────────────────────────────────────\r\n\r\n const driver: PadDriver = {\r\n getSignotecPads(): DeviceInfo[] {\r\n // Return cached list if fresh enough\r\n if (cachedDeviceList && Date.now() - cacheTimestamp < CACHE_TTL) {\r\n return cachedDeviceList;\r\n }\r\n\r\n try {\r\n const prot = new HidProtocol(config);\r\n const devices = prot.listDevices();\r\n cachedDeviceList = devices.map((d, i) => ({\r\n serialNo: d.serialNumber || `signotec-${i}`,\r\n type: 1,\r\n name: d.product || \"Sigma USB\",\r\n vendor: \"Signotec\",\r\n }));\r\n cacheTimestamp = Date.now();\r\n return cachedDeviceList;\r\n } catch (err) {\r\n emit(\"error\", \"Device discovery failed: \" + (err as Error).message, \"device\");\r\n return [];\r\n }\r\n },\r\n\r\n async startSigningProcess(serialNo, handlers, options) {\r\n // Serialize session access: if another session is running or cleaning up,\r\n // wait for it to finish before starting. This prevents concurrent device opens.\r\n let startError: Error | null = null;\r\n await new Promise<void>((resolve, reject) => {\r\n sessionLock = sessionLock.then(async () => {\r\n try {\r\n await doStartSession(serialNo, handlers, options);\r\n resolve();\r\n } catch (err) {\r\n startError = err as Error;\r\n resolve(); // resolve the lock chain even on error\r\n }\r\n });\r\n });\r\n if (startError) throw startError;\r\n },\r\n\r\n cancelSignature() {\r\n if (!currentSerialNo) return { status: false, message: \"No signature process started\" };\r\n log.info(\"Signotec: Signature cancelled (external)\");\r\n const serial = currentSerialNo;\r\n currentHandlers?.onUserEvent(\"cancel\", { serialNo: serial });\r\n cleanup();\r\n return { status: true, message: \"Signature process stopped\" };\r\n },\r\n\r\n confirmSignature() {\r\n if (!currentSerialNo || !currentHandlers) {\r\n throw new Error(\"No active signature process.\");\r\n }\r\n const serialNo = currentSerialNo;\r\n const handlers = currentHandlers;\r\n\r\n // Finalize current stroke\r\n if (currentStroke.length > 0) {\r\n allStrokes.push([...currentStroke]);\r\n currentStroke = [];\r\n }\r\n\r\n // Render signature image\r\n let base64Img = \"\";\r\n if (allStrokes.length > 0 && allStrokes.some(s => s.length >= 2)) {\r\n try {\r\n const pngBuffer = renderSignaturePng(\r\n allStrokes,\r\n SENSOR_RANGE,\r\n SENSOR_RANGE,\r\n {\r\n width: lastOptions?.outputOptions?.imageSize?.width || 400,\r\n height: lastOptions?.outputOptions?.imageSize?.height || 200,\r\n strokeWidth: lastOptions?.outputOptions?.strokeWidth || 2,\r\n }\r\n );\r\n\r\n if (pngBuffer.length >= MIN_SIGNATURE_SIZE) {\r\n base64Img = \"data:image/png;base64,\" + pngBuffer.toString(\"base64\");\r\n } else {\r\n log.warn(\"Signature too small, may be invalid\");\r\n }\r\n } catch (err) {\r\n log.error(\"Signature image rendering error:\", (err as Error).message);\r\n }\r\n }\r\n\r\n log.info(`Signotec: Signature confirmed (${allStrokes.length} strokes, ${base64Img.length} chars)`);\r\n handlers.onUserEvent(\"confirm\", { base64Img, serialNo });\r\n cleanup(); // starts async cleanup\r\n },\r\n\r\n async continueWithoutSignature() {\r\n if (!currentSerialNo) return { status: false, message: \"No matching device found\" };\r\n log.info(\"Signotec: Continue without signature\");\r\n try {\r\n currentHandlers?.onUserEvent(\"confirm\", { serialNo: currentSerialNo, base64Img: \"\" });\r\n cleanup();\r\n return { status: true, message: \"User prompt cleared\" };\r\n } catch (err) {\r\n log.error(\"continueWithoutSignature error:\", (err as Error).message);\r\n cleanup();\r\n return { status: false, message: \"User prompt could not be cleared\" };\r\n }\r\n },\r\n\r\n async setStandbyImage(imagePath: string | null): Promise<boolean> {\r\n if (!imagePath) return true;\r\n\r\n // Validate file exists and format\r\n if (!fs.existsSync(imagePath)) {\r\n log.error(`Standby image not found: ${imagePath}`);\r\n return false;\r\n }\r\n\r\n const ext = path.extname(imagePath).toLowerCase();\r\n if (ext !== \".png\" && ext !== \".bmp\") {\r\n log.error(`Unsupported standby image format: ${ext}. Use .png or .bmp`);\r\n return false;\r\n }\r\n\r\n try {\r\n const prot = new HidProtocol(config);\r\n const devices = prot.listDevices();\r\n if (devices.length === 0) {\r\n log.error(\"No Signotec device connected for standby image upload\");\r\n return false;\r\n }\r\n\r\n prot.open(devices[0].path);\r\n const info = await prot.getDeviceInfo();\r\n\r\n const w = info.displayWidth || 320;\r\n const h = info.displayHeight || 160;\r\n\r\n // Load and validate image dimensions\r\n const renderer = new DisplayRenderer(w, h);\r\n renderer.clear();\r\n\r\n if (ext === \".png\") renderer.drawPngFile(0, 0, imagePath);\r\n else renderer.drawBmpFile(0, 0, imagePath);\r\n\r\n // Store to flash\r\n log.info(`Storing standby image to flash: ${imagePath} (${w}x${h})`);\r\n const ok = await prot.storeStandbyImage(w, h, renderer.buffer);\r\n\r\n if (ok) {\r\n // Show on display immediately\r\n await prot.eraseDisplay();\r\n await new Promise(r => setTimeout(r, 200));\r\n await prot.drawImage(0, 0, w, h, renderer.buffer);\r\n log.info(\"Standby image stored to flash successfully\");\r\n } else {\r\n log.error(\"Failed to store standby image to flash\");\r\n }\r\n\r\n await new Promise(r => setTimeout(r, 300));\r\n prot.close();\r\n return ok;\r\n } catch (err) {\r\n log.error(\"setStandbyImage error:\", (err as Error).message);\r\n return false;\r\n }\r\n },\r\n\r\n async waitForDevice(timeoutMs = 30000): Promise<DeviceInfo | null> {\r\n const start = Date.now();\r\n const interval = 1000;\r\n\r\n while (Date.now() - start < timeoutMs) {\r\n const pads = driver.getSignotecPads();\r\n if (pads.length > 0) return pads[0];\r\n await new Promise(r => setTimeout(r, interval));\r\n }\r\n return null;\r\n },\r\n };\r\n\r\n return driver;\r\n}\r\n","/**\r\n * Raw USB transport fallback for Signotec pads.\r\n *\r\n * Used when `node-hid` cannot discover the device (e.g., Windows where the\r\n * HID class driver is not loaded). Communicates via interrupt transfers —\r\n * the same 63-byte reports as the HID path, just at the USB level.\r\n *\r\n * Key difference from node-hid: node-hid's write() is synchronous (blocks\r\n * until the USB transfer completes). libusb's transfer() is async. To match\r\n * the behavior the protocol layer expects, we serialize OUT transfers with\r\n * a write queue — each transfer waits for the previous one to complete.\r\n *\r\n * @module usb-transport\r\n */\r\n\r\nimport { EventEmitter } from \"events\";\r\nimport type { Logger } from \"./types\";\r\n\r\nconst SIGNOTEC_VID = 0x2133;\r\nconst SIGNOTEC_PID = 0x0001;\r\nconst REPORT_SIZE = 63;\r\n\r\ntype UsbDevice = any;\r\ntype UsbInterface = any;\r\ntype UsbEndpoint = any;\r\n\r\nexport interface UsbDeviceDescriptor {\r\n path: string;\r\n serialNumber: string;\r\n product: string;\r\n /** Raw libusb device reference for opening. */\r\n _usbDevice: UsbDevice;\r\n}\r\n\r\n/**\r\n * Wraps a raw USB device to expose the same interface as node-hid's HID class.\r\n * Emits \"data\" and \"error\" events, and provides write()/close().\r\n */\r\nexport class UsbTransportDevice extends EventEmitter {\r\n private usbDevice: UsbDevice | null = null;\r\n private iface: UsbInterface | null = null;\r\n private inEndpoint: UsbEndpoint | null = null;\r\n private outEndpoint: UsbEndpoint | null = null;\r\n private closed = false;\r\n private polling = false;\r\n private log: Logger;\r\n private transferSize: number = REPORT_SIZE;\r\n\r\n /**\r\n * Write queue: each entry is a callback that starts the OUT transfer and\r\n * calls `next()` when the transfer completes. This ensures the previous\r\n * USB transfer is fully on the wire before the next one starts — matching\r\n * node-hid's synchronous write() behavior.\r\n */\r\n private writeQueue: Array<() => void> = [];\r\n private writeBusy = false;\r\n\r\n constructor(usbDevice: UsbDevice, log: Logger) {\r\n super();\r\n this.usbDevice = usbDevice;\r\n this.log = log;\r\n\r\n try {\r\n this.usbDevice.open();\r\n } catch (err: any) {\r\n throw new Error(`Cannot open USB device: ${err.message}`);\r\n }\r\n\r\n // Find the interface with interrupt IN+OUT endpoints\r\n const { iface, inEp, outEp } = this.findEndpoints();\r\n this.iface = iface;\r\n this.inEndpoint = inEp;\r\n this.outEndpoint = outEp;\r\n\r\n // Use the endpoint's actual max packet size for IN poll buffer\r\n this.transferSize = this.inEndpoint.descriptor?.wMaxPacketSize || REPORT_SIZE;\r\n this.log.info?.(`USB endpoint max packet size: ${this.transferSize}`);\r\n\r\n // Claim the interface (detach kernel driver if needed on Linux)\r\n try {\r\n if (this.iface.isKernelDriverActive?.()) {\r\n this.iface.detachKernelDriver();\r\n }\r\n } catch {\r\n // Not supported on all platforms\r\n }\r\n\r\n try {\r\n this.iface.claim();\r\n } catch (err: any) {\r\n this.usbDevice.close();\r\n throw new Error(\r\n `Cannot claim USB interface: ${err.message}. ` +\r\n `On Windows, you may need to install WinUSB driver using Zadig.`\r\n );\r\n }\r\n\r\n // Use libusb continuous polling for reliable IN reads\r\n this.startPolling();\r\n }\r\n\r\n private findEndpoints(): { iface: UsbInterface; inEp: UsbEndpoint; outEp: UsbEndpoint } {\r\n const interfaces: UsbInterface[] = this.usbDevice.interfaces;\r\n for (const iface of interfaces) {\r\n let inEp: UsbEndpoint | null = null;\r\n let outEp: UsbEndpoint | null = null;\r\n\r\n for (const ep of iface.endpoints) {\r\n // Interrupt transfer type = 3\r\n if (ep.transferType === 3) {\r\n if (ep.direction === \"in\") inEp = ep;\r\n else if (ep.direction === \"out\") outEp = ep;\r\n }\r\n }\r\n\r\n if (inEp && outEp) {\r\n return { iface, inEp, outEp };\r\n }\r\n }\r\n throw new Error(\r\n \"No suitable USB interface found with interrupt IN+OUT endpoints. \" +\r\n \"The device may require a different driver.\"\r\n );\r\n }\r\n\r\n private startPolling(): void {\r\n if (this.closed || !this.inEndpoint || this.polling) return;\r\n this.polling = true;\r\n\r\n // startPoll keeps multiple IN transfers queued in the kernel\r\n this.inEndpoint.startPoll(3, this.transferSize);\r\n\r\n this.inEndpoint.on(\"data\", (data: Buffer) => {\r\n if (this.closed) return;\r\n if (!data || data.length === 0) return;\r\n this.emit(\"data\", Buffer.from(data));\r\n });\r\n\r\n this.inEndpoint.on(\"error\", (err: Error) => {\r\n if (this.closed) return;\r\n if (err.message?.includes(\"LIBUSB_TRANSFER_CANCELLED\")) return;\r\n if (err.message?.includes(\"LIBUSB_TRANSFER_NO_DEVICE\")) {\r\n this.emit(\"error\", new Error(\"Device disconnected\"));\r\n return;\r\n }\r\n this.log.error?.(\"USB IN error:\", err.message);\r\n this.emit(\"error\", err);\r\n });\r\n }\r\n\r\n /**\r\n * Queue an OUT transfer. Transfers are serialized: each one completes\r\n * before the next starts. This matches node-hid's synchronous write().\r\n */\r\n write(data: number[]): void {\r\n if (this.closed || !this.outEndpoint) {\r\n throw new Error(\"Device not connected\");\r\n }\r\n\r\n const buf = Buffer.alloc(REPORT_SIZE, 0);\r\n for (let i = 0; i < Math.min(data.length, REPORT_SIZE); i++) {\r\n buf[i] = data[i];\r\n }\r\n\r\n this.writeQueue.push(() => {\r\n if (this.closed || !this.outEndpoint) {\r\n // Device closed while queued — skip transfer, advance queue via microtask\r\n // to avoid synchronous re-entrancy from the push() call above.\r\n queueMicrotask(() => this.drainNext());\r\n return;\r\n }\r\n this.outEndpoint.transfer(buf, (err: Error | null) => {\r\n if (err && !this.closed) {\r\n this.log.error(\"USB write error:\", err.message);\r\n this.emit(\"error\", err);\r\n }\r\n this.drainNext();\r\n });\r\n });\r\n\r\n // Kick off the queue if idle\r\n if (!this.writeBusy) {\r\n this.drainNext();\r\n }\r\n }\r\n\r\n private drainNext(): void {\r\n const next = this.writeQueue.shift();\r\n if (next) {\r\n this.writeBusy = true;\r\n next();\r\n } else {\r\n this.writeBusy = false;\r\n // Resolve drain waiters (used by close() to wait for in-flight transfer)\r\n this.drainResolve?.();\r\n this.drainResolve = null;\r\n }\r\n }\r\n\r\n /** Resolve callback for close() waiting on the write queue to drain. */\r\n private drainResolve: (() => void) | null = null;\r\n\r\n /**\r\n * Close the device. Waits up to 1s for any in-flight transfer to complete\r\n * before releasing the USB interface.\r\n */\r\n close(): void {\r\n if (this.closed) return;\r\n this.closed = true;\r\n\r\n // Drop queued (not yet started) writes\r\n this.writeQueue.length = 0;\r\n\r\n const finish = () => {\r\n // Stop the continuous IN poll\r\n if (this.polling && this.inEndpoint) {\r\n try {\r\n this.inEndpoint.removeAllListeners(\"data\");\r\n this.inEndpoint.removeAllListeners(\"error\");\r\n this.inEndpoint.stopPoll(() => this.releaseAndClose());\r\n } catch {\r\n this.releaseAndClose();\r\n }\r\n } else {\r\n this.releaseAndClose();\r\n }\r\n this.polling = false;\r\n this.removeAllListeners();\r\n };\r\n\r\n if (this.writeBusy) {\r\n // Wait for the current in-flight transfer to complete (max 1s)\r\n const timeout = setTimeout(() => {\r\n this.log.warn(\"USB close: in-flight transfer did not complete in 1s, forcing close\");\r\n this.writeBusy = false;\r\n finish();\r\n }, 1000);\r\n\r\n new Promise<void>(resolve => {\r\n this.drainResolve = resolve;\r\n }).then(() => {\r\n clearTimeout(timeout);\r\n finish();\r\n });\r\n } else {\r\n finish();\r\n }\r\n }\r\n\r\n private releaseAndClose(): void {\r\n if (this.iface) {\r\n try {\r\n this.iface.release(true, () => {\r\n try { this.usbDevice?.close(); } catch {}\r\n this.usbDevice = null;\r\n });\r\n } catch {\r\n try { this.usbDevice?.close(); } catch {}\r\n this.usbDevice = null;\r\n }\r\n } else {\r\n try { this.usbDevice?.close(); } catch {}\r\n this.usbDevice = null;\r\n }\r\n this.inEndpoint = null;\r\n this.outEndpoint = null;\r\n this.iface = null;\r\n }\r\n}\r\n\r\n/**\r\n * Discover Signotec pads via raw USB enumeration (libusb).\r\n * This finds devices by VID/PID regardless of which driver Windows loaded.\r\n */\r\nexport function listUsbDevices(log: Logger): UsbDeviceDescriptor[] {\r\n let usb: any;\r\n try {\r\n usb = require(\"usb\");\r\n } catch {\r\n log.debug?.(\"usb package not available, skipping raw USB discovery\");\r\n return [];\r\n }\r\n\r\n try {\r\n const deviceList: UsbDevice[] = usb.getDeviceList();\r\n const results: UsbDeviceDescriptor[] = [];\r\n\r\n for (const device of deviceList) {\r\n const desc = device.deviceDescriptor;\r\n if (desc.idVendor === SIGNOTEC_VID && desc.idProduct === SIGNOTEC_PID) {\r\n results.push({\r\n path: `usb:${desc.idVendor}:${desc.idProduct}:${device.busNumber}:${device.deviceAddress}`,\r\n serialNumber: \"\",\r\n product: \"Signotec Pad\",\r\n _usbDevice: device,\r\n });\r\n }\r\n }\r\n\r\n return results;\r\n } catch (err) {\r\n log.error?.(\"Failed to enumerate USB devices:\", (err as Error).message);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Open a Signotec device via raw USB by its descriptor.\r\n */\r\nexport function openUsbDevice(descriptor: UsbDeviceDescriptor, log: Logger): UsbTransportDevice {\r\n return new UsbTransportDevice(descriptor._usbDevice, log);\r\n}\r\n","/**\r\n * Low-level HID protocol for Signotec signing pads.\r\n *\r\n * Handles command framing, register reads/writes, response parsing, and retry logic.\r\n * Protocol reverse-engineered from STPadLib.dll (Windows) and libSTPadLib.so (Linux).\r\n *\r\n * Transport: 63-byte HID output reports, no report ID prefix.\r\n * - Register read: [0x01, register] → response [0x20, register, length, data...]\r\n * - Register write: [0x10, register, length, data...] → response [0x20, register, ...]\r\n * - Commands: raw bytes → response first nibble 0x9X for success, 0xE0 for error\r\n *\r\n * @module hid-protocol\r\n */\r\n\r\nimport type { DriverConfig, Logger } from \"./types\";\r\nimport { listUsbDevices, openUsbDevice, type UsbDeviceDescriptor } from \"./usb-transport\";\r\n\r\n// ─── Constants ──────────────────────────────────────────────────────────────────\r\n\r\nconst SIGNOTEC_VID = 0x2133;\r\nconst SIGNOTEC_PID = 0x0001;\r\nconst HID_REPORT_SIZE = 63;\r\n\r\n/** Default driver configuration values. */\r\nconst DEFAULTS: Required<Omit<DriverConfig, \"logger\" | \"onDriverEvent\">> & { logger: Logger } = {\r\n commandTimeout: 3000,\r\n imageTransferTimeout: 15000,\r\n flashStoreTimeout: 25000,\r\n chunkDelayMs: 2,\r\n maxRetries: 2,\r\n reconnectAttempts: 10,\r\n reconnectIntervalMs: 2000,\r\n logger: console,\r\n};\r\n\r\n// ─── Protocol Constants (reverse-engineered) ────────────────────────────────────\r\n\r\n/** HID command bytes. */\r\nexport const CMD = {\r\n READ_REG: 0x01,\r\n WRITE_REG: 0x10,\r\n START_SIGN: 0x82,\r\n STOP_SIGN: 0x83,\r\n DRAW_IMAGE: 0x84,\r\n IMAGE_DONE: 0x85,\r\n ERASE_DISPLAY: 0x86,\r\n STORE_IMAGE: 0x89,\r\n SHOW_STORED: 0x8A,\r\n DATA_CHUNK: 0x60,\r\n STORE_CHUNK: 0x70,\r\n SLIDESHOW_CONFIG: 0xA4,\r\n EXTENDED: 0xA8,\r\n ADVANCED_BUTTON: 0xAD,\r\n} as const;\r\n\r\n/** Advanced button sub-commands (used with CMD.ADVANCED_BUTTON). */\r\nconst BUTTON_CMD = {\r\n CLEAR_ALL: 0x01,\r\n SET_RECT: 0x04,\r\n ENABLE_MONITORING: 0x0A,\r\n} as const;\r\n\r\n/** HID response byte types. */\r\nexport const RESP = {\r\n READ: 0x20,\r\n ACK: 0x90,\r\n START_ACK: 0x92,\r\n STOP_ACK: 0x93,\r\n IMAGE_ACK: 0x94,\r\n ERROR: 0xE0,\r\n IDLE: 0x50,\r\n} as const;\r\n\r\n/** Device register addresses. */\r\nexport const REG = {\r\n DEVICE_ID: 0x00,\r\n FW_VERSION1: 0x01,\r\n FW_VERSION2: 0x02,\r\n STATE: 0x10,\r\n CAPABILITIES: 0x11,\r\n SERIAL: 0x14,\r\n DISPLAY_WIDTH: 0x15,\r\n DISPLAY_HEIGHT: 0x16,\r\n SIGN_LEFT: 0x32,\r\n SIGN_TOP: 0x33,\r\n SIGN_RIGHT: 0x34,\r\n SIGN_BOTTOM: 0x35,\r\n} as const;\r\n\r\n/** Signature event types received from the device. */\r\nexport const SIG_EVENT = {\r\n PEN_UP: 0x40,\r\n PEN_DATA: 0x41,\r\n PEN_DATA_EXT: 0x42,\r\n HOTSPOT: 0x43,\r\n} as const;\r\n\r\n// ─── Types ──────────────────────────────────────────────────────────────────────\r\n\r\nexport type HIDDeviceHandle = {\r\n on(event: string, callback: (...args: any[]) => void): void;\r\n write(data: number[]): void;\r\n close(): void;\r\n removeAllListeners?(event?: string): void;\r\n};\r\n\r\n/** Device information read from pad registers. */\r\nexport type PadInfo = {\r\n serialNo: string;\r\n displayWidth: number;\r\n displayHeight: number;\r\n sensorWidth: number;\r\n sensorHeight: number;\r\n deviceId: number;\r\n fwMajor: number;\r\n fwMinor: number;\r\n capabilities: number;\r\n};\r\n\r\ntype PendingResponse = {\r\n resolve: (buf: Buffer | null) => void;\r\n timer: ReturnType<typeof setTimeout>;\r\n};\r\n\r\n/** Callback for signature/hotspot events from the device. */\r\nexport type SignatureEventCallback = (type: number, data: Buffer) => void;\r\n\r\n// ─── HidProtocol Class ─────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Low-level HID communication with a Signotec signing pad.\r\n *\r\n * Provides command framing, response parsing, retry logic, and all\r\n * protocol operations (display, signature, flash storage, hotspots).\r\n *\r\n * @example\r\n * ```typescript\r\n * const protocol = new HidProtocol({ commandTimeout: 5000 });\r\n * const devices = protocol.listDevices();\r\n * protocol.open(devices[0].path);\r\n * await protocol.eraseDisplay();\r\n * protocol.close();\r\n * ```\r\n */\r\nexport class HidProtocol {\r\n private device: HIDDeviceHandle | null = null;\r\n private pending: PendingResponse | null = null;\r\n private signatureCallback: SignatureEventCallback | null = null;\r\n private disconnectCallback: (() => void) | null = null;\r\n private connected = false;\r\n private closing = false;\r\n private HID: any;\r\n private log: Logger;\r\n private config: Required<Omit<DriverConfig, \"logger\" | \"onDriverEvent\">>;\r\n /** Cached USB device descriptors from last listDevices() call (for USB fallback). */\r\n private usbDeviceMap = new Map<string, UsbDeviceDescriptor>();\r\n\r\n constructor(config?: DriverConfig) {\r\n this.config = {\r\n commandTimeout: config?.commandTimeout ?? DEFAULTS.commandTimeout,\r\n imageTransferTimeout: config?.imageTransferTimeout ?? DEFAULTS.imageTransferTimeout,\r\n flashStoreTimeout: config?.flashStoreTimeout ?? DEFAULTS.flashStoreTimeout,\r\n chunkDelayMs: config?.chunkDelayMs ?? DEFAULTS.chunkDelayMs,\r\n maxRetries: config?.maxRetries ?? DEFAULTS.maxRetries,\r\n reconnectAttempts: config?.reconnectAttempts ?? DEFAULTS.reconnectAttempts,\r\n reconnectIntervalMs: config?.reconnectIntervalMs ?? DEFAULTS.reconnectIntervalMs,\r\n };\r\n this.log = config?.logger === null\r\n ? { info() {}, warn() {}, error() {}, debug() {} }\r\n : (config?.logger ?? DEFAULTS.logger);\r\n\r\n try {\r\n this.HID = require(\"node-hid\");\r\n } catch {\r\n throw new Error(\r\n \"node-hid is required for Signotec HID support. Install with: npm install node-hid\"\r\n );\r\n }\r\n }\r\n\r\n // ─── Device Management ──────────────────────────────────────────────────────\r\n\r\n /**\r\n * Discover all connected Signotec pads.\r\n * Tries node-hid first; falls back to raw USB enumeration (libusb) if no\r\n * HID devices are found (e.g., Windows without HID class driver).\r\n * @returns Array of device descriptors (never throws).\r\n */\r\n listDevices(): Array<{ path: string; serialNumber: string; product: string }> {\r\n this.usbDeviceMap.clear();\r\n\r\n // Try node-hid first\r\n try {\r\n const hidDevices = this.HID.devices()\r\n .filter((d: any) => d.vendorId === SIGNOTEC_VID && d.productId === SIGNOTEC_PID)\r\n .map((d: any) => ({\r\n path: d.path,\r\n serialNumber: d.serialNumber || \"\",\r\n product: d.product || \"Signotec Pad\",\r\n }));\r\n\r\n if (hidDevices.length > 0) {\r\n this.log.info(`Found ${hidDevices.length} Signotec pad(s) via HID`);\r\n return hidDevices;\r\n }\r\n } catch (err) {\r\n this.log.warn(\"HID enumeration failed:\", (err as Error).message);\r\n }\r\n\r\n // Fallback: raw USB discovery via libusb\r\n this.log.info(\"No Signotec pads found via HID, trying raw USB...\");\r\n try {\r\n const usbDevices = listUsbDevices(this.log);\r\n if (usbDevices.length > 0) {\r\n this.log.info(`Found ${usbDevices.length} Signotec pad(s) via raw USB`);\r\n for (const d of usbDevices) {\r\n this.usbDeviceMap.set(d.path, d);\r\n }\r\n return usbDevices.map(d => ({\r\n path: d.path,\r\n serialNumber: d.serialNumber || \"\",\r\n product: d.product || \"Signotec Pad\",\r\n }));\r\n }\r\n } catch (err) {\r\n this.log.warn(\"USB enumeration failed:\", (err as Error).message);\r\n }\r\n\r\n // Nothing found — log diagnostics\r\n this.logDiscoveryDiagnostics();\r\n return [];\r\n }\r\n\r\n /** Log diagnostic info when no devices are found. */\r\n private logDiscoveryDiagnostics(): void {\r\n try {\r\n const allHid = this.HID.devices();\r\n const signotecHid = allHid.filter((d: any) => d.vendorId === SIGNOTEC_VID);\r\n this.log.warn(\r\n `No Signotec pads found. HID bus: ${allHid.length} devices total, ` +\r\n `${signotecHid.length} matching VID=0x${SIGNOTEC_VID.toString(16)}.`\r\n );\r\n if (signotecHid.length > 0) {\r\n this.log.warn(\"Signotec HID entries (wrong PID?):\", JSON.stringify(\r\n signotecHid.map((d: any) => ({ pid: d.productId, usagePage: d.usagePage, product: d.product }))\r\n ));\r\n }\r\n } catch {}\r\n\r\n const platform = process.platform;\r\n if (platform === \"linux\") {\r\n this.log.warn(\r\n \"Linux: ensure udev rules are installed. Copy 99-signotec.rules to /etc/udev/rules.d/ \" +\r\n \"and run: sudo udevadm control --reload-rules && sudo udevadm trigger\"\r\n );\r\n } else if (platform === \"darwin\") {\r\n this.log.warn(\r\n \"macOS: check System Preferences > Security & Privacy > Input Monitoring permissions.\"\r\n );\r\n } else if (platform === \"win32\") {\r\n this.log.warn(\r\n \"Windows: the device may need the WinUSB driver. Install it using Zadig (https://zadig.akeo.ie/) \" +\r\n \"by selecting the Signotec device and choosing WinUSB.\"\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Open a device by its path (HID path or USB path).\r\n * USB paths start with \"usb:\" and use the raw USB transport fallback.\r\n * @throws Error if the device cannot be opened.\r\n */\r\n open(devicePath: string): void {\r\n if (this.device) this.close();\r\n this.closing = false;\r\n\r\n // Check if this is a raw USB device (fallback transport)\r\n const usbDescriptor = this.usbDeviceMap.get(devicePath);\r\n if (usbDescriptor) {\r\n this.log.info(\"Opening Signotec pad via raw USB transport\");\r\n this.device = openUsbDevice(usbDescriptor, this.log) as unknown as HIDDeviceHandle;\r\n } else {\r\n this.device = new this.HID.HID(devicePath) as HIDDeviceHandle;\r\n }\r\n this.connected = true;\r\n\r\n this.device.on(\"data\", (data: Buffer) => this.handleData(Buffer.from(data)));\r\n this.device.on(\"error\", (err: Error) => {\r\n if (this.closing) return;\r\n this.log.error(\"Signotec HID error:\", err.message);\r\n this.connected = false;\r\n this.disconnectCallback?.();\r\n });\r\n }\r\n\r\n /** Close the device connection and release resources. */\r\n close(): void {\r\n this.closing = true;\r\n this.connected = false;\r\n if (this.pending) {\r\n clearTimeout(this.pending.timer);\r\n this.pending.resolve(null);\r\n this.pending = null;\r\n }\r\n if (this.device) {\r\n try { this.device.removeAllListeners?.(); } catch {}\r\n try { this.device.close(); } catch (err) {\r\n this.log.warn(\"Error closing HID device:\", (err as Error).message);\r\n }\r\n this.device = null;\r\n }\r\n this.signatureCallback = null;\r\n }\r\n\r\n /** Check if the device connection is alive. */\r\n isConnected(): boolean {\r\n return this.connected && this.device !== null && !this.closing;\r\n }\r\n\r\n /**\r\n * Verify the device is actually responsive (sends a register read and checks response).\r\n * Useful after reconnection or before starting a session.\r\n */\r\n async isResponsive(): Promise<boolean> {\r\n if (!this.isConnected()) return false;\r\n const resp = await this.readRegister(REG.STATE);\r\n return resp !== null;\r\n }\r\n\r\n /** Register a callback for device disconnect events. */\r\n onDisconnect(cb: (() => void) | null): void {\r\n this.disconnectCallback = cb;\r\n }\r\n\r\n /** Register a callback for signature/hotspot events from the device. */\r\n onSignatureEvent(cb: SignatureEventCallback | null): void {\r\n this.signatureCallback = cb;\r\n }\r\n\r\n // ─── Core I/O ─────────────────────────────────────────────────────────────────\r\n\r\n private send(bytes: number[]): void {\r\n if (!this.device || !this.connected) throw new Error(\"Device not connected\");\r\n const buf = Buffer.alloc(HID_REPORT_SIZE, 0);\r\n for (let i = 0; i < Math.min(bytes.length, HID_REPORT_SIZE); i++) {\r\n buf[i] = bytes[i];\r\n }\r\n this.device.write([...buf]);\r\n }\r\n\r\n /**\r\n * Send a command and wait for the response.\r\n * @returns Response buffer, or null on timeout/error.\r\n */\r\n sendCommand(bytes: number[], timeout?: number): Promise<Buffer | null> {\r\n const t = timeout ?? this.config.commandTimeout;\r\n if (!this.device || !this.connected) return Promise.resolve(null);\r\n\r\n // Cancel any pending command (only one outstanding at a time)\r\n if (this.pending) {\r\n clearTimeout(this.pending.timer);\r\n this.pending.resolve(null);\r\n this.pending = null;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n const timer = setTimeout(() => {\r\n if (this.pending?.resolve === resolve) {\r\n this.pending = null;\r\n resolve(null);\r\n }\r\n }, t);\r\n\r\n this.pending = { resolve, timer };\r\n try {\r\n this.send(bytes);\r\n } catch {\r\n clearTimeout(timer);\r\n this.pending = null;\r\n this.connected = false;\r\n resolve(null);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Send a command with automatic retry on failure.\r\n * @param bytes Command bytes to send\r\n * @param validateFn Function to check if response is valid (defaults to non-null + non-error)\r\n * @param timeout Timeout per attempt\r\n * @param maxRetries Max retry count (from config if not specified)\r\n */\r\n async sendCommandWithRetry(\r\n bytes: number[],\r\n validateFn?: (resp: Buffer) => boolean,\r\n timeout?: number,\r\n maxRetries?: number\r\n ): Promise<Buffer | null> {\r\n const retries = maxRetries ?? this.config.maxRetries;\r\n const validate = validateFn ?? ((r: Buffer) => r[0] !== RESP.ERROR);\r\n\r\n for (let attempt = 0; attempt <= retries; attempt++) {\r\n const resp = await this.sendCommand(bytes, timeout);\r\n if (resp && validate(resp)) return resp;\r\n\r\n if (attempt < retries) {\r\n this.log.warn(`HID command 0x${bytes[0]?.toString(16)} failed (attempt ${attempt + 1}/${retries + 1}), retrying...`);\r\n await new Promise(r => setTimeout(r, 100 * (attempt + 1)));\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n /** Send raw bytes without waiting for a response (fire-and-forget). */\r\n sendRaw(bytes: number[]): void {\r\n try {\r\n this.send(bytes);\r\n } catch {\r\n this.connected = false;\r\n }\r\n }\r\n\r\n /**\r\n * Send a bulk data chunk for image transfers.\r\n * @param cmdByte Command byte (0x60 for display, 0x70 for flash store)\r\n * @param data Source buffer\r\n * @param offset Starting offset in data\r\n * @param maxPayload Max bytes per chunk (default 62)\r\n */\r\n private sendChunk(cmdByte: number, data: Buffer, offset: number, maxPayload = 62): void {\r\n const chunk = Buffer.alloc(HID_REPORT_SIZE, 0);\r\n chunk[0] = cmdByte;\r\n const toCopy = Math.min(maxPayload, data.length - offset);\r\n data.copy(chunk, 1, offset, offset + toCopy);\r\n try {\r\n this.device?.write([...chunk]);\r\n } catch {\r\n this.connected = false;\r\n }\r\n }\r\n\r\n private handleData(buf: Buffer): void {\r\n const type = buf[0];\r\n\r\n // Skip idle reports\r\n if (type === RESP.IDLE || type === 0x51) return;\r\n\r\n // Signature/hotspot events: forward to callback\r\n if (type === SIG_EVENT.PEN_DATA || type === SIG_EVENT.PEN_UP ||\r\n type === SIG_EVENT.PEN_DATA_EXT || type === SIG_EVENT.HOTSPOT) {\r\n this.signatureCallback?.(type, buf);\r\n return;\r\n }\r\n\r\n // Command responses\r\n if (this.pending) {\r\n clearTimeout(this.pending.timer);\r\n const p = this.pending;\r\n this.pending = null;\r\n p.resolve(buf);\r\n }\r\n }\r\n\r\n // ─── Register Operations ──────────────────────────────────────────────────────\r\n\r\n /** Read a device register. Returns the data portion or null on error/timeout. */\r\n async readRegister(reg: number): Promise<Buffer | null> {\r\n const resp = await this.sendCommand([CMD.READ_REG, reg]);\r\n if (resp && (resp[0] & 0xF0) === 0x20) {\r\n const len = resp[2];\r\n return Buffer.from(resp.slice(3, 3 + len));\r\n }\r\n return null;\r\n }\r\n\r\n /** Write a 4-byte little-endian value to a register. */\r\n async writeRegister(reg: number, value: number): Promise<boolean> {\r\n const resp = await this.sendCommand([\r\n CMD.WRITE_REG, reg, 0x04,\r\n value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF, (value >> 24) & 0xFF,\r\n ]);\r\n if (!resp) return false;\r\n return (resp[0] & 0xF0) === 0x20 || (resp[0] & 0xF0) === 0x90;\r\n }\r\n\r\n /** Read full device info from registers. */\r\n async getDeviceInfo(): Promise<PadInfo> {\r\n const info: PadInfo = {\r\n serialNo: \"unknown\", displayWidth: 320, displayHeight: 160,\r\n sensorWidth: 320, sensorHeight: 160, deviceId: 0,\r\n fwMajor: 0, fwMinor: 0, capabilities: 0,\r\n };\r\n\r\n const serial = await this.readRegister(REG.SERIAL);\r\n if (serial) info.serialNo = serial.toString(\"utf16le\").replace(/[\\0#]/g, \"\");\r\n\r\n const devId = await this.readRegister(REG.DEVICE_ID);\r\n if (devId?.length && devId.length >= 4) info.deviceId = devId.readUInt32LE(0);\r\n\r\n const fw1 = await this.readRegister(REG.FW_VERSION1);\r\n if (fw1?.length && fw1.length >= 4) {\r\n info.fwMajor = fw1.readUInt16LE(0);\r\n info.fwMinor = fw1.readUInt16LE(2);\r\n }\r\n\r\n const caps = await this.readRegister(REG.CAPABILITIES);\r\n if (caps?.length && caps.length >= 4) info.capabilities = caps.readUInt32LE(0);\r\n\r\n const dw = await this.readRegister(REG.DISPLAY_WIDTH);\r\n if (dw?.length && dw.length >= 4) info.displayWidth = dw.readUInt32LE(0);\r\n\r\n const dh = await this.readRegister(REG.DISPLAY_HEIGHT);\r\n if (dh?.length && dh.length >= 4) info.displayHeight = dh.readUInt32LE(0);\r\n\r\n return info;\r\n }\r\n\r\n // ─── Display Commands ─────────────────────────────────────────────────────────\r\n\r\n /** Erase the pad display (clear to white). */\r\n async eraseDisplay(): Promise<boolean> {\r\n const resp = await this.sendCommandWithRetry(\r\n [CMD.ERASE_DISPLAY],\r\n r => r[0] === RESP.ACK\r\n );\r\n return resp !== null;\r\n }\r\n\r\n /**\r\n * Send monochrome 1bpp bitmap data to the pad display.\r\n * Protocol: 0x84 header → 0x60 data chunks → 0x85 done.\r\n * Automatically inverts polarity (pad uses 1=black, framebuffer uses 0=black).\r\n */\r\n async drawImage(x: number, y: number, width: number, height: number, bitmapData: Buffer): Promise<boolean> {\r\n const imgHeader = Buffer.alloc(25, 0);\r\n imgHeader[0] = CMD.DRAW_IMAGE;\r\n imgHeader.writeInt32LE(x, 1);\r\n imgHeader.writeInt32LE(y, 5);\r\n imgHeader.writeInt32LE(width, 9);\r\n imgHeader.writeInt32LE(height, 13);\r\n\r\n const resp = await this.sendCommandWithRetry(\r\n [...imgHeader],\r\n r => r[0] === RESP.ACK,\r\n this.config.imageTransferTimeout\r\n );\r\n if (!resp) return false;\r\n\r\n // Invert polarity for display (pad: 1=black, our framebuffer: 0=black)\r\n const invertedData = Buffer.alloc(bitmapData.length);\r\n for (let i = 0; i < bitmapData.length; i++) {\r\n invertedData[i] = bitmapData[i] ^ 0xFF;\r\n }\r\n\r\n // Send data chunks\r\n const chunkPayload = 62;\r\n for (let offset = 0; offset < invertedData.length; offset += chunkPayload) {\r\n this.sendChunk(CMD.DATA_CHUNK, invertedData, offset, chunkPayload);\r\n if (offset % (chunkPayload * 10) === 0 && offset > 0) {\r\n await new Promise(r => setTimeout(r, this.config.chunkDelayMs));\r\n }\r\n }\r\n\r\n const doneResp = await this.sendCommand([CMD.IMAGE_DONE], this.config.imageTransferTimeout);\r\n return doneResp !== null && (doneResp[0] === RESP.IMAGE_ACK || doneResp[0] === RESP.ACK);\r\n }\r\n\r\n // ─── Flash Storage ────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Store a 1bpp bitmap to the pad's non-volatile flash as standby image.\r\n * Persists across power cycles and USB disconnects.\r\n *\r\n * Protocol: 0x89 header → 0x70 data chunks → 0xA4 standby config.\r\n * Flash uses direct polarity (opposite of display), auto-detected.\r\n */\r\n async storeStandbyImage(width: number, height: number, bitmapData: Buffer): Promise<boolean> {\r\n // Auto-detect polarity: flash uses fewer set bits for white background\r\n let ones = 0;\r\n for (let i = 0; i < bitmapData.length; i++) {\r\n for (let b = 0; b < 8; b++) {\r\n if (bitmapData[i] & (1 << b)) ones++;\r\n }\r\n }\r\n const needsInvert = ones > (bitmapData.length * 4); // >50% set bits → invert\r\n\r\n const storeData = Buffer.alloc(bitmapData.length);\r\n for (let i = 0; i < bitmapData.length; i++) {\r\n storeData[i] = needsInvert ? (bitmapData[i] ^ 0xFF) : bitmapData[i];\r\n }\r\n\r\n // Step 1: Store header (0x89)\r\n const storeHeader = Buffer.alloc(33, 0);\r\n storeHeader[0] = CMD.STORE_IMAGE;\r\n storeHeader.writeInt32LE(0, 1); // x\r\n storeHeader.writeInt32LE(0, 5); // y\r\n storeHeader.writeInt32LE(width, 9); // width\r\n storeHeader.writeInt32LE(height, 13); // height\r\n storeHeader.writeInt32LE(0, 17); // store slot 0\r\n storeHeader.writeInt32LE(1, 21); // encoding: uncompressed\r\n storeHeader.writeInt32LE(1, 25); // format: 1bpp\r\n storeHeader.writeInt32LE(0, 29); // extra\r\n\r\n const resp1 = await this.sendCommand([...storeHeader], this.config.flashStoreTimeout);\r\n if (!resp1 || resp1[0] !== RESP.ACK) {\r\n this.log.error(\"Flash store header rejected:\", resp1 ? `0x${resp1[0].toString(16)}` : \"timeout\");\r\n return false;\r\n }\r\n\r\n // Step 2: Send data via 0x70 chunks (NOT 0x60!)\r\n const chunkPayload = 62;\r\n for (let offset = 0; offset < storeData.length; offset += chunkPayload) {\r\n this.sendChunk(CMD.STORE_CHUNK, storeData, offset, chunkPayload);\r\n if (offset % (chunkPayload * 20) === 0 && offset > 0) {\r\n await new Promise(r => setTimeout(r, this.config.chunkDelayMs * 3));\r\n }\r\n }\r\n\r\n // Flush delay\r\n await new Promise(r => setTimeout(r, 500));\r\n\r\n // Step 3: Register as standby via 0xA4 (with 0xA8 wrapper for Sigma)\r\n return this.sendSlideshowConfig(2, 3, 100, 1);\r\n }\r\n\r\n /**\r\n * Show the stored standby image from flash on the display.\r\n * Command 0x8A = \"draw stored image\" (from APIClosePad → APIDrawStoredImage).\r\n *\r\n * Single HID command - no image data transfer. Works regardless of who\r\n * stored the image (our library, Signotec SlideShow tool, etc.)\r\n */\r\n async showStandbyFromFlash(): Promise<boolean> {\r\n const cmd = Buffer.alloc(33, 0);\r\n cmd[0] = CMD.SHOW_STORED;\r\n const resp = await this.sendCommand([...cmd], this.config.imageTransferTimeout);\r\n return resp !== null && (resp[0] === RESP.ACK || resp[0] === 0x98);\r\n }\r\n\r\n /**\r\n * Send a slideshow/standby configuration command (0xA4).\r\n * Automatically wraps in 0xA8 for Sigma pads (which don't support direct 0xA4).\r\n */\r\n private async sendSlideshowConfig(action: number, mode: number, count: number, flag: number): Promise<boolean> {\r\n const configCmd = Buffer.alloc(49, 0);\r\n configCmd[0] = CMD.SLIDESHOW_CONFIG;\r\n configCmd.writeInt32LE(action, 1);\r\n configCmd.writeInt32LE(mode, 5);\r\n configCmd.writeInt32LE(count, 9);\r\n configCmd.writeInt32LE(flag, 13);\r\n\r\n let resp = await this.sendCommand([...configCmd], 5000);\r\n if (!resp || resp[0] === RESP.ERROR) {\r\n // Sigma pad: wrap in 0xA8\r\n const a8cmd = Buffer.alloc(50, 0);\r\n a8cmd[0] = CMD.EXTENDED;\r\n configCmd.copy(a8cmd, 1, 0, 49);\r\n resp = await this.sendCommand([...a8cmd], 5000);\r\n }\r\n return resp !== null && (resp[0] === RESP.ACK || (resp[0] & 0xF0) === 0x90);\r\n }\r\n\r\n // ─── Sensor / Hotspot Commands ────────────────────────────────────────────────\r\n\r\n /** Set the signature capture rectangle (left, top, width, height → registers 0x32-0x35). */\r\n async setSignRect(left: number, top: number, width: number, height: number): Promise<boolean> {\r\n const r1 = await this.writeRegister(REG.SIGN_LEFT, Math.round(left));\r\n const r2 = await this.writeRegister(REG.SIGN_TOP, Math.round(top));\r\n const r3 = await this.writeRegister(REG.SIGN_RIGHT, Math.round(left + width));\r\n const r4 = await this.writeRegister(REG.SIGN_BOTTOM, Math.round(top + height));\r\n return r1 && r2 && r3 && r4;\r\n }\r\n\r\n /** Clear all hotspot areas. */\r\n async clearHotSpots(): Promise<boolean> {\r\n const resp = await this.sendCommand([CMD.ADVANCED_BUTTON, BUTTON_CMD.CLEAR_ALL]);\r\n return resp !== null && (resp[0] & 0xF0) === 0x90;\r\n }\r\n\r\n /**\r\n * Add a hotspot (touch-sensitive button area).\r\n * @param index Hotspot index (0-based)\r\n * @param left X position\r\n * @param top Y position\r\n * @param width Width in pixels\r\n * @param height Height in pixels\r\n */\r\n async addHotSpot(index: number, left: number, top: number, width: number, height: number): Promise<boolean> {\r\n const resp = await this.sendCommand([\r\n CMD.ADVANCED_BUTTON, BUTTON_CMD.SET_RECT,\r\n 0x01,\r\n (Math.round(index) & 0x7F) | 0x80,\r\n Math.round(left) & 0xFF, (Math.round(left) >> 8) & 0xFF,\r\n Math.round(top) & 0xFF, (Math.round(top) >> 8) & 0xFF,\r\n 0x00,\r\n Math.round(width) & 0xFF, (Math.round(width) >> 8) & 0xFF,\r\n Math.round(height) & 0xFF, (Math.round(height) >> 8) & 0xFF,\r\n ]);\r\n return resp !== null && (resp[0] & 0xF0) === 0x90;\r\n }\r\n\r\n /** Enable hotspot monitoring (call after addHotSpot). */\r\n async enableHotspotMonitoring(): Promise<boolean> {\r\n const resp = await this.sendCommand([CMD.ADVANCED_BUTTON, BUTTON_CMD.ENABLE_MONITORING]);\r\n return resp !== null && (resp[0] & 0xF0) === 0x90;\r\n }\r\n\r\n // ─── Signature Session ────────────────────────────────────────────────────────\r\n\r\n /** Start signature capture. Protocol: [0x82, 0x00, 0x00, 0x00, 0x00]. */\r\n async startSignature(): Promise<boolean> {\r\n const resp = await this.sendCommandWithRetry(\r\n [CMD.START_SIGN, 0x00, 0x00, 0x00, 0x00],\r\n r => r[0] === RESP.START_ACK\r\n );\r\n return resp !== null;\r\n }\r\n\r\n /** Stop signature capture. */\r\n async stopSignature(): Promise<boolean> {\r\n const resp = await this.sendCommand([CMD.STOP_SIGN]);\r\n return resp !== null && resp[0] === RESP.STOP_ACK;\r\n }\r\n}\r\n","/**\r\n * Display rendering for Signotec pads via HID.\r\n * Renders text and images into monochrome bitmaps, then sends them to the pad.\r\n *\r\n * The Signotec pad does NOT accept text commands directly.\r\n * Text is rendered client-side into bitmaps, then transferred as image data.\r\n */\r\n\r\nimport fs from \"fs\";\r\nimport path from \"path\";\r\nimport type { HidProtocol } from \"./hid-protocol\";\r\nimport { FONT_8X13 } from \"./font-8x13\";\r\n\r\n/**\r\n * Font sizing:\r\n * fontSize 1 = 8x13 at 1x (compact, ~35 chars/line, matches DLL \"Arial 30\")\r\n * fontSize 2 = 8x13 at 2x (large, ~17 chars/line)\r\n * fontSize 3 = 8x13 at 3x (headline, ~11 chars/line)\r\n *\r\n * The 8x13 font closely matches the DLL's Pango-rendered \"Arial 30\"\r\n * which produces ~15px characters (30 * 10/20.5 ≈ 14.6px).\r\n */\r\nfunction fontScale(fontSize: number): number {\r\n return Math.max(1, Math.min(3, Math.round(fontSize)));\r\n}\r\n\r\n/** Returns the line height (char height + gap) for a fontSize. */\r\nexport function fontLineHeight(fontSize: number): number {\r\n return 13 * fontScale(fontSize) + 2;\r\n}\r\n\r\n/** Returns the character width (including 1px gap) for a fontSize. */\r\nexport function fontCharWidth(fontSize: number): number {\r\n return 9 * fontScale(fontSize);\r\n}\r\n\r\n/**\r\n * Render text into a 1bpp monochrome bitmap suitable for the pad display.\r\n * Uses a built-in bitmap font (no canvas dependency).\r\n */\r\nexport class DisplayRenderer {\r\n private width: number;\r\n private height: number;\r\n private framebuffer: Buffer; // 1bpp, row-aligned to bytes\r\n\r\n constructor(width: number, height: number) {\r\n this.width = width;\r\n this.height = height;\r\n const rowBytes = Math.ceil(width / 8);\r\n this.framebuffer = Buffer.alloc(rowBytes * height, 0xFF); // White background (1=white in monochrome)\r\n }\r\n\r\n get buffer(): Buffer {\r\n return this.framebuffer;\r\n }\r\n\r\n clear(): void {\r\n this.framebuffer.fill(0xFF); // All white\r\n }\r\n\r\n /**\r\n * Set a pixel (0=black, 1=white) in the framebuffer.\r\n */\r\n setPixel(x: number, y: number, black: boolean): void {\r\n if (x < 0 || x >= this.width || y < 0 || y >= this.height) return;\r\n const rowBytes = Math.ceil(this.width / 8);\r\n const byteIndex = y * rowBytes + Math.floor(x / 8);\r\n const bitIndex = 7 - (x % 8);\r\n if (black) {\r\n this.framebuffer[byteIndex] &= ~(1 << bitIndex); // Clear bit = black\r\n } else {\r\n this.framebuffer[byteIndex] |= (1 << bitIndex); // Set bit = white\r\n }\r\n }\r\n\r\n /**\r\n * Draw a filled rectangle.\r\n */\r\n fillRect(x: number, y: number, w: number, h: number, black: boolean): void {\r\n for (let dy = 0; dy < h; dy++) {\r\n for (let dx = 0; dx < w; dx++) {\r\n this.setPixel(x + dx, y + dy, black);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Draw a horizontal line.\r\n */\r\n hLine(x: number, y: number, w: number): void {\r\n for (let dx = 0; dx < w; dx++) {\r\n this.setPixel(x + dx, y, true);\r\n }\r\n }\r\n\r\n /**\r\n * Draw text using the 8x13 bitmap font.\r\n * fontSize: 1=normal(8x13), 2=large(16x26), 3=headline(24x39)\r\n * bold: draws text twice with 1px right shift for thicker strokes\r\n */\r\n drawText(x: number, y: number, text: string, fontSize = 1, bold = false): number {\r\n const w = this._renderText(x, y, text, fontSize, true);\r\n if (bold) this._renderText(x + 1, y, text, fontSize, true);\r\n return w;\r\n }\r\n\r\n /** Draw inverted text (white on black) for button labels. */\r\n drawTextInverted(x: number, y: number, text: string, fontSize = 1, bold = false): number {\r\n const w = this._renderText(x, y, text, fontSize, false);\r\n if (bold) this._renderText(x + 1, y, text, fontSize, false);\r\n return w;\r\n }\r\n\r\n private _renderText(x: number, y: number, text: string, fontSize: number, black: boolean): number {\r\n const cleanText = text.replace(/[\\u200B-\\u200F\\u2028-\\u202F\\u2060-\\u206F\\uFEFF]/g, \"\");\r\n const scale = fontScale(fontSize);\r\n const charW = 9 * scale;\r\n let curX = x;\r\n for (const char of cleanText) {\r\n const glyph = FONT_8X13[char] || FONT_8X13[\"?\"];\r\n if (!glyph) continue;\r\n for (let row = 0; row < 13; row++) {\r\n for (let col = 0; col < 8; col++) {\r\n if (glyph[row] & (1 << (7 - col))) {\r\n for (let sy = 0; sy < scale; sy++) {\r\n for (let sx = 0; sx < scale; sx++) {\r\n this.setPixel(curX + col * scale + sx, y + row * scale + sy, black);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n curX += charW;\r\n }\r\n return curX - x;\r\n }\r\n\r\n /**\r\n * Draw text fitted within a rectangle. Wraps words and scales to fit.\r\n */\r\n drawTextInRect(left: number, top: number, width: number, height: number, text: string, fontSize = 1): void {\r\n const charW = fontCharWidth(fontSize);\r\n const charH = fontLineHeight(fontSize);\r\n const maxCols = Math.floor(width / charW);\r\n const maxRows = Math.floor(height / charH);\r\n\r\n // Simple word wrap\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n let currentLine = \"\";\r\n\r\n for (const word of words) {\r\n if (currentLine.length + word.length + 1 <= maxCols) {\r\n currentLine += (currentLine ? \" \" : \"\") + word;\r\n } else {\r\n if (currentLine) lines.push(currentLine);\r\n currentLine = word;\r\n }\r\n }\r\n if (currentLine) lines.push(currentLine);\r\n\r\n // Draw each line\r\n for (let i = 0; i < Math.min(lines.length, maxRows); i++) {\r\n this.drawText(left, top + i * charH, lines[i], fontSize);\r\n }\r\n }\r\n\r\n /**\r\n * Load a BMP file and draw it at the specified position.\r\n * Supports 1-bit, 8-bit, and 24-bit BMPs.\r\n */\r\n drawBmpFile(x: number, y: number, filePath: string): boolean {\r\n try {\r\n const data = fs.readFileSync(filePath);\r\n return this.drawBmpData(x, y, data);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Load a PNG file and draw it at the specified position.\r\n * Uses a minimal PNG decoder (no external dependencies).\r\n */\r\n drawPngFile(x: number, y: number, filePath: string): boolean {\r\n try {\r\n const data = fs.readFileSync(filePath);\r\n return this.drawImageData(x, y, data, filePath);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Draw image data. Detects format from header.\r\n */\r\n drawImageData(x: number, y: number, data: Buffer, hint = \"\"): boolean {\r\n // Check BMP magic\r\n if (data[0] === 0x42 && data[1] === 0x4D) {\r\n return this.drawBmpData(x, y, data);\r\n }\r\n // Check PNG magic\r\n if (data[0] === 0x89 && data[1] === 0x50 && data[2] === 0x4E && data[3] === 0x47) {\r\n return this.drawPngData(x, y, data);\r\n }\r\n return false;\r\n }\r\n\r\n private drawBmpData(x: number, y: number, data: Buffer): boolean {\r\n if (data.length < 54) return false;\r\n\r\n const dataOffset = data.readUInt32LE(10);\r\n const bmpWidth = data.readInt32LE(18);\r\n const bmpHeight = data.readInt32LE(22);\r\n const bitsPerPixel = data.readUInt16LE(28);\r\n const isBottomUp = bmpHeight > 0;\r\n const absHeight = Math.abs(bmpHeight);\r\n\r\n for (let row = 0; row < absHeight; row++) {\r\n const srcRow = isBottomUp ? (absHeight - 1 - row) : row;\r\n const dstY = y + row;\r\n\r\n if (bitsPerPixel === 1) {\r\n const rowBytes = Math.ceil(bmpWidth / 8);\r\n const paddedRowBytes = Math.ceil(rowBytes / 4) * 4;\r\n const rowOffset = dataOffset + srcRow * paddedRowBytes;\r\n\r\n for (let col = 0; col < bmpWidth; col++) {\r\n const byteIdx = rowOffset + Math.floor(col / 8);\r\n const bitIdx = 7 - (col % 8);\r\n const pixel = (data[byteIdx] >> bitIdx) & 1;\r\n this.setPixel(x + col, dstY, pixel === 0); // BMP: 0=black in 1bpp\r\n }\r\n } else if (bitsPerPixel === 24) {\r\n const paddedRowBytes = Math.ceil((bmpWidth * 3) / 4) * 4;\r\n const rowOffset = dataOffset + srcRow * paddedRowBytes;\r\n\r\n for (let col = 0; col < bmpWidth; col++) {\r\n const idx = rowOffset + col * 3;\r\n const b = data[idx];\r\n const g = data[idx + 1];\r\n const r = data[idx + 2];\r\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\r\n this.setPixel(x + col, dstY, brightness < 128);\r\n }\r\n } else if (bitsPerPixel === 8) {\r\n const paddedRowBytes = Math.ceil(bmpWidth / 4) * 4;\r\n const rowOffset = dataOffset + srcRow * paddedRowBytes;\r\n\r\n for (let col = 0; col < bmpWidth; col++) {\r\n const pixel = data[rowOffset + col];\r\n this.setPixel(x + col, dstY, pixel < 128);\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n private drawPngData(x: number, y: number, data: Buffer): boolean {\r\n // Minimal PNG decoder for simple cases\r\n // For the Signotec pad, images are small monochrome PNGs\r\n try {\r\n const { decodePng } = require(\"./png-decode\");\r\n const pixels = decodePng(data);\r\n if (!pixels) return false;\r\n\r\n for (let row = 0; row < pixels.height; row++) {\r\n for (let col = 0; col < pixels.width; col++) {\r\n const idx = (row * pixels.width + col) * pixels.channels;\r\n let brightness: number;\r\n if (pixels.channels >= 3) {\r\n brightness = (pixels.data[idx] * 299 + pixels.data[idx + 1] * 587 + pixels.data[idx + 2] * 114) / 1000;\r\n } else {\r\n brightness = pixels.data[idx];\r\n }\r\n // Handle alpha channel\r\n if (pixels.channels === 4 || pixels.channels === 2) {\r\n const alpha = pixels.data[idx + pixels.channels - 1];\r\n if (alpha < 128) continue; // Transparent pixel, leave as white\r\n }\r\n this.setPixel(x + col, y + row, brightness < 128);\r\n }\r\n }\r\n return true;\r\n } catch {\r\n // PNG decode not available - fall back to drawing nothing\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Send the entire framebuffer to the pad.\r\n */\r\n async sendToDevice(protocol: HidProtocol): Promise<boolean> {\r\n return protocol.drawImage(0, 0, this.width, this.height, this.framebuffer);\r\n }\r\n\r\n /**\r\n * Send a region of the framebuffer to the pad.\r\n */\r\n async sendRegionToDevice(protocol: HidProtocol, x: number, y: number, w: number, h: number): Promise<boolean> {\r\n const rowBytes = Math.ceil(this.width / 8);\r\n const regionRowBytes = Math.ceil(w / 8);\r\n const regionBuf = Buffer.alloc(regionRowBytes * h, 0xFF);\r\n\r\n for (let row = 0; row < h; row++) {\r\n for (let col = 0; col < w; col++) {\r\n const srcByteIdx = (y + row) * rowBytes + Math.floor((x + col) / 8);\r\n const srcBitIdx = 7 - ((x + col) % 8);\r\n const pixel = (this.framebuffer[srcByteIdx] >> srcBitIdx) & 1;\r\n\r\n const dstByteIdx = row * regionRowBytes + Math.floor(col / 8);\r\n const dstBitIdx = 7 - (col % 8);\r\n if (pixel === 0) {\r\n regionBuf[dstByteIdx] &= ~(1 << dstBitIdx);\r\n }\r\n }\r\n }\r\n\r\n return protocol.drawImage(x, y, w, h, regionBuf);\r\n }\r\n}\r\n\r\n// ============================================================\r\n// Built-in 5x7 bitmap font\r\n// Each character is 5 pixels wide, 7 pixels tall\r\n// Encoded as 7 bytes, each byte is a row, MSB first\r\n// ============================================================\r\nconst FONT_5X7: Record<string, number[]> = {\r\n \" \": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"!\": [0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04],\r\n '\"': [0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00],\r\n \"#\": [0x0A, 0x0A, 0x1F, 0x0A, 0x1F, 0x0A, 0x0A],\r\n \"$\": [0x04, 0x0F, 0x14, 0x0E, 0x05, 0x1E, 0x04],\r\n \"%\": [0x18, 0x19, 0x02, 0x04, 0x08, 0x13, 0x03],\r\n \"&\": [0x0C, 0x12, 0x14, 0x08, 0x15, 0x12, 0x0D],\r\n \"'\": [0x06, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00],\r\n \"(\": [0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02],\r\n \")\": [0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08],\r\n \"*\": [0x00, 0x04, 0x15, 0x0E, 0x15, 0x04, 0x00],\r\n \"+\": [0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00],\r\n \",\": [0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x08],\r\n \"-\": [0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00],\r\n \".\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06],\r\n \"/\": [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x00],\r\n \"0\": [0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E],\r\n \"1\": [0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E],\r\n \"2\": [0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F],\r\n \"3\": [0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E],\r\n \"4\": [0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02],\r\n \"5\": [0x1F, 0x10, 0x1E, 0x01, 0x01, 0x11, 0x0E],\r\n \"6\": [0x06, 0x08, 0x10, 0x1E, 0x11, 0x11, 0x0E],\r\n \"7\": [0x1F, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08],\r\n \"8\": [0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E],\r\n \"9\": [0x0E, 0x11, 0x11, 0x0F, 0x01, 0x02, 0x0C],\r\n \":\": [0x00, 0x06, 0x06, 0x00, 0x06, 0x06, 0x00],\r\n \";\": [0x00, 0x06, 0x06, 0x00, 0x06, 0x04, 0x08],\r\n \"A\": [0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11],\r\n \"B\": [0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E],\r\n \"C\": [0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E],\r\n \"D\": [0x1C, 0x12, 0x11, 0x11, 0x11, 0x12, 0x1C],\r\n \"E\": [0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F],\r\n \"F\": [0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10],\r\n \"G\": [0x0E, 0x11, 0x10, 0x17, 0x11, 0x11, 0x0F],\r\n \"H\": [0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11],\r\n \"I\": [0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E],\r\n \"J\": [0x07, 0x02, 0x02, 0x02, 0x02, 0x12, 0x0C],\r\n \"K\": [0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11],\r\n \"L\": [0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F],\r\n \"M\": [0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11],\r\n \"N\": [0x11, 0x11, 0x19, 0x15, 0x13, 0x11, 0x11],\r\n \"O\": [0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E],\r\n \"P\": [0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10],\r\n \"Q\": [0x0E, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0D],\r\n \"R\": [0x1E, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11],\r\n \"S\": [0x0F, 0x10, 0x10, 0x0E, 0x01, 0x01, 0x1E],\r\n \"T\": [0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04],\r\n \"U\": [0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E],\r\n \"V\": [0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04],\r\n \"W\": [0x11, 0x11, 0x11, 0x15, 0x15, 0x15, 0x0A],\r\n \"X\": [0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11],\r\n \"Y\": [0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04],\r\n \"Z\": [0x1F, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1F],\r\n \"a\": [0x00, 0x00, 0x0E, 0x01, 0x0F, 0x11, 0x0F],\r\n \"b\": [0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x1E],\r\n \"c\": [0x00, 0x00, 0x0E, 0x10, 0x10, 0x11, 0x0E],\r\n \"d\": [0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x0F],\r\n \"e\": [0x00, 0x00, 0x0E, 0x11, 0x1F, 0x10, 0x0E],\r\n \"f\": [0x06, 0x09, 0x08, 0x1C, 0x08, 0x08, 0x08],\r\n \"g\": [0x00, 0x0F, 0x11, 0x11, 0x0F, 0x01, 0x0E],\r\n \"h\": [0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x11],\r\n \"i\": [0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x0E],\r\n \"j\": [0x02, 0x00, 0x06, 0x02, 0x02, 0x12, 0x0C],\r\n \"k\": [0x10, 0x10, 0x12, 0x14, 0x18, 0x14, 0x12],\r\n \"l\": [0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E],\r\n \"m\": [0x00, 0x00, 0x1A, 0x15, 0x15, 0x11, 0x11],\r\n \"n\": [0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11],\r\n \"o\": [0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E],\r\n \"p\": [0x00, 0x00, 0x1E, 0x11, 0x1E, 0x10, 0x10],\r\n \"q\": [0x00, 0x00, 0x0D, 0x13, 0x0F, 0x01, 0x01],\r\n \"r\": [0x00, 0x00, 0x16, 0x19, 0x10, 0x10, 0x10],\r\n \"s\": [0x00, 0x00, 0x0E, 0x10, 0x0E, 0x01, 0x1E],\r\n \"t\": [0x08, 0x08, 0x1C, 0x08, 0x08, 0x09, 0x06],\r\n \"u\": [0x00, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0D],\r\n \"v\": [0x00, 0x00, 0x11, 0x11, 0x11, 0x0A, 0x04],\r\n \"w\": [0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A],\r\n \"x\": [0x00, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11],\r\n \"y\": [0x00, 0x00, 0x11, 0x11, 0x0F, 0x01, 0x0E],\r\n \"z\": [0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F],\r\n \"?\": [0x0E, 0x11, 0x01, 0x02, 0x04, 0x00, 0x04],\r\n // German characters\r\n \"\\u00C4\": [0x0A, 0x00, 0x0E, 0x11, 0x1F, 0x11, 0x11], // Ä\r\n \"\\u00D6\": [0x0A, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E], // Ö\r\n \"\\u00DC\": [0x0A, 0x00, 0x11, 0x11, 0x11, 0x11, 0x0E], // Ü\r\n \"\\u00E4\": [0x0A, 0x00, 0x0E, 0x01, 0x0F, 0x11, 0x0F], // ä\r\n \"\\u00F6\": [0x0A, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E], // ö\r\n \"\\u00FC\": [0x0A, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0D], // ü\r\n \"\\u00DF\": [0x0E, 0x11, 0x12, 0x14, 0x12, 0x11, 0x16], // ß\r\n};\r\n","// 8x13 Bitmap Font\r\n// Based on the classic X11/IBM VGA 8x13 bitmap font style.\r\n// Each character is 8 pixels wide and 13 pixels tall.\r\n// Each glyph is an array of 13 bytes; each byte represents one row (MSB = leftmost pixel).\r\n// Baseline is at row 10 (index 9). Rows 11-12 (indices 10-12) are used for descenders.\r\n\r\nexport const FONT_8X13: Record<string, number[]> = {\r\n // ─── Space ───────────────────────────────────────────────────────────────\r\n \" \": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n\r\n // ─── Digits ──────────────────────────────────────────────────────────────\r\n \"0\": [0x00, 0x00, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"1\": [0x00, 0x00, 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00],\r\n \"2\": [0x00, 0x00, 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00, 0x00, 0x00],\r\n \"3\": [0x00, 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"4\": [0x00, 0x00, 0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00],\r\n \"5\": [0x00, 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"6\": [0x00, 0x00, 0x1C, 0x30, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"7\": [0x00, 0x00, 0x7E, 0x06, 0x0C, 0x18, 0x18, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00],\r\n \"8\": [0x00, 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"9\": [0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00, 0x00, 0x00],\r\n\r\n // ─── Uppercase A–Z ───────────────────────────────────────────────────────\r\n \"A\": [0x00, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"B\": [0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00],\r\n \"C\": [0x00, 0x00, 0x3C, 0x66, 0x60, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"D\": [0x00, 0x00, 0x78, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x6C, 0x78, 0x00, 0x00, 0x00],\r\n \"E\": [0x00, 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x7E, 0x00, 0x00, 0x00],\r\n \"F\": [0x00, 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00],\r\n \"G\": [0x00, 0x00, 0x3C, 0x66, 0x60, 0x60, 0x6E, 0x66, 0x66, 0x3E, 0x00, 0x00, 0x00],\r\n \"H\": [0x00, 0x00, 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"I\": [0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00],\r\n \"J\": [0x00, 0x00, 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"K\": [0x00, 0x00, 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"L\": [0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00, 0x00, 0x00],\r\n \"M\": [0x00, 0x00, 0x42, 0x66, 0x7E, 0x7E, 0x5A, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00],\r\n \"N\": [0x00, 0x00, 0x62, 0x72, 0x7A, 0x6E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"O\": [0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"P\": [0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00],\r\n \"Q\": [0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x76, 0x6C, 0x36, 0x00, 0x00, 0x00],\r\n \"R\": [0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x78, 0x6C, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"S\": [0x00, 0x00, 0x3C, 0x66, 0x60, 0x38, 0x0C, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"T\": [0x00, 0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \"U\": [0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"V\": [0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \"W\": [0x00, 0x00, 0x42, 0x42, 0x42, 0x5A, 0x5A, 0x7E, 0x66, 0x42, 0x00, 0x00, 0x00],\r\n \"X\": [0x00, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"Y\": [0x00, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \"Z\": [0x00, 0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x60, 0x7E, 0x00, 0x00, 0x00],\r\n\r\n // ─── Lowercase a–z ───────────────────────────────────────────────────────\r\n // Baseline row = index 9 (row 10). Descenders use indices 10-11.\r\n \"a\": [0x00, 0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x00, 0x00, 0x00],\r\n \"b\": [0x00, 0x00, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00],\r\n \"c\": [0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x60, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"d\": [0x00, 0x00, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, 0x00, 0x00],\r\n \"e\": [0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"f\": [0x00, 0x00, 0x0E, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \"g\": [0x00, 0x00, 0x00, 0x00, 0x3E, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x3C, 0x00],\r\n \"h\": [0x00, 0x00, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"i\": [0x00, 0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00],\r\n \"j\": [0x00, 0x00, 0x06, 0x00, 0x0E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x46, 0x3C, 0x00],\r\n \"k\": [0x00, 0x00, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x7C, 0x6C, 0x66, 0x00, 0x00, 0x00],\r\n \"l\": [0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00],\r\n \"m\": [0x00, 0x00, 0x00, 0x00, 0x6C, 0x7E, 0x7E, 0x6A, 0x62, 0x62, 0x00, 0x00, 0x00],\r\n \"n\": [0x00, 0x00, 0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"o\": [0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"p\": [0x00, 0x00, 0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00],\r\n \"q\": [0x00, 0x00, 0x00, 0x00, 0x3E, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x06, 0x00],\r\n \"r\": [0x00, 0x00, 0x00, 0x00, 0x6C, 0x76, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00],\r\n \"s\": [0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x38, 0x0C, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"t\": [0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00],\r\n \"u\": [0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, 0x00, 0x00],\r\n \"v\": [0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00],\r\n \"w\": [0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x5A, 0x5A, 0x7E, 0x24, 0x00, 0x00, 0x00],\r\n \"x\": [0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"y\": [0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x46, 0x3C, 0x00],\r\n \"z\": [0x00, 0x00, 0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00, 0x00, 0x00],\r\n\r\n // ─── Punctuation ─────────────────────────────────────────────────────────\r\n \".\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \",\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00],\r\n \":\": [0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \";\": [0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00],\r\n \"!\": [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00],\r\n \"?\": [0x00, 0x00, 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00],\r\n \"-\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"+\": [0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00],\r\n \"=\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"(\": [0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00],\r\n \")\": [0x00, 0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00],\r\n \"/\": [0x00, 0x00, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00],\r\n \"\\\\\": [0x00, 0x00, 0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00],\r\n \"'\": [0x00, 0x18, 0x18, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"\\\"\": [0x00, 0x66, 0x66, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"_\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00],\r\n \"@\": [0x00, 0x00, 0x3C, 0x66, 0x6E, 0x6A, 0x6E, 0x60, 0x62, 0x3C, 0x00, 0x00, 0x00],\r\n \"#\": [0x00, 0x00, 0x24, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x24, 0x00, 0x00, 0x00],\r\n \"&\": [0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x76, 0xCE, 0xCC, 0x76, 0x00, 0x00, 0x00],\r\n \"%\": [0x00, 0x00, 0x62, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x46, 0x00, 0x00, 0x00, 0x00],\r\n \"*\": [0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"<\": [0x00, 0x00, 0x00, 0x06, 0x1C, 0x70, 0x70, 0x1C, 0x06, 0x00, 0x00, 0x00, 0x00],\r\n \">\": [0x00, 0x00, 0x00, 0x60, 0x38, 0x0E, 0x0E, 0x38, 0x60, 0x00, 0x00, 0x00, 0x00],\r\n \"[\": [0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00],\r\n \"]\": [0x00, 0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, 0x00],\r\n \"{\": [0x00, 0x00, 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00],\r\n \"}\": [0x00, 0x00, 0x70, 0x18, 0x18, 0x0C, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00],\r\n \"|\": [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00],\r\n \"~\": [0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"^\": [0x00, 0x18, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n \"`\": [0x00, 0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],\r\n\r\n // ─── German characters ────────────────────────────────────────────────────\r\n // Umlauts: dots sit at rows 0-1, letter body follows below\r\n \"ä\": [0x00, 0x24, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x00, 0x00, 0x00],\r\n \"ö\": [0x00, 0x24, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"ü\": [0x00, 0x24, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, 0x00, 0x00],\r\n \"Ä\": [0x24, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00],\r\n \"Ö\": [0x24, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n \"Ü\": [0x24, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00],\r\n // ß: sharp-s / eszett\r\n \"ß\": [0x00, 0x00, 0x3C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x00],\r\n\r\n // ─── Currency / special symbols ──────────────────────────────────────────\r\n // € (Euro): slightly narrower than full width, classic double-bar C shape\r\n \"€\": [0x00, 0x00, 0x1E, 0x30, 0x7C, 0x30, 0x7C, 0x30, 0x30, 0x1E, 0x00, 0x00, 0x00],\r\n};\r\n","/**\r\n * AES-256-CBC decryption for Signotec signature point data.\r\n *\r\n * The Sigma pad encrypts all signature coordinates using AES-256-CBC.\r\n * The pad uses the static default key (KAESDEFKEY) without key exchange.\r\n *\r\n * Decrypted 16-byte block format (verified from real device capture):\r\n * Offset 0: uint32 LE - timestamp (sequential counter)\r\n * Offset 4: uint16 LE - X coordinate (sensor units, ~0-4096)\r\n * Offset 6: uint16 LE - Y coordinate (sensor units, ~0-4096)\r\n * Offset 8: uint16 LE - pressure (0xFFFF = pen up)\r\n * Offset 10: uint16 LE - extra data (pad-specific flags)\r\n * Offset 12: uint32 LE - padding/extra\r\n *\r\n * CBC IV starts as all zeros and chains with each block's ciphertext.\r\n */\r\n\r\nimport crypto from \"crypto\";\r\n\r\n// Static AES-256 key from the Signotec library (kaesdefkey, 32 bytes)\r\n// Verified to work directly on Sigma USB pads without key exchange\r\nconst KAESDEFKEY = Buffer.from([\r\n 0x26, 0xd4, 0xa5, 0xa8, 0x90, 0x01, 0xab, 0x13,\r\n 0x7f, 0x71, 0x31, 0x51, 0xd9, 0x2f, 0xcf, 0x1f,\r\n 0x11, 0x87, 0x86, 0x16, 0x4e, 0x81, 0xb7, 0x94,\r\n 0x2d, 0x8e, 0xdf, 0xd2, 0xda, 0x06, 0x24, 0xf5,\r\n]);\r\n\r\n// Pen-up pressure sentinel value\r\nconst PEN_UP_PRESSURE = 0xFFFF;\r\n\r\nexport interface DecryptedPoint {\r\n x: number;\r\n y: number;\r\n pressure: number;\r\n timestamp: number;\r\n penUp: boolean;\r\n}\r\n\r\n/**\r\n * Manages AES-256-CBC decryption state for a signature session.\r\n * Each session starts with IV = all zeros and chains through all blocks.\r\n */\r\nexport class SignatureDecryptor {\r\n private key: Buffer;\r\n private iv: Buffer;\r\n\r\n constructor(key?: Buffer) {\r\n this.key = Buffer.from(key || KAESDEFKEY);\r\n this.iv = Buffer.alloc(16, 0);\r\n }\r\n\r\n /**\r\n * Create a decryptor using the static default key.\r\n * This works for Sigma USB pads (verified).\r\n */\r\n static withDefaultKey(): SignatureDecryptor {\r\n return new SignatureDecryptor();\r\n }\r\n\r\n /**\r\n * Reset the CBC IV to all zeros (for retry/new signature session).\r\n */\r\n resetIv(): void {\r\n this.iv = Buffer.alloc(16, 0);\r\n }\r\n\r\n /**\r\n * Decrypt a single 16-byte AES block from a 0x41 HID event.\r\n * The ciphertext is at bytes 4-19 of the HID report.\r\n *\r\n * Implements AES-256-CBC manually:\r\n * 1. ECB decrypt the block\r\n * 2. XOR with previous IV\r\n * 3. Update IV to current ciphertext\r\n */\r\n decryptBlock(ciphertext: Buffer): DecryptedPoint | null {\r\n if (ciphertext.length < 16) return null;\r\n\r\n try {\r\n const block = ciphertext.slice(0, 16);\r\n\r\n // AES-256-ECB decrypt (single block, no padding)\r\n const decipher = crypto.createDecipheriv(\"aes-256-ecb\", this.key, null);\r\n decipher.setAutoPadding(false);\r\n const decrypted = Buffer.concat([decipher.update(block), decipher.final()]);\r\n\r\n // CBC: XOR with IV\r\n for (let i = 0; i < 16; i++) {\r\n decrypted[i] ^= this.iv[i];\r\n }\r\n\r\n // Update IV for next block (standard CBC chaining)\r\n block.copy(this.iv, 0, 0, 16);\r\n\r\n // Parse the decrypted data\r\n const timestamp = decrypted.readUInt32LE(0);\r\n const x = decrypted.readUInt16LE(4);\r\n const y = decrypted.readUInt16LE(6);\r\n const pressure = decrypted.readUInt16LE(8);\r\n\r\n return {\r\n timestamp,\r\n x,\r\n y,\r\n pressure,\r\n penUp: pressure === PEN_UP_PRESSURE,\r\n };\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Decrypt a point from a raw 0x41 HID event buffer.\r\n * Extracts the 16-byte ciphertext from bytes 4-19.\r\n */\r\n decryptEvent(eventData: Buffer): DecryptedPoint | null {\r\n if (eventData.length < 20) return null;\r\n return this.decryptBlock(eventData.slice(4, 20));\r\n }\r\n}\r\n","/**\r\n * Renders signature strokes into a PNG image buffer.\r\n * Pure TypeScript implementation - no canvas or native dependencies.\r\n * Uses zlib for PNG compression (built into Node.js).\r\n */\r\n\r\nimport zlib from \"zlib\";\r\n\r\ntype Point = { x: number; y: number; pressure?: number };\r\ntype Stroke = Point[];\r\n\r\nexport interface RenderOptions {\r\n width: number;\r\n height: number;\r\n strokeWidth: number;\r\n strokeColor: { r: number; g: number; b: number };\r\n backgroundColor: { r: number; g: number; b: number };\r\n padding: number;\r\n smooth: boolean;\r\n}\r\n\r\nconst DEFAULT_OPTIONS: RenderOptions = {\r\n width: 400,\r\n height: 200,\r\n strokeWidth: 2,\r\n strokeColor: { r: 0, g: 0, b: 0 },\r\n backgroundColor: { r: 255, g: 255, b: 255 },\r\n padding: 10,\r\n smooth: true,\r\n};\r\n\r\n/**\r\n * Render signature strokes to a PNG buffer.\r\n */\r\nexport function renderSignaturePng(\r\n strokes: Stroke[],\r\n sensorWidth: number,\r\n sensorHeight: number,\r\n options: Partial<RenderOptions> = {}\r\n): Buffer {\r\n const opts = { ...DEFAULT_OPTIONS, ...options };\r\n const { width, height, strokeWidth, strokeColor, backgroundColor, padding } = opts;\r\n\r\n // Create RGBA pixel buffer\r\n const pixels = Buffer.alloc(width * height * 4);\r\n\r\n // Fill background\r\n for (let i = 0; i < width * height; i++) {\r\n pixels[i * 4] = backgroundColor.r;\r\n pixels[i * 4 + 1] = backgroundColor.g;\r\n pixels[i * 4 + 2] = backgroundColor.b;\r\n pixels[i * 4 + 3] = 255;\r\n }\r\n\r\n if (strokes.length === 0) {\r\n return encodePng(pixels, width, height);\r\n }\r\n\r\n // Calculate bounding box of all strokes\r\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\r\n for (const stroke of strokes) {\r\n for (const pt of stroke) {\r\n if (pt.x < minX) minX = pt.x;\r\n if (pt.y < minY) minY = pt.y;\r\n if (pt.x > maxX) maxX = pt.x;\r\n if (pt.y > maxY) maxY = pt.y;\r\n }\r\n }\r\n\r\n // Scale to fit output dimensions with padding\r\n const dataWidth = maxX - minX || 1;\r\n const dataHeight = maxY - minY || 1;\r\n const scaleX = (width - padding * 2) / dataWidth;\r\n const scaleY = (height - padding * 2) / dataHeight;\r\n const scale = Math.min(scaleX, scaleY);\r\n const offsetX = padding + (width - padding * 2 - dataWidth * scale) / 2;\r\n const offsetY = padding + (height - padding * 2 - dataHeight * scale) / 2;\r\n\r\n // Draw strokes\r\n for (const stroke of strokes) {\r\n if (stroke.length < 2) continue;\r\n\r\n for (let i = 1; i < stroke.length; i++) {\r\n const x0 = offsetX + (stroke[i - 1].x - minX) * scale;\r\n const y0 = offsetY + (stroke[i - 1].y - minY) * scale;\r\n const x1 = offsetX + (stroke[i].x - minX) * scale;\r\n const y1 = offsetY + (stroke[i].y - minY) * scale;\r\n\r\n drawLine(pixels, width, height, x0, y0, x1, y1, strokeWidth, strokeColor);\r\n }\r\n }\r\n\r\n return encodePng(pixels, width, height);\r\n}\r\n\r\n/**\r\n * Draw an anti-aliased line with thickness using Bresenham + circle brush.\r\n */\r\nfunction drawLine(\r\n pixels: Buffer,\r\n imgWidth: number,\r\n imgHeight: number,\r\n x0: number, y0: number,\r\n x1: number, y1: number,\r\n thickness: number,\r\n color: { r: number; g: number; b: number }\r\n): void {\r\n const dx = Math.abs(x1 - x0);\r\n const dy = Math.abs(y1 - y0);\r\n const sx = x0 < x1 ? 1 : -1;\r\n const sy = y0 < y1 ? 1 : -1;\r\n let err = dx - dy;\r\n\r\n const steps = Math.max(Math.ceil(Math.sqrt(dx * dx + dy * dy)), 1);\r\n const radius = thickness / 2;\r\n\r\n for (let step = 0; step <= steps; step++) {\r\n const t = steps > 0 ? step / steps : 0;\r\n const cx = x0 + (x1 - x0) * t;\r\n const cy = y0 + (y1 - y0) * t;\r\n\r\n // Draw filled circle at each step\r\n const r = Math.ceil(radius);\r\n for (let dy = -r; dy <= r; dy++) {\r\n for (let dx = -r; dx <= r; dx++) {\r\n if (dx * dx + dy * dy <= radius * radius) {\r\n const px = Math.round(cx + dx);\r\n const py = Math.round(cy + dy);\r\n if (px >= 0 && px < imgWidth && py >= 0 && py < imgHeight) {\r\n const idx = (py * imgWidth + px) * 4;\r\n pixels[idx] = color.r;\r\n pixels[idx + 1] = color.g;\r\n pixels[idx + 2] = color.b;\r\n pixels[idx + 3] = 255;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Encode RGBA pixel buffer as PNG.\r\n * Minimal PNG encoder - no external dependencies.\r\n */\r\nfunction encodePng(pixels: Buffer, width: number, height: number): Buffer {\r\n // Build raw image data with filter bytes\r\n const rawData = Buffer.alloc(height * (1 + width * 4));\r\n for (let y = 0; y < height; y++) {\r\n rawData[y * (1 + width * 4)] = 0; // Filter: None\r\n pixels.copy(\r\n rawData,\r\n y * (1 + width * 4) + 1,\r\n y * width * 4,\r\n (y + 1) * width * 4\r\n );\r\n }\r\n\r\n // Compress with zlib\r\n const compressed = zlib.deflateSync(rawData);\r\n\r\n // Build PNG file\r\n const chunks: Buffer[] = [];\r\n\r\n // PNG signature\r\n chunks.push(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]));\r\n\r\n // IHDR chunk\r\n const ihdr = Buffer.alloc(13);\r\n ihdr.writeUInt32BE(width, 0);\r\n ihdr.writeUInt32BE(height, 4);\r\n ihdr[8] = 8; // bit depth\r\n ihdr[9] = 6; // color type: RGBA\r\n ihdr[10] = 0; // compression\r\n ihdr[11] = 0; // filter\r\n ihdr[12] = 0; // interlace\r\n chunks.push(pngChunk(\"IHDR\", ihdr));\r\n\r\n // IDAT chunk\r\n chunks.push(pngChunk(\"IDAT\", compressed));\r\n\r\n // IEND chunk\r\n chunks.push(pngChunk(\"IEND\", Buffer.alloc(0)));\r\n\r\n return Buffer.concat(chunks);\r\n}\r\n\r\nfunction pngChunk(type: string, data: Buffer): Buffer {\r\n const length = Buffer.alloc(4);\r\n length.writeUInt32BE(data.length, 0);\r\n\r\n const typeAndData = Buffer.concat([Buffer.from(type, \"ascii\"), data]);\r\n const crc = crc32(typeAndData);\r\n const crcBuf = Buffer.alloc(4);\r\n crcBuf.writeUInt32BE(crc >>> 0, 0);\r\n\r\n return Buffer.concat([length, typeAndData, crcBuf]);\r\n}\r\n\r\n// CRC-32 lookup table\r\nconst CRC_TABLE: number[] = [];\r\nfor (let n = 0; n < 256; n++) {\r\n let c = n;\r\n for (let k = 0; k < 8; k++) {\r\n if (c & 1) {\r\n c = 0xEDB88320 ^ (c >>> 1);\r\n } else {\r\n c = c >>> 1;\r\n }\r\n }\r\n CRC_TABLE[n] = c;\r\n}\r\n\r\nfunction crc32(data: Buffer): number {\r\n let crc = 0xFFFFFFFF;\r\n for (let i = 0; i < data.length; i++) {\r\n crc = CRC_TABLE[(crc ^ data[i]) & 0xFF] ^ (crc >>> 8);\r\n }\r\n return (crc ^ 0xFFFFFFFF) >>> 0;\r\n}\r\n","/**\r\n * Embedded button images as Base64.\r\n * Eliminates the need for extraResources in electron-builder.\r\n * The library is completely self-contained - no external files needed.\r\n *\r\n * @module assets-embedded\r\n */\r\n\r\nexport const CANCEL_BMP = Buffer.from(`Qk02IQAAAAAAADYAAAAoAAAAVQAAACEAAAABABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAA////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAD/////////////AAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAA/////////wAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAP////8AAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAD/AAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAA////////////////////////////////////////////////////////AAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAD/AAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAA////////////////////////////////////////////////////////AAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAA/////wAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAP///////////////////////////////////////////////////////////////wAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAP////////8AAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAD/////////////AAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA/////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////`, 'base64');\r\n\r\nexport const OK_BMP = Buffer.from(`Qk02IQAAAAAAADYAAAAoAAAAVQAAACEAAAABABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAA////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAD/////////////AAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAA/////////wAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAP////8AAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAD/AAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAA////////////////////AAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAP///////////////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAD///////////////////////////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAD/AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA/wAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAP8AAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAD/AAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAA/////wAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wAAAAAAAAAAAP////////8AAAAAAAAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAD/////////////AAAAAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA/////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////`, 'base64');\r\n\r\nexport const RETRY_PNG = Buffer.from(`iVBORw0KGgoAAAANSUhEUgAAAFUAAAAhCAYAAACo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2B,IAAc,OAAO;AAC1D,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,MAAM,cAAc,YAAY,KAAmC;AACjE,YAAM,QAAQ,KAAK,IAAI;AACvB,YAAM,WAAW;AAEjB,aAAO,KAAK,IAAI,IAAI,QAAQ,WAAW;AACrC,cAAM,OAAO,OAAO,gBAAgB;AACpC,YAAI,KAAK,SAAS,EAAG,QAAO,KAAK,CAAC;AAClC,cAAM,IAAI,QAAQ,OAAK,WAAW,GAAG,QAAQ,CAAC;AAAA,MAChD;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":["exports","module","fs","path","dir","platform","arch","runtime","abi","require_node_gyp_build","exports","module","module","exports","exports","exports","buf","error","buffer","exports","module","iface","alternate","exports","exports","exports","exports","zlib","import_fs","SIGNOTEC_VID","SIGNOTEC_PID","fs","decodePng","crypto","import_zlib","dy","dx","zlib","fs","path"]}