// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
package dev.kreuzberg;

import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.jspecify.annotations.Nullable;

/**
 * Comprehensive Djot document structure with semantic preservation.
 *
 * This type captures the full richness of Djot markup, including:
 * - Block-level structures (headings, lists, blockquotes, code blocks, etc.)
 * - Inline formatting (emphasis, strong, highlight, subscript, superscript, etc.)
 * - Attributes (classes, IDs, key-value pairs)
 * - Links, images, footnotes
 * - Math expressions (inline and display)
 * - Tables with full structure
 *
 * Available when the {@code djot} feature is enabled.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = DjotContent.Builder.class)
public record DjotContent(
    /**
     * Plain text representation for backwards compatibility
     */
    @JsonProperty("plain_text") String plainText,
    /**
     * Structured block-level content
     */
    @JsonProperty("blocks") List<FormattedBlock> blocks,
    /**
     * Metadata from YAML frontmatter
     */
    @JsonProperty("metadata") Metadata metadata,
    /**
     * Extracted tables as structured data
     */
    @JsonProperty("tables") List<Table> tables,
    /**
     * Extracted images with metadata
     */
    @JsonProperty("images") List<DjotImage> images,
    /**
     * Extracted links with URLs
     */
    @JsonProperty("links") List<DjotLink> links,
    /**
     * Footnote definitions
     */
    @JsonProperty("footnotes") List<Footnote> footnotes,
    /**
     * Attributes mapped by element identifier (if present)
     */
    @Nullable @JsonProperty("attributes") List<String> attributes
) {
    public static Builder builder() {
        return new Builder();
    }

    // CPD-OFF
    @JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
    public static final class Builder {

        @JsonProperty("plain_text")
private String plainText = "";
private List<FormattedBlock> blocks = List.of();
private Metadata metadata = null;
private List<Table> tables = List.of();
private List<DjotImage> images = List.of();
private List<DjotLink> links = List.of();
private List<Footnote> footnotes = List.of();
private List<String> attributes = null;

        /** Sets the plainText field. */
        @JsonProperty("plain_text")
        public Builder withPlainText(final String value) {
            this.plainText = value;
            return this;
        }

        /** Sets the blocks field. */
        @JsonProperty("blocks")
        public Builder withBlocks(final List<FormattedBlock> value) {
            this.blocks = value;
            return this;
        }

        /** Sets the metadata field. */
        @JsonProperty("metadata")
        public Builder withMetadata(final Metadata value) {
            this.metadata = value;
            return this;
        }

        /** Sets the tables field. */
        @JsonProperty("tables")
        public Builder withTables(final List<Table> value) {
            this.tables = value;
            return this;
        }

        /** Sets the images field. */
        @JsonProperty("images")
        public Builder withImages(final List<DjotImage> value) {
            this.images = value;
            return this;
        }

        /** Sets the links field. */
        @JsonProperty("links")
        public Builder withLinks(final List<DjotLink> value) {
            this.links = value;
            return this;
        }

        /** Sets the footnotes field. */
        @JsonProperty("footnotes")
        public Builder withFootnotes(final List<Footnote> value) {
            this.footnotes = value;
            return this;
        }

        /** Sets the attributes field. */
        @JsonProperty("attributes")
        public Builder withAttributes(final @Nullable List<String> value) {
            this.attributes = value;
            return this;
        }

        /** Builds the DjotContent instance. */
        public DjotContent build() {
            return new DjotContent(
                plainText,
                blocks,
                metadata,
                tables,
                images,
                links,
                footnotes,
                attributes
            );
        }
    }
    // CPD-ON
}
