/* ExportMermaid.c generated by valac 0.56.19, the Vala compiler
 * generated from ExportMermaid.vala, do not modify */

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <libxml/tree.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <cairo-gobject.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_EXPORT (export_get_type ())
#define EXPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORT, Export))
#define EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORT, ExportClass))
#define IS_EXPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORT))
#define IS_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORT))
#define EXPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORT, ExportClass))

typedef struct _Export Export;
typedef struct _ExportClass ExportClass;
typedef struct _ExportPrivate ExportPrivate;

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;

#define TYPE_EXPORT_MERMAID (export_mermaid_get_type ())
#define EXPORT_MERMAID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORT_MERMAID, ExportMermaid))
#define EXPORT_MERMAID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORT_MERMAID, ExportMermaidClass))
#define IS_EXPORT_MERMAID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORT_MERMAID))
#define IS_EXPORT_MERMAID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORT_MERMAID))
#define EXPORT_MERMAID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORT_MERMAID, ExportMermaidClass))

typedef struct _ExportMermaid ExportMermaid;
typedef struct _ExportMermaidClass ExportMermaidClass;
typedef struct _ExportMermaidPrivate ExportMermaidPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_NODE (node_get_type ())
#define NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE, Node))
#define NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE, NodeClass))
#define IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE))
#define IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE))
#define NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE, NodeClass))

typedef struct _Node Node;
typedef struct _NodeClass NodeClass;

#define TYPE_LAYOUT (layout_get_type ())
#define LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LAYOUT, Layout))
#define LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LAYOUT, LayoutClass))
#define IS_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LAYOUT))
#define IS_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LAYOUT))
#define LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LAYOUT, LayoutClass))

typedef struct _Layout Layout;
typedef struct _LayoutClass LayoutClass;
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

#define TYPE_CANVAS_TEXT (canvas_text_get_type ())
#define CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CANVAS_TEXT, CanvasText))
#define CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CANVAS_TEXT, CanvasTextClass))
#define IS_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CANVAS_TEXT))
#define IS_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CANVAS_TEXT))
#define CANVAS_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CANVAS_TEXT, CanvasTextClass))

typedef struct _CanvasText CanvasText;
typedef struct _CanvasTextClass CanvasTextClass;

#define TYPE_FORMATTED_TEXT (formatted_text_get_type ())
#define FORMATTED_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FORMATTED_TEXT, FormattedText))
#define FORMATTED_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FORMATTED_TEXT, FormattedTextClass))
#define IS_FORMATTED_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FORMATTED_TEXT))
#define IS_FORMATTED_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FORMATTED_TEXT))
#define FORMATTED_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FORMATTED_TEXT, FormattedTextClass))

typedef struct _FormattedText FormattedText;
typedef struct _FormattedTextClass FormattedTextClass;

#define TYPE_NODE_IMAGE (node_image_get_type ())
#define NODE_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_IMAGE, NodeImage))
#define NODE_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE_IMAGE, NodeImageClass))
#define IS_NODE_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_IMAGE))
#define IS_NODE_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE_IMAGE))
#define NODE_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE_IMAGE, NodeImageClass))

typedef struct _NodeImage NodeImage;
typedef struct _NodeImageClass NodeImageClass;

#define TYPE_STYLE (style_get_type ())
#define STYLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STYLE, Style))
#define STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STYLE, StyleClass))
#define IS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STYLE))
#define IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STYLE))
#define STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STYLE, StyleClass))

typedef struct _Style Style;
typedef struct _StyleClass StyleClass;

#define TYPE_NODE_BORDER (node_border_get_type ())
#define NODE_BORDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_BORDER, NodeBorder))
#define IS_NODE_BORDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_BORDER))
#define NODE_BORDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_NODE_BORDER, NodeBorderIface))

typedef struct _NodeBorder NodeBorder;
typedef struct _NodeBorderIface NodeBorderIface;
typedef enum  {
	NODE_SIDE_LEFT = 1,
	NODE_SIDE_TOP = 2,
	NODE_SIDE_RIGHT = 4,
	NODE_SIDE_BOTTOM = 8
} NodeSide;

#define TYPE_NODE_SIDE (node_side_get_type ())

#define TYPE_LINK_DASH (link_dash_get_type ())
#define LINK_DASH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LINK_DASH, LinkDash))
#define LINK_DASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LINK_DASH, LinkDashClass))
#define IS_LINK_DASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LINK_DASH))
#define IS_LINK_DASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LINK_DASH))
#define LINK_DASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LINK_DASH, LinkDashClass))

typedef struct _LinkDash LinkDash;
typedef struct _LinkDashClass LinkDashClass;
typedef struct _LinkDashPrivate LinkDashPrivate;
#define __vala_GdkRGBA_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkRGBA_free (var), NULL)))

#define EXPORT_MERMAID_TYPE_NODE_HIER (export_mermaid_node_hier_get_type ())
#define EXPORT_MERMAID_NODE_HIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXPORT_MERMAID_TYPE_NODE_HIER, ExportMermaidNodeHier))
#define EXPORT_MERMAID_NODE_HIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EXPORT_MERMAID_TYPE_NODE_HIER, ExportMermaidNodeHierClass))
#define EXPORT_MERMAID_IS_NODE_HIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EXPORT_MERMAID_TYPE_NODE_HIER))
#define EXPORT_MERMAID_IS_NODE_HIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EXPORT_MERMAID_TYPE_NODE_HIER))
#define EXPORT_MERMAID_NODE_HIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EXPORT_MERMAID_TYPE_NODE_HIER, ExportMermaidNodeHierClass))

typedef struct _ExportMermaidNodeHier ExportMermaidNodeHier;
typedef struct _ExportMermaidNodeHierClass ExportMermaidNodeHierClass;
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

#define TYPE_MAP_MODEL (map_model_get_type ())
#define MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAP_MODEL, MapModel))
#define MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAP_MODEL, MapModelClass))
#define IS_MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAP_MODEL))
#define IS_MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAP_MODEL))
#define MAP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAP_MODEL, MapModelClass))

typedef struct _MapModel MapModel;
typedef struct _MapModelClass MapModelClass;

#define TYPE_STYLES (styles_get_type ())
#define STYLES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STYLES, Styles))
#define STYLES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STYLES, StylesClass))
#define IS_STYLES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STYLES))
#define IS_STYLES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STYLES))
#define STYLES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STYLES, StylesClass))

typedef struct _Styles Styles;
typedef struct _StylesClass StylesClass;
#define _export_mermaid_node_hier_unref0(var) ((var == NULL) ? NULL : (var = (export_mermaid_node_hier_unref (var), NULL)))
typedef struct _ExportMermaidNodeHierPrivate ExportMermaidNodeHierPrivate;
typedef struct _ExportMermaidParamSpecNodeHier ExportMermaidParamSpecNodeHier;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Export {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ExportPrivate * priv;
};

struct _ExportClass {
	GTypeClass parent_class;
	void (*finalize) (Export *self);
	gboolean (*export) (Export* self, const gchar* fname, MindMap* map);
	gboolean (*import) (Export* self, const gchar* fname, MindMap* map);
	void (*add_settings) (Export* self, GtkGrid* grid);
	void (*save_settings) (Export* self, xmlNode* node);
	void (*load_settings) (Export* self, xmlNode* node);
};

struct _ExportMermaid {
	Export parent_instance;
	ExportMermaidPrivate * priv;
};

struct _ExportMermaidClass {
	ExportClass parent_class;
};

struct _NodeBorderIface {
	GTypeInterface parent_iface;
	gchar* (*name) (NodeBorder* self);
	gchar* (*display_name) (NodeBorder* self);
	gchar* (*light_icon_name) (NodeBorder* self);
	gchar* (*dark_icon_name) (NodeBorder* self);
	gboolean (*is_fillable) (NodeBorder* self);
	void (*draw_border) (NodeBorder* self, cairo_t* ctx, gdouble x, gdouble y, gdouble w, gdouble h, NodeSide s, gint padding);
	void (*draw_fill) (NodeBorder* self, cairo_t* ctx, gdouble x, gdouble y, gdouble w, gdouble h, NodeSide s, gint padding);
};

struct _LinkDash {
	GObject parent_instance;
	LinkDashPrivate * priv;
	gchar* name;
	gchar* display_name;
	gdouble* pattern;
	gint pattern_length1;
};

struct _LinkDashClass {
	GObjectClass parent_class;
};

struct _ExportMermaidNodeHier {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ExportMermaidNodeHierPrivate * priv;
};

struct _ExportMermaidNodeHierClass {
	GTypeClass parent_class;
	void (*finalize) (ExportMermaidNodeHier *self);
};

struct _ExportMermaidNodeHierPrivate {
	Node* _node;
	gint _prefix;
};

struct _ExportMermaidParamSpecNodeHier {
	GParamSpec parent_instance;
};

static gpointer export_mermaid_parent_class = NULL;
VALA_EXTERN Styles* style_inspector_styles;
static gint ExportMermaidNodeHier_private_offset;
static gpointer export_mermaid_node_hier_parent_class = NULL;

VALA_EXTERN gpointer export_ref (gpointer instance);
VALA_EXTERN void export_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_export (const gchar* name,
                               const gchar* nick,
                               const gchar* blurb,
                               GType object_type,
                               GParamFlags flags);
VALA_EXTERN void value_set_export (GValue* value,
                       gpointer v_object);
VALA_EXTERN void value_take_export (GValue* value,
                        gpointer v_object);
VALA_EXTERN gpointer value_get_export (const GValue* value);
VALA_EXTERN GType export_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Export, export_unref)
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN GType export_mermaid_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ExportMermaid, export_unref)
VALA_EXTERN gboolean export_export (Export* self,
                        const gchar* fname,
                        MindMap* map);
VALA_EXTERN gboolean export_import (Export* self,
                        const gchar* fname,
                        MindMap* map);
VALA_EXTERN void export_add_settings (Export* self,
                          GtkGrid* grid);
VALA_EXTERN void export_save_settings (Export* self,
                           xmlNode* node);
VALA_EXTERN void export_load_settings (Export* self,
                           xmlNode* node);
VALA_EXTERN ExportMermaid* export_mermaid_new (void);
VALA_EXTERN ExportMermaid* export_mermaid_construct (GType object_type);
VALA_EXTERN Export* export_new (const gchar* name,
                    const gchar* label,
                    gchar** extensions,
                    gint extensions_length1,
                    gboolean exportable,
                    gboolean importable,
                    gboolean dir,
                    gboolean clippable);
VALA_EXTERN Export* export_construct (GType object_type,
                          const gchar* name,
                          const gchar* label,
                          gchar** extensions,
                          gint extensions_length1,
                          gboolean exportable,
                          gboolean importable,
                          gboolean dir,
                          gboolean clippable);
static gboolean export_mermaid_real_export (Export* base,
                                     const gchar* fname,
                                     MindMap* map);
VALA_EXTERN gboolean export_get_bool (Export* self,
                          const gchar* name);
static gchar* export_mermaid_export_top_nodes_mindmap (ExportMermaid* self,
                                                MindMap* map);
static gchar* export_mermaid_export_top_nodes_graph (ExportMermaid* self,
                                              MindMap* map);
VALA_EXTERN gboolean export_send_to_clipboard (Export* self);
VALA_EXTERN void minder_clipboard_copy_text (const gchar* txt);
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
static gchar* export_mermaid_map_layout_to_direction (ExportMermaid* self,
                                               Node* n);
