{"version":3,"file":"templateOnly.cjs","names":["isTemplate"],"sources":["../../../src/Slots/utils/templateOnly.ts"],"sourcesContent":["import { cloneElement, Children } from 'react';\nimport { isTemplate } from './isTemplate';\n\n/**\n * Returns only `Template` elements from a child collection.\n *\n * Used by `Template.only` to keep the public helper that extracts template\n * markers while ignoring ordinary children.\n *\n * @param children - Child or children to filter.\n * @returns Template children with stable keys when an array is supplied.\n */\nexport function templateOnly<T, C>(children: C | readonly C[]): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>> {\n  if (!Array.isArray(children)) {\n    return !isTemplate(children) ? null as any : children as any;\n  }\n\n  const result: Array<Exclude<T, boolean | null | undefined>> = [];\n\n  Children.forEach(children, (child: C, index: number) => {\n    if (isTemplate(child)) {\n      result.push(cloneElement(child as any, { key: index }) as any);\n    }\n  });\n\n  return result as any;\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,aAAmB,UAA4G;CAC7I,IAAI,CAAC,MAAM,QAAQ,QAAQ,GACzB,OAAO,CAACA,+BAAAA,WAAW,QAAQ,IAAI,OAAc;CAG/C,MAAM,SAAwD,CAAC;CAE/D,MAAA,SAAS,QAAQ,WAAW,OAAU,UAAkB;EACtD,IAAIA,+BAAAA,WAAW,KAAK,GAClB,OAAO,MAAA,GAAA,MAAA,aAAA,CAAkB,OAAc,EAAE,KAAK,MAAM,CAAC,CAAQ;CAEjE,CAAC;CAED,OAAO;AACT"}