export function camelToSnakeObjectDeep(obj) {
    if (obj === undefined || obj === null) {
        return obj;
    }
    // If it's not an object (primitive types), return as-is
    if (typeof obj !== "object") {
        return obj;
    }
    if (obj instanceof RegExp) {
        return obj;
    }
    // Handle arrays
    if (Array.isArray(obj)) {
        return obj.map(camelToSnakeObjectDeep);
    }
    // Handle objects
    return Object.fromEntries(Object.entries(obj).map(([key, value]) => [
        key
            .replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2") // Handle consecutive capitals: "FOOBar" -> "FOO_Bar"
            .replace(/([a-z])([A-Z])/g, "$1_$2") // Handle normal camelCase: "fooBar" -> "foo_Bar"
            .toLowerCase(),
        Array.isArray(value)
            ? value.map(camelToSnakeObjectDeep)
            : typeof value === "object" && value !== null
                ? camelToSnakeObjectDeep(value)
                : value,
    ]));
}
//# sourceMappingURL=camel-to-snake.js.map