"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var CaseAuthenticatedTag_exports = {};
__export(CaseAuthenticatedTag_exports, {
  CaseAuthenticatedTag: () => CaseAuthenticatedTag,
  TlvCaseAuthenticatedTag: () => TlvCaseAuthenticatedTag
});
module.exports = __toCommonJS(CaseAuthenticatedTag_exports);
var import_general = require("#general");
var import_ValidationError = require("../common/ValidationError.js");
var import_TlvNumber = require("../tlv/TlvNumber.js");
var import_TlvWrapper = require("../tlv/TlvWrapper.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
const logger = import_general.Logger.get("CaseAuthenticatedTag");
function CaseAuthenticatedTag(idOrTag, version) {
  if (version !== void 0) {
    idOrTag = idOrTag << 16 | version;
  }
  if ((idOrTag & 65535) === 0) {
    throw new import_ValidationError.ValidationOutOfBoundsError("CaseAuthenticatedTag version number must not be 0.");
  }
  if (idOrTag >>> 16 > 61439) {
    logger.warn(
      `CaseAuthenticatedTag Identifier 0x${(idOrTag >>> 16).toString(16).toUpperCase()} SHOULD NOT exceed 0xEFFF. Please choose a lower value.`
    );
  }
  return idOrTag;
}
((CaseAuthenticatedTag2) => {
  CaseAuthenticatedTag2.AdministratorIdentifier = (version = 1) => {
    if (version <= 0 || version > 65535) {
      throw new import_ValidationError.ValidationOutOfBoundsError("CaseAuthenticatedTag version number must be between 1 and 0xffff.");
    }
    return 65533 << 16 | version;
  };
  CaseAuthenticatedTag2.AnchorIdentifier = (version = 1) => {
    if (version <= 0 || version > 65535) {
      throw new import_ValidationError.ValidationOutOfBoundsError("CaseAuthenticatedTag version number must be between 1 and 0xffff.");
    }
    return 65534 << 16 | version;
  };
  CaseAuthenticatedTag2.getIdentifyValue = (tag) => tag >>> 16;
  CaseAuthenticatedTag2.getVersion = (tag) => tag & 65535;
  CaseAuthenticatedTag2.increaseVersion = (tag) => {
    const version = (0, CaseAuthenticatedTag2.getVersion)(tag);
    if (version === 65535) {
      throw new import_ValidationError.ValidationOutOfBoundsError("CaseAuthenticatedTag version number must not exceed 0xffff.");
    }
    return CaseAuthenticatedTag2(tag + 1);
  };
  CaseAuthenticatedTag2.validateNocTagList = (tags) => {
    if (tags.length > 3) {
      throw new import_ValidationError.ValidationOutOfBoundsError(`Too many CaseAuthenticatedTags (${tags.length}).`);
    }
    const tagIdentifierValues = new Set(tags.map((cat) => CaseAuthenticatedTag2.getIdentifyValue(cat)));
    if (tagIdentifierValues.size !== tags.length) {
      throw new import_ValidationError.ValidationOutOfBoundsError("CASEAuthenticatedTags field contains duplicate identifier values.");
    }
  };
})(CaseAuthenticatedTag || (CaseAuthenticatedTag = {}));
class TlvCaseAuthenticatedTagSchema extends import_TlvWrapper.TlvWrapper {
  constructor() {
    super(
      import_TlvNumber.TlvUInt32,
      (caseAuthenticatedTag) => caseAuthenticatedTag,
      (value) => CaseAuthenticatedTag(value)
    );
  }
  validate(value) {
    super.validate(value);
    if ((value & 65535) === 0) {
      throw new import_ValidationError.ValidationOutOfBoundsError("CaseAuthenticatedTag version number must not be 0.");
    }
  }
}
const TlvCaseAuthenticatedTag = new TlvCaseAuthenticatedTagSchema();
//# sourceMappingURL=CaseAuthenticatedTag.js.map