VALA_EXTERN GType layout_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Layout, g_object_unref)
VALA_EXTERN Layout* node_get_layout (Node* self);
VALA_EXTERN const gchar* layout_get_name (Layout* self);
VALA_EXTERN GArray* mind_map_get_nodes (MindMap* self);
static gchar* export_mermaid_export_node_graph (ExportMermaid* self,
                                         Node* node,
                                         gint* link_id);
VALA_EXTERN GArray* node_children (Node* self);
static gchar* export_mermaid_make_title (ExportMermaid* self,
                                  Node* n,
                                  gboolean for_mindmap);
static gchar* export_mermaid_export_node_mindmap (ExportMermaid* self,
                                           Node* node,
                                           const gchar* prefix);
static gchar* export_mermaid_make_id (ExportMermaid* self,
                               Node* n);
VALA_EXTERN gboolean node_is_root (Node* self);
VALA_EXTERN gint node_id (Node* self);
VALA_EXTERN GType canvas_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CanvasText, g_object_unref)
VALA_EXTERN CanvasText* node_get_name (Node* self);
VALA_EXTERN gpointer formatted_text_ref (gpointer instance);
VALA_EXTERN void formatted_text_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_formatted_text (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_formatted_text (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_formatted_text (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_formatted_text (const GValue* value);
VALA_EXTERN GType formatted_text_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FormattedText, formatted_text_unref)
VALA_EXTERN FormattedText* canvas_text_get_text (CanvasText* self);
VALA_EXTERN const gchar* formatted_text_get_text (FormattedText* self);
VALA_EXTERN gpointer node_image_ref (gpointer instance);
VALA_EXTERN void node_image_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_node_image (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
VALA_EXTERN void value_set_node_image (GValue* value,
                           gpointer v_object);
VALA_EXTERN void value_take_node_image (GValue* value,
                            gpointer v_object);
VALA_EXTERN gpointer value_get_node_image (const GValue* value);
VALA_EXTERN GType node_image_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeImage, node_image_unref)
VALA_EXTERN NodeImage* node_get_image (Node* self);
VALA_EXTERN gpointer style_ref (gpointer instance);
VALA_EXTERN void style_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_style (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags);
VALA_EXTERN void value_set_style (GValue* value,
                      gpointer v_object);
VALA_EXTERN void value_take_style (GValue* value,
                       gpointer v_object);
VALA_EXTERN gpointer value_get_style (const GValue* value);
VALA_EXTERN GType style_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Style, style_unref)
VALA_EXTERN Style* node_get_style (Node* self);
VALA_EXTERN gboolean* style_get_node_markup (Style* self);
VALA_EXTERN GType node_side_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType node_border_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeBorder, g_object_unref)
VALA_EXTERN NodeBorder* style_get_node_border (Style* self);
VALA_EXTERN gchar* node_border_name (NodeBorder* self);
static gchar* export_mermaid_make_link (ExportMermaid* self,
                                 Node* n);
VALA_EXTERN gboolean* style_get_link_arrow (Style* self);
VALA_EXTERN GType link_dash_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (LinkDash, g_object_unref)
VALA_EXTERN LinkDash* style_get_link_dash (Style* self);
static gchar* export_mermaid_make_link_color (ExportMermaid* self,
                                       Node* n);
VALA_EXTERN GdkRGBA* node_get_link_color (Node* self);
static GdkRGBA* _vala_GdkRGBA_copy (GdkRGBA* self);
static void _vala_GdkRGBA_free (GdkRGBA* self);
static gchar* export_mermaid_make_node_style (ExportMermaid* self,
                                       Node* n);
VALA_EXTERN gboolean* style_get_node_fill (Style* self);
VALA_EXTERN gint* style_get_node_borderwidth (Style* self);
static gchar* export_mermaid_make_link_style (ExportMermaid* self,
                                       Node* n,
                                       gint* link_id);
VALA_EXTERN gint* style_get_link_width (Style* self);
static gdouble* _vala_array_dup5 (gdouble* self,
                           gssize length);
static gboolean export_mermaid_real_import (Export* base,
                                     const gchar* fname,
                                     MindMap* map);
static gboolean export_mermaid_import_text (ExportMermaid* self,
                                     const gchar* txt,
                                     MindMap* map);
