//#region src/types.d.ts
type NodeType = 'document' | 'page' | 'section' | 'row' | 'column' | 'heading' | 'text' | 'link' | 'image' | 'table' | 'list' | 'list-item' | 'page-break' | 'code' | 'divider' | 'spacer' | 'button' | 'quote';
/** A format-agnostic document node. */
interface DocNode {
  type: NodeType;
  props: Record<string, unknown>;
  children: DocChild[];
  /** Resolved styles from ui-system connector (optional). */
  styles?: ResolvedStyles;
}
type DocChild = DocNode | string;
interface ResolvedStyles {
  fontSize?: number;
  fontFamily?: string;
  fontWeight?: 'normal' | 'bold' | number;
  fontStyle?: 'normal' | 'italic';
  textDecoration?: 'none' | 'underline' | 'line-through';
  color?: string;
  backgroundColor?: string;
  textAlign?: 'left' | 'center' | 'right' | 'justify';
  lineHeight?: number;
  letterSpacing?: number;
  padding?: number | [number, number] | [number, number, number, number];
  margin?: number | [number, number] | [number, number, number, number];
  borderRadius?: number;
  borderWidth?: number;
  borderColor?: string;
  borderStyle?: 'solid' | 'dashed' | 'dotted';
  width?: number | string;
  height?: number | string;
  maxWidth?: number | string;
  opacity?: number;
}
interface DocumentProps {
  title?: string;
  author?: string;
  subject?: string;
  keywords?: string[];
  language?: string;
  children?: unknown;
}
type PageSize = 'A4' | 'A3' | 'A5' | 'letter' | 'legal' | 'tabloid';
type PageOrientation = 'portrait' | 'landscape';
interface PageProps {
  size?: PageSize;
  orientation?: PageOrientation;
  margin?: number | [number, number] | [number, number, number, number];
  children?: unknown;
  /** Header content for this page (PDF/DOCX). */
  header?: DocNode;
  /** Footer content for this page (PDF/DOCX). */
  footer?: DocNode;
}
interface SectionProps {
  direction?: 'column' | 'row';
  gap?: number;
  padding?: number | [number, number] | [number, number, number, number];
  background?: string;
  borderRadius?: number;
  border?: string;
  children?: unknown;
}
interface RowProps {
  gap?: number;
  align?: 'start' | 'center' | 'end' | 'stretch';
  children?: unknown;
}
interface ColumnProps {
  width?: number | string;
  align?: 'start' | 'center' | 'end';
  children?: unknown;
}
interface HeadingProps {
  level?: 1 | 2 | 3 | 4 | 5 | 6;
  color?: string;
  align?: 'left' | 'center' | 'right';
  children?: unknown;
}
interface TextProps {
  size?: number;
  color?: string;
  bold?: boolean;
  italic?: boolean;
  underline?: boolean;
  strikethrough?: boolean;
  align?: 'left' | 'center' | 'right' | 'justify';
  lineHeight?: number;
  children?: unknown;
}
interface LinkProps {
  href: string;
  color?: string;
  children?: unknown;
}
interface ImageProps {
  src: string;
  width?: number;
  height?: number;
  alt?: string;
  align?: 'left' | 'center' | 'right';
  caption?: string;
}
interface TableColumn {
  header: string;
  width?: number | string;
  align?: 'left' | 'center' | 'right';
}
interface TableProps {
  columns: (string | TableColumn)[];
  rows: (string | number)[][];
  headerStyle?: {
    background?: string;
    color?: string;
    bold?: boolean;
  };
  striped?: boolean;
  bordered?: boolean;
  caption?: string;
  /** Keep table together on one page — avoid page breaks within table (PDF/DOCX). */
  keepTogether?: boolean;
}
interface ListProps {
  ordered?: boolean;
  children?: unknown;
}
interface ListItemProps {
  children?: unknown;
}
interface CodeProps {
  language?: string;
  children?: unknown;
}
interface DividerProps {
  color?: string;
  thickness?: number;
}
interface SpacerProps {
  height: number;
}
interface ButtonProps {
  href: string;
  background?: string;
  color?: string;
  borderRadius?: number;
  padding?: number | [number, number];
  align?: 'left' | 'center' | 'right';
  children?: unknown;
}
interface QuoteProps {
  borderColor?: string;
  children?: unknown;
}
type OutputFormat = 'html' | 'pdf' | 'docx' | 'pptx' | 'email' | 'xlsx' | 'md' | 'text' | 'csv' | 'svg' | 'slack' | 'teams' | 'discord' | 'telegram' | 'notion' | 'confluence' | 'whatsapp' | 'google-chat' | 'json' | 'jsonl';
interface RenderOptions {
  /** Custom styles to apply (overrides component styles). */
  styles?: Record<string, ResolvedStyles>;
  /** Base URL for relative image sources. */
  baseUrl?: string;
  /** Text direction — 'ltr' (default) or 'rtl'. */
  direction?: 'ltr' | 'rtl';
  /** Custom font configuration for PDF. */
  fonts?: Record<string, {
    normal?: string;
    bold?: string;
    italics?: string;
    bolditalics?: string;
  }>;
}
type RenderResult = string | Uint8Array;
/** A document renderer that converts a node tree to a specific format. */
interface DocumentRenderer {
  render(node: DocNode, options?: RenderOptions): Promise<RenderResult>;
}
interface DocumentBuilder {
  heading(text: string, props?: Omit<HeadingProps, 'children'>): DocumentBuilder;
  text(text: string, props?: Omit<TextProps, 'children'>): DocumentBuilder;
  paragraph(text: string, props?: Omit<TextProps, 'children'>): DocumentBuilder;
  image(src: string, props?: Omit<ImageProps, 'src'>): DocumentBuilder;
  table(props: TableProps): DocumentBuilder;
  list(items: string[], props?: Omit<ListProps, 'children'>): DocumentBuilder;
  code(text: string, props?: Omit<CodeProps, 'children'>): DocumentBuilder;
  divider(props?: DividerProps): DocumentBuilder;
  spacer(height: number): DocumentBuilder;
  quote(text: string, props?: Omit<QuoteProps, 'children'>): DocumentBuilder;
  button(text: string, props: Omit<ButtonProps, 'children'>): DocumentBuilder;
  link(text: string, props: Omit<LinkProps, 'children'>): DocumentBuilder;
  pageBreak(): DocumentBuilder;
  /** Add an arbitrary DocNode (or fragment returned by a helper function). */
  add(node: DocNode | DocNode[]): DocumentBuilder;
  /** Add a group of nodes as a logical section. */
  section(children: DocNode[]): DocumentBuilder;
  /** Add a chart snapshot from a @pyreon/charts instance. */
  chart(instance: unknown, props?: {
    width?: number;
    height?: number;
    caption?: string;
  }): DocumentBuilder;
  /** Add a flow diagram snapshot from a @pyreon/flow instance. */
  flow(instance: unknown, props?: {
    width?: number;
    height?: number;
    caption?: string;
  }): DocumentBuilder;
  /** Build the document node tree. */
  build(): DocNode;
  /** Render to a specific format. */
  toHtml(options?: RenderOptions): Promise<string>;
  toPdf(options?: RenderOptions): Promise<Uint8Array>;
  toDocx(options?: RenderOptions): Promise<Uint8Array>;
  toPptx(options?: RenderOptions): Promise<Uint8Array>;
  toEmail(options?: RenderOptions): Promise<string>;
  toXlsx(options?: RenderOptions): Promise<Uint8Array>;
  toMarkdown(options?: RenderOptions): Promise<string>;
  toText(options?: RenderOptions): Promise<string>;
  toCsv(options?: RenderOptions): Promise<string>;
  toSlack(options?: RenderOptions): Promise<string>;
  toSvg(options?: RenderOptions): Promise<string>;
  toTeams(options?: RenderOptions): Promise<string>;
  toDiscord(options?: RenderOptions): Promise<string>;
  toTelegram(options?: RenderOptions): Promise<string>;
  toNotion(options?: RenderOptions): Promise<string>;
  toConfluence(options?: RenderOptions): Promise<string>;
  toWhatsApp(options?: RenderOptions): Promise<string>;
  toGoogleChat(options?: RenderOptions): Promise<string>;
  /** Download the document (browser only). */
  download(filename: string, options?: RenderOptions): Promise<void>;
}
//#endregion
//#region src/builder.d.ts
/**
 * Create a document using the builder pattern — no JSX needed.
 *
 * @example
 * ```ts
 * const doc = createDocument({ title: 'Report' })
 *   .heading('Sales Report')
 *   .text('Q4 performance summary.')
 *   .table({ columns: ['Region', 'Revenue'], rows: [['US', '$1M']] })
 *
 * await doc.toPdf()
 * await doc.download('report.pdf')
 * ```
 */
