{"version":3,"file":"useAriaIdentifiers.mjs","names":[],"sources":["../../../../src/a11y/hooks/useAriaIdentifiers.ts"],"sourcesContent":["import { useMemo } from 'react';\n\ntype AriaIdentifierDescriptor = 'description' | 'title';\n\nconst sanitizeAriaRootId = (rootId?: string) =>\n  rootId?.trim().replace(/[^A-Za-z0-9:_-]/g, '-') ?? '';\n\nconst buildAriaIdentifier = (\n  sanitizedRootId: string,\n  descriptor: AriaIdentifierDescriptor,\n) => (sanitizedRootId ? `${sanitizedRootId}-${descriptor}` : undefined);\n\n/**\n * Derives `titleId` and `descriptionId` (`<rootId>-title`, `<rootId>-description`) from a root ID.\n * The root ID is trimmed and characters outside `[A-Za-z0-9:_-]` become `-`; both IDs are\n * `undefined` when no root ID is left.\n */\nexport const useAriaIdentifiers = (rootId?: string) => {\n  const sanitizedRootId = sanitizeAriaRootId(rootId);\n\n  return useMemo(\n    () => ({\n      descriptionId: buildAriaIdentifier(sanitizedRootId, 'description'),\n      titleId: buildAriaIdentifier(sanitizedRootId, 'title'),\n    }),\n    [sanitizedRootId],\n  );\n};\n"],"mappings":";;AAIA,IAAM,sBAAsB,WAC1B,QAAQ,KAAK,CAAC,CAAC,QAAQ,oBAAoB,GAAG,KAAK;AAErD,IAAM,uBACJ,iBACA,eACI,kBAAkB,GAAG,gBAAgB,GAAG,eAAe,KAAA;;;;;;AAO7D,IAAa,sBAAsB,WAAoB;CACrD,MAAM,kBAAkB,mBAAmB,MAAM;CAEjD,OAAO,eACE;EACL,eAAe,oBAAoB,iBAAiB,aAAa;EACjE,SAAS,oBAAoB,iBAAiB,OAAO;CACvD,IACA,CAAC,eAAe,CAClB;AACF"}