/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let react = require("react");
let lodash_isFunction_js = require("lodash/isFunction.js");
lodash_isFunction_js = require_runtime.__toESM(lodash_isFunction_js);

//#region src/utils/intersperse.ts
/**
* Given an array of items, place an item between each of the original values with either a constant
* value or the result of a function which knows the index it is being inserted before.
*
* @example
* const ANIMALS = ["Lions", "Tigers", "Bears"];
* const animalesInterspersedWithAmpersands = intersperse(ANIMALS, "&");
* // ["Lions", "&", "Tigers", "&", "Bears"]
* console.log(animalesInterspersedWithAmpersands.join(" ") + '. OH MY!');
*/
const intersperse = (list, inter) => {
	const interFn = (0, lodash_isFunction_js.default)(inter) ? inter : () => inter;
	return list.flatMap((item, i) => i !== 0 ? [interFn(i), item] : [item]);
};
/**
* Given ReactNode, if it is a list of children nodes, place a new React node between each of the
* original nodes with either a constant ReactElement or the result of a function which knows the
* index it is being inserted before.
*
* @example
* const SplitParagraphsWithHorizontalRule = ({ paragraphs }: { paragraphs: string[] }) => {
*   const paragraphNodes =  paragraphs.map((str) => <p>{str}</p>);
*
*   return (<div>
*     {intersperseReactChildren(paragraphNodes, <hr />)}
*   </div>);
* }
*/
const intersperseReactChildren = (children, inter) => {
	return intersperse(react.Children.toArray(children), (i) => {
		const node = (0, lodash_isFunction_js.default)(inter) ? inter(i) : inter;
		return (0, react.isValidElement)(node) ? (0, react.cloneElement)(node, {
			...node.props,
			key: node.key ?? `interspersed-${i}`
		}) : null;
	});
};

//#endregion
exports.intersperse = intersperse;
exports.intersperseReactChildren = intersperseReactChildren;