// Generated by alef. Do not edit by hand.
@file:Suppress(
    "ktlint:standard:max-line-length",
    "ktlint:standard:trailing-comma-on-declaration-site",
    "ktlint:standard:trailing-comma-on-call-site",
    "ktlint:standard:annotation",
    "MaxLineLength",
    "TooManyFunctions",
    "LongParameterList",
    "LongMethod",
)

package dev.kreuzberg

import com.fasterxml.jackson.core.type.TypeReference

@Suppress("TooManyFunctions")
class Document internal constructor(internal val handle: Long) : AutoCloseable {
    companion object {
        private val MAPPER = com.fasterxml.jackson.databind.ObjectMapper()
            .registerModule(com.fasterxml.jackson.datatype.jdk8.Jdk8Module())
            .findAndRegisterModules()
            .setPropertyNamingStrategy(com.fasterxml.jackson.databind.PropertyNamingStrategies.SNAKE_CASE)
    }

    // Return the 1-based page number for each top-level table in the document.
    fun tablePageNumbers(): List<Long> {
        val responseJson = KreuzbergBridge.nativeDocumentTablePageNumbers(handle)
        return MAPPER.readValue(responseJson, object : TypeReference<List<Long>>() {})
    }

    override fun close() { KreuzbergBridge.nativeFreeDocument(handle) }
}
