/* auto-generated by NAPI-RS */
/* eslint-disable */
/**
 * Same as `apply_commands_and_render_handle` but for the MDX → JS path.
 * Fuses apply + simplify + compile + drop.
 */
export declare function applyCommandsAndCompileHandle(handle: HastHandle, commandBuf: Uint8Array, options?: JsMdxOptions | undefined | null): CompileJsOneShot

/**
 * Apply MDAST commands and convert to HAST handle in one step.
 * The MDAST handle is consumed (emptied).
 */
export declare function applyCommandsAndConvertToHastHandle(handle: MdastHandle, commandBuf: Uint8Array, convertOptions?: JsConvertOptions | undefined | null): HastHandle

/**
 * Fused tail step for `markdownToHtml` with a HAST plugin: apply the plugin's
 * command buffer, render the resulting HAST to HTML, and leave the handle
 * drained, all in one NAPI roundtrip. Saves the `apply` + `render` + `drop`
 * crossings the old path made separately.
 *
 * The handle keeps existing (callers can still `dropHandle` it on the JS
 * side if they want explicit cleanup), but the arena inside is left empty so
 * the next access sees no state and the underlying allocations are freed.
 */
export declare function applyCommandsAndRenderHandle(handle: HastHandle, commandBuf: Uint8Array): RenderHtmlOneShot

/**
 * Apply a command buffer to a HAST handle's arena in-place. Returns how many
 * patches were dropped because their target lived inside a subtree this pass
 * removed or replaced (see the lenient note below); the JS pipeline warns when
 * non-zero. Mirrors `apply_commands_to_mdast_handle`.
 */
export declare function applyCommandsToHandle(handle: HastHandle, commandBuf: Uint8Array): number

/**
 * Apply a command buffer to an MDAST handle in-place. Returns how many patches
 * were dropped because their target lived inside a subtree this pass removed or
 * replaced (see the lenient note below); the JS pipeline warns when non-zero.
 */
export declare function applyCommandsToMdastHandle(handle: MdastHandle, commandBuf: Uint8Array): number

/**
 * Fused tail for `mdxToJs` when there's an MDAST plugin but no HAST plugin.
 * Apply → extract frontmatter → convert → simplify → compile, all in one
 * NAPI roundtrip.
 */
export declare function applyMdastCommandsAndConvertAndCompile(handle: MdastHandle, commandBuf: Uint8Array, options?: JsMdxOptions | undefined | null, convertOptions?: JsConvertOptions | undefined | null): MdxJsOneShot

/**
 * Fused tail for `markdownToHtml` when there's an MDAST plugin but no HAST
 * plugin: apply the MDAST commands, extract frontmatter from the (now
 * possibly-mutated) MDAST, convert MDAST → HAST, render to HTML. All in one
 * NAPI roundtrip. Saves the convert + render + drop + frontmatter crossings
 * the old path made separately, and reads frontmatter *after* mutations so a
 * plugin that rewrites yaml/toml is observed correctly.
 */
export declare function applyMdastCommandsAndConvertAndRender(handle: MdastHandle, commandBuf: Uint8Array, convertOptions?: JsConvertOptions | undefined | null): MarkdownHtmlOneShot

/** Compile a HAST handle's arena to MDX JavaScript. Does not consume the handle. */
export declare function compileHandle(handle: HastHandle, options?: JsMdxOptions | undefined | null): string

/** Result of the fused apply + compile tail; see [`RenderHtmlOneShot`]. */
export interface CompileJsOneShot {
  code: string
  droppedTransforms: number
}

/** Compile MDX source directly to JavaScript. */
export declare function compileMdx(source: string, options: JsMdxOptions | undefined | null, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null): string

/** Convert an MDAST handle to a HAST handle. The MDAST handle is consumed (emptied). */
export declare function convertMdastToHastHandle(handle: MdastHandle, convertOptions?: JsConvertOptions | undefined | null): HastHandle

