{"version":3,"file":"renderSlotContent.cjs","names":[],"sources":["../../../src/Slots/utils/renderSlotContent.ts"],"sourcesContent":["import { cloneElement, createElement, isValidElement, type ReactNode } from 'react';\nimport type { SlotFunction, SlotProps } from '../types';\n\n/**\n * Renders one collected slot item.\n *\n * Function slots become React elements, element slots receive injected props,\n * and custom `map` callbacks can override rendering entirely.\n *\n * @param child - Collected slot content.\n * @param index - Child index inside the slot.\n * @param slotProps - Props to inject into element/function slot content.\n * @param map - Optional mapper from `SlotProps`.\n * @returns Renderable React content.\n */\nexport function renderSlotContent(\n  child: ReactNode | SlotFunction,\n  index: number,\n  slotProps?: Record<string, any>,\n  map?: SlotProps['map'],\n): ReactNode | ReactNode[] {\n  if (map) return map(child, index);\n  if (typeof child === 'function') return createElement(child, slotProps);\n  if (isValidElement(child) && slotProps && Object.keys(slotProps).length) {\n    return cloneElement(child, slotProps);\n  }\n\n  return child;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,kBACd,OACA,OACA,WACA,KACyB;CACzB,IAAI,KAAK,OAAO,IAAI,OAAO,KAAK;CAChC,IAAI,OAAO,UAAU,YAAY,QAAA,GAAA,MAAA,cAAA,CAAqB,OAAO,SAAS;CACtE,KAAA,GAAA,MAAA,eAAA,CAAmB,KAAK,KAAK,aAAa,OAAO,KAAK,SAAS,CAAC,CAAC,QAC/D,QAAA,GAAA,MAAA,aAAA,CAAoB,OAAO,SAAS;CAGtC,OAAO;AACT"}