{"version":3,"file":"MentionsOptions.cjs","names":["Combobox"],"sources":["../../../src/components/Mentions/MentionsOptions.tsx"],"sourcesContent":["import type { GetStylesApi } from '../../core';\nimport { Combobox } from '../Combobox';\nimport type { MentionsFactory } from './Mentions';\nimport type { ResolvedMentionSource } from './resolve-sources';\nimport type { MentionsQueryState } from './use-mentions-query';\n\nexport interface MentionsOptionsProps {\n  query: string;\n  queryState: MentionsQueryState;\n  source: ResolvedMentionSource | null;\n  optionIdPrefix: string;\n  selectedOptionId: string | null;\n  nothingFoundMessage: React.ReactNode;\n  loadingMessage: React.ReactNode;\n  errorMessage: React.ReactNode;\n  getStyles: GetStylesApi<MentionsFactory>;\n}\n\nexport function MentionsOptions({\n  query,\n  queryState,\n  source,\n  optionIdPrefix,\n  selectedOptionId,\n  nothingFoundMessage,\n  loadingMessage,\n  errorMessage,\n  getStyles,\n}: MentionsOptionsProps) {\n  if (queryState.error) {\n    return (\n      <Combobox.Empty {...getStyles('nothingFound')}>\n        {source?.props.renderError?.(query, queryState.error) ?? errorMessage}\n      </Combobox.Empty>\n    );\n  }\n\n  if (queryState.loading) {\n    return <Combobox.Empty {...getStyles('nothingFound')}>{loadingMessage}</Combobox.Empty>;\n  }\n\n  if (queryState.items.length === 0) {\n    const empty = source?.props.renderEmpty?.(query) ?? nothingFoundMessage;\n    return empty ? <Combobox.Empty {...getStyles('nothingFound')}>{empty}</Combobox.Empty> : null;\n  }\n\n  return queryState.items.map((item, index) => {\n    const optionId = `${optionIdPrefix}-${index}`;\n    return (\n      <Combobox.Option value={item.id} key={item.id} id={optionId}>\n        {source?.props.renderSuggestion?.({\n          item,\n          query,\n          highlighted: optionId === selectedOptionId,\n          index,\n        }) ??\n          item.display ??\n          item.id}\n      </Combobox.Option>\n    );\n  });\n}\n\nMentionsOptions.displayName = '@mantine/core/MentionsOptions';\n"],"mappings":";;;;AAkBA,SAAgB,gBAAgB,EAC9B,OACA,YACA,QACA,gBACA,kBACA,qBACA,gBACA,cACA,aACuB;CACvB,IAAI,WAAW,OACb,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,iBAAAA,SAAS,OAAV;EAAgB,GAAI,UAAU,cAAc;EACzC,UAAA,QAAQ,MAAM,cAAc,OAAO,WAAW,KAAK,KAAK;CAC3C,CAAA;CAIpB,IAAI,WAAW,SACb,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,iBAAAA,SAAS,OAAV;EAAgB,GAAI,UAAU,cAAc;EAAI,UAAA;CAA+B,CAAA;CAGxF,IAAI,WAAW,MAAM,WAAW,GAAG;EACjC,MAAM,QAAQ,QAAQ,MAAM,cAAc,KAAK,KAAK;EACpD,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAACA,iBAAAA,SAAS,OAAV;GAAgB,GAAI,UAAU,cAAc;GAAI,UAAA;EAAsB,CAAA,IAAI;CAC3F;CAEA,OAAO,WAAW,MAAM,KAAK,MAAM,UAAU;EAC3C,MAAM,WAAW,GAAG,eAAe,GAAG;EACtC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,iBAAAA,SAAS,QAAV;GAAiB,OAAO,KAAK;GAAkB,IAAI;GAChD,UAAA,QAAQ,MAAM,mBAAmB;IAChC;IACA;IACA,aAAa,aAAa;IAC1B;GACF,CAAC,KACC,KAAK,WACL,KAAK;EACQ,GATqB,KAAK,EAS1B;CAErB,CAAC;AACH;AAEA,gBAAgB,cAAc"}