/**
 * DOM utility functions — safe element access, type-checked selectors.
 */

/**
 * Get an element by ID with a meaningful error if not found.
 * Use this instead of `document.getElementById('x')!` to get
 * a clear error message pointing to the missing element.
 */
export function getEl(id: string): HTMLElement {
    const el = document.getElementById(id);
    if (!el) throw new Error(`Element #${id} not found in DOM`);
    return el;
}

/**
 * Get an element by ID, returning null if not found.
 * Typed alternative to `document.getElementById` that avoids
 * the `HTMLElement | null` ambiguity in non-null assertion contexts.
 */
export function queryEl(id: string): HTMLElement | null {
    return document.getElementById(id);
}