declare function createDocument(props?: DocumentProps): DocumentBuilder;
//#endregion
//#region src/download.d.ts
/**
 * Download a document in the browser.
 *
 * @example
 * ```tsx
 * await download(doc, 'report.pdf')
 * await download(doc, 'report.docx')
 * ```
 */
declare function download(node: DocNode, filename: string, options?: RenderOptions): Promise<void>;
//#endregion
//#region src/nodes.d.ts
/** Type guard — checks if a value is a DocNode. */
declare function isDocNode(value: unknown): value is DocNode;
/**
 * Root document container. Holds metadata and pages.
 *
 * @example
 * ```tsx
 * <Document title="Invoice #1234" author="Acme Corp">
 *   <Page>...</Page>
 * </Document>
 * ```
 */
declare function Document(props: DocumentProps): DocNode;
declare namespace Document {
  var _documentType: "document";
}
/**
 * Page container. Maps to a PDF page, DOCX section, or email block.
 *
 * @example
 * ```tsx
 * <Page size="A4" margin={40}>
 *   <Heading>Title</Heading>
 * </Page>
 * ```
 */
declare function Page(props: PageProps): DocNode;
declare namespace Page {
  var _documentType: "page";
}
/**
 * Layout section — groups content with optional direction, padding, background.
 *
 * @example
 * ```tsx
 * <Section background="#f5f5f5" padding={20} direction="row" gap={12}>
 *   <Text>Left</Text>
 *   <Text>Right</Text>
 * </Section>
 * ```
 */
