```typescript
/**
 * Flattens nested arrays up to depth levels.
 *
 * @param items The input array, containing strings and/or nested arrays.
 * @param depth The maximum recursion level. Defaults to Infinity (unlimited).
 */
export function flatten(items: readonly unknown[], depth?: number): unknown[] {
    if (typeof depth !== 'number' || isNaN(depth) || depth < 0) {
        throw new Error('Depth must be a non-negative integer or Infinity.');
    }

    const result = [];

    for (const item of items) {
        if (typeof item === 'string') {
            // If the item is already a string, simply add it to the result.
            result.push(item);
        } else if (Array.isArray(item)) {
            // If the item is an array, recursively flatten its elements with reduced depth.
            const flatened = flatten(item, Math.min(depth - 1, Infinity));
            result.push(...flatened);
        }
    }

    return result;
}
```