{"version":3,"file":"useIdColorHash.cjs","names":[],"sources":["../../../src/components/Avatar/useIdColorHash.ts"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\n/**\n * Determines a number for a given Matrix ID or room ID, helps disambiguating users\n * who are trying to impersonate someone else.\n * @param id - a Matrix ID or room ID\n * @returns a hash of the ID provided\n */\nexport function useIdColorHash(id: string): number {\n  const MIN = 1;\n  const MAX = 6;\n  // Sum up the values of all the char codes in the string\n  const charCodeSum = id.split(\"\").reduce((sum, char) => {\n    return sum + char.charCodeAt(0);\n  }, 0);\n  return (charCodeSum % MAX) + MIN;\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,eAAe,IAAoB;AAOjD,QAHoB,GAAG,MAAM,GAAG,CAAC,QAAQ,KAAK,SAAS;AACrD,SAAO,MAAM,KAAK,WAAW,EAAE;IAC9B,EAAE,GAJO,IADA"}