// #region Imports
import { CssLength } from '@breadstone/mosaik-themes';
/**
 * Resolves a single gap axis value into a CSS length string.
 *
 * Delegates to `CssLength.toString` for number → px conversion
 * and validates that the value is non-negative.
 *
 * @param value - A `CssLength` value (number or CSS length string).
 * @returns A CSS length string (e.g. `'16px'`, `'1rem'`).
 *
 * @throws {Error} If the value is negative.
 *
 * @internal
 */
function resolveGapAxis(value) {
    if (value === 'auto') {
        throw new Error('Grid gap does not support "auto".');
    }
    const numericPart = CssLength.toNumber(value);
    if (numericPart < 0) {
        throw new Error(`Grid gap value must be non-negative. Received: ${typeof value === 'string' ? `"${value}"` : value}`);
    }
    return CssLength.toString(value);
}
/**
 * Parses a `GridLayoutGap` input into a resolved `IGridLayoutGap`
 * with both axes normalised to CSS length strings.
 *
 * @example
 * ```ts
 * parseGridLayoutGap(16);
 * // → { rows: '16px', columns: '16px' }
 *
 * parseGridLayoutGap('1rem');
 * // → { rows: '1rem', columns: '1rem' }
 *
 * parseGridLayoutGap({ rows: 8, columns: '1.5rem' });
 * // → { rows: '8px', columns: '1.5rem' }
 * ```
 *
 * @param value - The raw gap input.
 * @returns An object with resolved `rows` and `columns` CSS strings.
 *
 * @throws {Error} If any axis value is invalid or negative.
 *
 * @public
 */
export function parseGridLayoutGap(value) {
    if (typeof value === 'number' || typeof value === 'string') {
        const resolved = resolveGapAxis(value);
        return { rows: resolved, columns: resolved };
    }
    const rows = resolveGapAxis(value.rows ?? 0);
    const columns = resolveGapAxis(value.columns ?? 0);
    return { rows, columns };
}
//# sourceMappingURL=IGridLayoutGap.js.map