// Phase 96: json_loader next_non_ws loop (minimal)
// Purpose: Trim系の実ループを fixtures/smoke で押さえる。

static box Main {
    next_non_ws(s) {
        local i = 0
        local n = s.length()

        loop(i < n) {
            local ch = s.substring(i, i + 1)
            // Treat empty substring as whitespace for robustness
            if ch == "" || ch == " " || ch == "\n" || ch == "\r" || ch == "\t" {
                i = i + 1
            } else {
                break
            }
        }

        if i < n {
            return i
        }
        return -1
    }

    main() {
        // Input mirrors MiniJsonLoader.next_non_ws
        print(next_non_ws(" " + " " + "hi"))          // expect 2
        print(next_non_ws(" " + "\t"))                // expect -1
        print(next_non_ws("\n" + "\r" + "\t" + "X"))  // expect 3 (mixed newline/CR/tab)
        return "OK"
    }
}
