{"version":3,"sources":["../src/testing/mocks/characteristics.ts","../src/testing/mocks/device.ts","../src/testing/mocks/bluetooth.ts","../src/testing/index.ts"],"names":["MockGATTServer","device","configs","config","MockService","service","uuid","beacioDomException","MOCK_SERVICE_ABSENT","s","deviceProxy","self","_device","charConfig","MockCharacteristic","char","MOCK_CHARACTERISTIC_ABSENT","chars","c","buffer","descConfig","MockDescriptor","data","event","listeners","listener","value","type","desc","MOCK_DESCRIPTOR_ABSENT","descriptors","charProxy","d","characteristic","deviceIdCounter","MockBleDevice","options","filter","proxy","_event","rssi","sink","unsupportedExtensionApi","noop","MockBluetooth","opts","MOCK_NO_ADAPTER","matching","MOCK_NO_DEVICE_MATCH","scan","id","available","deviceId","filters","createMockBluetooth","installMockBluetooth","BLE_UUIDS","devices","name"],"mappings":"6DA4DO,IAAMA,CAAAA,CAAN,KAAqB,CAK1B,WAAA,CAAYC,EAAuBC,CAAAA,CAA8B,CAJjE,IAAA,CAAQ,UAAA,CAAa,MAErB,IAAA,CAAQ,SAAA,CAAsC,IAAI,GAAA,CAGhD,KAAK,OAAA,CAAUD,CAAAA,CACf,IAAA,IAAWE,CAAAA,IAAUD,CAAAA,CACnB,IAAA,CAAK,SAAA,CAAU,GAAA,CACbC,EAAO,IAAA,CACP,IAAIC,CAAAA,CAAYH,CAAAA,CAAQE,CAAM,CAChC,EAEJ,CAEA,IAAI,WAAqB,CACvB,OAAO,IAAA,CAAK,UACd,CAEA,MAAM,OAAA,EAA8C,CAClD,GAAI,IAAA,CAAK,OAAA,CAAQ,iBAAA,EAAkB,CACjC,MAAM,IAAI,YAAA,CAAa,wCAAA,CAA0C,cAAc,EAEjF,OAAA,IAAA,CAAK,UAAA,CAAa,IAAA,CACX,IAAA,CAAK,2BAAA,EACd,CAEA,UAAA,EAAmB,CACjB,IAAA,CAAK,UAAA,CAAa,KAAA,CAElB,IAAA,IAAWE,KAAW,IAAA,CAAK,SAAA,CAAU,MAAA,EAAO,CAC1CA,EAAQ,oBAAA,GAEZ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AE,GAAA,CAAItC,CAAAA,EAAKA,EAAE,UAAA,CAAW,CAAC,CAAC,CAAC,CACxE,CACF,CACF,CACF,CACF,CACF,CACF","file":"chunk-IJRTYZ5P.mjs","sourcesContent":["/**\n * Mock GATT Server, Services, and Characteristics\n *\n * Stateful mocks that simulate real BLE behavior:\n * - Characteristic reads return configured values\n * - Writes store values\n * - Notifications can be pumped programmatically\n */\n\nimport type { MockBleDevice } from './device';\n// S5-D: the three {uuid}-template rows for the mock GATT tree's genuine absences. The\n// factory REQUIRES the uuid for exactly these ids (ConditionParams) and substitutes with a\n// FUNCTION replacement, so a caller-supplied `$&`/`$'` uuid interpolates verbatim —\n// byte-identical to the legacy template literals (R2). RELATIVE import: tsup.\nimport {\n  MOCK_CHARACTERISTIC_ABSENT,\n  MOCK_DESCRIPTOR_ABSENT,\n  MOCK_SERVICE_ABSENT,\n  beacioDomException,\n} from '../../error-conditions';\n\nexport interface MockCharacteristicConfig {\n  /** Characteristic UUID */\n  uuid: string;\n  /** Characteristic properties (all default to false except read) */\n  properties?: {\n    broadcast?: boolean;\n    read?: boolean;\n    write?: boolean;\n    writeWithoutResponse?: boolean;\n    notify?: boolean;\n    indicate?: boolean;\n    authenticatedSignedWrites?: boolean;\n    reliableWrite?: boolean;\n    writableAuxiliaries?: boolean;\n  };\n  /** Initial value (DataView or Uint8Array) */\n  value?: ArrayBuffer | Uint8Array;\n  /** Descriptors for this characteristic */\n  descriptors?: MockDescriptorConfig[];\n}\n\nexport interface MockServiceConfig {\n  /** Service UUID */\n  uuid: string;\n  /** Whether this is a primary service (default: true) */\n  isPrimary?: boolean;\n  /** Characteristics in this service */\n  characteristics?: MockCharacteristicConfig[];\n}\n\nexport interface MockDescriptorConfig {\n  /** Descriptor UUID */\n  uuid: string;\n  /** Initial value */\n  value?: ArrayBuffer | Uint8Array;\n}\n\n// --- Mock GATT Server ---\n\nexport class MockGATTServer {\n  private _connected = false;\n  private _device: MockBleDevice;\n  private _services: Map<string, MockService> = new Map();\n\n  constructor(device: MockBleDevice, configs: MockServiceConfig[]) {\n    this._device = device;\n    for (const config of configs) {\n      this._services.set(\n        config.uuid,\n        new MockService(device, config)\n      );\n    }\n  }\n\n  get connected(): boolean {\n    return this._connected;\n  }\n\n  async connect(): Promise<BluetoothRemoteGATTServer> {\n    if (this._device.shouldFailConnect()) {\n      throw new DOMException('Simulated transient connection failure', 'NetworkError');\n    }\n    this._connected = true;\n    return this.asBluetoothRemoteGATTServer();\n  }\n\n  disconnect(): void {\n    this._connected = false;\n    // Stop all notifications\n    for (const service of this._services.values()) {\n      service.stopAllNotifications();\n    }\n  }\n\n  async getPrimaryService(uuid: string): Promise<BluetoothRemoteGATTService> {\n    this._assertConnected();\n    const service = this._services.get(uuid);\n    if (!service) {\n      throw beacioDomException(MOCK_SERVICE_ABSENT, uuid);\n    }\n    return service.asBluetoothRemoteGATTService();\n  }\n\n  async getPrimaryServices(\n    uuid?: string\n  ): Promise<BluetoothRemoteGATTService[]> {\n    this._assertConnected();\n    const services = uuid\n      ? [this._services.get(uuid)].filter(Boolean)\n      : Array.from(this._services.values());\n    return (services as MockService[]).map((s) =>\n      s.asBluetoothRemoteGATTService()\n    );\n  }\n\n  /** Get a mock service for test control */\n  getService(uuid: string): MockService | undefined {\n    return this._services.get(uuid);\n  }\n\n  asBluetoothRemoteGATTServer(deviceProxy?: BluetoothDevice): BluetoothRemoteGATTServer {\n    const self = this;\n    const server = {\n      get connected() {\n        return self._connected;\n      },\n      get device() {\n        return deviceProxy!;\n      },\n      connect: () => self.connect(),\n      disconnect: () => self.disconnect(),\n      getPrimaryService: (uuid: string) =>\n        self.getPrimaryService(uuid),\n      getPrimaryServices: (uuid?: string) =>\n        self.getPrimaryServices(uuid),\n    } as unknown as BluetoothRemoteGATTServer;\n    return server;\n  }\n\n  private _assertConnected(): void {\n    if (!this._connected) {\n      throw new DOMException(\n        'GATT Server is disconnected. Cannot perform GATT operations.',\n        'NetworkError'\n      );\n    }\n  }\n}\n\n// --- Mock Service ---\n\nexport class MockService {\n  readonly uuid: string;\n  readonly isPrimary: boolean;\n  private _characteristics: Map<string, MockCharacteristic> = new Map();\n\n  constructor(_device: MockBleDevice, config: MockServiceConfig) {\n    this.uuid = config.uuid;\n    this.isPrimary = config.isPrimary ?? true;\n    for (const charConfig of config.characteristics ?? []) {\n      this._characteristics.set(\n        charConfig.uuid,\n        new MockCharacteristic(charConfig)\n      );\n    }\n  }\n\n  async getCharacteristic(\n    uuid: string\n  ): Promise<BluetoothRemoteGATTCharacteristic> {\n    const char = this._characteristics.get(uuid);\n    if (!char) {\n      throw beacioDomException(MOCK_CHARACTERISTIC_ABSENT, uuid);\n    }\n    return char.asBluetoothRemoteGATTCharacteristic(\n      this.asBluetoothRemoteGATTService()\n    );\n  }\n\n  async getCharacteristics(\n    uuid?: string\n  ): Promise<BluetoothRemoteGATTCharacteristic[]> {\n    const chars = uuid\n      ? [this._characteristics.get(uuid)].filter(Boolean)\n      : Array.from(this._characteristics.values());\n    const service = this.asBluetoothRemoteGATTService();\n    return (chars as MockCharacteristic[]).map((c) =>\n      c.asBluetoothRemoteGATTCharacteristic(service)\n    );\n  }\n\n  /** Get a mock characteristic for test control */\n  getChar(uuid: string): MockCharacteristic | undefined {\n    return this._characteristics.get(uuid);\n  }\n\n  stopAllNotifications(): void {\n    for (const char of this._characteristics.values()) {\n      char.stopNotifications();\n    }\n  }\n\n  asBluetoothRemoteGATTService(deviceProxy?: BluetoothDevice): BluetoothRemoteGATTService {\n    const self = this;\n    return {\n      uuid: this.uuid,\n      isPrimary: this.isPrimary,\n      get device() {\n        return deviceProxy!;\n      },\n      getCharacteristic: (uuid: string) => self.getCharacteristic(uuid),\n      getCharacteristics: (uuid?: string) =>\n        self.getCharacteristics(uuid),\n      getIncludedService: async () => {\n        throw new DOMException('Not implemented', 'NotSupportedError');\n      },\n      getIncludedServices: async () => [],\n      addEventListener: () => {},\n      removeEventListener: () => {},\n      dispatchEvent: () => true,\n      oncharacteristicvaluechanged: null,\n      onserviceadded: null,\n      onservicechanged: null,\n      onserviceremoved: null,\n    } as unknown as BluetoothRemoteGATTService;\n  }\n}\n\n// --- Mock Characteristic ---\n\nexport class MockCharacteristic {\n  readonly uuid: string;\n  private _properties: {\n    broadcast: boolean;\n    read: boolean;\n    write: boolean;\n    writeWithoutResponse: boolean;\n    notify: boolean;\n    indicate: boolean;\n    authenticatedSignedWrites: boolean;\n    reliableWrite: boolean;\n    writableAuxiliaries: boolean;\n  };\n  private _value: DataView;\n  private _notifying = false;\n  private _listeners: Map<string, Set<EventListener>> = new Map();\n  private _descriptors: Map<string, MockDescriptor> = new Map();\n\n  constructor(config: MockCharacteristicConfig) {\n    this.uuid = config.uuid;\n    this._properties = {\n      broadcast: config.properties?.broadcast ?? false,\n      read: config.properties?.read ?? true,\n      write: config.properties?.write ?? false,\n      writeWithoutResponse: config.properties?.writeWithoutResponse ?? false,\n      notify: config.properties?.notify ?? false,\n      indicate: config.properties?.indicate ?? false,\n      authenticatedSignedWrites: config.properties?.authenticatedSignedWrites ?? false,\n      reliableWrite: config.properties?.reliableWrite ?? false,\n      writableAuxiliaries: config.properties?.writableAuxiliaries ?? false,\n    };\n\n    if (config.value) {\n      const buffer =\n        config.value instanceof Uint8Array\n          ? config.value.buffer.slice(\n              config.value.byteOffset,\n              config.value.byteOffset + config.value.byteLength\n            )\n          : config.value;\n      this._value = new DataView(buffer);\n    } else {\n      this._value = new DataView(new ArrayBuffer(0));\n    }\n\n    for (const descConfig of config.descriptors ?? []) {\n      this._descriptors.set(descConfig.uuid, new MockDescriptor(descConfig));\n    }\n  }\n\n  /** Set the characteristic value (for test setup) */\n  setValue(data: ArrayBuffer | Uint8Array): void {\n    const buffer =\n      data instanceof Uint8Array\n        ? data.buffer.slice(\n            data.byteOffset,\n            data.byteOffset + data.byteLength\n          )\n        : data;\n    this._value = new DataView(buffer);\n  }\n\n  /** Pump a notification to all listeners */\n  emitNotification(data: ArrayBuffer | Uint8Array): void {\n    const buffer =\n      data instanceof Uint8Array\n        ? data.buffer.slice(\n            data.byteOffset,\n            data.byteOffset + data.byteLength\n          )\n        : data;\n    this._value = new DataView(buffer);\n\n    const event = new Event('characteristicvaluechanged');\n    Object.defineProperty(event, 'target', {\n      value: { value: this._value },\n      writable: false,\n    });\n\n    const listeners = this._listeners.get('characteristicvaluechanged');\n    if (listeners) {\n      for (const listener of listeners) {\n        listener(event);\n      }\n    }\n  }\n\n  stopNotifications(): void {\n    this._notifying = false;\n  }\n\n  get isNotifying(): boolean {\n    return this._notifying;\n  }\n\n  /** Get a mock descriptor for test control */\n  getDesc(uuid: string): MockDescriptor | undefined {\n    return this._descriptors.get(uuid);\n  }\n\n  asBluetoothRemoteGATTCharacteristic(\n    service: BluetoothRemoteGATTService\n  ): BluetoothRemoteGATTCharacteristic {\n    const self = this;\n    return {\n      uuid: this.uuid,\n      service,\n      properties: {\n        broadcast: this._properties.broadcast,\n        read: this._properties.read,\n        writeWithoutResponse: this._properties.writeWithoutResponse,\n        write: this._properties.write,\n        notify: this._properties.notify,\n        indicate: this._properties.indicate,\n        authenticatedSignedWrites: this._properties.authenticatedSignedWrites,\n        reliableWrite: this._properties.reliableWrite,\n        writableAuxiliaries: this._properties.writableAuxiliaries,\n      },\n      get value() {\n        return self._value;\n      },\n      readValue: async () => {\n        if (!self._properties.read) {\n          throw new DOMException(\n            'Characteristic does not support read',\n            'NotSupportedError'\n          );\n        }\n        return self._value;\n      },\n      writeValue: async (value: BufferSource) => {\n        if (!self._properties.write) {\n          throw new DOMException(\n            'Characteristic does not support write',\n            'NotSupportedError'\n          );\n        }\n        self._writeValue(value);\n      },\n      writeValueWithResponse: async (value: BufferSource) => {\n        if (!self._properties.write) {\n          throw new DOMException(\n            'Characteristic does not support write',\n            'NotSupportedError'\n          );\n        }\n        self._writeValue(value);\n      },\n      writeValueWithoutResponse: async (value: BufferSource) => {\n        if (!self._properties.writeWithoutResponse) {\n          throw new DOMException(\n            'Characteristic does not support write without response',\n            'NotSupportedError'\n          );\n        }\n        self._writeValue(value);\n      },\n      startNotifications: async function () {\n        if (!self._properties.notify && !self._properties.indicate) {\n          throw new DOMException(\n            'Characteristic does not support notifications',\n            'NotSupportedError'\n          );\n        }\n        self._notifying = true;\n        return this;\n      },\n      stopNotifications: async function () {\n        self._notifying = false;\n        return this;\n      },\n      addEventListener: (type: string, listener: EventListener) => {\n        if (!self._listeners.has(type)) {\n          self._listeners.set(type, new Set());\n        }\n        self._listeners.get(type)!.add(listener);\n      },\n      removeEventListener: (type: string, listener: EventListener) => {\n        self._listeners.get(type)?.delete(listener);\n      },\n      dispatchEvent: () => true,\n      getDescriptor: async (uuid: string) => {\n        const desc = self._descriptors.get(uuid);\n        if (!desc) {\n          throw beacioDomException(MOCK_DESCRIPTOR_ABSENT, uuid);\n        }\n        return desc.asBluetoothRemoteGATTDescriptor(\n          self.asBluetoothRemoteGATTCharacteristic(service)\n        );\n      },\n      getDescriptors: async (uuid?: string) => {\n        const descriptors = uuid\n          ? [self._descriptors.get(uuid)].filter(Boolean)\n          : Array.from(self._descriptors.values());\n        const charProxy = self.asBluetoothRemoteGATTCharacteristic(service);\n        return (descriptors as MockDescriptor[]).map((d) =>\n          d.asBluetoothRemoteGATTDescriptor(charProxy)\n        );\n      },\n      oncharacteristicvaluechanged: null,\n    } as unknown as BluetoothRemoteGATTCharacteristic;\n  }\n\n  private _writeValue(value: BufferSource): void {\n    const buffer =\n      value instanceof ArrayBuffer\n        ? value\n        : (value as DataView).buffer ?? (value as Uint8Array).buffer;\n    this._value = new DataView(buffer);\n  }\n}\n\n// --- Mock Descriptor ---\n\nexport class MockDescriptor {\n  readonly uuid: string;\n  private _value: DataView;\n\n  constructor(config: MockDescriptorConfig) {\n    this.uuid = config.uuid;\n    if (config.value) {\n      const buffer =\n        config.value instanceof Uint8Array\n          ? config.value.buffer.slice(\n              config.value.byteOffset,\n              config.value.byteOffset + config.value.byteLength\n            )\n          : config.value;\n      this._value = new DataView(buffer);\n    } else {\n      this._value = new DataView(new ArrayBuffer(0));\n    }\n  }\n\n  /** Set the descriptor value (for test setup) */\n  setValue(data: ArrayBuffer | Uint8Array): void {\n    const buffer =\n      data instanceof Uint8Array\n        ? data.buffer.slice(\n            data.byteOffset,\n            data.byteOffset + data.byteLength\n          )\n        : data;\n    this._value = new DataView(buffer);\n  }\n\n  /** Get the current value */\n  get value(): DataView {\n    return this._value;\n  }\n\n  asBluetoothRemoteGATTDescriptor(\n    characteristic: BluetoothRemoteGATTCharacteristic\n  ): BluetoothRemoteGATTDescriptor {\n    const self = this;\n    return {\n      uuid: this.uuid,\n      characteristic,\n      get value() {\n        return self._value;\n      },\n      readValue: async () => {\n        return self._value;\n      },\n      writeValue: async (value: BufferSource) => {\n        const buffer =\n          value instanceof ArrayBuffer\n            ? value\n            : (value as DataView).buffer ?? (value as Uint8Array).buffer;\n        self._value = new DataView(buffer);\n      },\n    } as unknown as BluetoothRemoteGATTDescriptor;\n  }\n}\n","/**\n * Mock BLE Device — stateful device with GATT server, services, characteristics\n */\n\nimport {\n  MockGATTServer,\n  type MockServiceConfig,\n} from './characteristics';\n\nlet deviceIdCounter = 0;\n\nexport interface MockDeviceOptions {\n  /** Device ID (auto-generated if not provided) */\n  id?: string;\n  /** Device name */\n  name?: string;\n  /** Advertised service UUIDs */\n  serviceUUIDs?: string[];\n  /** GATT service configurations */\n  services?: MockServiceConfig[];\n  /** Initial RSSI value */\n  rssi?: number;\n  /** Fail the first N connect() attempts with a NetworkError. */\n  failConnectAttempts?: number;\n  /** Optional platform-reported write limits for MTU-aware write tests. */\n  writeLimits?: {\n    withResponse?: number | null;\n    withoutResponse?: number | null;\n    mtu?: number | null;\n  };\n}\n\nexport interface MockAdvertisementOptions {\n  /** Override RSSI for this advertisement */\n  rssi?: number;\n  /** Optional TX power value */\n  txPower?: number;\n  /** Override advertised UUIDs for this advertisement */\n  uuids?: string[];\n  /** Optional manufacturer data payloads */\n  manufacturerData?: Map<number, DataView>;\n  /** Optional service data payloads */\n  serviceData?: Map<string, DataView>;\n}\n\ninterface ExtendedGatt extends BluetoothRemoteGATTServer {\n  getMtu?: () => Promise<number | null>;\n  getWriteLimits?: () => Promise<Record<string, number | null>>;\n}\n\nexport class MockBleDevice {\n  readonly id: string;\n  readonly name: string | undefined;\n  private _serviceUUIDs: string[];\n  private _gatt: MockGATTServer;\n  private _listeners: Map<string, Set<EventListener>> = new Map();\n  private _rssi: number;\n  private _watchingAdvertisements = false;\n  private _advertisementSink?: (\n    device: MockBleDevice,\n    options: MockAdvertisementOptions\n  ) => void;\n  private _remainingConnectFailures: number;\n  private _writeLimits: {\n    withResponse: number | null;\n    withoutResponse: number | null;\n    mtu: number | null;\n  };\n\n  constructor(options: MockDeviceOptions = {}) {\n    this.id = options.id ?? `mock-device-${++deviceIdCounter}`;\n    this.name = options.name;\n    this._serviceUUIDs = options.serviceUUIDs ?? [];\n    this._gatt = new MockGATTServer(this, options.services ?? []);\n    this._rssi = options.rssi ?? -60;\n    this._remainingConnectFailures = options.failConnectAttempts ?? 0;\n    this._writeLimits = {\n      withResponse: options.writeLimits?.withResponse ?? null,\n      withoutResponse: options.writeLimits?.withoutResponse ?? null,\n      mtu: options.writeLimits?.mtu ?? null,\n    };\n  }\n\n  /** Check if this device matches a scan filter */\n  matchesFilter(filter: BluetoothLEScanFilter): boolean {\n    if (filter.services) {\n      const hasService = filter.services.some((uuid) =>\n        this._serviceUUIDs.includes(String(uuid))\n      );\n      if (!hasService) return false;\n    }\n    if (filter.name && filter.name !== this.name) return false;\n    if (filter.namePrefix && !this.name?.startsWith(filter.namePrefix))\n      return false;\n    return true;\n  }\n\n  /** Return a Web Bluetooth-compatible BluetoothDevice object */\n  asBluetoothDevice(): BluetoothDevice {\n    const self = this;\n    // Build the device proxy first, then wire up gatt to avoid circular calls\n    const proxy = {\n      id: this.id,\n      name: this.name ?? null,\n      gatt: null as unknown as BluetoothRemoteGATTServer,\n      watchAdvertisements: async (options?: { signal?: AbortSignal }) => {\n        self._watchingAdvertisements = true;\n        if (options?.signal) {\n          if (options.signal.aborted) {\n            self._watchingAdvertisements = false;\n            return;\n          }\n\n          options.signal.addEventListener(\n            'abort',\n            () => {\n              self._watchingAdvertisements = false;\n            },\n            { once: true }\n          );\n        }\n      },\n      addEventListener: (type: string, listener: EventListener) => {\n        self._addListener(type, listener);\n      },\n      removeEventListener: (type: string, listener: EventListener) => {\n        self._removeListener(type, listener);\n      },\n      dispatchEvent: (_event: Event) => true,\n      get watchingAdvertisements() {\n        return self._watchingAdvertisements;\n      },\n      unwatchAdvertisements: async () => {\n        self._watchingAdvertisements = false;\n      },\n      forget: async () => {},\n      onadvertisementreceived: null,\n      ongattserverdisconnected: null,\n      oncharacteristicvaluechanged: null,\n      onserviceadded: null,\n      onservicechanged: null,\n      onserviceremoved: null,\n    } as object as BluetoothDevice;\n    // Wire gatt with a back-reference to the proxy (no recursion)\n    (proxy as { gatt: ExtendedGatt }).gatt = this._gatt.asBluetoothRemoteGATTServer(proxy) as ExtendedGatt;\n    (proxy as { gatt: ExtendedGatt }).gatt.getMtu = async () => this._writeLimits.mtu;\n    (proxy as { gatt: ExtendedGatt }).gatt.getWriteLimits = async () => ({ ...this._writeLimits });\n\n    return proxy;\n  }\n\n  shouldFailConnect(): boolean {\n    if (this._remainingConnectFailures <= 0) {\n      return false;\n    }\n    this._remainingConnectFailures -= 1;\n    return true;\n  }\n\n  /** Simulate a disconnect event */\n  simulateDisconnect(): void {\n    this._gatt.disconnect();\n    this._emit('gattserverdisconnected', new Event('gattserverdisconnected'));\n  }\n\n  /** Get the mock GATT server for direct test control */\n  get gatt(): MockGATTServer {\n    return this._gatt;\n  }\n\n  get serviceUUIDs(): readonly string[] {\n    return this._serviceUUIDs;\n  }\n\n  get rssi(): number {\n    return this._rssi;\n  }\n\n  /** Emit an advertisement for requestLEScan()/watchAdvertisements() tests */\n  emitAdvertisement(options: MockAdvertisementOptions = {}): void {\n    if (this._advertisementSink) {\n      this._advertisementSink(this, options);\n      return;\n    }\n\n    this.dispatchAdvertisementEvent(options);\n  }\n\n  /** Update RSSI between advertisements */\n  setRSSI(rssi: number): void {\n    this._rssi = rssi;\n  }\n\n  /** Internal hook used by MockBluetooth to receive advertisement pumps */\n  setAdvertisementSink(\n    sink: ((device: MockBleDevice, options: MockAdvertisementOptions) => void) | undefined\n  ): void {\n    this._advertisementSink = sink;\n  }\n\n  /** Internal bridge for watchAdvertisements() listeners */\n  dispatchAdvertisementEvent(options: MockAdvertisementOptions = {}): void {\n    if (!this._watchingAdvertisements) {\n      return;\n    }\n\n    this._emit(\n      'advertisementreceived',\n      this.createAdvertisementEvent(this.asBluetoothDevice(), options)\n    );\n  }\n\n  /** Build a Web Bluetooth-style advertisementreceived event */\n  createAdvertisementEvent(\n    deviceProxy: BluetoothDevice,\n    options: MockAdvertisementOptions = {}\n  ): Event {\n    const event = new Event('advertisementreceived') as Event & {\n      device?: BluetoothDevice;\n      name?: string;\n      uuids?: string[];\n      rssi?: number;\n      txPower?: number;\n      manufacturerData?: Map<number, DataView>;\n      serviceData?: Map<string, DataView>;\n    };\n\n    Object.defineProperties(event, {\n      device: { value: deviceProxy, writable: false },\n      name: { value: this.name, writable: false },\n      uuids: {\n        value: [...(options.uuids ?? this._serviceUUIDs)],\n        writable: false,\n      },\n      rssi: { value: options.rssi ?? this._rssi, writable: false },\n      txPower: { value: options.txPower, writable: false },\n      manufacturerData: {\n        value: options.manufacturerData ?? new Map<number, DataView>(),\n        writable: false,\n      },\n      serviceData: {\n        value: options.serviceData ?? new Map<string, DataView>(),\n        writable: false,\n      },\n    });\n\n    return event;\n  }\n\n  // --- Internal ---\n\n  private _addListener(type: string, listener: EventListener): void {\n    if (!this._listeners.has(type)) {\n      this._listeners.set(type, new Set());\n    }\n    this._listeners.get(type)!.add(listener);\n  }\n\n  private _removeListener(type: string, listener: EventListener): void {\n    this._listeners.get(type)?.delete(listener);\n  }\n\n  private _emit(type: string, event: Event): void {\n    const listeners = this._listeners.get(type);\n    if (listeners) {\n      for (const listener of listeners) {\n        listener(event);\n      }\n    }\n  }\n}\n","/**\n * Mock Bluetooth API — drop-in replacement for navigator.bluetooth\n *\n * Provides a stateful mock that tracks devices, manages connections,\n * and can be configured for various test scenarios.\n */\n\nimport {\n  MockBleDevice,\n  type MockAdvertisementOptions,\n  type MockDeviceOptions,\n} from './device';\nimport type {\n  MockCharacteristicConfig,\n  MockServiceConfig,\n} from './characteristics';\n// S5-D: @beacio/testing is a PUBLISHED package — its messages land in a real consumer's\n// catch exactly like the polyfill's, so its NotFoundErrors are conditions too (both are\n// genuine absences, deliberately sharing DEVICE_NOT_FOUND). RELATIVE import: tsup.\nimport { MOCK_NO_ADAPTER, MOCK_NO_DEVICE_MATCH, beacioDomException } from '../../error-conditions';\n\nexport interface MockBluetoothOptions {\n  /** Whether Bluetooth is available (default: true) */\n  available?: boolean;\n  /** Pre-registered devices that will appear in scans */\n  devices?: MockDeviceOptions[];\n}\n\nconst unsupportedExtensionApi = (): Promise<never> =>\n  Promise.reject(new DOMException('Beacio extension API not implemented in MockBluetooth', 'NotSupportedError'));\n\nconst noop = (): void => {};\n\nexport class MockBluetooth {\n  private _available: boolean;\n  private _devices: Map<string, MockBleDevice> = new Map();\n  private _listeners: Map<string, Set<EventListener>> = new Map();\n  private _scanActive = false;\n  private _installedNavigatorBluetooth?: unknown;\n  private _lastScanOptions?: BluetoothLEScanOptions;\n\n  readonly backgroundSync = {\n    requestPermission: unsupportedExtensionApi,\n    requestBackgroundConnection: unsupportedExtensionApi,\n    registerCharacteristicNotifications: unsupportedExtensionApi,\n    registerBeaconScanning: unsupportedExtensionApi,\n    getRegistrations: unsupportedExtensionApi,\n    unregister: unsupportedExtensionApi,\n    update: unsupportedExtensionApi,\n    connect: unsupportedExtensionApi,\n    subscribe: unsupportedExtensionApi,\n    scan: unsupportedExtensionApi,\n    list: unsupportedExtensionApi,\n    destroy: noop,\n  };\n\n  readonly peripheral = {\n    advertising: false,\n    advertise: unsupportedExtensionApi,\n    stopAdvertising: unsupportedExtensionApi,\n    send: unsupportedExtensionApi,\n    destroy: noop,\n    addEventListener: noop,\n    removeEventListener: noop,\n    onwriterequest: null,\n    onsubscriptionchange: null,\n    onconnectionstatechange: null,\n    onadvertisingstatechange: null,\n  };\n\n  constructor(options: MockBluetoothOptions = {}) {\n    this._available = options.available ?? true;\n    if (options.devices) {\n      for (const opts of options.devices) {\n        const device = new MockBleDevice(opts);\n        device.setAdvertisementSink(this._handleAdvertisement);\n        this._devices.set(device.id, device);\n      }\n    }\n  }\n\n  // --- Public API (matches navigator.bluetooth) ---\n\n  async getAvailability(): Promise<boolean> {\n    return this._available;\n  }\n\n  async requestDevice(\n    options?: RequestDeviceOptions\n  ): Promise<BluetoothDevice> {\n    if (!this._available) {\n      // Period-less on purpose (≠ Chromium's \"…available.\") — see the row's doc.\n      throw beacioDomException(MOCK_NO_ADAPTER);\n    }\n\n    const matching = this._findMatchingDevices(options as Record<string, unknown>);\n    if (matching.length === 0) {\n      throw beacioDomException(MOCK_NO_DEVICE_MATCH);\n    }\n\n    // Return the first matching device (simulates user picking)\n    return matching[0].asBluetoothDevice();\n  }\n\n  async getDevices(): Promise<BluetoothDevice[]> {\n    return Array.from(this._devices.values()).map((d) =>\n      d.asBluetoothDevice()\n    );\n  }\n\n  async requestLEScan(\n    options?: BluetoothLEScanOptions\n  ): Promise<BluetoothLEScan> {\n    if (this._scanActive) {\n      throw new DOMException('Scan already in progress', 'InvalidStateError');\n    }\n    this._scanActive = true;\n    this._lastScanOptions = options;\n    const scan = {\n      active: true,\n      keepRepeatedDevices: options?.keepRepeatedDevices ?? false,\n      acceptAllAdvertisements: options?.acceptAllAdvertisements ?? false,\n      stop: () => {\n        this._scanActive = false;\n        this._lastScanOptions = undefined;\n        scan.active = false;\n      },\n    } as BluetoothLEScan & { active: boolean };\n    return scan as BluetoothLEScan;\n  }\n\n  addEventListener(type: string, listener: EventListener): void {\n    if (!this._listeners.has(type)) {\n      this._listeners.set(type, new Set());\n    }\n    this._listeners.get(type)!.add(listener);\n  }\n\n  removeEventListener(type: string, listener: EventListener): void {\n    this._listeners.get(type)?.delete(listener);\n  }\n\n  // --- Test helpers ---\n\n  /** Add a device to the mock registry */\n  addDevice(options: MockDeviceOptions): MockBleDevice {\n    const device = new MockBleDevice(options);\n    device.setAdvertisementSink(this._handleAdvertisement);\n    this._devices.set(device.id, device);\n    return device;\n  }\n\n  /** Remove a device from the registry */\n  removeDevice(id: string): void {\n    const device = this._devices.get(id);\n    if (device) {\n      device.setAdvertisementSink(undefined);\n      device.simulateDisconnect();\n      this._devices.delete(id);\n    }\n  }\n\n  /** Get a mock device by ID for test assertions */\n  getDevice(id: string): MockBleDevice | undefined {\n    return this._devices.get(id);\n  }\n\n  /** Set Bluetooth availability */\n  setAvailable(available: boolean): void {\n    this._available = available;\n  }\n\n  /** Install this mock instance onto navigator.bluetooth */\n  install(): this {\n    if (typeof globalThis.navigator === 'undefined') {\n      return this;\n    }\n\n    this._installedNavigatorBluetooth = (globalThis.navigator as Navigator & {\n      bluetooth?: unknown;\n    }).bluetooth;\n\n    Object.defineProperty(globalThis.navigator, 'bluetooth', {\n      value: this,\n      writable: true,\n      configurable: true,\n    });\n    return this;\n  }\n\n  /** Restore the previous navigator.bluetooth value */\n  uninstall(): void {\n    if (typeof globalThis.navigator === 'undefined') {\n      return;\n    }\n\n    Object.defineProperty(globalThis.navigator, 'bluetooth', {\n      value: this._installedNavigatorBluetooth,\n      writable: true,\n      configurable: true,\n    });\n    this._installedNavigatorBluetooth = undefined;\n  }\n\n  /** Emit a Bluetooth-level advertisementreceived event */\n  emitAdvertisement(\n    deviceId: string,\n    options: MockAdvertisementOptions = {}\n  ): void {\n    const device = this._devices.get(deviceId);\n    if (!device) {\n      throw new Error(`Unknown mock device: ${deviceId}`);\n    }\n\n    this._handleAdvertisement(device, options);\n  }\n\n  /** Reset all state */\n  reset(): void {\n    for (const device of this._devices.values()) {\n      device.setAdvertisementSink(undefined);\n      device.simulateDisconnect();\n    }\n    this._devices.clear();\n    this._listeners.clear();\n    this._scanActive = false;\n    this._lastScanOptions = undefined;\n    this._available = true;\n  }\n\n  // --- Internal ---\n\n  private _findMatchingDevices(\n    options?: Record<string, unknown>\n  ): MockBleDevice[] {\n    if (!options || (options as { acceptAllDevices?: boolean }).acceptAllDevices) {\n      return Array.from(this._devices.values());\n    }\n\n    const filters = ((options as { filters?: BluetoothLEScanFilter[] }).filters) ?? [];\n    return Array.from(this._devices.values()).filter((device) =>\n      filters.some((filter: BluetoothLEScanFilter) => device.matchesFilter(filter))\n    );\n  }\n\n  private readonly _handleAdvertisement = (\n    device: MockBleDevice,\n    options: MockAdvertisementOptions\n  ): void => {\n    device.dispatchAdvertisementEvent(options);\n\n    if (!this._scanActive) {\n      return;\n    }\n\n    if (!this._matchesScan(device)) {\n      return;\n    }\n\n    const event = device.createAdvertisementEvent(device.asBluetoothDevice(), options);\n    const listeners = this._listeners.get('advertisementreceived');\n    if (!listeners) {\n      return;\n    }\n\n    for (const listener of listeners) {\n      listener(event);\n    }\n  };\n\n  private _matchesScan(device: MockBleDevice): boolean {\n    const options = this._lastScanOptions;\n    if (!options) {\n      return true;\n    }\n\n    if (options.acceptAllAdvertisements) {\n      return true;\n    }\n\n    const filters = options.filters ?? [];\n    if (filters.length === 0) {\n      return true;\n    }\n\n    return filters.some((filter) => device.matchesFilter(filter));\n  }\n}\n\n/**\n * Install mock Bluetooth API on the global navigator object.\n * Returns a MockBluetooth instance for test control.\n */\nexport function createMockBluetooth(\n  options?: MockBluetoothOptions\n): MockBluetooth {\n  return new MockBluetooth(options);\n}\n\n/**\n * Install mock Bluetooth on navigator.bluetooth.\n * Returns the mock instance for control.\n */\nexport function installMockBluetooth(\n  options?: MockBluetoothOptions\n): MockBluetooth {\n  const mock = createMockBluetooth(options);\n  return mock.install();\n}\n\nexport type {\n  MockServiceConfig,\n  MockCharacteristicConfig,\n  MockAdvertisementOptions,\n};\n","/**\n * @beacio/core/testing — Mock Bluetooth API for testing BLE web apps\n *\n * Folded in from the former @beacio/testing package (B10-t): the hardware-free\n * mock/virtual Web Bluetooth surface that powers the \"playground\" first-run\n * (a dev sees `requestDevice()` succeed in Chrome before ever touching iOS).\n * Reached via the `@beacio/core/testing` subpath export.\n *\n * Provides stateful mocks for the Web Bluetooth API:\n * - MockBluetooth: drop-in replacement for navigator.bluetooth\n * - MockBleDevice: stateful device with GATT services/characteristics\n * - MockCharacteristic: value simulation and notification pump\n * - Advertisement simulation for requestLEScan/watchAdvertisements tests\n *\n * Usage:\n *   import { createMockBluetooth, installMockBluetooth } from '@beacio/core/testing'\n *\n *   // Option A: Create and install on navigator.bluetooth\n *   const mock = installMockBluetooth({ available: true })\n *\n *   // Option B: Create without installing (for custom setups)\n *   const mock = createMockBluetooth()\n *\n *   // Add test devices\n *   const device = mock.addDevice({\n *     name: 'HR Sensor',\n *     failConnectAttempts: 1,\n *     writeLimits: { withResponse: 20, mtu: 23 },\n *     serviceUUIDs: ['0000180d-0000-1000-8000-00805f9b34fb'],\n *     services: [{\n *       uuid: '0000180d-0000-1000-8000-00805f9b34fb',\n *       characteristics: [{\n *         uuid: '00002a37-0000-1000-8000-00805f9b34fb',\n *         properties: { notify: true, read: true },\n *         value: new Uint8Array([0x00, 72]),\n *       }],\n *     }],\n *   })\n *\n *   // Pump notifications in tests\n *   const char = device.gatt.getService('0000180d-...')?.getChar('00002a37-...')\n *   char?.emitNotification(new Uint8Array([0x00, 80]))\n *\n *   // Emit advertisements for scan/beacon-style tests\n *   device.emitAdvertisement({ rssi: -42 })\n *\n *   // Reset between tests\n *   mock.reset()\n */\n\nexport {\n  MockBluetooth,\n  createMockBluetooth,\n  installMockBluetooth,\n  type MockBluetoothOptions,\n  type MockAdvertisementOptions,\n} from './mocks/bluetooth';\n\nexport {\n  MockBleDevice,\n  type MockDeviceOptions,\n} from './mocks/device';\n\nexport {\n  MockGATTServer,\n  MockService,\n  MockCharacteristic,\n  MockDescriptor,\n  type MockServiceConfig,\n  type MockCharacteristicConfig,\n  type MockDescriptorConfig,\n} from './mocks/characteristics';\n\n/** Common Bluetooth SIG UUIDs for test convenience */\nexport const BLE_UUIDS = {\n  services: {\n    HEART_RATE: '0000180d-0000-1000-8000-00805f9b34fb',\n    BATTERY: '0000180f-0000-1000-8000-00805f9b34fb',\n    DEVICE_INFO: '0000180a-0000-1000-8000-00805f9b34fb',\n    ENVIRONMENTAL_SENSING: '0000181a-0000-1000-8000-00805f9b34fb',\n  },\n  characteristics: {\n    HEART_RATE_MEASUREMENT: '00002a37-0000-1000-8000-00805f9b34fb',\n    BODY_SENSOR_LOCATION: '00002a38-0000-1000-8000-00805f9b34fb',\n    BATTERY_LEVEL: '00002a19-0000-1000-8000-00805f9b34fb',\n    MANUFACTURER_NAME: '00002a29-0000-1000-8000-00805f9b34fb',\n    MODEL_NUMBER: '00002a24-0000-1000-8000-00805f9b34fb',\n    TEMPERATURE: '00002a6e-0000-1000-8000-00805f9b34fb',\n  },\n  descriptors: {\n    /** Client Characteristic Configuration Descriptor */\n    CCCD: '00002902-0000-1000-8000-00805f9b34fb',\n    /** Characteristic User Description */\n    USER_DESCRIPTION: '00002901-0000-1000-8000-00805f9b34fb',\n    /** Characteristic Presentation Format */\n    PRESENTATION_FORMAT: '00002904-0000-1000-8000-00805f9b34fb',\n  },\n} as const;\n\n/** Pre-configured device factories for common test scenarios */\nexport const devices = {\n  /** Heart rate sensor with notification support */\n  heartRate(name = 'Mock HR Sensor'): import('./mocks/device').MockDeviceOptions {\n    return {\n      name,\n      serviceUUIDs: [BLE_UUIDS.services.HEART_RATE],\n      services: [\n        {\n          uuid: BLE_UUIDS.services.HEART_RATE,\n          characteristics: [\n            {\n              uuid: BLE_UUIDS.characteristics.HEART_RATE_MEASUREMENT,\n              properties: { read: true, notify: true },\n              value: new Uint8Array([0x00, 72]), // 72 bpm\n            },\n            {\n              uuid: BLE_UUIDS.characteristics.BODY_SENSOR_LOCATION,\n              properties: { read: true },\n              value: new Uint8Array([1]), // Chest\n            },\n          ],\n        },\n      ],\n    };\n  },\n\n  /** Battery service device */\n  battery(name = 'Mock Battery Device'): import('./mocks/device').MockDeviceOptions {\n    return {\n      name,\n      serviceUUIDs: [BLE_UUIDS.services.BATTERY],\n      services: [\n        {\n          uuid: BLE_UUIDS.services.BATTERY,\n          characteristics: [\n            {\n              uuid: BLE_UUIDS.characteristics.BATTERY_LEVEL,\n              properties: { read: true, notify: true },\n              value: new Uint8Array([85]), // 85%\n            },\n          ],\n        },\n      ],\n    };\n  },\n\n  /** Device with multiple services */\n  full(name = 'Mock Full Device'): import('./mocks/device').MockDeviceOptions {\n    return {\n      name,\n      serviceUUIDs: [\n        BLE_UUIDS.services.HEART_RATE,\n        BLE_UUIDS.services.BATTERY,\n        BLE_UUIDS.services.DEVICE_INFO,\n      ],\n      services: [\n        {\n          uuid: BLE_UUIDS.services.HEART_RATE,\n          characteristics: [\n            {\n              uuid: BLE_UUIDS.characteristics.HEART_RATE_MEASUREMENT,\n              properties: { read: true, notify: true },\n              value: new Uint8Array([0x00, 72]),\n            },\n          ],\n        },\n        {\n          uuid: BLE_UUIDS.services.BATTERY,\n          characteristics: [\n            {\n              uuid: BLE_UUIDS.characteristics.BATTERY_LEVEL,\n              properties: { read: true, notify: true },\n              value: new Uint8Array([100]),\n            },\n          ],\n        },\n        {\n          uuid: BLE_UUIDS.services.DEVICE_INFO,\n          characteristics: [\n            {\n              uuid: BLE_UUIDS.characteristics.MANUFACTURER_NAME,\n              properties: { read: true },\n              value: Uint8Array.from(Array.from('Beacio Test Corp').map(c => c.charCodeAt(0))),\n            },\n            {\n              uuid: BLE_UUIDS.characteristics.MODEL_NUMBER,\n              properties: { read: true },\n              value: Uint8Array.from(Array.from('WBT-001').map(c => c.charCodeAt(0))),\n            },\n          ],\n        },\n      ],\n    };\n  },\n};\n"]}