VALA_EXTERN void mind_map_queue_draw (MindMap* self);
VALA_EXTERN void mind_map_auto_save (MindMap* self);
VALA_EXTERN gpointer export_mermaid_node_hier_ref (gpointer instance);
VALA_EXTERN void export_mermaid_node_hier_unref (gpointer instance);
VALA_EXTERN GParamSpec* export_mermaid_param_spec_node_hier (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void export_mermaid_value_set_node_hier (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void export_mermaid_value_take_node_hier (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer export_mermaid_value_get_node_hier (const GValue* value);
VALA_EXTERN GType export_mermaid_node_hier_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ExportMermaidNodeHier, export_mermaid_node_hier_unref)
static void _export_mermaid_node_hier_unref0_ (gpointer var);
static void _vala_ExportMermaidNodeHier_free_function_content_of (gpointer data);
static Node* export_mermaid_get_parent (ExportMermaid* self,
                                 GArray* stack,
                                 gint prefix);
VALA_EXTERN gpointer map_model_ref (gpointer instance);
VALA_EXTERN void map_model_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_map_model (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_map_model (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_map_model (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_map_model (const GValue* value);
VALA_EXTERN GType map_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapModel, map_model_unref)
VALA_EXTERN MapModel* mind_map_get_model (MindMap* self);
VALA_EXTERN Node* map_model_create_root_node (MapModel* self,
                                  const gchar* name);
VALA_EXTERN Node* node_get_parent (Node* self);
VALA_EXTERN Node* map_model_create_main_node (MapModel* self,
                                  Node* root,
                                  NodeSide side,
                                  const gchar* name);
VALA_EXTERN Node* map_model_create_child_node (MapModel* self,
                                   Node* parent,
                                   const gchar* name);
VALA_EXTERN gpointer styles_ref (gpointer instance);
VALA_EXTERN void styles_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_styles (const gchar* name,
                               const gchar* nick,
                               const gchar* blurb,
                               GType object_type,
                               GParamFlags flags);
VALA_EXTERN void value_set_styles (GValue* value,
                       gpointer v_object);
VALA_EXTERN void value_take_styles (GValue* value,
                        gpointer v_object);
VALA_EXTERN gpointer value_get_styles (const GValue* value);
VALA_EXTERN GType styles_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Styles, styles_unref)
VALA_EXTERN NodeBorder* styles_get_node_border (Styles* self,
                                    const gchar* name);
VALA_EXTERN void style_set_node_border (Style* self,
                            NodeBorder* value);
VALA_EXTERN void style_set_node_markup (Style* self,
                            gboolean* value);
VALA_EXTERN ExportMermaidNodeHier* export_mermaid_node_hier_new (Node* n,
                                                     gint p);
VALA_EXTERN ExportMermaidNodeHier* export_mermaid_node_hier_construct (GType object_type,
                                                           Node* n,
                                                           gint p);
VALA_EXTERN gint export_mermaid_node_hier_get_prefix (ExportMermaidNodeHier* self);
VALA_EXTERN Node* export_mermaid_node_hier_get_node (ExportMermaidNodeHier* self);
static void export_mermaid_real_add_settings (Export* base,
                                       GtkGrid* grid);
VALA_EXTERN void export_add_setting_bool (Export* self,
                              const gchar* name,
                              GtkGrid* grid,
                              const gchar* label,
                              const gchar* help,
                              gboolean dflt);
static void export_mermaid_real_save_settings (Export* base,
                                        xmlNode* node);
static void export_mermaid_real_load_settings (Export* base,
                                        xmlNode* node);
VALA_EXTERN void export_set_bool (Export* self,
                      const gchar* name,
                      gboolean value);
VALA_EXTERN void export_mermaid_node_hier_set_node (ExportMermaidNodeHier* self,
                                        Node* value);
VALA_EXTERN void export_mermaid_node_hier_set_prefix (ExportMermaidNodeHier* self,
                                          gint value);
static void export_mermaid_node_hier_finalize (ExportMermaidNodeHier * obj);
static GType export_mermaid_node_hier_get_type_once (void);
static GType export_mermaid_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

ExportMermaid*
export_mermaid_construct (GType object_type)
{
	ExportMermaid* self = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	_tmp0_ = g_strdup (".mmd");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = 1;
	self = (ExportMermaid*) export_construct (object_type, "mermaid", _ ("Mermaid"), _tmp2_, (gint) 1, TRUE, TRUE, FALSE, TRUE);
	_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
	return self;
}

ExportMermaid*
export_mermaid_new (void)
{
	return export_mermaid_construct (TYPE_EXPORT_MERMAID);
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static gboolean
export_mermaid_real_export (Export* base,
                            const gchar* fname,
                            MindMap* map)
{
	ExportMermaid * self;
	gboolean retval = FALSE;
	gchar* text = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (ExportMermaid*) base;
	g_return_val_if_fail (fname != NULL, FALSE);
	g_return_val_if_fail (map != NULL, FALSE);
	retval = TRUE;
	_tmp0_ = g_strdup ("");
	text = _tmp0_;
	if (export_get_bool ((Export*) self, "mindmap")) {
		gchar* _tmp1_;
		_tmp1_ = export_mermaid_export_top_nodes_mindmap (self, map);
		_g_free0 (text);
		text = _tmp1_;
	} else {
		gchar* _tmp2_;
		_tmp2_ = export_mermaid_export_top_nodes_graph (self, map);
		_g_free0 (text);
		text = _tmp2_;
	}
	if (export_send_to_clipboard ((Export*) self)) {
		const gchar* _tmp3_;
		_tmp3_ = text;
		minder_clipboard_copy_text (_tmp3_);
	} else {
		GFile* file = NULL;
		GFile* _tmp4_;
		_tmp4_ = g_file_new_for_path (fname);
		file = _tmp4_;
		{
			GFileOutputStream* os = NULL;
			GFile* _tmp5_;
			GFileOutputStream* _tmp6_;
			GFileOutputStream* _tmp7_;
			const gchar* _tmp8_;
			guint8* _tmp9_;
			gint _tmp9__length1;
			gint _tmp10_ = 0;
			guint8* _tmp11_;
			gint _tmp11__length1;
			_tmp5_ = file;
			_tmp6_ = g_file_replace (_tmp5_, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error0_);
			os = _tmp6_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp7_ = os;
			_tmp8_ = text;
			_tmp9_ = string_get_data (_tmp8_, &_tmp10_);
			_tmp9__length1 = _tmp10_;
			_tmp11_ = _tmp9_;
			_tmp11__length1 = _tmp9__length1;
			g_output_stream_write ((GOutputStream*) _tmp7_, _tmp11_, (gsize) _tmp11__length1, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (os);
				goto __catch0_g_error;
			}
			_g_object_unref0 (os);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
			retval = FALSE;
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp12_ = FALSE;
			_g_object_unref0 (file);
			_g_free0 (text);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp12_;
		}
		_g_object_unref0 (file);
	}
	result = retval;
	_g_free0 (text);
	return result;
}

static gchar*
export_mermaid_map_layout_to_direction (ExportMermaid* self,
                                        Node* n)
{
	gchar* lname = NULL;
	Layout* _tmp0_;
	Layout* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	_tmp0_ = node_get_layout (n);
	_tmp1_ = _tmp0_;
	_tmp2_ = layout_get_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup (_tmp3_);
	lname = _tmp4_;
	_tmp6_ = lname;
	if (g_strcmp0 (_tmp6_, _ ("Vertical")) == 0) {
		_tmp5_ = TRUE;
	} else {
		const gchar* _tmp7_;
		_tmp7_ = lname;
		_tmp5_ = g_strcmp0 (_tmp7_, _ ("Downwards")) == 0;
	}
	if (_tmp5_) {
		gchar* _tmp8_;
		_tmp8_ = g_strdup ("TB");
		result = _tmp8_;
		_g_free0 (lname);
		return result;
	} else {
		const gchar* _tmp9_;
		_tmp9_ = lname;
		if (g_strcmp0 (_tmp9_, _ ("To left")) == 0) {
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("RL");
			result = _tmp10_;
			_g_free0 (lname);
			return result;
		} else {
			const gchar* _tmp11_;
			_tmp11_ = lname;
			if (g_strcmp0 (_tmp11_, _ ("Upwards")) == 0) {
				gchar* _tmp12_;
				_tmp12_ = g_strdup ("BT");
				result = _tmp12_;
				_g_free0 (lname);
				return result;
			}
		}
	}
	_tmp13_ = g_strdup ("LR");
	result = _tmp13_;
	_g_free0 (lname);
	return result;
}

static gchar*
export_mermaid_export_top_nodes_graph (ExportMermaid* self,
                                       MindMap* map)
{
	gchar* retval = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (map != NULL, NULL);
	_tmp0_ = g_strdup ("");
	retval = _tmp0_;
	{
		GArray* nodes = NULL;
		GArray* _tmp1_;
		gint link_id = 0;
		GArray* _tmp2_;
		gchar* title = NULL;
		GArray* _tmp3_;
		Node* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp1_ = mind_map_get_nodes (map);
		nodes = _tmp1_;
		link_id = 0;
		_tmp2_ = nodes;
		if (_tmp2_->len == ((guint) 0)) {
			result = retval;
			_g_array_unref0 (nodes);
			return result;
		}
		_tmp3_ = nodes;
		_tmp4_ = g_array_index (_tmp3_, Node*, (guint) 0);
		_tmp5_ = export_mermaid_map_layout_to_direction (self, _tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strconcat ("graph ", _tmp6_, NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strconcat (_tmp8_, "\n", NULL);
		_tmp10_ = _tmp9_;
		_g_free0 (_tmp8_);
		_g_free0 (_tmp6_);
		title = _tmp10_;
		_tmp11_ = retval;
		_tmp12_ = title;
		_tmp13_ = g_strconcat (_tmp11_, _tmp12_, NULL);
		_g_free0 (retval);
		retval = _tmp13_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp14_ = FALSE;
				_tmp14_ = TRUE;
				while (TRUE) {
					GArray* _tmp16_;
					const gchar* _tmp17_;
					GArray* _tmp18_;
					Node* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					gchar* _tmp22_;
					if (!_tmp14_) {
						gint _tmp15_;
						_tmp15_ = i;
						i = _tmp15_ + 1;
					}
					_tmp14_ = FALSE;
					_tmp16_ = nodes;
					if (!(((guint) i) < _tmp16_->len)) {
						break;
					}
					_tmp17_ = retval;
					_tmp18_ = nodes;
					_tmp19_ = g_array_index (_tmp18_, Node*, (guint) i);
					_tmp20_ = export_mermaid_export_node_graph (self, _tmp19_, &link_id);
					_tmp21_ = _tmp20_;
					_tmp22_ = g_strconcat (_tmp17_, _tmp21_, NULL);
					_g_free0 (retval);
					retval = _tmp22_;
					_g_free0 (_tmp21_);
				}
			}
		}
		_g_free0 (title);
		_g_array_unref0 (nodes);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (retval);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = retval;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static gchar*
export_mermaid_export_top_nodes_mindmap (ExportMermaid* self,
                                         MindMap* map)
{
	gchar* retval = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (map != NULL, NULL);
	_tmp0_ = g_strdup ("");
	retval = _tmp0_;
	{
		GArray* nodes = NULL;
		GArray* _tmp1_;
		GArray* _tmp2_;
		Node* root = NULL;
		GArray* _tmp3_;
		Node* _tmp4_;
		Node* _tmp5_;
		GArray* children = NULL;
		Node* _tmp6_;
		GArray* _tmp7_;
		gchar* title = NULL;
		Node* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp1_ = mind_map_get_nodes (map);
		nodes = _tmp1_;
		_tmp2_ = nodes;
		if (_tmp2_->len != ((guint) 1)) {
			result = retval;
			_g_array_unref0 (nodes);
			return result;
		}
		_tmp3_ = nodes;
		_tmp4_ = g_array_index (_tmp3_, Node*, (guint) 0);
		_tmp5_ = _g_object_ref0 (_tmp4_);
		root = _tmp5_;
		_tmp6_ = root;
		_tmp7_ = node_children (_tmp6_);
		children = _tmp7_;
		_tmp8_ = root;
		_tmp9_ = export_mermaid_make_title (self, _tmp8_, TRUE);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_strdup_printf ("mindmap\n%s\n", _tmp10_);
		_tmp12_ = _tmp11_;
		_g_free0 (_tmp10_);
		title = _tmp12_;
		_tmp13_ = retval;
		_tmp14_ = title;
		_tmp15_ = g_strconcat (_tmp13_, _tmp14_, NULL);
		_g_free0 (retval);
		retval = _tmp15_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp16_ = FALSE;
				_tmp16_ = TRUE;
				while (TRUE) {
					GArray* _tmp18_;
					const gchar* _tmp19_;
					GArray* _tmp20_;
					Node* _tmp21_;
					gchar* _tmp22_;
					gchar* _tmp23_;
					gchar* _tmp24_;
					if (!_tmp16_) {
						gint _tmp17_;
						_tmp17_ = i;
						i = _tmp17_ + 1;
					}
					_tmp16_ = FALSE;
					_tmp18_ = children;
					if (!(((guint) i) < _tmp18_->len)) {
						break;
					}
					_tmp19_ = retval;
					_tmp20_ = children;
					_tmp21_ = g_array_index (_tmp20_, Node*, (guint) i);
					_tmp22_ = export_mermaid_export_node_mindmap (self, _tmp21_, "  ");
					_tmp23_ = _tmp22_;
					_tmp24_ = g_strconcat (_tmp19_, _tmp23_, NULL);
					_g_free0 (retval);
					retval = _tmp24_;
					_g_free0 (_tmp23_);
				}
			}
		}
		_g_free0 (title);
		_g_array_unref0 (children);
		_g_object_unref0 (root);
		_g_array_unref0 (nodes);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (retval);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = retval;
	return result;
}

static gchar*
export_mermaid_make_id (ExportMermaid* self,
                        Node* n)
{
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	if (node_is_root (n)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("root");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp1_ = g_strdup_printf ("%i", node_id (n));
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strconcat ("id", _tmp2_, NULL);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		result = _tmp4_;
		return result;
	}
}

static gchar*
export_mermaid_make_title (ExportMermaid* self,
                           Node* n,
                           gboolean for_mindmap)
{
	gchar* name = NULL;
	CanvasText* _tmp0_;
	CanvasText* _tmp1_;
	FormattedText* _tmp2_;
	FormattedText* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	const gchar* _tmp8_;
	gboolean _tmp12_ = FALSE;
	Style* _tmp13_;
	Style* _tmp14_;
	gboolean* _tmp15_;
	gboolean* _tmp16_;
	Style* _tmp21_;
	Style* _tmp22_;
	NodeBorder* _tmp23_;
	NodeBorder* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	GQuark _tmp28_ = 0U;
	static GQuark _tmp27_label0 = 0;
	static GQuark _tmp27_label1 = 0;
	static GQuark _tmp27_label2 = 0;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	_tmp0_ = node_get_name (n);
	_tmp1_ = _tmp0_;
	_tmp2_ = canvas_text_get_text (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = formatted_text_get_text (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup (_tmp5_);
	name = _tmp6_;
	_tmp8_ = name;
	if (g_strcmp0 (_tmp8_, "") == 0) {
		NodeImage* _tmp9_;
		NodeImage* _tmp10_;
		_tmp9_ = node_get_image (n);
		_tmp10_ = _tmp9_;
		_tmp7_ = _tmp10_ != NULL;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		gchar* _tmp11_;
		_tmp11_ = g_strdup ("Image");
		_g_free0 (name);
		name = _tmp11_;
	}
	_tmp13_ = node_get_style (n);
	_tmp14_ = _tmp13_;
	_tmp15_ = style_get_node_markup (_tmp14_);
	_tmp16_ = _tmp15_;
	if (*_tmp16_) {
		_tmp12_ = for_mindmap;
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		const gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp17_ = name;
		_tmp18_ = g_strconcat ("`", _tmp17_, NULL);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_strconcat (_tmp19_, "`", NULL);
		_g_free0 (name);
		name = _tmp20_;
		_g_free0 (_tmp19_);
	}
	_tmp21_ = node_get_style (n);
	_tmp22_ = _tmp21_;
	_tmp23_ = style_get_node_border (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = node_border_name (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp28_ = (NULL == _tmp26_) ? 0 : g_quark_from_string (_tmp26_);
	g_free (_tmp26_);
	if (_tmp28_ == ((0 != _tmp27_label0) ? _tmp27_label0 : (_tmp27_label0 = g_quark_from_static_string ("rounded")))) {
		switch (0) {
			default:
			{
				gchar* _tmp29_;
				gchar* _tmp30_;
				gchar* _tmp31_;
				gchar* _tmp32_;
				const gchar* _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				gchar* _tmp36_;
				gchar* _tmp37_;
				_tmp29_ = export_mermaid_make_id (self, n);
				_tmp30_ = _tmp29_;
				_tmp31_ = g_strconcat (_tmp30_, "(\"", NULL);
				_tmp32_ = _tmp31_;
				_tmp33_ = name;
				_tmp34_ = g_strconcat (_tmp32_, _tmp33_, NULL);
				_tmp35_ = _tmp34_;
				_tmp36_ = g_strconcat (_tmp35_, "\")", NULL);
				_tmp37_ = _tmp36_;
				_g_free0 (_tmp35_);
				_g_free0 (_tmp32_);
				_g_free0 (_tmp30_);
				result = _tmp37_;
				_g_free0 (name);
				return result;
			}
		}
	} else if (_tmp28_ == ((0 != _tmp27_label1) ? _tmp27_label1 : (_tmp27_label1 = g_quark_from_static_string ("pilled")))) {
		switch (0) {
			default:
			{
				gchar* _tmp38_;
				gchar* _tmp39_;
				gchar* _tmp40_;
				gchar* _tmp41_;
				const gchar* _tmp42_;
				gchar* _tmp43_;
				gchar* _tmp44_;
				gchar* _tmp45_;
				gchar* _tmp46_;
				_tmp38_ = export_mermaid_make_id (self, n);
				_tmp39_ = _tmp38_;
				_tmp40_ = g_strconcat (_tmp39_, "((\"", NULL);
				_tmp41_ = _tmp40_;
				_tmp42_ = name;
				_tmp43_ = g_strconcat (_tmp41_, _tmp42_, NULL);
				_tmp44_ = _tmp43_;
				_tmp45_ = g_strconcat (_tmp44_, "\"))", NULL);
				_tmp46_ = _tmp45_;
				_g_free0 (_tmp44_);
				_g_free0 (_tmp41_);
				_g_free0 (_tmp39_);
				result = _tmp46_;
				_g_free0 (name);
				return result;
			}
		}
	} else if (_tmp28_ == ((0 != _tmp27_label2) ? _tmp27_label2 : (_tmp27_label2 = g_quark_from_static_string ("squared")))) {
		switch (0) {
			default:
			{
				gchar* _tmp47_;
				gchar* _tmp48_;
				gchar* _tmp49_;
				gchar* _tmp50_;
				const gchar* _tmp51_;
				gchar* _tmp52_;
				gchar* _tmp53_;
				gchar* _tmp54_;
				gchar* _tmp55_;
				_tmp47_ = export_mermaid_make_id (self, n);
				_tmp48_ = _tmp47_;
				_tmp49_ = g_strconcat (_tmp48_, "[\"", NULL);
				_tmp50_ = _tmp49_;
				_tmp51_ = name;
				_tmp52_ = g_strconcat (_tmp50_, _tmp51_, NULL);
				_tmp53_ = _tmp52_;
				_tmp54_ = g_strconcat (_tmp53_, "\"]", NULL);
				_tmp55_ = _tmp54_;
				_g_free0 (_tmp53_);
				_g_free0 (_tmp50_);
				_g_free0 (_tmp48_);
				result = _tmp55_;
				_g_free0 (name);
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				if (for_mindmap) {
					const gchar* _tmp56_;
					gchar* _tmp57_;
					gchar* _tmp58_;
					gchar* _tmp59_;
					gchar* _tmp60_;
					_tmp56_ = name;
					_tmp57_ = g_strconcat ("\"", _tmp56_, NULL);
					_tmp58_ = _tmp57_;
					_tmp59_ = g_strconcat (_tmp58_, "\"", NULL);
					_tmp60_ = _tmp59_;
					_g_free0 (_tmp58_);
					result = _tmp60_;
					_g_free0 (name);
					return result;
				} else {
					gchar* _tmp61_;
					gchar* _tmp62_;
					gchar* _tmp63_;
					gchar* _tmp64_;
					const gchar* _tmp65_;
					gchar* _tmp66_;
					gchar* _tmp67_;
					gchar* _tmp68_;
					gchar* _tmp69_;
					_tmp61_ = export_mermaid_make_id (self, n);
					_tmp62_ = _tmp61_;
					_tmp63_ = g_strconcat (_tmp62_, "[\"", NULL);
					_tmp64_ = _tmp63_;
					_tmp65_ = name;
					_tmp66_ = g_strconcat (_tmp64_, _tmp65_, NULL);
					_tmp67_ = _tmp66_;
					_tmp68_ = g_strconcat (_tmp67_, "\"]", NULL);
					_tmp69_ = _tmp68_;
					_g_free0 (_tmp67_);
					_g_free0 (_tmp64_);
					_g_free0 (_tmp62_);
					result = _tmp69_;
					_g_free0 (name);
					return result;
				}
			}
		}
	}
}

static gchar*
export_mermaid_make_link (ExportMermaid* self,
                          Node* n)
{
	gboolean arrow = FALSE;
	Style* _tmp0_;
	Style* _tmp1_;
	gboolean* _tmp2_;
	gboolean* _tmp3_;
	gboolean solid = FALSE;
	Style* _tmp4_;
	Style* _tmp5_;
	LinkDash* _tmp6_;
	LinkDash* _tmp7_;
	const gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	_tmp0_ = node_get_style (n);
	_tmp1_ = _tmp0_;
	_tmp2_ = style_get_link_arrow (_tmp1_);
	_tmp3_ = _tmp2_;
	arrow = *_tmp3_;
	_tmp4_ = node_get_style (n);
	_tmp5_ = _tmp4_;
	_tmp6_ = style_get_link_dash (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->name;
	solid = g_strcmp0 (_tmp8_, "solid") == 0;
	if (arrow) {
		const gchar* _tmp9_ = NULL;
		gchar* _tmp10_;
		if (solid) {
			_tmp9_ = "-->";
		} else {
			_tmp9_ = "-.->";
		}
		_tmp10_ = g_strdup (_tmp9_);
		result = _tmp10_;
		return result;
	} else {
		const gchar* _tmp11_ = NULL;
		gchar* _tmp12_;
		if (solid) {
			_tmp11_ = "---";
		} else {
			_tmp11_ = "-.-";
		}
		_tmp12_ = g_strdup (_tmp11_);
		result = _tmp12_;
		return result;
	}
}

static GdkRGBA*
_vala_GdkRGBA_copy (GdkRGBA* self)
{
	return g_boxed_copy (gdk_rgba_get_type (), self);
}

static gpointer
__vala_GdkRGBA_copy0 (gpointer self)
{
	return self ? _vala_GdkRGBA_copy (self) : NULL;
}

static void
_vala_GdkRGBA_free (GdkRGBA* self)
{
	g_boxed_free (gdk_rgba_get_type (), self);
}

static gchar*
export_mermaid_make_link_color (ExportMermaid* self,
                                Node* n)
{
	GdkRGBA* rgba = NULL;
	GdkRGBA* _tmp0_;
	GdkRGBA* _tmp1_;
	GdkRGBA* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	_tmp0_ = node_get_link_color (n);
	_tmp1_ = _tmp0_;
	_tmp2_ = __vala_GdkRGBA_copy0 (_tmp1_);
	rgba = _tmp2_;
	_tmp3_ = g_strdup_printf ("#%02x%02x%02x", (guint) ((gint) ((*rgba).red * 255)), (guint) ((gint) ((*rgba).green * 255)), (guint) ((gint) ((*rgba).blue * 255)));
	result = _tmp3_;
	__vala_GdkRGBA_free0 (rgba);
	return result;
}

static gchar*
export_mermaid_make_node_style (ExportMermaid* self,
                                Node* n)
{
	gchar* color = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_ = NULL;
	Style* _tmp2_;
	Style* _tmp3_;
	gboolean* _tmp4_;
	gboolean* _tmp5_;
	gchar* fill = NULL;
	gchar* _tmp11_;
	gchar* width = NULL;
	Style* _tmp12_;
	Style* _tmp13_;
	gint* _tmp14_;
	gint* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	_tmp0_ = export_mermaid_make_link_color (self, n);
	color = _tmp0_;
	_tmp2_ = node_get_style (n);
	_tmp3_ = _tmp2_;
	_tmp4_ = style_get_node_fill (_tmp3_);
	_tmp5_ = _tmp4_;
	if (*_tmp5_) {
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp6_ = color;
		_tmp7_ = g_strconcat ("fill:", _tmp6_, NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strconcat (_tmp8_, ",", NULL);
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp9_;
		_g_free0 (_tmp8_);
	} else {
		gchar* _tmp10_;
		_tmp10_ = g_strdup ("");
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp10_;
	}
	_tmp11_ = _tmp1_;
	_tmp1_ = NULL;
	fill = _tmp11_;
	_tmp12_ = node_get_style (n);
	_tmp13_ = _tmp12_;
	_tmp14_ = style_get_node_borderwidth (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strdup_printf ("%i", *_tmp15_);
	width = _tmp16_;
	_tmp17_ = export_mermaid_make_id (self, n);
	_tmp18_ = _tmp17_;
	_tmp19_ = g_strconcat ("style ", _tmp18_, NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_strconcat (_tmp20_, " ", NULL);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_strconcat (_tmp22_, fill, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, "stroke:", NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = color;
	_tmp28_ = g_strconcat (_tmp26_, _tmp27_, NULL);
	_tmp29_ = _tmp28_;
	_tmp30_ = g_strconcat (_tmp29_, ",stroke-width:", NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = g_strconcat (_tmp31_, width, NULL);
	_tmp33_ = _tmp32_;
	_tmp34_ = g_strconcat (_tmp33_, "px", NULL);
	_tmp35_ = _tmp34_;
	_g_free0 (_tmp33_);
	_g_free0 (_tmp31_);
	_g_free0 (_tmp29_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_g_free0 (_tmp22_);
	_g_free0 (_tmp20_);
	_g_free0 (_tmp18_);
	result = _tmp35_;
	_g_free0 (width);
	_g_free0 (fill);
	_g_free0 (_tmp1_);
	_g_free0 (color);
	return result;
}

static gdouble*
_vala_array_dup5 (gdouble* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gdouble));
	}
	return NULL;
}

static gchar*
export_mermaid_make_link_style (ExportMermaid* self,
                                Node* n,
                                gint* link_id)
{
	gchar* color = NULL;
	gchar* _tmp0_;
	gchar* width = NULL;
	Style* _tmp1_;
	Style* _tmp2_;
	gint* _tmp3_;
	gint* _tmp4_;
	gchar* _tmp5_;
	gint lid = 0;
	gint _tmp6_;
	gdouble* pattern = NULL;
	Style* _tmp7_;
	Style* _tmp8_;
	LinkDash* _tmp9_;
	LinkDash* _tmp10_;
	gdouble* _tmp11_;
	gint _tmp11__length1;
	gdouble* _tmp12_;
	gint _tmp12__length1;
	gint pattern_length1;
	gint _pattern_size_;
	gchar* pattern_str = NULL;
	gchar* _tmp13_;
	gdouble* _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (n != NULL, NULL);
	_tmp0_ = export_mermaid_make_link_color (self, n);
	color = _tmp0_;
	_tmp1_ = node_get_style (n);
	_tmp2_ = _tmp1_;
	_tmp3_ = style_get_link_width (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strdup_printf ("%i", *_tmp4_);
	width = _tmp5_;
	_tmp6_ = *link_id;
	*link_id = _tmp6_ + 1;
	lid = _tmp6_;
	_tmp7_ = node_get_style (n);
	_tmp8_ = _tmp7_;
	_tmp9_ = style_get_link_dash (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp10_->pattern;
	_tmp11__length1 = _tmp10_->pattern_length1;
	_tmp12_ = (_tmp11_ != NULL) ? _vala_array_dup5 (_tmp11_, _tmp11__length1) : _tmp11_;
	_tmp12__length1 = _tmp11__length1;
	pattern = _tmp12_;
	pattern_length1 = _tmp12__length1;
	_pattern_size_ = pattern_length1;
	_tmp13_ = g_strdup ("");
	pattern_str = _tmp13_;
	_tmp14_ = pattern;
	_tmp14__length1 = pattern_length1;
	if (_tmp14__length1 > 0) {
		gchar* _tmp15_;
		_tmp15_ = g_strdup (",stroke-dasharray:");
		_g_free0 (pattern_str);
		pattern_str = _tmp15_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp16_ = FALSE;
				_tmp16_ = TRUE;
				while (TRUE) {
					gdouble* _tmp18_;
					gint _tmp18__length1;
					const gchar* _tmp19_ = NULL;
					const gchar* _tmp20_;
					gdouble* _tmp21_;
					gint _tmp21__length1;
					gdouble _tmp22_;
					gchar* _tmp23_;
					gchar* _tmp24_;
					gchar* _tmp25_;
					if (!_tmp16_) {
						gint _tmp17_;
						_tmp17_ = i;
						i = _tmp17_ + 1;
					}
					_tmp16_ = FALSE;
					_tmp18_ = pattern;
					_tmp18__length1 = pattern_length1;
					if (!(i < _tmp18__length1)) {
						break;
					}
					if (i == 0) {
						_tmp19_ = "";
					} else {
						_tmp19_ = ",";
					}
					_tmp20_ = pattern_str;
					_tmp21_ = pattern;
					_tmp21__length1 = pattern_length1;
					_tmp22_ = _tmp21_[i];
					_tmp23_ = g_strdup_printf ("%s%d", _tmp19_, (gint) _tmp22_);
					_tmp24_ = _tmp23_;
					_tmp25_ = g_strconcat (_tmp20_, _tmp24_, NULL);
					_g_free0 (pattern_str);
					pattern_str = _tmp25_;
					_g_free0 (_tmp24_);
				}
			}
		}
	}
	_tmp26_ = g_strdup_printf ("%i", lid);
	_tmp27_ = _tmp26_;
	_tmp28_ = g_strconcat ("linkStyle ", _tmp27_, NULL);
	_tmp29_ = _tmp28_;
	_tmp30_ = g_strconcat (_tmp29_, " stroke:", NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = color;
	_tmp33_ = g_strconcat (_tmp31_, _tmp32_, NULL);
	_tmp34_ = _tmp33_;
	_tmp35_ = g_strconcat (_tmp34_, ",stroke-width:", NULL);
	_tmp36_ = _tmp35_;
	_tmp37_ = width;
	_tmp38_ = g_strconcat (_tmp36_, _tmp37_, NULL);
	_tmp39_ = _tmp38_;
	_tmp40_ = g_strconcat (_tmp39_, "px", NULL);
	_tmp41_ = _tmp40_;
	_tmp42_ = pattern_str;
	_tmp43_ = g_strconcat (_tmp41_, _tmp42_, NULL);
	_tmp44_ = _tmp43_;
	_g_free0 (_tmp41_);
	_g_free0 (_tmp39_);
	_g_free0 (_tmp36_);
	_g_free0 (_tmp34_);
	_g_free0 (_tmp31_);
	_g_free0 (_tmp29_);
	_g_free0 (_tmp27_);
	result = _tmp44_;
	_g_free0 (pattern_str);
	pattern = (g_free (pattern), NULL);
	_g_free0 (width);
	_g_free0 (color);
	return result;
}

static gchar*
export_mermaid_export_node_graph (ExportMermaid* self,
                                  Node* node,
                                  gint* link_id)
{
	gchar* retval = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = g_strdup ("");
	retval = _tmp0_;
	{
		gchar* title = NULL;
		gchar* _tmp1_;
		GArray* children = NULL;
		GArray* _tmp2_;
		gboolean _tmp3_ = FALSE;
		_tmp1_ = export_mermaid_make_title (self, node, FALSE);
		title = _tmp1_;
		_tmp2_ = node_children (node);
		children = _tmp2_;
		if (node_is_root (node)) {
			GArray* _tmp4_;
			_tmp4_ = children;
			_tmp3_ = _tmp4_->len == ((guint) 0);
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			gchar* line = NULL;
			const gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			gchar* _tmp12_;
			_tmp5_ = title;
			_tmp6_ = g_strconcat ("  ", _tmp5_, NULL);
			_tmp7_ = _tmp6_;
			_tmp8_ = g_strconcat (_tmp7_, ";\n", NULL);
			_tmp9_ = _tmp8_;
			_g_free0 (_tmp7_);
			line = _tmp9_;
			_tmp10_ = retval;
			_tmp11_ = line;
			_tmp12_ = g_strconcat (_tmp10_, _tmp11_, NULL);
			_g_free0 (retval);
			retval = _tmp12_;
			_g_free0 (line);
		} else {
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp13_ = FALSE;
					_tmp13_ = TRUE;
					while (TRUE) {
						GArray* _tmp15_;
						gchar* link = NULL;
						GArray* _tmp16_;
						Node* _tmp17_;
						gchar* _tmp18_;
						gchar* ctitle = NULL;
						GArray* _tmp19_;
						Node* _tmp20_;
						gchar* _tmp21_;
						gchar* nstyle = NULL;
						GArray* _tmp22_;
						Node* _tmp23_;
						gchar* _tmp24_;
						gchar* lstyle = NULL;
						GArray* _tmp25_;
						Node* _tmp26_;
						gchar* _tmp27_;
						gchar* line = NULL;
						const gchar* _tmp28_;
						gchar* _tmp29_;
						gchar* _tmp30_;
						gchar* _tmp31_;
						gchar* _tmp32_;
						const gchar* _tmp33_;
						gchar* _tmp34_;
						gchar* _tmp35_;
						gchar* _tmp36_;
						gchar* _tmp37_;
						const gchar* _tmp38_;
						gchar* _tmp39_;
						gchar* _tmp40_;
						gchar* _tmp41_;
						gchar* _tmp42_;
						const gchar* _tmp43_;
						gchar* _tmp44_;
						gchar* _tmp45_;
						gchar* _tmp46_;
						gchar* _tmp47_;
						const gchar* _tmp48_;
						gchar* _tmp49_;
						gchar* _tmp50_;
						gchar* _tmp51_;
						gchar* _tmp52_;
						const gchar* _tmp53_;
						const gchar* _tmp54_;
						gchar* _tmp55_;
						const gchar* _tmp56_;
						GArray* _tmp57_;
						Node* _tmp58_;
						gchar* _tmp59_;
						gchar* _tmp60_;
						gchar* _tmp61_;
						if (!_tmp13_) {
							gint _tmp14_;
							_tmp14_ = i;
							i = _tmp14_ + 1;
						}
						_tmp13_ = FALSE;
						_tmp15_ = children;
						if (!(((guint) i) < _tmp15_->len)) {
							break;
						}
						_tmp16_ = children;
						_tmp17_ = g_array_index (_tmp16_, Node*, (guint) i);
						_tmp18_ = export_mermaid_make_link (self, _tmp17_);
						link = _tmp18_;
						_tmp19_ = children;
						_tmp20_ = g_array_index (_tmp19_, Node*, (guint) i);
						_tmp21_ = export_mermaid_make_title (self, _tmp20_, FALSE);
						ctitle = _tmp21_;
						_tmp22_ = children;
						_tmp23_ = g_array_index (_tmp22_, Node*, (guint) i);
						_tmp24_ = export_mermaid_make_node_style (self, _tmp23_);
						nstyle = _tmp24_;
						_tmp25_ = children;
						_tmp26_ = g_array_index (_tmp25_, Node*, (guint) i);
						_tmp27_ = export_mermaid_make_link_style (self, _tmp26_, link_id);
						lstyle = _tmp27_;
						_tmp28_ = title;
						_tmp29_ = g_strconcat ("  ", _tmp28_, NULL);
						_tmp30_ = _tmp29_;
						_tmp31_ = g_strconcat (_tmp30_, " ", NULL);
						_tmp32_ = _tmp31_;
						_tmp33_ = link;
						_tmp34_ = g_strconcat (_tmp32_, _tmp33_, NULL);
						_tmp35_ = _tmp34_;
						_tmp36_ = g_strconcat (_tmp35_, " ", NULL);
						_tmp37_ = _tmp36_;
						_tmp38_ = ctitle;
						_tmp39_ = g_strconcat (_tmp37_, _tmp38_, NULL);
						_tmp40_ = _tmp39_;
						_tmp41_ = g_strconcat (_tmp40_, ";  ", NULL);
						_tmp42_ = _tmp41_;
						_tmp43_ = nstyle;
						_tmp44_ = g_strconcat (_tmp42_, _tmp43_, NULL);
						_tmp45_ = _tmp44_;
						_tmp46_ = g_strconcat (_tmp45_, ";  ", NULL);
						_tmp47_ = _tmp46_;
						_tmp48_ = lstyle;
						_tmp49_ = g_strconcat (_tmp47_, _tmp48_, NULL);
						_tmp50_ = _tmp49_;
						_tmp51_ = g_strconcat (_tmp50_, ";\n", NULL);
						_tmp52_ = _tmp51_;
						_g_free0 (_tmp50_);
						_g_free0 (_tmp47_);
						_g_free0 (_tmp45_);
						_g_free0 (_tmp42_);
						_g_free0 (_tmp40_);
						_g_free0 (_tmp37_);
						_g_free0 (_tmp35_);
						_g_free0 (_tmp32_);
						_g_free0 (_tmp30_);
						line = _tmp52_;
						_tmp53_ = retval;
						_tmp54_ = line;
						_tmp55_ = g_strconcat (_tmp53_, _tmp54_, NULL);
						_g_free0 (retval);
						retval = _tmp55_;
						_tmp56_ = retval;
						_tmp57_ = children;
						_tmp58_ = g_array_index (_tmp57_, Node*, (guint) i);
						_tmp59_ = export_mermaid_export_node_graph (self, _tmp58_, link_id);
						_tmp60_ = _tmp59_;
						_tmp61_ = g_strconcat (_tmp56_, _tmp60_, NULL);
						_g_free0 (retval);
						retval = _tmp61_;
						_g_free0 (_tmp60_);
						_g_free0 (line);
						_g_free0 (lstyle);
						_g_free0 (nstyle);
						_g_free0 (ctitle);
						_g_free0 (link);
					}
				}
			}
		}
		_g_array_unref0 (children);
		_g_free0 (title);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (retval);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = retval;
	return result;
}

static gchar*
export_mermaid_export_node_mindmap (ExportMermaid* self,
                                    Node* node,
                                    const gchar* prefix)
{
	gchar* retval = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (node != NULL, NULL);
	g_return_val_if_fail (prefix != NULL, NULL);
	_tmp0_ = g_strdup ("");
	retval = _tmp0_;
	{
		gchar* title = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		GArray* children = NULL;
		GArray* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp1_ = export_mermaid_make_title (self, node, TRUE);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strconcat (prefix, _tmp2_, NULL);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strconcat (_tmp4_, "\n", NULL);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		_g_free0 (_tmp2_);
		title = _tmp6_;
		_tmp7_ = node_children (node);
		children = _tmp7_;
		_tmp8_ = retval;
		_tmp9_ = title;
		_tmp10_ = g_strconcat (_tmp8_, _tmp9_, NULL);
		_g_free0 (retval);
		retval = _tmp10_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp11_ = FALSE;
				_tmp11_ = TRUE;
				while (TRUE) {
					GArray* _tmp13_;
					const gchar* _tmp14_;
					GArray* _tmp15_;
					Node* _tmp16_;
					gchar* _tmp17_;
					gchar* _tmp18_;
					gchar* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					if (!_tmp11_) {
						gint _tmp12_;
						_tmp12_ = i;
						i = _tmp12_ + 1;
					}
					_tmp11_ = FALSE;
					_tmp13_ = children;
					if (!(((guint) i) < _tmp13_->len)) {
						break;
					}
					_tmp14_ = retval;
					_tmp15_ = children;
					_tmp16_ = g_array_index (_tmp15_, Node*, (guint) i);
					_tmp17_ = g_strconcat (prefix, "  ", NULL);
					_tmp18_ = _tmp17_;
					_tmp19_ = export_mermaid_export_node_mindmap (self, _tmp16_, _tmp18_);
					_tmp20_ = _tmp19_;
					_tmp21_ = g_strconcat (_tmp14_, _tmp20_, NULL);
					_g_free0 (retval);
					retval = _tmp21_;
					_g_free0 (_tmp20_);
					_g_free0 (_tmp18_);
				}
			}
		}
		_g_array_unref0 (children);
		_g_free0 (title);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (retval);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = retval;
	return result;
}

static gboolean
export_mermaid_real_import (Export* base,
                            const gchar* fname,
                            MindMap* map)
{
	ExportMermaid * self;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (ExportMermaid*) base;
	g_return_val_if_fail (fname != NULL, FALSE);
	g_return_val_if_fail (map != NULL, FALSE);
	{
		GFile* file = NULL;
		GFile* _tmp0_;
		GFileInputStream* _tmp1_ = NULL;
		GFile* _tmp2_;
		GFileInputStream* _tmp3_;
		GDataInputStream* dis = NULL;
		GDataInputStream* _tmp4_;
		gsize len = 0UL;
		GArray* nodes = NULL;
		gchar* _tmp5_ = NULL;
		GDataInputStream* _tmp6_;
		gsize _tmp7_ = 0UL;
		gchar* _tmp8_;
		gchar* str = NULL;
		gchar* _tmp9_;
		const gchar* _tmp10_;
		_tmp0_ = g_file_new_for_path (fname);
		file = _tmp0_;
		_tmp2_ = file;
		_tmp3_ = g_file_read (_tmp2_, NULL, &_inner_error0_);
		_tmp1_ = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (file);
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			goto __catch0_g_error;
		}
		_tmp4_ = g_data_input_stream_new ((GInputStream*) _tmp1_);
		dis = _tmp4_;
		_tmp6_ = dis;
		_tmp8_ = g_data_input_stream_read_upto (_tmp6_, "\0", (gssize) 1, &_tmp7_, NULL, &_inner_error0_);
		len = _tmp7_;
		_tmp5_ = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_array_unref0 (nodes);
			_g_object_unref0 (dis);
			_g_object_unref0 (_tmp1_);
			_g_object_unref0 (file);
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			goto __catch0_g_error;
		}
		_tmp9_ = g_strconcat (_tmp5_, "\0", NULL);
		str = _tmp9_;
		_tmp10_ = str;
		if (export_mermaid_import_text (self, _tmp10_, map)) {
			mind_map_queue_draw (map);
			mind_map_auto_save (map);
		} else {
			result = FALSE;
			_g_free0 (str);
			_g_free0 (_tmp5_);
			_g_array_unref0 (nodes);
			_g_object_unref0 (dis);
			_g_object_unref0 (_tmp1_);
			_g_object_unref0 (file);
			return result;
		}
		_g_free0 (str);
		_g_free0 (_tmp5_);
		_g_array_unref0 (nodes);
		_g_object_unref0 (dis);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (file);
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		g_clear_error (&_inner_error0_);
		result = FALSE;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = FALSE;
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp11_ = FALSE;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp11_;
	}
	result = TRUE;
	return result;
}

static void
_export_mermaid_node_hier_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (export_mermaid_node_hier_unref (var), NULL));
}

static void
_vala_ExportMermaidNodeHier_free_function_content_of (gpointer data)
{
	ExportMermaidNodeHier* self;
	self = *((ExportMermaidNodeHier**) data);
	_export_mermaid_node_hier_unref0_ (self);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gchar*
string_chug (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strchug (_result_);
	result = _result_;
	return result;
}

static gint
string_index_of_nth_char (const gchar* self,
                          glong c)
{
	gchar* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_offset_to_pointer (self, c);
	result = (gint) (_tmp0_ - ((gchar*) self));
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static gboolean
export_mermaid_import_text (ExportMermaid* self,
                            const gchar* txt,
                            MindMap* map)
{
	GArray* stack = NULL;
	GArray* _tmp0_;
	GArray* _tmp138_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (txt != NULL, FALSE);
	g_return_val_if_fail (map != NULL, FALSE);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (ExportMermaidNodeHier*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_ExportMermaidNodeHier_free_function_content_of);
	stack = _tmp0_;
	{
		gchar** lines = NULL;
		gchar** _tmp1_;
		gchar** _tmp2_;
		gint lines_length1;
		gint _lines_size_;
		GRegex* start_re = NULL;
		GRegex* _tmp3_;
		gboolean first = FALSE;
		gboolean in_header = FALSE;
		gboolean in_title = FALSE;
		gboolean quoted = FALSE;
		gboolean markdown = FALSE;
		gint prefix = 0;
		gchar* end_shape = NULL;
		gchar* _tmp5_;
		gchar* border = NULL;
		gchar* _tmp6_;
		gchar* title = NULL;
		gchar* _tmp7_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		_tmp2_ = _tmp1_ = g_strsplit (txt, "\n", 0);
		lines = _tmp2_;
		lines_length1 = _vala_array_length (_tmp1_);
		_lines_size_ = lines_length1;
		_tmp3_ = g_regex_new ("^(\\w+)([\\[\\(\\)\\{]{1,2})(.*)$", 0, 0, &_inner_error0_);
		start_re = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp4_ = FALSE;
			lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_array_unref0 (stack);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp4_;
		}
		first = TRUE;
		in_header = FALSE;
		in_title = FALSE;
		quoted = FALSE;
		markdown = FALSE;
		prefix = 0;
		_tmp5_ = g_strdup ("");
		end_shape = _tmp5_;
		_tmp6_ = g_strdup ("");
		border = _tmp6_;
		_tmp7_ = g_strdup ("");
		title = _tmp7_;
		_tmp8_ = lines;
		_tmp8__length1 = lines_length1;
		{
			gchar** line_collection = NULL;
			gint line_collection_length1 = 0;
			gint _line_collection_size_ = 0;
			gint line_it = 0;
			line_collection = _tmp8_;
			line_collection_length1 = _tmp8__length1;
			for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
				gchar* _tmp9_;
				gchar* line = NULL;
				_tmp9_ = g_strdup (line_collection[line_it]);
				line = _tmp9_;
				{
					GMatchInfo* match_info = NULL;
					gchar* stripped = NULL;
					const gchar* _tmp10_;
					gchar* _tmp11_;
					const gchar* _tmp12_;
					_tmp10_ = line;
					_tmp11_ = string_strip (_tmp10_);
					stripped = _tmp11_;
					_tmp12_ = stripped;
					if (g_strcmp0 (_tmp12_, "") != 0) {
						if (first) {
							const gchar* _tmp13_;
							_tmp13_ = stripped;
							if (g_strcmp0 (_tmp13_, "---") == 0) {
								in_header = TRUE;
							} else {
								const gchar* _tmp14_;
								_tmp14_ = stripped;
								if (g_strcmp0 (_tmp14_, "mindmap") != 0) {
									result = FALSE;
									_g_free0 (stripped);
									_g_match_info_unref0 (match_info);
									_g_free0 (line);
									_g_free0 (title);
									_g_free0 (border);
									_g_free0 (end_shape);
									_g_regex_unref0 (start_re);
									lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
									_g_array_unref0 (stack);
									return result;
								}
							}
							first = FALSE;
						} else {
							const gchar* _tmp15_;
							_tmp15_ = stripped;
							if (g_strcmp0 (_tmp15_, "---") == 0) {
								first = TRUE;
								in_header = FALSE;
							} else {
								gboolean _tmp16_ = FALSE;
								gboolean _tmp17_ = FALSE;
								const gchar* _tmp18_;
								_tmp18_ = stripped;
								if (!g_str_has_prefix (_tmp18_, "::icon(")) {
									const gchar* _tmp19_;
									_tmp19_ = stripped;
									_tmp17_ = !g_str_has_prefix (_tmp19_, ":::");
								} else {
									_tmp17_ = FALSE;
								}
								if (_tmp17_) {
									_tmp16_ = !in_header;
								} else {
									_tmp16_ = FALSE;
								}
								if (_tmp16_) {
									if (!in_title) {
										const gchar* _tmp20_;
										const gchar* _tmp21_;
										gchar* _tmp22_;
										gchar* _tmp23_;
										gchar* _tmp24_;
										gchar* _tmp25_;
										GRegex* _tmp26_;
										const gchar* _tmp27_;
										GMatchInfo* _tmp28_ = NULL;
										gboolean _tmp29_;
										const gchar* _tmp46_;
										const gchar* _tmp50_;
										gchar* _tmp54_;
										_tmp20_ = line;
										_tmp21_ = line;
										_tmp22_ = string_chug (_tmp21_);
										_tmp23_ = _tmp22_;
										prefix = g_utf8_strlen (_tmp20_, (gssize) -1) - g_utf8_strlen (_tmp23_, (gssize) -1);
										_g_free0 (_tmp23_);
										_tmp24_ = g_strdup ("");
										_g_free0 (end_shape);
										end_shape = _tmp24_;
										_tmp25_ = g_strdup ("underlined");
										_g_free0 (border);
										border = _tmp25_;
										_tmp26_ = start_re;
										_tmp27_ = stripped;
										_tmp29_ = g_regex_match (_tmp26_, _tmp27_, 0, &_tmp28_);
										_g_match_info_unref0 (match_info);
										match_info = _tmp28_;
										if (_tmp29_) {
											GMatchInfo* _tmp30_;
											gchar* _tmp31_;
											gchar* _tmp32_;
											GQuark _tmp34_ = 0U;
											static GQuark _tmp33_label0 = 0;
											static GQuark _tmp33_label1 = 0;
											static GQuark _tmp33_label2 = 0;
											static GQuark _tmp33_label3 = 0;
											static GQuark _tmp33_label4 = 0;
											static GQuark _tmp33_label5 = 0;
											GMatchInfo* _tmp44_;
											gchar* _tmp45_;
											_tmp30_ = match_info;
											_tmp31_ = g_match_info_fetch (_tmp30_, 2);
											_tmp32_ = _tmp31_;
											_tmp34_ = (NULL == _tmp32_) ? 0 : g_quark_from_string (_tmp32_);
											g_free (_tmp32_);
											if (_tmp34_ == ((0 != _tmp33_label0) ? _tmp33_label0 : (_tmp33_label0 = g_quark_from_static_string ("(")))) {
												switch (0) {
													default:
													{
														gchar* _tmp35_;
														gchar* _tmp36_;
														_tmp35_ = g_strdup (")");
														_g_free0 (end_shape);
														end_shape = _tmp35_;
														_tmp36_ = g_strdup ("rounded");
														_g_free0 (border);
														border = _tmp36_;
														break;
													}
												}
											} else if (_tmp34_ == ((0 != _tmp33_label1) ? _tmp33_label1 : (_tmp33_label1 = g_quark_from_static_string ("[")))) {
												switch (0) {
													default:
													{
														gchar* _tmp37_;
														gchar* _tmp38_;
														_tmp37_ = g_strdup ("]");
														_g_free0 (end_shape);
														end_shape = _tmp37_;
														_tmp38_ = g_strdup ("squared");
														_g_free0 (border);
														border = _tmp38_;
														break;
													}
												}
											} else if (_tmp34_ == ((0 != _tmp33_label2) ? _tmp33_label2 : (_tmp33_label2 = g_quark_from_static_string ("((")))) {
												switch (0) {
													default:
													{
														gchar* _tmp39_;
														gchar* _tmp40_;
														_tmp39_ = g_strdup ("))");
														_g_free0 (end_shape);
														end_shape = _tmp39_;
														_tmp40_ = g_strdup ("pilled");
														_g_free0 (border);
														border = _tmp40_;
														break;
													}
												}
											} else if (_tmp34_ == ((0 != _tmp33_label3) ? _tmp33_label3 : (_tmp33_label3 = g_quark_from_static_string ("))")))) {
												switch (0) {
													default:
													{
														gchar* _tmp41_;
														_tmp41_ = g_strdup ("((");
														_g_free0 (end_shape);
														end_shape = _tmp41_;
														break;
													}
												}
											} else if (_tmp34_ == ((0 != _tmp33_label4) ? _tmp33_label4 : (_tmp33_label4 = g_quark_from_static_string (")")))) {
												switch (0) {
													default:
													{
														gchar* _tmp42_;
														_tmp42_ = g_strdup ("(");
														_g_free0 (end_shape);
														end_shape = _tmp42_;
														break;
													}
												}
											} else if (_tmp34_ == ((0 != _tmp33_label5) ? _tmp33_label5 : (_tmp33_label5 = g_quark_from_static_string ("{{")))) {
												switch (0) {
													default:
													{
														gchar* _tmp43_;
														_tmp43_ = g_strdup ("}}");
														_g_free0 (end_shape);
														end_shape = _tmp43_;
														break;
													}
												}
											}
											_tmp44_ = match_info;
											_tmp45_ = g_match_info_fetch (_tmp44_, 3);
											_g_free0 (stripped);
											stripped = _tmp45_;
										}
										_tmp46_ = stripped;
										quoted = g_str_has_prefix (_tmp46_, "\"");
										if (quoted) {
											gint start = 0;
											const gchar* _tmp47_;
											const gchar* _tmp48_;
											gchar* _tmp49_;
											_tmp47_ = stripped;
											start = string_index_of_nth_char (_tmp47_, (glong) 1);
											_tmp48_ = stripped;
											_tmp49_ = string_substring (_tmp48_, (glong) start, (glong) -1);
											_g_free0 (stripped);
											stripped = _tmp49_;
										}
										_tmp50_ = stripped;
										markdown = g_str_has_prefix (_tmp50_, "`");
										if (markdown) {
											gint start = 0;
											const gchar* _tmp51_;
											const gchar* _tmp52_;
											gchar* _tmp53_;
											_tmp51_ = stripped;
											start = string_index_of_nth_char (_tmp51_, (glong) 1);
											_tmp52_ = stripped;
											_tmp53_ = string_substring (_tmp52_, (glong) start, (glong) -1);
											_g_free0 (stripped);
											stripped = _tmp53_;
										}
										_tmp54_ = g_strdup ("");
										_g_free0 (title);
										title = _tmp54_;
										in_title = TRUE;
									}
									if (in_title) {
										gboolean _tmp55_ = FALSE;
										const gchar* _tmp56_;
										_tmp56_ = end_shape;
										if (g_strcmp0 (_tmp56_, "") != 0) {
											const gchar* _tmp57_;
											const gchar* _tmp58_;
											_tmp57_ = stripped;
											_tmp58_ = end_shape;
											_tmp55_ = g_str_has_suffix (_tmp57_, _tmp58_);
										} else {
											_tmp55_ = FALSE;
										}
										if (_tmp55_) {
											const gchar* _tmp59_;
											const gchar* _tmp60_;
											gint _tmp61_;
											gint _tmp62_;
											const gchar* _tmp63_;
											gint _tmp64_;
											gint _tmp65_;
											gchar* _tmp66_;
											_tmp59_ = stripped;
											_tmp60_ = stripped;
											_tmp61_ = strlen (_tmp60_);
											_tmp62_ = _tmp61_;
											_tmp63_ = end_shape;
											_tmp64_ = strlen (_tmp63_);
											_tmp65_ = _tmp64_;
											_tmp66_ = string_substring (_tmp59_, (glong) 0, (glong) (_tmp62_ - _tmp65_));
											_g_free0 (stripped);
											stripped = _tmp66_;
											in_title = FALSE;
										}
										if (quoted) {
											const gchar* _tmp67_;
											const gchar* _tmp84_;
											const gchar* _tmp85_;
											gchar* _tmp86_;
											gchar* _tmp87_;
											gchar* _tmp88_;
											_tmp67_ = stripped;
											if (g_str_has_suffix (_tmp67_, "\"")) {
												const gchar* _tmp68_;
												const gchar* _tmp69_;
												gint _tmp70_;
												gint _tmp71_;
												gint _tmp72_;
												gint _tmp73_;
												gchar* _tmp74_;
												gboolean _tmp75_ = FALSE;
												_tmp68_ = stripped;
												_tmp69_ = stripped;
												_tmp70_ = strlen (_tmp69_);
												_tmp71_ = _tmp70_;
												_tmp72_ = strlen ("\"");
												_tmp73_ = _tmp72_;
												_tmp74_ = string_substring (_tmp68_, (glong) 0, (glong) (_tmp71_ - _tmp73_));
												_g_free0 (stripped);
												stripped = _tmp74_;
												if (markdown) {
													const gchar* _tmp76_;
													_tmp76_ = stripped;
													_tmp75_ = g_str_has_suffix (_tmp76_, "`");
												} else {
													_tmp75_ = FALSE;
												}
												if (_tmp75_) {
													const gchar* _tmp77_;
													const gchar* _tmp78_;
													gint _tmp79_;
													gint _tmp80_;
													gint _tmp81_;
													gint _tmp82_;
													gchar* _tmp83_;
													_tmp77_ = stripped;
													_tmp78_ = stripped;
													_tmp79_ = strlen (_tmp78_);
													_tmp80_ = _tmp79_;
													_tmp81_ = strlen ("`");
													_tmp82_ = _tmp81_;
													_tmp83_ = string_substring (_tmp77_, (glong) 0, (glong) (_tmp80_ - _tmp82_));
													_g_free0 (stripped);
													stripped = _tmp83_;
												}
												in_title = FALSE;
											}
											_tmp84_ = title;
											_tmp85_ = stripped;
											_tmp86_ = g_strconcat ("\n", _tmp85_, NULL);
											_tmp87_ = _tmp86_;
											_tmp88_ = g_strconcat (_tmp84_, _tmp87_, NULL);
											_g_free0 (title);
											title = _tmp88_;
											_g_free0 (_tmp87_);
										} else {
											gboolean _tmp89_ = FALSE;
											const gchar* _tmp98_;
											gchar* _tmp99_;
											if (markdown) {
												const gchar* _tmp90_;
												_tmp90_ = stripped;
												_tmp89_ = g_str_has_suffix (_tmp90_, "`");
											} else {
												_tmp89_ = FALSE;
											}
											if (_tmp89_) {
												const gchar* _tmp91_;
												const gchar* _tmp92_;
												gint _tmp93_;
												gint _tmp94_;
												gint _tmp95_;
												gint _tmp96_;
												gchar* _tmp97_;
												_tmp91_ = stripped;
												_tmp92_ = stripped;
												_tmp93_ = strlen (_tmp92_);
												_tmp94_ = _tmp93_;
												_tmp95_ = strlen ("`");
												_tmp96_ = _tmp95_;
												_tmp97_ = string_substring (_tmp91_, (glong) 0, (glong) (_tmp94_ - _tmp96_));
												_g_free0 (stripped);
												stripped = _tmp97_;
											}
											_tmp98_ = stripped;
											_tmp99_ = g_strdup (_tmp98_);
											_g_free0 (title);
											title = _tmp99_;
											in_title = FALSE;
										}
									}
									if (!in_title) {
										Node* parent = NULL;
										GArray* _tmp100_;
										Node* _tmp101_;
										Node* node = NULL;
										const gchar* _tmp102_;
										gchar* _tmp103_;
										gchar* _tmp104_;
										gchar* _tmp105_;
										Node* _tmp106_;
										Node* _tmp124_;
										Style* _tmp125_;
										Style* _tmp126_;
										Styles* _tmp127_;
										const gchar* _tmp128_;
										NodeBorder* _tmp129_;
										NodeBorder* _tmp130_;
										Node* _tmp131_;
										Style* _tmp132_;
										Style* _tmp133_;
										GArray* _tmp134_;
										Node* _tmp135_;
										ExportMermaidNodeHier* _tmp136_;
										_tmp100_ = stack;
										_tmp101_ = export_mermaid_get_parent (self, _tmp100_, prefix);
										parent = _tmp101_;
										_tmp102_ = title;
										_tmp103_ = string_chug (_tmp102_);
										_tmp104_ = _tmp103_;
										_tmp105_ = string_replace (_tmp104_, "<br/>", "\n");
										_g_free0 (title);
										title = _tmp105_;
										_g_free0 (_tmp104_);
										_tmp106_ = parent;
										if (_tmp106_ == NULL) {
											MapModel* _tmp107_;
											MapModel* _tmp108_;
											const gchar* _tmp109_;
											Node* _tmp110_;
											_tmp107_ = mind_map_get_model (map);
											_tmp108_ = _tmp107_;
											_tmp109_ = title;
											_tmp110_ = map_model_create_root_node (_tmp108_, _tmp109_);
											_g_object_unref0 (node);
											node = _tmp110_;
										} else {
											Node* _tmp111_;
											Node* _tmp112_;
											Node* _tmp113_;
											_tmp111_ = parent;
											_tmp112_ = node_get_parent (_tmp111_);
											_tmp113_ = _tmp112_;
											if (_tmp113_ == NULL) {
												MapModel* _tmp114_;
												MapModel* _tmp115_;
												Node* _tmp116_;
												const gchar* _tmp117_;
												Node* _tmp118_;
												_tmp114_ = mind_map_get_model (map);
												_tmp115_ = _tmp114_;
												_tmp116_ = parent;
												_tmp117_ = title;
												_tmp118_ = map_model_create_main_node (_tmp115_, _tmp116_, NODE_SIDE_RIGHT, _tmp117_);
												_g_object_unref0 (node);
												node = _tmp118_;
											} else {
												MapModel* _tmp119_;
												MapModel* _tmp120_;
												Node* _tmp121_;
												const gchar* _tmp122_;
												Node* _tmp123_;
												_tmp119_ = mind_map_get_model (map);
												_tmp120_ = _tmp119_;
												_tmp121_ = parent;
												_tmp122_ = title;
												_tmp123_ = map_model_create_child_node (_tmp120_, _tmp121_, _tmp122_);
												_g_object_unref0 (node);
												node = _tmp123_;
											}
										}
										_tmp124_ = node;
										_tmp125_ = node_get_style (_tmp124_);
										_tmp126_ = _tmp125_;
										_tmp127_ = style_inspector_styles;
										_tmp128_ = border;
										_tmp129_ = styles_get_node_border (_tmp127_, _tmp128_);
										_tmp130_ = _tmp129_;
										style_set_node_border (_tmp126_, _tmp130_);
										_g_object_unref0 (_tmp130_);
										_tmp131_ = node;
										_tmp132_ = node_get_style (_tmp131_);
										_tmp133_ = _tmp132_;
										style_set_node_markup (_tmp133_, &markdown);
										_tmp134_ = stack;
										_tmp135_ = node;
										_tmp136_ = export_mermaid_node_hier_new (_tmp135_, prefix);
										g_array_append_val (_tmp134_, _tmp136_);
										_g_object_unref0 (node);
										_g_object_unref0 (parent);
									}
								}
							}
						}
					}
					_g_free0 (stripped);
					_g_match_info_unref0 (match_info);
					_g_free0 (line);
				}
			}
		}
		_g_free0 (title);
		_g_free0 (border);
		_g_free0 (end_shape);
		_g_regex_unref0 (start_re);
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		result = FALSE;
		_g_array_unref0 (stack);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp137_ = FALSE;
		_g_array_unref0 (stack);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp137_;
	}
	_tmp138_ = stack;
	result = _tmp138_->len > ((guint) 0);
	_g_array_unref0 (stack);
	return result;
}

static gpointer
vala_g_array_remove_index (GArray* self,
                           guint index)
{
	gpointer g = NULL;
	gpointer* _tmp0_;
	gint _tmp0__length1;
	gpointer _tmp1_;
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	_vala_assert (self->len > index, "length > index");
	_tmp0_ = self->data;
	_tmp0__length1 = self->len;
	_tmp1_ = _tmp0_[index];
	_tmp0_[index] = NULL;
	g = _tmp1_;
	g_array_remove_index (self, index);
	result = g;
	return result;
}

static Node*
export_mermaid_get_parent (ExportMermaid* self,
                           GArray* stack,
                           gint prefix)
{
	gint last = 0;
	Node* _tmp6_ = NULL;
	Node* _tmp10_;
	Node* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stack != NULL, NULL);
	last = (gint) (stack->len - 1);
	while (TRUE) {
		gboolean _tmp0_ = FALSE;
		ExportMermaidNodeHier* _tmp4_;
		ExportMermaidNodeHier* _tmp5_;
		if (last >= 0) {
			ExportMermaidNodeHier* _tmp1_;
			gint _tmp2_;
			gint _tmp3_;
			_tmp1_ = g_array_index (stack, ExportMermaidNodeHier*, (guint) last);
			_tmp2_ = export_mermaid_node_hier_get_prefix (_tmp1_);
			_tmp3_ = _tmp2_;
			_tmp0_ = prefix <= _tmp3_;
		} else {
			_tmp0_ = FALSE;
		}
		if (!_tmp0_) {
			break;
		}
		_tmp4_ = vala_g_array_remove_index (stack, (guint) last);
		_tmp5_ = _tmp4_;
		_export_mermaid_node_hier_unref0 (_tmp5_);
		last = (gint) (stack->len - 1);
	}
	if (stack->len == ((guint) 0)) {
		_tmp6_ = NULL;
	} else {
		ExportMermaidNodeHier* _tmp7_;
		Node* _tmp8_;
		Node* _tmp9_;
		_tmp7_ = g_array_index (stack, ExportMermaidNodeHier*, (guint) last);
		_tmp8_ = export_mermaid_node_hier_get_node (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp6_ = _tmp9_;
	}
	_tmp10_ = _g_object_ref0 (_tmp6_);
	result = _tmp10_;
	return result;
}

static void
export_mermaid_real_add_settings (Export* base,
                                  GtkGrid* grid)
{
	ExportMermaid * self;
	self = (ExportMermaid*) base;
	g_return_if_fail (grid != NULL);
	export_add_setting_bool ((Export*) self, "mindmap", grid, _ ("Use Mermaid Mindmap Format"), NULL, FALSE);
}

static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static void
export_mermaid_real_save_settings (Export* base,
                                   xmlNode* node)
{
	ExportMermaid * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	self = (ExportMermaid*) base;
	_tmp0_ = bool_to_string (export_get_bool ((Export*) self, "mindmap"));
	_tmp1_ = _tmp0_;
	xmlSetProp (node, (xmlChar*) "mindmap", (xmlChar*) _tmp1_);
	_g_free0 (_tmp1_);
}

static gboolean
bool_parse (const gchar* str)
{
	gboolean result;
	g_return_val_if_fail (str != NULL, FALSE);
	if (g_strcmp0 (str, "true") == 0) {
		result = TRUE;
		return result;
	} else {
		result = FALSE;
		return result;
	}
}

static void
export_mermaid_real_load_settings (Export* base,
                                   xmlNode* node)
{
	ExportMermaid * self;
	gchar* mm = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	self = (ExportMermaid*) base;
	_tmp0_ = (gchar*) xmlGetProp (node, (xmlChar*) "mindmap");
	mm = _tmp0_;
	_tmp1_ = mm;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		_tmp2_ = mm;
		export_set_bool ((Export*) self, "mindmap", bool_parse (_tmp2_));
	}
	_g_free0 (mm);
}

static inline gpointer
export_mermaid_node_hier_get_instance_private (ExportMermaidNodeHier* self)
{
	return G_STRUCT_MEMBER_P (self, ExportMermaidNodeHier_private_offset);
}

ExportMermaidNodeHier*
export_mermaid_node_hier_construct (GType object_type,
                                    Node* n,
                                    gint p)
{
	ExportMermaidNodeHier* self = NULL;
	g_return_val_if_fail (n != NULL, NULL);
	self = (ExportMermaidNodeHier*) g_type_create_instance (object_type);
	export_mermaid_node_hier_set_node (self, n);
	export_mermaid_node_hier_set_prefix (self, p);
	return self;
}

ExportMermaidNodeHier*
export_mermaid_node_hier_new (Node* n,
                              gint p)
{
	return export_mermaid_node_hier_construct (EXPORT_MERMAID_TYPE_NODE_HIER, n, p);
}

Node*
export_mermaid_node_hier_get_node (ExportMermaidNodeHier* self)
{
	Node* result;
	Node* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_node;
	result = _tmp0_;
	return result;
}

void
export_mermaid_node_hier_set_node (ExportMermaidNodeHier* self,
                                   Node* value)
{
	Node* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_node);
	self->priv->_node = _tmp0_;
}

gint
export_mermaid_node_hier_get_prefix (ExportMermaidNodeHier* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_prefix;
	return result;
}

void
export_mermaid_node_hier_set_prefix (ExportMermaidNodeHier* self,
                                     gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_prefix = value;
}

static void
export_mermaid_value_node_hier_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
export_mermaid_value_node_hier_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		export_mermaid_node_hier_unref (value->data[0].v_pointer);
	}
}

static void
export_mermaid_value_node_hier_copy_value (const GValue* src_value,
                                           GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = export_mermaid_node_hier_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
export_mermaid_value_node_hier_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
export_mermaid_value_node_hier_collect_value (GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		ExportMermaidNodeHier * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = export_mermaid_node_hier_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
export_mermaid_value_node_hier_lcopy_value (const GValue* value,
                                            guint n_collect_values,
                                            GTypeCValue* collect_values,
                                            guint collect_flags)
{
	ExportMermaidNodeHier ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = export_mermaid_node_hier_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
export_mermaid_param_spec_node_hier (const gchar* name,
                                     const gchar* nick,
                                     const gchar* blurb,
                                     GType object_type,
                                     GParamFlags flags)
{
	ExportMermaidParamSpecNodeHier* spec;
	g_return_val_if_fail (g_type_is_a (object_type, EXPORT_MERMAID_TYPE_NODE_HIER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
export_mermaid_value_get_node_hier (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EXPORT_MERMAID_TYPE_NODE_HIER), NULL);
	return value->data[0].v_pointer;
}

void
export_mermaid_value_set_node_hier (GValue* value,
                                    gpointer v_object)
{
	ExportMermaidNodeHier * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EXPORT_MERMAID_TYPE_NODE_HIER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EXPORT_MERMAID_TYPE_NODE_HIER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		export_mermaid_node_hier_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		export_mermaid_node_hier_unref (old);
	}
}

void
export_mermaid_value_take_node_hier (GValue* value,
                                     gpointer v_object)
{
	ExportMermaidNodeHier * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EXPORT_MERMAID_TYPE_NODE_HIER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EXPORT_MERMAID_TYPE_NODE_HIER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		export_mermaid_node_hier_unref (old);
	}
}

static void
export_mermaid_node_hier_class_init (ExportMermaidNodeHierClass * klass,
                                     gpointer klass_data)
{
	export_mermaid_node_hier_parent_class = g_type_class_peek_parent (klass);
	((ExportMermaidNodeHierClass *) klass)->finalize = export_mermaid_node_hier_finalize;
	g_type_class_adjust_private_offset (klass, &ExportMermaidNodeHier_private_offset);
}

static void
export_mermaid_node_hier_instance_init (ExportMermaidNodeHier * self,
                                        gpointer klass)
{
	self->priv = export_mermaid_node_hier_get_instance_private (self);
	self->priv->_prefix = 0;
	self->ref_count = 1;
}

static void
export_mermaid_node_hier_finalize (ExportMermaidNodeHier * obj)
{
	ExportMermaidNodeHier * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EXPORT_MERMAID_TYPE_NODE_HIER, ExportMermaidNodeHier);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_node);
}

static GType
export_mermaid_node_hier_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { export_mermaid_value_node_hier_init, export_mermaid_value_node_hier_free_value, export_mermaid_value_node_hier_copy_value, export_mermaid_value_node_hier_peek_pointer, "p", export_mermaid_value_node_hier_collect_value, "p", export_mermaid_value_node_hier_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (ExportMermaidNodeHierClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) export_mermaid_node_hier_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ExportMermaidNodeHier), 0, (GInstanceInitFunc) export_mermaid_node_hier_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType export_mermaid_node_hier_type_id;
	export_mermaid_node_hier_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ExportMermaidNodeHier", &g_define_type_info, &g_define_type_fundamental_info, 0);
	ExportMermaidNodeHier_private_offset = g_type_add_instance_private (export_mermaid_node_hier_type_id, sizeof (ExportMermaidNodeHierPrivate));
	return export_mermaid_node_hier_type_id;
}

GType
export_mermaid_node_hier_get_type (void)
{
	static volatile gsize export_mermaid_node_hier_type_id__once = 0;
	if (g_once_init_enter (&export_mermaid_node_hier_type_id__once)) {
		GType export_mermaid_node_hier_type_id;
		export_mermaid_node_hier_type_id = export_mermaid_node_hier_get_type_once ();
		g_once_init_leave (&export_mermaid_node_hier_type_id__once, export_mermaid_node_hier_type_id);
	}
	return export_mermaid_node_hier_type_id__once;
}

gpointer
export_mermaid_node_hier_ref (gpointer instance)
{
	ExportMermaidNodeHier * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
export_mermaid_node_hier_unref (gpointer instance)
{
	ExportMermaidNodeHier * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		EXPORT_MERMAID_NODE_HIER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
export_mermaid_class_init (ExportMermaidClass * klass,
                           gpointer klass_data)
{
	export_mermaid_parent_class = g_type_class_peek_parent (klass);
	((ExportClass *) klass)->export = (gboolean (*) (Export*, const gchar*, MindMap*)) export_mermaid_real_export;
	((ExportClass *) klass)->import = (gboolean (*) (Export*, const gchar*, MindMap*)) export_mermaid_real_import;
	((ExportClass *) klass)->add_settings = (void (*) (Export*, GtkGrid*)) export_mermaid_real_add_settings;
	((ExportClass *) klass)->save_settings = (void (*) (Export*, xmlNode*)) export_mermaid_real_save_settings;
	((ExportClass *) klass)->load_settings = (void (*) (Export*, xmlNode*)) export_mermaid_real_load_settings;
}

static void
export_mermaid_instance_init (ExportMermaid * self,
                              gpointer klass)
{
}

static GType
export_mermaid_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ExportMermaidClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) export_mermaid_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ExportMermaid), 0, (GInstanceInitFunc) export_mermaid_instance_init, NULL };
	GType export_mermaid_type_id;
	export_mermaid_type_id = g_type_register_static (TYPE_EXPORT, "ExportMermaid", &g_define_type_info, 0);
	return export_mermaid_type_id;
}

GType
export_mermaid_get_type (void)
{
	static volatile gsize export_mermaid_type_id__once = 0;
	if (g_once_init_enter (&export_mermaid_type_id__once)) {
		GType export_mermaid_type_id;
		export_mermaid_type_id = export_mermaid_get_type_once ();
		g_once_init_leave (&export_mermaid_type_id__once, export_mermaid_type_id);
	}
	return export_mermaid_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