declare function Section(props: SectionProps): DocNode;
declare namespace Section {
  var _documentType: "section";
}
/**
 * Horizontal layout container.
 *
 * @example
 * ```tsx
 * <Row gap={20}>
 *   <Column width="60%"><Text>Main</Text></Column>
 *   <Column width="40%"><Text>Side</Text></Column>
 * </Row>
 * ```
 */
declare function Row(props: RowProps): DocNode;
declare namespace Row {
  var _documentType: "row";
}
/**
 * Column within a Row.
 */
declare function Column(props: ColumnProps): DocNode;
declare namespace Column {
  var _documentType: "column";
}
/**
 * Heading text (h1–h6).
 *
 * @example
 * ```tsx
 * <Heading level={1}>Invoice #1234</Heading>
 * <Heading level={2} color="#666">Details</Heading>
 * ```
 */
declare function Heading(props: HeadingProps): DocNode;
declare namespace Heading {
  var _documentType: "heading";
}
/**
 * Text paragraph with optional formatting.
 *
 * @example
 * ```tsx
 * <Text bold size={14} color="#333">Hello World</Text>
 * <Text italic align="right">Subtotal: $100</Text>
 * ```
 */
declare function Text(props: TextProps): DocNode;
declare namespace Text {
  var _documentType: "text";
}
/**
 * Hyperlink.
 *
 * @example
 * ```tsx
 * <Link href="https://example.com">Visit site</Link>
 * ```
 */
declare function Link(props: LinkProps): DocNode;
declare namespace Link {
  var _documentType: "link";
}
/**
 * Image with optional sizing and caption.
 *
 * @example
 * ```tsx
 * <Image src="/logo.png" width={120} alt="Company Logo" />
 * <Image src={chartDataUrl} width={500} caption="Revenue Chart" />
 * ```
 */
declare function Image(props: ImageProps): DocNode;
declare namespace Image {
  var _documentType: "image";
}
/**
 * Data table with columns and rows.
 *
 * @example
 * ```tsx
 * <Table
 *   columns={['Name', 'Price', 'Qty']}
 *   rows={[['Widget', '$10', '5'], ['Gadget', '$20', '3']]}
 *   striped
 *   headerStyle={{ background: '#1a1a2e', color: '#fff' }}
 * />
 * ```
 */
declare function Table(props: TableProps): DocNode;
declare namespace Table {
  var _documentType: "table";
}
/**
 * Ordered or unordered list.
 *
 * @example
 * ```tsx
 * <List ordered>
 *   <ListItem>First item</ListItem>
 *   <ListItem>Second item</ListItem>
 * </List>
 * ```
 */