/**
 * Parse markdown source and convert to HAST. Returns an opaque handle.
 * The arena stays in Rust memory, no buffer is copied to JS.
 */
export declare function createHastHandle(source: string, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null, trackPositions?: boolean | undefined | null): HastHandle

/**
 * Parse an HTML string into structured HAST (elements, text, comments).
 * Parses as a fragment when `fragment` is set, keeping the top-level nodes as
 * they are instead of implying `<html>`/`<head>`/`<body>`. `space` picks the
 * namespace a fragment's own top-level content parses in: "html" or "svg".
 * Returns an opaque handle; the arena stays in Rust memory.
 */
export declare function createHastHandleFromHtml(html: string, fragment?: boolean | undefined | null, space?: string | undefined | null): HastHandle

/**
 * Parse + frontmatter + HAST conversion in one crossing (HAST-plugin path
 * head). Returns a `[handle, frontmatter]` pair.
 */
export declare function createHastHandleWithFrontmatter(source: string, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null, trackPositions?: boolean | undefined | null): [HastHandle, JsFrontmatter | undefined | null]

/**
 * Parse markdown source into an MDAST arena handle.
 *
 * `track_positions` (default `true`) controls whether `position` is recorded
 * on nodes. The plugin pipeline passes `false` when no plugin reads positions,
 * skipping the `LineIndex` build + per-node line/column lookups (~15% of parse).
 */
export declare function createMdastHandle(source: string, parseOptions: number, trackPositions?: boolean | undefined | null): MdastHandle

/** Parse MDX source and convert to HAST. Returns an opaque handle. */
export declare function createMdxHastHandle(source: string, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null, trackPositions?: boolean | undefined | null): HastHandle

/** MDX variant of [`create_hast_handle_with_frontmatter`]. */
export declare function createMdxHastHandleWithFrontmatter(source: string, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null, trackPositions?: boolean | undefined | null): [HastHandle, JsFrontmatter | undefined | null]

/** Parse MDX source into an MDAST arena handle. */
export declare function createMdxMdastHandle(source: string, parseOptions: number, trackPositions?: boolean | undefined | null): MdastHandle

/**
 * Empty a handle's arena into the thread-local pool; the handle stays valid
 * (subsequent calls are no-ops or return empty results).
 */
export declare function dropHandle(handle: AnyHandle): void

/**
 * Get the source string from a handle. Kind-agnostic: source is the
 * original markdown/MDX input and is identical across MDAST and HAST.
 */
export declare function getHandleSource(handle: AnyHandle): string

/**
 * Return the first YAML or TOML frontmatter block in the MDAST arena, if any.
 * Walks the root node's direct children and returns the first yaml/toml literal.
 */
export declare function getMdastFrontmatter(handle: MdastHandle): JsFrontmatter | null

/**
 * Read the node_data JSON blob for a node. Returns null if none is set.
 * Works for both MDAST and HAST handles.
 */
export declare function getNodeData(handle: AnyHandle, nodeId: number): string | null

/**
 * MDAST→HAST conversion options passed from JavaScript.
 *
 * Input-only: `object_to_js = false` because `FunctionRef` only crosses
 * JS → Rust. A `JsConvertOptions` never gets serialized back to JS.
 */
export interface JsConvertOptions {
  /** `<h2>` label opening the footnotes section. Default: `"Footnotes"`. */
  footnoteLabel?: string
  /** Backref `<a>` content. Default: `"\u{21a9}"` (↩). */
  footnoteBackContent?: string | ((arg0: number, arg1: number) => string)
  /**
   * Backref `aria-label`. The token `{reference}` is replaced with the
   * footnote number (`1`) or `number-K` (`1-2`) for repeated references.
   * Default: `"Back to reference {reference}"`.
   */
  footnoteBackLabel?: string | ((arg0: number, arg1: number) => string)
  /**
   * Prefix applied to footnote IDs to prevent DOM clobbering.
   * Default: `"user-content-"`.
   */
  clobberPrefix?: string
  /**
   * Reparse raw HTML embedded in markdown into real HAST nodes. Default:
   * false. Only effective in builds with the `from-html` feature.
   */
  rawHtml?: boolean
}

