{"version":3,"file":"types.cjs","names":["RichTextNodeType"],"sources":["../../src/richtext/types.ts"],"sourcesContent":["import type {\n\tRTAnyNode,\n\tRTEmNode,\n\tRTEmbedNode,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTImageNode,\n\tRTLabelNode,\n\tRTLinkNode,\n\tRTListItemNode,\n\tRTListNode,\n\tRTOListItemNode,\n\tRTOListNode,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTSpanNode,\n\tRTStrongNode,\n\tRichTextNodeTypes,\n} from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\n// Serializers\n\n/**\n * Serializes a node from a rich text or title field with a function\n *\n * @typeParam ReturnType - Return type of the function serializer.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextFunctionSerializer<ReturnType> = (\n\ttype: RichTextNodeTypes,\n\tnode: RTAnyNode,\n\ttext: string | undefined,\n\tchildren: ReturnType[],\n\tkey: string,\n) => ReturnType | null | undefined\n\n/**\n * Map serializer's tag function serializer, can be helpful for typing those handlers\n *\n * @typeParam ReturnType - Return type of the tag serializer\n */\nexport type RichTextMapSerializerFunction<\n\tReturnType,\n\tNode extends RTAnyNode = RTAnyNode,\n\tTextType = string | undefined,\n> = (payload: {\n\ttype: Node[\"type\"]\n\tnode: Node\n\ttext: TextType\n\tchildren: ReturnType[]\n\tkey: string\n}) => ReturnType | null | undefined\n\n/**\n * Serializes a node from a rich text field with a map.\n *\n * @remarks\n *   This type of serializer needs to be processed through {@link wrapMapSerializer} before being\n *   used with {@link serialize}.\n * @typeParam ReturnType - Return type of the map serializer.\n * @see Learn how to work with rich text fields: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextMapSerializer<ReturnType> = {\n\theading1?: RichTextMapSerializerFunction<ReturnType, RTHeading1Node, undefined>\n\theading2?: RichTextMapSerializerFunction<ReturnType, RTHeading2Node, undefined>\n\theading3?: RichTextMapSerializerFunction<ReturnType, RTHeading3Node, undefined>\n\theading4?: RichTextMapSerializerFunction<ReturnType, RTHeading4Node, undefined>\n\theading5?: RichTextMapSerializerFunction<ReturnType, RTHeading5Node, undefined>\n\theading6?: RichTextMapSerializerFunction<ReturnType, RTHeading6Node, undefined>\n\tparagraph?: RichTextMapSerializerFunction<ReturnType, RTParagraphNode, undefined>\n\tpreformatted?: RichTextMapSerializerFunction<ReturnType, RTPreformattedNode, undefined>\n\tstrong?: RichTextMapSerializerFunction<ReturnType, RTStrongNode, string>\n\tem?: RichTextMapSerializerFunction<ReturnType, RTEmNode, string>\n\tlistItem?: RichTextMapSerializerFunction<ReturnType, RTListItemNode, undefined>\n\toListItem?: RichTextMapSerializerFunction<ReturnType, RTOListItemNode, undefined>\n\tlist?: RichTextMapSerializerFunction<ReturnType, RTListNode, undefined>\n\toList?: RichTextMapSerializerFunction<ReturnType, RTOListNode, undefined>\n\timage?: RichTextMapSerializerFunction<ReturnType, RTImageNode, undefined>\n\tembed?: RichTextMapSerializerFunction<ReturnType, RTEmbedNode, undefined>\n\thyperlink?: RichTextMapSerializerFunction<ReturnType, RTLinkNode, string>\n\tlabel?: RichTextMapSerializerFunction<ReturnType, RTLabelNode, string>\n\tspan?: RichTextMapSerializerFunction<ReturnType, RTSpanNode, string>\n}\n\n// Tree\nexport interface Tree {\n\tkey: string\n\tchildren: TreeNode[]\n}\n\nexport interface TreeNode {\n\tkey: string\n\ttype: RichTextNodeTypes\n\ttext?: string\n\tnode: RTAnyNode\n\tchildren: TreeNode[]\n}\n\n// Helpers\nexport const RichTextReversedNodeType = {\n\t[RichTextNodeType.listItem]: \"listItem\",\n\t[RichTextNodeType.oListItem]: \"oListItem\",\n\t[RichTextNodeType.list]: \"list\",\n\t[RichTextNodeType.oList]: \"oList\",\n} as const\n"],"mappings":";;AAwGA,MAAa,2BAA2B;EACtCA,iBAAAA,iBAAiB,WAAW;EAC5BA,iBAAAA,iBAAiB,YAAY;EAC7BA,iBAAAA,iBAAiB,OAAO;EACxBA,iBAAAA,iBAAiB,QAAQ;CAC1B"}