{"version":3,"file":"RolesList.mjs","sources":["../../../../../../../../web/src/adminPortal/components/RolesList.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\n\nimport { ROLE_ID_STYTCH_MEMBER } from '../utils/roles';\nimport { useRoleSortFn } from '../utils/useRoleSortFn';\nimport { TagList } from './TagList';\n\ninterface RolesListProps {\n  roles:\n    | readonly {\n        role_id: string;\n      }[]\n    | readonly string[];\n  /**\n   * Specifies whether to omit `stytch_member` if there are other roles present\n   */\n  hideStytchMemberWithOtherRoles?: boolean;\n}\n\nexport const RolesList = ({ hideStytchMemberWithOtherRoles, roles }: RolesListProps) => {\n  const sortRows = useRoleSortFn();\n  const roleObjects = useMemo(\n    () => roles.map((role) => (typeof role === 'string' ? { role_id: role } : role)),\n    [roles],\n  );\n  const sortedRoles = useMemo(\n    () =>\n      sortRows(\n        // When specified, only show `stytch_member` if it is the only role\n        !hideStytchMemberWithOtherRoles || roleObjects.length === 1\n          ? roleObjects\n          : roleObjects.filter((role) => role.role_id !== ROLE_ID_STYTCH_MEMBER),\n      ).map((role) => role.displayName),\n    [hideStytchMemberWithOtherRoles, roleObjects, sortRows],\n  );\n\n  return <TagList tags={sortedRoles} />;\n};\n"],"names":["RolesList","hideStytchMemberWithOtherRoles","roles","sortRows","useRoleSortFn","roleObjects","useMemo","map","role","role_id","sortedRoles","length","filter","ROLE_ID_STYTCH_MEMBER","displayName","React","TagList","tags"],"mappings":";;;;;;MAkBaA,SAAAA,GAAY,CAAC,EAAEC,8BAA8B,EAAEC,KAAK,EAAkB,GAAA;AACjF,IAAA,MAAMC,QAAAA,GAAWC,aAAAA,EAAAA;IACjB,MAAMC,WAAAA,GAAcC,CAAAA,CAClB,IAAMJ,KAAAA,CAAMK,GAAG,CAAC,CAACC,IAAAA,GAAU,OAAOA,IAAAA,KAAS,QAAA,GAAW;gBAAEC,OAAAA,EAASD;AAAK,aAAA,GAAIA,IAAAA,CAAAA,EAC1E;AAACN,QAAAA;AAAM,KAAA,CAAA;AAET,IAAA,MAAMQ,WAAAA,GAAcJ,CAAAA,CAClB,IACEH,QAAAA;QAEE,CAACF,8BAAAA,IAAkCI,YAAYM,MAAM,KAAK,IACtDN,WAAAA,GACAA,WAAAA,CAAYO,MAAM,CAAC,CAACJ,OAASA,IAAAA,CAAKC,OAAO,KAAKI,qBAAAA,CAAAA,CAAAA,CAClDN,GAAG,CAAC,CAACC,IAAAA,GAASA,IAAAA,CAAKM,WAAW,CAAA,EAClC;AAACb,QAAAA,8BAAAA;AAAgCI,QAAAA,WAAAA;AAAaF,QAAAA;AAAS,KAAA,CAAA;AAGzD,IAAA,qBAAOY,EAAA,CAAA,aAAA,CAACC,OAAAA,EAAAA;QAAQC,IAAAA,EAAMP;;AACxB;;;;"}