/** Frontmatter extracted from an MDAST arena. */
export interface JsFrontmatter {
  /** Either `"yaml"` or `"toml"`. */
  kind: string
  /** Raw frontmatter content between the delimiters (no `---`/`+++` lines). */
  value: string
}

/** MDX compile options passed from JavaScript. */
export interface JsMdxOptions {
  /**
   * Static subtree optimization. If provided, static subtrees are collapsed
   * into raw HTML strings using the specified component and prop.
   */
  optimizeStatic?: JsOptimizeStaticConfig
  /**
   * Place to import automatic JSX runtimes from (e.g. "react", "preact").
   * Default: "react".
   */
  jsxImportSource?: string
  /** Whether to keep JSX instead of compiling it away. Default: false. */
  jsx?: boolean
  /** JSX runtime: "automatic" (default) or "classic". */
  jsxRuntime?: string
  /**
   * Whether to add extra info to error messages and use the development
   * JSX runtime. Default: false.
   */
  development?: boolean
  /** Place to import a provider from (e.g. "@mdx-js/react"). */
  providerImportSource?: string
  /** Pragma for JSX in classic runtime (default: "React.createElement"). */
  pragma?: string
  /** Pragma for JSX fragments in classic runtime (default: "React.Fragment"). */
  pragmaFrag?: string
  /** Where to import the pragma from in classic runtime (default: "react"). */
  pragmaImportSource?: string
  /** Output format: "program" (default) or "function-body". */
  outputFormat?: string
  /**
   * Casing for HTML/SVG attribute names on plain (rehype-produced)
   * elements. "react" (default) emits `className`, `htmlFor`, etc.;
   * "html" emits `class`, `for`, `stroke-linecap`, etc.
   */
  elementAttributeNameCase?: string
  /**
   * Casing for keys in `style` objects parsed from `style="…"` strings.
   * "dom" (default) emits `{backgroundColor: …}`; "css" emits
   * `{"background-color": …}`.
   */
  stylePropertyNameCase?: string
}

/** Static optimization config passed from JavaScript. */
export interface JsOptimizeStaticConfig {
  /** Component/element name to wrap collapsed HTML in (e.g. "Fragment", "div"). */
  component: string
  /** Prop name for the HTML string (e.g. "set:html", "dangerouslySetInnerHTML"). */
  prop: string
  /** If true, prop value is wrapped as `{ __html: "..." }` (React-style). */
  wrapPropValue?: boolean
  /** Element tag names to exclude from collapsing. */
  ignoreElements?: Array<string>
}

/** A subscription passed from JS. */
export interface JsSubscription {
  nodeType: number
  tagFilter: Array<string>
}

/** Options for `mdast_text_content_handle`, matching `mdast-util-to-string`. */
export interface JsTextContentOptions {
  /** Include `alt` text from image nodes. Default: true. */
  includeImageAlt?: boolean
  /** Include `value` from HTML nodes. Default: true. */
  includeHtml?: boolean
}

/**
 * One-shot result returned by the no-plugin fast path and the MDAST-plugin
 * fused tail. `dropped_transforms` is only ever non-zero on the fused-tail
 * path (the fast path applies no commands).
 */
export interface MarkdownHtmlOneShot {
  html: string
  frontmatter?: JsFrontmatter
  droppedTransforms: number
}

/**
 * Fast path: parse markdown → MDAST → HAST → HTML, plus extract frontmatter,
 * in a single NAPI roundtrip. Used by `markdownToHtml` when the caller didn't
 * configure any plugins. Skips 5 of the 6 NAPI crossings the handle-based
 * path makes (createMdast, getFrontmatter, convertToHast, dropMdast, render,
 * dropHast → just one call).
 */