declare function List(props: ListProps): DocNode;
declare namespace List {
  var _documentType: "list";
}
/**
 * Single list item within a List.
 */
declare function ListItem(props: ListItemProps): DocNode;
declare namespace ListItem {
  var _documentType: "list-item";
}
/**
 * Code block with optional language hint.
 *
 * @example
 * ```tsx
 * <Code language="typescript">const x = 42</Code>
 * ```
 */
declare function Code(props: CodeProps): DocNode;
declare namespace Code {
  var _documentType: "code";
}
/**
 * Horizontal divider line.
 *
 * @example
 * ```tsx
 * <Divider color="#ddd" thickness={2} />
 * ```
 */
declare function Divider(props?: DividerProps): DocNode;
declare namespace Divider {
  var _documentType: "divider";
}
/**
 * Page break — forces content after this point to the next page (PDF/DOCX)
 * or inserts a visual separator (HTML/email).
 *
 * @example
 * ```tsx
 * <PageBreak />
 * ```
 */
declare function PageBreak(): DocNode;
declare namespace PageBreak {
  var _documentType: "page-break";
}
/**
 * Vertical spacer.
 *
 * @example
 * ```tsx
 * <Spacer height={20} />
 * ```
 */
declare function Spacer(props: SpacerProps): DocNode;
declare namespace Spacer {
  var _documentType: "spacer";
}
/**
 * CTA button — renders as a bulletproof button in email, styled link in PDF/DOCX.
 *
 * @example
 * ```tsx
 * <Button href="https://acme.com/pay" background="#4f46e5" color="#fff">
 *   Pay Now
 * </Button>
 * ```
 */
declare function Button(props: ButtonProps): DocNode;
declare namespace Button {
  var _documentType: "button";
}
/**
 * Block quote.
 *
 * @example
 * ```tsx
 * <Quote borderColor="#4f46e5">This is a quote.</Quote>
 * ```
 */
declare function Quote(props: QuoteProps): DocNode;
declare namespace Quote {
  var _documentType: "quote";
}
//#endregion
//#region src/render.d.ts
/**
 * Register a custom renderer for a format.
 *
 * @example
 * ```ts
 * registerRenderer('thermal', {
 *   render(node, options) {
 *     // Walk nodes → ESC/POS commands
 *     return escPosBuffer
 *   },
 * })
 *
 * await render(receipt, 'thermal')
 * ```
 */
declare function registerRenderer(format: string, renderer: DocumentRenderer | (() => Promise<DocumentRenderer>)): void;
/**
 * Remove a registered renderer.
 */
declare function unregisterRenderer(format: string): void;
/**
 * Render a document node tree to the specified format.
 *
 * @example
 * ```tsx
 * const doc = <Document title="Report"><Page>...</Page></Document>
 *
 * const html = await render(doc, 'html')    // → HTML string
 * const pdf = await render(doc, 'pdf')      // → PDF Uint8Array
 * const docx = await render(doc, 'docx')    // → DOCX Uint8Array
 * const email = await render(doc, 'email')  // → email-safe HTML string
 * const md = await render(doc, 'md')        // → Markdown string
 * ```
 */
declare function render(node: DocNode, format: OutputFormat | string, options?: RenderOptions): Promise<RenderResult>;
/** @internal For testing — reset renderer registry to defaults. */
declare function _resetRenderers(): void;
//#endregion
export { Button, type ButtonProps, Code, type CodeProps, Column, type ColumnProps, Divider, type DividerProps, type DocChild, type DocNode, Document, type DocumentBuilder, type DocumentProps, type DocumentRenderer, Heading, type HeadingProps, Image, type ImageProps, Link, type LinkProps, List, ListItem, type ListItemProps, type ListProps, type NodeType, type OutputFormat, Page, PageBreak, type PageOrientation, type PageProps, type PageSize, Quote, type QuoteProps, type RenderOptions, type RenderResult, type ResolvedStyles, Row, type RowProps, Section, type SectionProps, Spacer, type SpacerProps, Table, type TableColumn, type TableProps, Text, type TextProps, _resetRenderers, createDocument, download, isDocNode, registerRenderer, render, unregisterRenderer };
//# sourceMappingURL=index2.d.ts.map