import { FC, HTMLAttributes, JSX, Key, ReactNode, createElement } from "react";

//#region src/components/MarkDownRender/processor.d.ts

/**
 * Analogous to `node.type`. Please note that the values here may change at any time,
 * so do not hard code against the value directly.
 */
declare const RuleType: {
  readonly blockQuote: "0";
  readonly breakLine: "1";
  readonly breakThematic: "2";
  readonly codeBlock: "3";
  readonly codeFenced: "4";
  readonly codeInline: "5";
  readonly footnote: "6";
  readonly footnoteReference: "7";
  readonly gfmTask: "8";
  readonly heading: "9";
  readonly headingSetext: "10";
  /** only available if not `disableHTMLParsing` */
  readonly htmlBlock: "11";
  readonly htmlComment: "12";
  /** only available if not `disableHTMLParsing` */
  readonly htmlSelfClosing: "13";
  /** Custom components like <Tabs>, <TabItem> */
  readonly customComponent: "34";
  readonly image: "14";
  readonly link: "15";
  /** emits a `link` 'node', does not render directly */
  readonly linkAngleBraceStyleDetector: "16";
  /** emits a `link` 'node', does not render directly */
  readonly linkBareUrlDetector: "17";
  /** emits a `link` 'node', does not render directly */
  readonly newlineCoalescer: "19";
  readonly orderedList: "20";
  readonly paragraph: "21";
  readonly ref: "22";
  readonly refImage: "23";
  readonly refLink: "24";
  readonly table: "25";
  readonly tableSeparator: "26";
  readonly text: "27";
  readonly textBolded: "28";
  readonly textEmphasized: "29";
  readonly textEscaped: "30";
  readonly textMarked: "31";
  readonly textStrikethroughed: "32";
  readonly unorderedList: "33";
};
type RuleType = (typeof RuleType)[keyof typeof RuleType];
declare const slugify: (str: string) => string;
declare const sanitizer: (input: string) => string | null;
declare const compiler: (markdown?: string, options?: MarkdownProcessorOptions) => JSX.Element;
/**
 * A simple HOC for easy React use. Feed the markdown content as a direct child
 * and the rest is taken care of automatically.
 */
