{"version":3,"file":"resolve-sources.mjs","names":[],"sources":["../../../src/components/Mentions/resolve-sources.ts"],"sourcesContent":["import { Children, isValidElement } from 'react';\nimport { toMentionConfig } from './get-mentions';\nimport { Mention, MentionProps } from './Mention';\nimport { makeTriggerRegex } from './utils/make-trigger-regex';\nimport type { MentionConfig } from './utils/types';\n\nexport interface ResolvedMentionSource {\n  sourceIndex: number;\n  props: MentionProps;\n  config: MentionConfig;\n  regex: RegExp;\n}\n\nexport function resolveSources(children: React.ReactNode): ResolvedMentionSource[] {\n  const sources: ResolvedMentionSource[] = [];\n\n  Children.forEach(children, (child) => {\n    if (!isValidElement(child) || child.type !== Mention) {\n      return;\n    }\n\n    const props = child.props as MentionProps;\n\n    sources.push({\n      sourceIndex: sources.length,\n      props,\n      config: toMentionConfig(props),\n      regex: makeTriggerRegex(props.trigger ?? '@', { allowSpaceInQuery: props.allowSpaceInQuery }),\n    });\n  });\n\n  return sources;\n}\n"],"mappings":";;;;;;AAaA,SAAgB,eAAe,UAAoD;CACjF,MAAM,UAAmC,CAAC;CAE1C,SAAS,QAAQ,WAAW,UAAU;EACpC,IAAI,CAAC,eAAe,KAAK,KAAK,MAAM,SAAS,SAC3C;EAGF,MAAM,QAAQ,MAAM;EAEpB,QAAQ,KAAK;GACX,aAAa,QAAQ;GACrB;GACA,QAAQ,gBAAgB,KAAK;GAC7B,OAAO,iBAAiB,MAAM,WAAW,KAAK,EAAE,mBAAmB,MAAM,kBAAkB,CAAC;EAC9F,CAAC;CACH,CAAC;CAED,OAAO;AACT"}