/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ValidationOutOfBoundsError, validatorOf } from "../common/ValidationError.js";
import { TlvUInt32 } from "../tlv/TlvNumber.js";
import { TlvWrapper } from "../tlv/TlvWrapper.js";
import { Mei } from "./ManufacturerExtensibleIdentifier.js";
function DeviceTypeId(deviceTypeId, validate = true) {
  if (!validate) {
    return deviceTypeId;
  }
  const { typeSuffix } = Mei.fromMei(deviceTypeId);
  if (typeSuffix >= 0 && typeSuffix <= 49151) {
    return deviceTypeId;
  }
  throw new ValidationOutOfBoundsError(`Invalid device type ID: ${deviceTypeId}`);
}
((DeviceTypeId2) => {
  DeviceTypeId2.isValid = validatorOf(DeviceTypeId2);
})(DeviceTypeId || (DeviceTypeId = {}));
const TlvDeviceTypeId = new TlvWrapper(
  TlvUInt32,
  (deviceTypeId) => deviceTypeId,
  (value) => DeviceTypeId(value, false)
  // No automatic validation on decode
);
export {
  DeviceTypeId,
  TlvDeviceTypeId
};
//# sourceMappingURL=DeviceTypeId.js.map
