/** * Builds a stable, unique element id from slide index and a logical path. Used as fallback * when the slide or child object does not define an explicit `id`. The format is * `s{slideIndex}-{path0}-{path1}-...` (e.g. "s0-tag", "s1-features-2", "s2-elements-0-elements-1"). * * Prefer resolveId when you have slide data (it respects explicit ids and slide.ids). Use * elemId when constructing an id without the full slide (e.g. for initialElementState keys * when you know the path convention). * * @param slideIndex - Zero-based slide index. If undefined, 0 is used. * @param path - Rest args: property names and indices (e.g. 'tag'; 'features', 2; 'elements', 0, 'elements', 1). * @returns Id string. Safe for data-lumina-id, engine.element(id), and meta.initialElementState. * * @example * elemId(0, 'tag') // "s0-tag" * elemId(1, 'features', 2) // "s1-features-2" * elemId(2, 'elements', 0, 'elements', 1) // "s2-elements-0-elements-1" * * @see resolveId * @see getElementIds * @see DeckMeta.initialElementState */ export function elemId(slideIndex: number | undefined, ...path: (string | number)[]): string { const s = slideIndex ?? 0; if (path.length === 0) return `s${s}`; return `s${s}-${path.map(String).join('-')}`; }