declare const MarkdownProcessor: FC<Omit<HTMLAttributes<Element>, 'children'> & {
  children: string;
  options?: MarkdownProcessorOptions;
}>;
/**
 * RequireAtLeastOne<{ ... }> <- only requires at least one key
 */
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
type CreateElement = typeof createElement;
type HTMLTags = keyof JSX.IntrinsicElements;
type State = {
  /** true if the current content is inside anchor link grammar */
  inAnchor?: boolean;
  /** true if parsing in an HTML context */
  inHTML?: boolean;
  /** true if parsing in an inline context (subset of rules around formatting and links) */
  inline?: boolean;
  /** true if in a table */
  inTable?: boolean;
  /** use this for the `key` prop */
  key?: Key;
  /** true if in a list */
  list?: boolean;
  /** used for lookbacks */
  prevCapture?: string;
  /** true if parsing in inline context w/o links */
  simple?: boolean;
};
type BlockQuoteNode = {
  alert?: string;
  children: ParserResult[];
  type: typeof RuleType.blockQuote;
};
type BreakLineNode = {
  type: typeof RuleType.breakLine;
};
type BreakThematicNode = {
  type: typeof RuleType.breakThematic;
};
type CodeBlockNode = {
  type: typeof RuleType.codeBlock;
  attrs?: JSX.IntrinsicAttributes;
  lang?: string;
  text: string;
};
type CodeFencedNode = {
  type: typeof RuleType.codeFenced;
};
type CodeInlineNode = {
  type: typeof RuleType.codeInline;
  text: string;
};
type FootnoteNode = {
  type: typeof RuleType.footnote;
};
type FootnoteReferenceNode = {
  type: typeof RuleType.footnoteReference;
  target: string;
  text: string;
};
type GFMTaskNode = {
  type: typeof RuleType.gfmTask;
  completed: boolean;
};
type HeadingNode = {
  type: typeof RuleType.heading;
  children: ParserResult[];
  id: string;
  level: 1 | 2 | 3 | 4 | 5 | 6;
};
type HeadingSetextNode = {
  type: typeof RuleType.headingSetext;
};
type HTMLCommentNode = {
  type: typeof RuleType.htmlComment;
};
type ImageNode = {
  type: typeof RuleType.image;
  alt?: string;
  target: string;
  title?: string;
};
type LinkNode = {
  type: typeof RuleType.link;
  children: ParserResult[];
  target: string;
  title?: string;
};
type LinkAngleBraceNode = {
  type: typeof RuleType.linkAngleBraceStyleDetector;
};
type LinkBareURLNode = {
  type: typeof RuleType.linkBareUrlDetector;
};
type LinkMailtoNode = {
  type: typeof RuleType.linkAngleBraceStyleDetector;
};
type OrderedListNode = {
  type: typeof RuleType.orderedList;
  items: ParserResult[][];
  ordered: true;
  start?: number;
};
type UnorderedListNode = {
  type: typeof RuleType.unorderedList;
  items: ParserResult[][];
  ordered: false;
};
type NewlineNode = {
  type: typeof RuleType.newlineCoalescer;
};
type ParagraphNode = {
  type: typeof RuleType.paragraph;
  children: ParserResult[];
};
type ReferenceNode = {
  type: typeof RuleType.ref;
};
type ReferenceImageNode = {
  type: typeof RuleType.refImage;
  alt?: string;
  ref: string;
};
type ReferenceLinkNode = {
  type: typeof RuleType.refLink;
  children: ParserResult[];
  fallbackChildren: string;
  ref: string;
};
type TableNode = {
  type: typeof RuleType.table;
  /**
   * alignment for each table column
   */
  align: ('left' | 'right' | 'center')[];
  cells: ParserResult[][][];
  header: ParserResult[][];
};
type TableSeparatorNode = {
  type: typeof RuleType.tableSeparator;
};
type TextNode = {
  type: typeof RuleType.text;
  text: string;
};
type BoldTextNode = {
  type: typeof RuleType.textBolded;
  children: ParserResult[];
};
type ItalicTextNode = {
  type: typeof RuleType.textEmphasized;
  children: ParserResult[];
};
type EscapedTextNode = {
  type: typeof RuleType.textEscaped;
};
type MarkedTextNode = {
  type: typeof RuleType.textMarked;
  children: ParserResult[];
};
type StrikethroughTextNode = {
  type: typeof RuleType.textStrikethroughed;
  children: ParserResult[];
};
type HTMLNode = {
  type: typeof RuleType.htmlBlock;
  attrs: JSX.IntrinsicAttributes | null;
  children?: ReturnType<NestedParser> | undefined;
  noInnerParse: boolean;
  tag: HTMLTags;
  text?: string | undefined;
};
type HTMLSelfClosingNode = {
  type: typeof RuleType.htmlSelfClosing;
  attrs: JSX.IntrinsicAttributes | null;
  tag: string;
};
type CustomComponentNode = {
  type: typeof RuleType.customComponent;
  attrs: JSX.IntrinsicAttributes | null;
  children?: ReturnType<NestedParser> | undefined;
  noInnerParse: boolean;
  tag: string;
  text?: string | undefined;
};
type ParserResult = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeFencedNode | CodeInlineNode | CustomComponentNode | FootnoteNode | FootnoteReferenceNode | GFMTaskNode | HeadingNode | HeadingSetextNode | HTMLCommentNode | ImageNode | LinkNode | LinkAngleBraceNode | LinkBareURLNode | LinkMailtoNode | OrderedListNode | UnorderedListNode | NewlineNode | ParagraphNode | ReferenceNode | ReferenceImageNode | ReferenceLinkNode | TableNode | TableSeparatorNode | TextNode | BoldTextNode | ItalicTextNode | EscapedTextNode | MarkedTextNode | StrikethroughTextNode | HTMLNode | HTMLSelfClosingNode;
type NestedParser = (input: string, state: State) => ParserResult[];
type RuleOutput = (ast: ParserResult | ParserResult[], state: State) => ReactNode;
type Override = RequireAtLeastOne<{
  component: any;
  props: Record<string, any>;
}> | any;
type Overrides = { [tag in HTMLTags]?: Override } & {
  [customComponent: string]: Override;
};
type MarkdownProcessorOptions = Partial<{
  /**
   * Ultimate control over the output of all rendered JSX.
   */
  createElement: (tag: Parameters<CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
  /**
   * The library automatically generates an anchor tag for bare URLs included in the markdown
   * document, but this behavior can be disabled if desired.
   */
  disableAutoLink: boolean;
  /**
   * Disable the compiler's best-effort transcription of provided raw HTML
   * into JSX-equivalent. This is the functionality that prevents the need to
   * use `dangerouslySetInnerHTML` in
   */
  disableParsingRawHTML: boolean;
  /**
   * Forces the compiler to have space between hash sign and the header text which
   * is explicitly stated in the most of the markdown specs.
   * https://github.github.com/gfm/#atx-heading
   * `The opening sequence of # characters must be followed by a space or by the end of line.`
   */
  enforceAtxHeadings: boolean;
  /**
   * Forces the compiler to always output content with a block-level wrapper
   * (`<p>` or any block-level syntax your markdown already contains.)
   */
  forceBlock: boolean;
  /**
   * Forces the compiler to always output content with an inline wrapper (`<span>`)
   */
  forceInline: boolean;
  /**
   * Forces the compiler to wrap results, even if there is only a single
   * child or no children.
   */
  forceWrapper: boolean;
  /**
   * Supply additional HTML entity: unicode replacement mappings.
   *
   * Pass only the inner part of the entity as the key,
   * e.g. `&le;` -> `{ "le": "\u2264" }`
   *
   * By default
   * the following entities are replaced with their unicode equivalents:
   *
   * ```
   * &amp;
   * &apos;
   * &gt;
   * &lt;
   * &nbsp;
   * &quot;
   * ```
   */
  namedCodesToUnicode: {
    [key: string]: string;
  };
  /**
   * Selectively control the output of particular HTML tags as they would be
   * emitted by the compiler.
   */
  overrides: Overrides;
  /**
   * Allows for full control over rendering of particular rules.
   * For example, to implement a LaTeX renderer such as `react-katex`:
   *
   * ```
   * renderRule(next, node, renderChildren, state) {
   *   if (node.type === RuleType.codeBlock && node.lang === 'latex') {
   *     return (
   *       <TeX as="div" key={state.key}>
   *         {String.raw`${node.text}`}
   *       </TeX>
   *     )
   *   }
   *
   *   return next();
   * }
   * ```
   *
   * Thar be dragons obviously, but you can do a lot with this
   * (have fun!) To see how things work internally, check the `render`
   * method in source for a particular rule.
   */
  renderRule: (/** Resume normal processing, call this function as a fallback if you are not returning custom JSX. */
  next: () => ReactNode, /** the current AST node, use `RuleType` against `node.type` for identification */
  node: ParserResult, /** use as `renderChildren(node.children)` for block nodes */
  renderChildren: RuleOutput, /** contains `key` which should be supplied to the topmost JSX element */
  state: State) => ReactNode;
  /**
   * Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library export called `sanitizer`.
   */
  sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
  /**
   * Override normalization of non-URI-safe characters for use in generating
   * HTML IDs for anchor linking purposes.
   */
  slugify: (input: string, defaultFn: (input: string) => string) => string;
  /**
   * Declare the type of the wrapper to be used when there are multiple
   * children to render. Set to `null` to get an array of children back
   * without any wrapper, or use `Fragment` to get a React element
   * that won't show up in the DOM.
   */
  wrapper: any | null;
}>;
//#endregion
export { MarkdownProcessor, MarkdownProcessorOptions, RuleType, compiler, sanitizer, slugify };
//# sourceMappingURL=processor.d.ts.map