/**
 * @license
 * Copyright 2022-2025 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 CommandId(commandId, validate = true) {
  if (!validate) {
    return commandId;
  }
  const { typeSuffix } = Mei.fromMei(commandId);
  if (typeSuffix >= 0 && typeSuffix <= 255) {
    return commandId;
  }
  throw new ValidationOutOfBoundsError(`Invalid command ID: ${commandId}`);
}
((CommandId2) => {
  CommandId2.isValid = validatorOf(CommandId2);
})(CommandId || (CommandId = {}));
const TlvCommandId = new TlvWrapper(
  TlvUInt32,
  (commandId) => commandId,
  (value) => CommandId(value, false)
  // No automatic validation on decode
);
export {
  CommandId,
  TlvCommandId
};
//# sourceMappingURL=CommandId.js.map
