export function createPairingStore() {
  /** @type {Record<string, { code: string; name: string; createdAt: number }>} */
  const authCodes = {};
  /** @type {Record<string, { name: string; token: string; createdAt: number }>} */
  const pairedDevices = {};

  return {
    setPairingCode(code, name = 'JTL-POS') {
      authCodes[code] = { code, name, createdAt: Date.now() };
    },
    revokePairingCode(code) {
      delete authCodes[code];
    },
    hasPairingCode(code) {
      return Boolean(authCodes[code]);
    },
    registerDevice(token, name = 'JTL-POS') {
      pairedDevices[token] = { name, token, createdAt: Date.now() };
    },
    getPairedDevices() {
      return { ...pairedDevices };
    },
  };
}