export declare function markdownToHtmlFast(source: string, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null): MarkdownHtmlOneShot

/**
 * Plain-Markdown variant of [`mdx_to_js_fast`]: MDX syntax stays literal text.
 * Used by `markdownToJs` when the caller didn't configure any plugins.
 */
export declare function markdownToJsFast(source: string, parseOptions: number, options?: JsMdxOptions | undefined | null, convertOptions?: JsConvertOptions | undefined | null): MdxJsOneShot

/**
 * Collect the concatenated text content of an MDAST node and all its descendants.
 * Mirrors `mdast-util-to-string`: collects value from text nodes, alt from images.
 */
export declare function mdastTextContentHandle(handle: MdastHandle, nodeId: number, options?: JsTextContentOptions | undefined | null): string

/**
 * One-shot result returned by the no-plugin `mdxToJs` fast path and the
 * MDAST-plugin fused tail; see [`MarkdownHtmlOneShot`].
 */
export interface MdxJsOneShot {
  code: string
  frontmatter?: JsFrontmatter
  droppedTransforms: number
}

/**
 * Fast path: parse MDX → MDAST → HAST → JS, plus extract frontmatter, in a
 * single NAPI roundtrip. Used by `mdxToJs` when the caller didn't configure
 * any plugins. Skips 5 of the 6 NAPI crossings the handle-based path makes.
 */
export declare function mdxToJsFast(source: string, parseOptions: number, options?: JsMdxOptions | undefined | null, convertOptions?: JsConvertOptions | undefined | null): MdxJsOneShot

/** Parse ESM (import/export statements) and return ESTree-compatible AST as JSON. */
export declare function parseEsm(source: string): string | null

/**
 * Parse a JavaScript expression and return its ESTree-compatible AST as a JSON string.
 * Returns null if parsing fails. The JS layer calls JSON.parse (faster than serde_json → NAPI).
 */
export declare function parseExpression(source: string): string | null

/** Parse Markdown source and return HTML string directly. */
export declare function parseToHtml(source: string, parseOptions: number, convertOptions?: JsConvertOptions | undefined | null): string

/** Render a HAST handle's arena to HTML. Does not consume the handle. */
export declare function renderHandle(handle: HastHandle): string

/**
 * Result of the fused apply + render tail. `dropped_transforms` mirrors the
 * count `apply_commands_to_handle` returns: patches dropped because their
 * target lived inside a removed/replaced subtree; the JS pipeline warns when
 * non-zero.
 */
export interface RenderHtmlOneShot {
  html: string
  droppedTransforms: number
}

/**
 * Serialize a handle's arena to the wire-format buffer JS instantiates a
 * reader from. The kind tag in the header tells the JS side whether to
 * pick `MdastReader` or `HastReader`.
 */
export declare function serializeHandle(handle: AnyHandle): Uint8Array

/**
 * Set the `data` blob (JSON bytes) for a node. Works for both MDAST and
 * HAST handles — `node_data` is a per-node JSON blob with no kind-specific
 * shape on the Rust side.
 */
export declare function setNodeData(handle: AnyHandle, nodeId: number, json: Uint8Array): void

/**
 * Collect the concatenated text content of a HAST node and all its descendants.
 * Walks entirely in Rust, no per-child NAPI round-trips.
 */
export declare function textContentHandle(handle: HastHandle, nodeId: number): string

/** Walk a HAST handle's arena and return matched nodes as a flat binary buffer. */
export declare function walkHandle(handle: HastHandle, subscriptions: Array<JsSubscription>): Uint8Array

/** Walk an MDAST handle's arena and return matched nodes as a flat binary buffer. */
export declare function walkMdastHandle(handle: MdastHandle, subscriptions: Array<JsSubscription>): Uint8Array
