{"version":3,"file":"reduceWithOut.cjs","names":["isSlot","isTemplate"],"sources":["../../../src/Slots/utils/reduceWithOut.ts"],"sourcesContent":["import { Children } from 'react';\nimport { isSlot } from './isSlot';\nimport { isTemplate } from './isTemplate';\n\n/**\n * Maps children while excluding `Slot` and `Template` marker elements.\n *\n * Used by `Template.reduce` to preserve the public helper that filters slot\n * markers out of mixed children collections.\n *\n * @param children - Child or children to reduce.\n * @param fn - Mapper called for every non-slot child.\n * @returns The mapped children.\n */\nexport function reduceWithOut<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>> {\n  if (!Array.isArray(children)) {\n    return !isSlot(children) && !isTemplate(children) ? fn(children as C, 0) as any : null as any;\n  }\n\n  const result: Array<Exclude<T, boolean | null | undefined>> = [];\n\n  Children.forEach(children, (child: C, index: number) => {\n\n    switch (child) {\n      case null:\n      case undefined:\n        return;\n      default:\n        if (isSlot(child) || isTemplate(child)) return;\n        break;\n    }\n\n    const value = fn(child, index);\n    result.push(value as Exclude<T, boolean | null | undefined>);\n  });\n\n  return result as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,cAAoB,UAA4B,IAAoH;CAClL,IAAI,CAAC,MAAM,QAAQ,QAAQ,GACzB,OAAO,CAACA,2BAAAA,OAAO,QAAQ,KAAK,CAACC,+BAAAA,WAAW,QAAQ,IAAI,GAAG,UAAe,CAAC,IAAW;CAGpF,MAAM,SAAwD,CAAC;CAE/D,MAAA,SAAS,QAAQ,WAAW,OAAU,UAAkB;EAEtD,QAAQ,OAAR;GACE,KAAK;GACL,KAAK,KAAA,GACH;GACF;IACE,IAAID,2BAAAA,OAAO,KAAK,KAAKC,+BAAAA,WAAW,KAAK,GAAG;IACxC;EACJ;EAEA,MAAM,QAAQ,GAAG,OAAO,KAAK;EAC7B,OAAO,KAAK,KAA+C;CAC7D,CAAC;CAED,OAAO;AACT"}