/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { DatatypeOverride, DerObject, DerType } from "#codec/DerCodec.js";
import { InternalError } from "#MatterError.js";
import { hex } from "#util/String.js";
var X520;
((X5202) => {
  X5202.NON_WELL_DEFINED_DATE = /* @__PURE__ */ new Date("9999-12-31 23:59:59Z");
  X5202.OID_TO_FIELD_MAP = {
    // All others are registered dynamically during function creation
    "06092a864886f70d010901": "domainComponent"
  };
  const GenericString_X520 = (id, fieldName) => {
    const oidHex = `5504${hex.byte(id)}`;
    if (X5202.OID_TO_FIELD_MAP[oidHex] !== void 0 && X5202.OID_TO_FIELD_MAP[oidHex] !== fieldName) {
      throw new InternalError(
        `X520 GenericString_X520 mapping for OID ${id} already exists with a different field name: "${X5202.OID_TO_FIELD_MAP[oidHex]}" vs "${fieldName}"`
      );
    }
    X5202.OID_TO_FIELD_MAP[oidHex] = fieldName;
    return (data, asPrintedString = false) => {
      let value = data;
      if (asPrintedString) {
        value = DatatypeOverride(DerType.PrintableString, value);
      }
      return [DerObject(oidHex, { value })];
    };
  };
  X5202.CommonName = GenericString_X520(3, "commonName");
  X5202.SurName = GenericString_X520(4, "surName");
  X5202.SerialNumber = GenericString_X520(5, "serialNum");
  X5202.CountryName = GenericString_X520(6, "countryName");
  X5202.LocalityName = GenericString_X520(7, "localityName");
  X5202.StateOrProvinceName = GenericString_X520(8, "stateOrProvinceName");
  X5202.OrganisationName = GenericString_X520(10, "orgName");
  X5202.OrganizationalUnitName = GenericString_X520(11, "orgUnitName");
  X5202.Title = GenericString_X520(12, "title");
  X5202.Name = GenericString_X520(41, "name");
  X5202.GivenName = GenericString_X520(42, "givenName");
  X5202.Initials = GenericString_X520(43, "initials");
  X5202.GenerationQualifier = GenericString_X520(44, "genQualifier");
  X5202.DnQualifier = GenericString_X520(46, "dnQualifier");
  X5202.Pseudonym = GenericString_X520(65, "pseudonym");
  X5202.DomainComponent = (value) => [
    DerObject("06092A864886F70D010901", { value: DatatypeOverride(DerType.IA5String, value) })
  ];
})(X520 || (X520 = {}));
export {
  X520
};
//# sourceMappingURL=X520.js.map
