/* ExportOPML.c generated by valac 0.56.19, the Vala compiler
 * generated from ExportOPML.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 <libxml/parser.h>
#include <float.h>
#include <math.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_OPML (export_opml_get_type ())
#define EXPORT_OPML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXPORT_OPML, ExportOPML))
#define EXPORT_OPML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXPORT_OPML, ExportOPMLClass))
#define IS_EXPORT_OPML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXPORT_OPML))
#define IS_EXPORT_OPML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXPORT_OPML))
#define EXPORT_OPML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXPORT_OPML, ExportOPMLClass))

typedef struct _ExportOPML ExportOPML;
typedef struct _ExportOPMLClass ExportOPMLClass;
typedef struct _ExportOPMLPrivate ExportOPMLPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmlFreeDoc0(var) ((var == NULL) ? NULL : (var = (xmlFreeDoc (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_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 _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_LAYOUTS (layouts_get_type ())
#define LAYOUTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LAYOUTS, Layouts))
#define LAYOUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LAYOUTS, LayoutsClass))
#define IS_LAYOUTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LAYOUTS))
#define IS_LAYOUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LAYOUTS))
#define LAYOUTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LAYOUTS, LayoutsClass))

typedef struct _Layouts Layouts;
typedef struct _LayoutsClass LayoutsClass;

#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_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_THEME (theme_get_type ())
#define THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEME, Theme))
#define THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEME, ThemeClass))
#define IS_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEME))
#define IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEME))
#define THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEME, ThemeClass))

typedef struct _Theme Theme;
typedef struct _ThemeClass ThemeClass;

#define TYPE_DRAW_AREA (draw_area_get_type ())
#define DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DRAW_AREA, DrawArea))
#define DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DRAW_AREA, DrawAreaClass))
#define IS_DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DRAW_AREA))
#define IS_DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DRAW_AREA))
#define DRAW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DRAW_AREA, DrawAreaClass))

typedef struct _DrawArea DrawArea;
typedef struct _DrawAreaClass DrawAreaClass;

#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_BOUNDS (node_bounds_get_type ())
#define NODE_BOUNDS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_BOUNDS, NodeBounds))
#define NODE_BOUNDS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE_BOUNDS, NodeBoundsClass))
#define IS_NODE_BOUNDS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_BOUNDS))
#define IS_NODE_BOUNDS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE_BOUNDS))
#define NODE_BOUNDS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE_BOUNDS, NodeBoundsClass))

typedef struct _NodeBounds NodeBounds;
typedef struct _NodeBoundsClass NodeBoundsClass;
#define _node_bounds_unref0(var) ((var == NULL) ? NULL : (var = (node_bounds_unref (var), NULL)))
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 _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 _ExportOPML {
	Export parent_instance;
	ExportOPMLPrivate * priv;
};

struct _ExportOPMLClass {
	ExportClass parent_class;
};

static gpointer export_opml_parent_class = NULL;
VALA_EXTERN gchar* minder_version;

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_opml_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ExportOPML, 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 ExportOPML* export_opml_new (void);
VALA_EXTERN ExportOPML* export_opml_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_opml_real_export (Export* base,
                                  const gchar* fname,
                                  MindMap* map);
static xmlNode* export_opml_export_body (ExportOPML* self,
                                  MindMap* map,
                                  gchar** expand_state);
static xmlNode* export_opml_export_head (ExportOPML* self,
                                  const gchar* title,
                                  const gchar* expand_state);
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)
VALA_EXTERN GArray* mind_map_get_nodes (MindMap* self);
static void export_opml_export_node (ExportOPML* self,
                              Node* node,
                              xmlNode* parent,
                              gint* node_id,
                              GArray** expand_state);
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 gboolean node_is_task (Node* self);
VALA_EXTERN gint node_get_done_count (Node* self);
VALA_EXTERN const gchar* node_get_note (Node* self);
VALA_EXTERN GArray* node_children (Node* self);
VALA_EXTERN gboolean node_get_folded (Node* self);
static gboolean export_opml_real_import (Export* base,
                                  const gchar* fname,
                                  MindMap* map);
static void export_opml_import_header (ExportOPML* self,
                                xmlNode* n,
                                GArray** expand_state);
static void export_opml_import_body (ExportOPML* self,
                              MindMap* map,
                              xmlNode* n,
                              GArray** expand_state);
VALA_EXTERN GType layouts_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Layouts, g_object_unref)
VALA_EXTERN Layouts* mind_map_get_layouts (MindMap* self);
VALA_EXTERN GType layout_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Layout, g_object_unref)
VALA_EXTERN Layout* layouts_get_default (Layouts* self);
VALA_EXTERN Node* node_new (MindMap* map,
                Layout* layout);
VALA_EXTERN Node* node_construct (GType object_type,
                      MindMap* map,
                      Layout* layout);
VALA_EXTERN GType theme_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Theme, g_object_unref)
static void export_opml_import_node (ExportOPML* self,
                              MindMap* map,
                              Node* node,
                              xmlNode* parent,
                              gint node_id,
                              GArray** expand_state,
                              Theme* theme);
VALA_EXTERN Theme* mind_map_get_theme (MindMap* self);
VALA_EXTERN GType draw_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DrawArea, g_object_unref)
VALA_EXTERN DrawArea* mind_map_get_canvas (MindMap* self);
VALA_EXTERN void node_set_posx (Node* self,
                    gdouble value);
VALA_EXTERN void node_set_posy (Node* self,
                    gdouble value);
VALA_EXTERN Layout* node_get_layout (Node* self);
VALA_EXTERN void layout_position_root (Layout* self,
                           Node* last,
                           Node* n);
VALA_EXTERN void formatted_text_insert_text (FormattedText* self,
                                 gint index,
                                 const gchar* str);
VALA_EXTERN void node_enable_task (Node* self,
                       gboolean task);
VALA_EXTERN void node_set_task_done (Node* self,
                         gboolean done);
VALA_EXTERN void node_set_note (Node* self,
                    const gchar* value);
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* mind_map_get_global_style (MindMap* self);
VALA_EXTERN void node_set_style (Node* self,
                     Style* value);
VALA_EXTERN void node_set_folded (Node* self,
                      gboolean value);
VALA_EXTERN void node_attach (Node* self,
                  Node* parent,
                  gint idx,
                  Theme* theme,
                  gboolean set_side);
VALA_EXTERN gpointer node_bounds_ref (gpointer instance);
VALA_EXTERN void node_bounds_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_node_bounds (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags);
VALA_EXTERN void value_set_node_bounds (GValue* value,
                            gpointer v_object);
VALA_EXTERN void value_take_node_bounds (GValue* value,
                             gpointer v_object);
VALA_EXTERN gpointer value_get_node_bounds (const GValue* value);
VALA_EXTERN GType node_bounds_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeBounds, node_bounds_unref)
VALA_EXTERN NodeBounds* layout_bbox (Layout* self,
                         Node* parent,
                         gint side_mask,
                         const gchar* msg);
VALA_EXTERN void node_set_tree_bbox (Node* self,
                         NodeBounds* value);
VALA_EXTERN GType node_side_get_type (void) G_GNUC_CONST ;
VALA_EXTERN NodeSide node_get_side (Node* self);
VALA_EXTERN gboolean node_side_horizontal (NodeSide self);
VALA_EXTERN NodeBounds* node_get_tree_bbox (Node* self);
VALA_EXTERN gdouble node_bounds_get_height (NodeBounds* self);
VALA_EXTERN gdouble node_bounds_get_width (NodeBounds* self);
VALA_EXTERN void node_set_tree_size (Node* self,
                         gdouble value);
static GType export_opml_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);

ExportOPML*
export_opml_construct (GType object_type)
{
	ExportOPML* self = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	_tmp0_ = g_strdup (".opml");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = 1;
	self = (ExportOPML*) export_construct (object_type, "opml", _ ("OPML"), _tmp2_, (gint) 1, TRUE, TRUE, FALSE, TRUE);
	_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
	return self;
}

ExportOPML*
export_opml_new (void)
{
	return export_opml_construct (TYPE_EXPORT_OPML);
}

static gboolean
export_opml_real_export (Export* base,
                         const gchar* fname,
                         MindMap* map)
{
	ExportOPML * self;
	xmlDoc* doc = NULL;
	xmlDoc* _tmp0_;
	xmlNode* opml = NULL;
	xmlNode* _tmp1_;
	gchar* expand_state = NULL;
	xmlNode* body = NULL;
	gchar* _tmp2_ = NULL;
	xmlNode* _tmp3_;
	xmlNode* _tmp4_;
	xmlNode* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	xmlNode* _tmp11_;
	xmlNode* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	xmlNode* _tmp16_;
	xmlNode* _tmp17_;
	xmlNode* _tmp18_;
	xmlDoc* _tmp19_;
	xmlNode* _tmp20_;
	xmlDoc* _tmp26_;
	gboolean result;
	self = (ExportOPML*) base;
	g_return_val_if_fail (fname != NULL, FALSE);
	g_return_val_if_fail (map != NULL, FALSE);
	_tmp0_ = xmlNewDoc ((xmlChar*) "1.0");
	doc = _tmp0_;
	_tmp1_ = xmlNewNode (NULL, (xmlChar*) "opml");
	opml = _tmp1_;
	_tmp3_ = export_opml_export_body (self, map, &_tmp2_);
	_g_free0 (expand_state);
	expand_state = _tmp2_;
	body = _tmp3_;
	_tmp4_ = opml;
	xmlNewProp (_tmp4_, (xmlChar*) "version", (xmlChar*) "2.0");
	_tmp5_ = opml;
	_tmp6_ = g_strconcat (_ ("Generated by Minder"), " ", NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = minder_version;
	_tmp9_ = g_strconcat (_tmp7_, _tmp8_, NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = xmlNewComment ((xmlChar*) _tmp10_);
	xmlAddChild (_tmp5_, _tmp11_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp7_);
	_tmp12_ = opml;
	_tmp13_ = g_path_get_basename (fname);
	_tmp14_ = _tmp13_;
	_tmp15_ = expand_state;
	_tmp16_ = export_opml_export_head (self, _tmp14_, _tmp15_);
	xmlAddChild (_tmp12_, _tmp16_);
	_g_free0 (_tmp14_);
	_tmp17_ = opml;
	_tmp18_ = body;
	xmlAddChild (_tmp17_, _tmp18_);
	_tmp19_ = doc;
	_tmp20_ = opml;
	xmlDocSetRootElement (_tmp19_, _tmp20_);
	if (export_send_to_clipboard ((Export*) self)) {
		gchar* text = NULL;
		gchar* _tmp21_;
		xmlDoc* _tmp22_;
		gchar* _tmp23_ = NULL;
		const gchar* _tmp24_;
		_tmp21_ = g_strdup ("");
		text = _tmp21_;
		_tmp22_ = doc;
		xmlDocDumpFormatMemory (_tmp22_, (xmlChar*) (&_tmp23_), NULL, TRUE);
		_g_free0 (text);
		text = _tmp23_;
		_tmp24_ = text;
		minder_clipboard_copy_text (_tmp24_);
		_g_free0 (text);
	} else {
		xmlDoc* _tmp25_;
		_tmp25_ = doc;
		xmlSaveFormatFile (fname, _tmp25_, 1);
	}
	_tmp26_ = doc;
	_xmlFreeDoc0 (_tmp26_);
	result = TRUE;
	_g_free0 (expand_state);
	return result;
}

static gchar*
g_date_time_to_string (GDateTime* self)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_date_time_format (self, "%FT%H:%M:%S%z");
	result = _tmp0_;
	return result;
}

static xmlNode*
export_opml_export_head (ExportOPML* self,
                         const gchar* title,
                         const gchar* expand_state)
{
	xmlNode* head = NULL;
	xmlNode* _tmp0_;
	GDateTime* now = NULL;
	GDateTime* _tmp1_;
	const gchar* _tmp2_ = NULL;
	xmlNode* _tmp3_;
	xmlNode* _tmp4_;
	GDateTime* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	xmlNode* _tmp9_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (expand_state != NULL, NULL);
	_tmp0_ = xmlNewNode (NULL, (xmlChar*) "head");
	head = _tmp0_;
	_tmp1_ = g_date_time_new_now_local ();
	now = _tmp1_;
	_tmp2_ = title;
	if (_tmp2_ == NULL) {
		_tmp2_ = "Mind Map";
	}
	_tmp3_ = head;
	xmlNewTextChild (_tmp3_, NULL, (xmlChar*) "title", (xmlChar*) _tmp2_);
	_tmp4_ = head;
	_tmp5_ = now;
	_tmp6_ = g_date_time_to_string (_tmp5_);
	_tmp7_ = _tmp6_;
	xmlNewTextChild (_tmp4_, NULL, (xmlChar*) "dateCreated", (xmlChar*) _tmp7_);
	_g_free0 (_tmp7_);
	if (g_strcmp0 (expand_state, "") != 0) {
		xmlNode* _tmp8_;
		_tmp8_ = head;
		xmlNewTextChild (_tmp8_, NULL, (xmlChar*) "expansionState", (xmlChar*) expand_state);
	}
	_tmp9_ = head;
	result = _tmp9_;
	_g_date_time_unref0 (now);
	return result;
}

static xmlNode*
export_opml_export_body (ExportOPML* self,
                         MindMap* map,
                         gchar** expand_state)
{
	gchar* _vala_expand_state = NULL;
	xmlNode* body = NULL;
	xmlNode* _tmp0_;
	GArray* estate = NULL;
	GArray* _tmp1_;
	gint node_id = 0;
	gchar* _tmp11_;
	xmlNode* _tmp22_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (map != NULL, NULL);
	_tmp0_ = xmlNewNode (NULL, (xmlChar*) "body");
	body = _tmp0_;
	_tmp1_ = g_array_new (TRUE, TRUE, sizeof (gint));
	estate = _tmp1_;
	node_id = 1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				GArray* _tmp4_;
				GArray* _tmp5_;
				gboolean _tmp6_;
				GArray* _tmp7_;
				GArray* _tmp8_;
				Node* _tmp9_;
				xmlNode* _tmp10_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = mind_map_get_nodes (map);
				_tmp5_ = _tmp4_;
				_tmp6_ = !(((guint) i) < _tmp5_->len);
				_g_array_unref0 (_tmp5_);
				if (_tmp6_) {
					break;
				}
				_tmp7_ = mind_map_get_nodes (map);
				_tmp8_ = _tmp7_;
				_tmp9_ = g_array_index (_tmp8_, Node*, (guint) i);
				_tmp10_ = body;
				export_opml_export_node (self, _tmp9_, _tmp10_, &node_id, &estate);
				_g_array_unref0 (_tmp8_);
			}
		}
	}
	_tmp11_ = g_strdup ("");
	_g_free0 (_vala_expand_state);
	_vala_expand_state = _tmp11_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp12_ = FALSE;
			_tmp12_ = TRUE;
			while (TRUE) {
				GArray* _tmp14_;
				const gchar* _tmp17_;
				GArray* _tmp18_;
				gchar* _tmp19_;
				gchar* _tmp20_;
				gchar* _tmp21_;
				if (!_tmp12_) {
					gint _tmp13_;
					_tmp13_ = i;
					i = _tmp13_ + 1;
				}
				_tmp12_ = FALSE;
				_tmp14_ = estate;
				if (!(((guint) i) < _tmp14_->len)) {
					break;
				}
				if (i > 0) {
					const gchar* _tmp15_;
					gchar* _tmp16_;
					_tmp15_ = _vala_expand_state;
					_tmp16_ = g_strconcat (_tmp15_, ",", NULL);
					_g_free0 (_vala_expand_state);
					_vala_expand_state = _tmp16_;
				}
				_tmp17_ = _vala_expand_state;
				_tmp18_ = estate;
				_tmp19_ = g_strdup_printf ("%i", g_array_index (_tmp18_, gint, (guint) i));
				_tmp20_ = _tmp19_;
				_tmp21_ = g_strconcat (_tmp17_, _tmp20_, NULL);
				_g_free0 (_vala_expand_state);
				_vala_expand_state = _tmp21_;
				_g_free0 (_tmp20_);
			}
		}
	}
	_tmp22_ = body;
	result = _tmp22_;
	_g_array_unref0 (estate);
	if (expand_state) {
		*expand_state = _vala_expand_state;
	} else {
		_g_free0 (_vala_expand_state);
	}
	return result;
}

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_opml_export_node (ExportOPML* self,
                         Node* node,
                         xmlNode* parent,
                         gint* node_id,
                         GArray** expand_state)
{
	xmlNode* outline = NULL;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	CanvasText* _tmp2_;
	CanvasText* _tmp3_;
	FormattedText* _tmp4_;
	FormattedText* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gboolean _tmp18_ = FALSE;
	GArray* _tmp19_;
	GArray* _tmp20_;
	gboolean _tmp21_;
	gint _tmp24_;
	xmlNode* _tmp34_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	g_return_if_fail (*expand_state != NULL);
	_tmp0_ = xmlNewNode (NULL, (xmlChar*) "outline");
	outline = _tmp0_;
	_tmp1_ = outline;
	_tmp2_ = node_get_name (node);
	_tmp3_ = _tmp2_;
	_tmp4_ = canvas_text_get_text (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = formatted_text_get_text (_tmp5_);
	_tmp7_ = _tmp6_;
	xmlNewProp (_tmp1_, (xmlChar*) "text", (xmlChar*) _tmp7_);
	if (node_is_task (node)) {
		gboolean checked = FALSE;
		gint _tmp8_;
		gint _tmp9_;
		xmlNode* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp8_ = node_get_done_count (node);
		_tmp9_ = _tmp8_;
		checked = _tmp9_ > 0;
		_tmp10_ = outline;
		_tmp11_ = bool_to_string (checked);
		_tmp12_ = _tmp11_;
		xmlNewProp (_tmp10_, (xmlChar*) "checked", (xmlChar*) _tmp12_);
		_g_free0 (_tmp12_);
	}
	_tmp13_ = node_get_note (node);
	_tmp14_ = _tmp13_;
	if (g_strcmp0 (_tmp14_, "") != 0) {
		xmlNode* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		_tmp15_ = outline;
		_tmp16_ = node_get_note (node);
		_tmp17_ = _tmp16_;
		xmlNewProp (_tmp15_, (xmlChar*) "note", (xmlChar*) _tmp17_);
	}
	_tmp19_ = node_children (node);
	_tmp20_ = _tmp19_;
	_tmp21_ = _tmp20_->len > ((guint) 1);
	_g_array_unref0 (_tmp20_);
	if (_tmp21_) {
		gboolean _tmp22_;
		gboolean _tmp23_;
		_tmp22_ = node_get_folded (node);
		_tmp23_ = _tmp22_;
		_tmp18_ = !_tmp23_;
	} else {
		_tmp18_ = FALSE;
	}
	if (_tmp18_) {
		g_array_append_val (*expand_state, *node_id);
	}
	_tmp24_ = *node_id;
	*node_id = _tmp24_ + 1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp25_ = FALSE;
			_tmp25_ = TRUE;
			while (TRUE) {
				GArray* _tmp27_;
				GArray* _tmp28_;
				gboolean _tmp29_;
				GArray* _tmp30_;
				GArray* _tmp31_;
				Node* _tmp32_;
				xmlNode* _tmp33_;
				if (!_tmp25_) {
					gint _tmp26_;
					_tmp26_ = i;
					i = _tmp26_ + 1;
				}
				_tmp25_ = FALSE;
				_tmp27_ = node_children (node);
				_tmp28_ = _tmp27_;
				_tmp29_ = !(((guint) i) < _tmp28_->len);
				_g_array_unref0 (_tmp28_);
				if (_tmp29_) {
					break;
				}
				_tmp30_ = node_children (node);
				_tmp31_ = _tmp30_;
				_tmp32_ = g_array_index (_tmp31_, Node*, (guint) i);
				_tmp33_ = outline;
				export_opml_export_node (self, _tmp32_, _tmp33_, node_id, expand_state);
				_g_array_unref0 (_tmp31_);
			}
		}
	}
	_tmp34_ = outline;
	xmlAddChild (parent, _tmp34_);
}

static gboolean
export_opml_real_import (Export* base,
                         const gchar* fname,
                         MindMap* map)
{
	ExportOPML * self;
	xmlDoc* doc = NULL;
	xmlDoc* _tmp0_;
	xmlDoc* _tmp1_;
	xmlDoc* _tmp17_;
	gboolean result;
	self = (ExportOPML*) base;
	g_return_val_if_fail (fname != NULL, FALSE);
	g_return_val_if_fail (map != NULL, FALSE);
	_tmp0_ = xmlReadFile (fname, NULL, (gint) XML_PARSE_HUGE);
	doc = _tmp0_;
	_tmp1_ = doc;
	if (_tmp1_ == NULL) {
		result = FALSE;
		return result;
	}
	{
		xmlNode* it = NULL;
		xmlDoc* _tmp2_;
		xmlNode* _tmp3_;
		xmlNode* _tmp4_;
		_tmp2_ = doc;
		_tmp3_ = xmlDocGetRootElement (_tmp2_);
		_tmp4_ = _tmp3_->children;
		it = _tmp4_;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp8_;
				xmlNode* _tmp9_;
				if (!_tmp5_) {
					xmlNode* _tmp6_;
					xmlNode* _tmp7_;
					_tmp6_ = it;
					_tmp7_ = _tmp6_->next;
					it = _tmp7_;
				}
				_tmp5_ = FALSE;
				_tmp8_ = it;
				if (!(_tmp8_ != NULL)) {
					break;
				}
				_tmp9_ = it;
				if (_tmp9_->type == XML_ELEMENT_NODE) {
					GArray* expand_state = NULL;
					xmlNode* _tmp10_;
					const gchar* _tmp11_;
					const gchar* _tmp12_;
					GQuark _tmp14_ = 0U;
					static GQuark _tmp13_label0 = 0;
					static GQuark _tmp13_label1 = 0;
					expand_state = NULL;
					_tmp10_ = it;
					_tmp11_ = _tmp10_->name;
					_tmp12_ = _tmp11_;
					_tmp14_ = (NULL == _tmp12_) ? 0 : g_quark_from_string (_tmp12_);
					if (_tmp14_ == ((0 != _tmp13_label0) ? _tmp13_label0 : (_tmp13_label0 = g_quark_from_static_string ("head")))) {
						switch (0) {
							default:
							{
								xmlNode* _tmp15_;
								_tmp15_ = it;
								export_opml_import_header (self, _tmp15_, &expand_state);
								break;
							}
						}
					} else if (_tmp14_ == ((0 != _tmp13_label1) ? _tmp13_label1 : (_tmp13_label1 = g_quark_from_static_string ("body")))) {
						switch (0) {
							default:
							{
								xmlNode* _tmp16_;
								_tmp16_ = it;
								export_opml_import_body (self, map, _tmp16_, &expand_state);
								break;
							}
						}
					}
					_g_array_unref0 (expand_state);
				}
			}
		}
	}
	_tmp17_ = doc;
	_xmlFreeDoc0 (_tmp17_);
	result = TRUE;
	return result;
}

static void
export_opml_import_header (ExportOPML* self,
                           xmlNode* n,
                           GArray** expand_state)
{
	g_return_if_fail (self != NULL);
	{
		xmlNode* it = NULL;
		xmlNode* _tmp0_;
		_tmp0_ = n->children;
		it = _tmp0_;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp4_;
				xmlNode* _tmp5_;
				if (!_tmp1_) {
					xmlNode* _tmp2_;
					xmlNode* _tmp3_;
					_tmp2_ = it;
					_tmp3_ = _tmp2_->next;
					it = _tmp3_;
				}
				_tmp1_ = FALSE;
				_tmp4_ = it;
				if (!(_tmp4_ != NULL)) {
					break;
				}
				_tmp5_ = it;
				if (_tmp5_->type == XML_ELEMENT_NODE) {
					xmlNode* _tmp6_;
					const gchar* _tmp7_;
					const gchar* _tmp8_;
					GQuark _tmp10_ = 0U;
					static GQuark _tmp9_label0 = 0;
					_tmp6_ = it;
					_tmp7_ = _tmp6_->name;
					_tmp8_ = _tmp7_;
					_tmp10_ = (NULL == _tmp8_) ? 0 : g_quark_from_string (_tmp8_);
					if (_tmp10_ == ((0 != _tmp9_label0) ? _tmp9_label0 : (_tmp9_label0 = g_quark_from_static_string ("expansionState")))) {
						switch (0) {
							default:
							{
								gboolean _tmp11_ = FALSE;
								xmlNode* _tmp12_;
								xmlNode* _tmp13_;
								_tmp12_ = it;
								_tmp13_ = _tmp12_->children;
								if (_tmp13_ != NULL) {
									xmlNode* _tmp14_;
									xmlNode* _tmp15_;
									_tmp14_ = it;
									_tmp15_ = _tmp14_->children;
									_tmp11_ = _tmp15_->type == XML_TEXT_NODE;
								} else {
									_tmp11_ = FALSE;
								}
								if (_tmp11_) {
									GArray* _tmp16_;
									gchar** values = NULL;
									xmlNode* _tmp17_;
									gchar* _tmp18_;
									gchar* _tmp19_;
									gchar** _tmp20_;
									gchar** _tmp21_;
									gchar** _tmp22_;
									gint _tmp22__length1;
									gint values_length1;
									gint _values_size_;
									gchar** _tmp23_;
									gint _tmp23__length1;
									_tmp16_ = g_array_new (TRUE, TRUE, sizeof (gint));
									_g_array_unref0 (*expand_state);
									*expand_state = _tmp16_;
									_tmp17_ = n->children;
									_tmp18_ = (gchar*) xmlNodeGetContent (_tmp17_);
									_tmp19_ = _tmp18_;
									_tmp21_ = _tmp20_ = g_strsplit (_tmp19_, ",", 0);
									_tmp22_ = _tmp21_;
									_tmp22__length1 = _vala_array_length (_tmp20_);
									_g_free0 (_tmp19_);
									values = _tmp22_;
									values_length1 = _tmp22__length1;
									_values_size_ = values_length1;
									_tmp23_ = values;
									_tmp23__length1 = values_length1;
									{
										gchar** val_collection = NULL;
										gint val_collection_length1 = 0;
										gint _val_collection_size_ = 0;
										gint val_it = 0;
										val_collection = _tmp23_;
										val_collection_length1 = _tmp23__length1;
										for (val_it = 0; val_it < val_collection_length1; val_it = val_it + 1) {
											gchar* _tmp24_;
											gchar* val = NULL;
											_tmp24_ = g_strdup (val_collection[val_it]);
											val = _tmp24_;
											{
												gint intval = 0;
												const gchar* _tmp25_;
												_tmp25_ = val;
												intval = atoi (_tmp25_);
												g_array_append_val (*expand_state, intval);
												_g_free0 (val);
											}
										}
									}
									values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
								}
								break;
							}
						}
					}
				}
			}
		}
	}
}

static gpointer*
vala_g_array_remove_range (GArray* self,
                           guint index,
                           guint length,
                           gint* result_length1)
{
	gpointer* ga = NULL;
	gpointer* _tmp0_;
	gint ga_length1;
	gint _ga_size_;
	gpointer* _tmp6_;
	gint _tmp6__length1;
	gpointer* result;
	g_return_val_if_fail (self != NULL, NULL);
	_vala_assert (self->len >= (index + length), "this.length >= index + length");
	_tmp0_ = g_new0 (gpointer, length);
	ga = _tmp0_;
	ga_length1 = length;
	_ga_size_ = ga_length1;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gpointer* _tmp3_;
				gint _tmp3__length1;
				gpointer* _tmp4_;
				gint _tmp4__length1;
				gpointer _tmp5_;
				if (!_tmp1_) {
					guint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < length)) {
					break;
				}
				_tmp3_ = ga;
				_tmp3__length1 = ga_length1;
				_tmp4_ = self->data;
				_tmp4__length1 = self->len;
				_tmp5_ = _tmp4_[i + index];
				_tmp4_[i + index] = NULL;
				_tmp3_[i] = _tmp5_;
			}
		}
	}
	g_array_remove_range (self, index, length);
	_tmp6_ = ga;
	_tmp6__length1 = ga_length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}

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

static void
export_opml_import_body (ExportOPML* self,
                         MindMap* map,
                         xmlNode* n,
                         GArray** expand_state)
{
	gint node_id = 0;
	GArray* _tmp0_;
	GArray* _tmp1_;
	GArray* _tmp2_;
	GArray* _tmp3_;
	gint _tmp4_ = 0;
	gpointer* _tmp5_;
	Node** _tmp6_;
	gint _tmp6__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	node_id = 1;
	_tmp0_ = mind_map_get_nodes (map);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_nodes (map);
	_tmp3_ = _tmp2_;
	_tmp5_ = vala_g_array_remove_range (_tmp1_, (guint) 0, _tmp3_->len, &_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp4_;
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_object_unref), NULL);
	_g_array_unref0 (_tmp3_);
	_g_array_unref0 (_tmp1_);
	{
		xmlNode* it = NULL;
		xmlNode* _tmp7_;
		_tmp7_ = n->children;
		it = _tmp7_;
		{
			gboolean _tmp8_ = FALSE;
			_tmp8_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp11_;
				xmlNode* _tmp12_;
				if (!_tmp8_) {
					xmlNode* _tmp9_;
					xmlNode* _tmp10_;
					_tmp9_ = it;
					_tmp10_ = _tmp9_->next;
					it = _tmp10_;
				}
				_tmp8_ = FALSE;
				_tmp11_ = it;
				if (!(_tmp11_ != NULL)) {
					break;
				}
				_tmp12_ = it;
				if (_tmp12_->type == XML_ELEMENT_NODE) {
					xmlNode* _tmp13_;
					const gchar* _tmp14_;
					_tmp13_ = it;
					_tmp14_ = _tmp13_->name;
					if (g_strcmp0 (_tmp14_, "outline") == 0) {
						Node* root = NULL;
						Layouts* _tmp15_;
						Layouts* _tmp16_;
						Layout* _tmp17_;
						Layout* _tmp18_;
						Node* _tmp19_;
						Node* _tmp20_;
						Node* _tmp21_;
						xmlNode* _tmp22_;
						Theme* _tmp23_;
						Theme* _tmp24_;
						GArray* _tmp25_;
						GArray* _tmp26_;
						gboolean _tmp27_;
						GArray* _tmp47_;
						GArray* _tmp48_;
						Node* _tmp49_;
						Node* _tmp50_;
						_tmp15_ = mind_map_get_layouts (map);
						_tmp16_ = _tmp15_;
						_tmp17_ = layouts_get_default (_tmp16_);
						_tmp18_ = _tmp17_;
						_tmp19_ = node_new (map, _tmp18_);
						_tmp20_ = _tmp19_;
						_g_object_unref0 (_tmp18_);
						root = _tmp20_;
						_tmp21_ = root;
						_tmp22_ = it;
						_tmp23_ = mind_map_get_theme (map);
						_tmp24_ = _tmp23_;
						export_opml_import_node (self, map, _tmp21_, _tmp22_, node_id, expand_state, _tmp24_);
						_g_object_unref0 (_tmp24_);
						_tmp25_ = mind_map_get_nodes (map);
						_tmp26_ = _tmp25_;
						_tmp27_ = _tmp26_->len == ((guint) 0);
						_g_array_unref0 (_tmp26_);
						if (_tmp27_) {
							Node* _tmp28_;
							DrawArea* _tmp29_;
							DrawArea* _tmp30_;
							Node* _tmp31_;
							DrawArea* _tmp32_;
							DrawArea* _tmp33_;
							_tmp28_ = root;
							_tmp29_ = mind_map_get_canvas (map);
							_tmp30_ = _tmp29_;
							node_set_posx (_tmp28_, (gdouble) ((gtk_widget_get_allocated_width ((GtkWidget*) _tmp30_) / 2) - 30));
							_tmp31_ = root;
							_tmp32_ = mind_map_get_canvas (map);
							_tmp33_ = _tmp32_;
							node_set_posy (_tmp31_, (gdouble) ((gtk_widget_get_allocated_height ((GtkWidget*) _tmp33_) / 2) - 10));
						} else {
							GArray* _tmp34_;
							GArray* _tmp35_;
							GArray* _tmp36_;
							GArray* _tmp37_;
							Node* _tmp38_;
							Layout* _tmp39_;
							Layout* _tmp40_;
							GArray* _tmp41_;
							GArray* _tmp42_;
							GArray* _tmp43_;
							GArray* _tmp44_;
							Node* _tmp45_;
							Node* _tmp46_;
							_tmp34_ = mind_map_get_nodes (map);
							_tmp35_ = _tmp34_;
							_tmp36_ = mind_map_get_nodes (map);
							_tmp37_ = _tmp36_;
							_tmp38_ = g_array_index (_tmp35_, Node*, _tmp37_->len - 1);
							_tmp39_ = node_get_layout (_tmp38_);
							_tmp40_ = _tmp39_;
							_tmp41_ = mind_map_get_nodes (map);
							_tmp42_ = _tmp41_;
							_tmp43_ = mind_map_get_nodes (map);
							_tmp44_ = _tmp43_;
							_tmp45_ = g_array_index (_tmp42_, Node*, _tmp44_->len - 1);
							_tmp46_ = root;
							layout_position_root (_tmp40_, _tmp45_, _tmp46_);
							_g_array_unref0 (_tmp44_);
							_g_array_unref0 (_tmp42_);
							_g_array_unref0 (_tmp37_);
							_g_array_unref0 (_tmp35_);
						}
						_tmp47_ = mind_map_get_nodes (map);
						_tmp48_ = _tmp47_;
						_tmp49_ = root;
						_tmp50_ = _g_object_ref0 (_tmp49_);
						g_array_append_val (_tmp48_, _tmp50_);
						_g_array_unref0 (_tmp48_);
						_g_object_unref0 (root);
					}
				}
			}
		}
	}
}

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 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 void
export_opml_import_node (ExportOPML* self,
                         MindMap* map,
                         Node* node,
                         xmlNode* parent,
                         gint node_id,
                         GArray** expand_state,
                         Theme* theme)
{
	gchar* n = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* t = NULL;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* o = NULL;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	Style* _tmp13_;
	Style* _tmp14_;
	gint _tmp17_;
	Layout* _tmp33_;
	Layout* _tmp34_;
	NodeBounds* _tmp35_;
	NodeBounds* _tmp36_;
	gdouble _tmp37_ = 0.0;
	NodeSide _tmp38_;
	NodeSide _tmp39_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	g_return_if_fail (node != NULL);
	g_return_if_fail (*expand_state != NULL);
	g_return_if_fail (theme != NULL);
	_tmp0_ = (gchar*) xmlGetProp (parent, (xmlChar*) "text");
	n = _tmp0_;
	_tmp1_ = n;
	if (_tmp1_ != NULL) {
		CanvasText* _tmp2_;
		CanvasText* _tmp3_;
		FormattedText* _tmp4_;
		FormattedText* _tmp5_;
		const gchar* _tmp6_;
		_tmp2_ = node_get_name (node);
		_tmp3_ = _tmp2_;
		_tmp4_ = canvas_text_get_text (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = n;
		formatted_text_insert_text (_tmp5_, 0, _tmp6_);
	}
	_tmp7_ = (gchar*) xmlGetProp (parent, (xmlChar*) "checked");
	t = _tmp7_;
	_tmp8_ = t;
	if (_tmp8_ != NULL) {
		const gchar* _tmp9_;
		node_enable_task (node, TRUE);
		_tmp9_ = t;
		if (bool_parse (_tmp9_)) {
			node_set_task_done (node, TRUE);
		}
	}
	_tmp10_ = (gchar*) xmlGetProp (parent, (xmlChar*) "note");
	o = _tmp10_;
	_tmp11_ = o;
	if (_tmp11_ != NULL) {
		const gchar* _tmp12_;
		_tmp12_ = o;
		node_set_note (node, _tmp12_);
	}
	_tmp13_ = mind_map_get_global_style (map);
	_tmp14_ = _tmp13_;
	node_set_style (node, _tmp14_);
	if ((*expand_state) != NULL) {
		node_set_folded (node, TRUE);
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp15_ = FALSE;
				_tmp15_ = TRUE;
				while (TRUE) {
					if (!_tmp15_) {
						gint _tmp16_;
						_tmp16_ = i;
						i = _tmp16_ + 1;
					}
					_tmp15_ = FALSE;
					if (!(((guint) i) < (*expand_state)->len)) {
						break;
					}
					if (g_array_index (*expand_state, gint, (guint) i) == node_id) {
						node_set_folded (node, FALSE);
						vala_g_array_remove_index (*expand_state, (guint) i);
						break;
					}
				}
			}
		}
	}
	_tmp17_ = node_id;
	node_id = _tmp17_ + 1;
	{
		xmlNode* it2 = NULL;
		xmlNode* _tmp18_;
		_tmp18_ = parent->children;
		it2 = _tmp18_;
		{
			gboolean _tmp19_ = FALSE;
			_tmp19_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp22_;
				gboolean _tmp23_ = FALSE;
				xmlNode* _tmp24_;
				if (!_tmp19_) {
					xmlNode* _tmp20_;
					xmlNode* _tmp21_;
					_tmp20_ = it2;
					_tmp21_ = _tmp20_->next;
					it2 = _tmp21_;
				}
				_tmp19_ = FALSE;
				_tmp22_ = it2;
				if (!(_tmp22_ != NULL)) {
					break;
				}
				_tmp24_ = it2;
				if (_tmp24_->type == XML_ELEMENT_NODE) {
					xmlNode* _tmp25_;
					const gchar* _tmp26_;
					_tmp25_ = it2;
					_tmp26_ = _tmp25_->name;
					_tmp23_ = g_strcmp0 (_tmp26_, "outline") == 0;
				} else {
					_tmp23_ = FALSE;
				}
				if (_tmp23_) {
					Node* child = NULL;
					Layout* _tmp27_;
					Layout* _tmp28_;
					Node* _tmp29_;
					Node* _tmp30_;
					xmlNode* _tmp31_;
					Node* _tmp32_;
					_tmp27_ = node_get_layout (node);
					_tmp28_ = _tmp27_;
					_tmp29_ = node_new (map, _tmp28_);
					child = _tmp29_;
					_tmp30_ = child;
					_tmp31_ = it2;
					export_opml_import_node (self, map, _tmp30_, _tmp31_, node_id, expand_state, theme);
					_tmp32_ = child;
					node_attach (_tmp32_, node, -1, theme, TRUE);
					_g_object_unref0 (child);
				}
			}
		}
	}
	_tmp33_ = node_get_layout (node);
	_tmp34_ = _tmp33_;
	_tmp35_ = layout_bbox (_tmp34_, node, -1, "import_opml");
	_tmp36_ = _tmp35_;
	node_set_tree_bbox (node, _tmp36_);
	_node_bounds_unref0 (_tmp36_);
	_tmp38_ = node_get_side (node);
	_tmp39_ = _tmp38_;
	if (node_side_horizontal (_tmp39_)) {
		NodeBounds* _tmp40_;
		NodeBounds* _tmp41_;
		gdouble _tmp42_;
		gdouble _tmp43_;
		_tmp40_ = node_get_tree_bbox (node);
		_tmp41_ = _tmp40_;
		_tmp42_ = node_bounds_get_height (_tmp41_);
		_tmp43_ = _tmp42_;
		_tmp37_ = _tmp43_;
	} else {
		NodeBounds* _tmp44_;
		NodeBounds* _tmp45_;
		gdouble _tmp46_;
		gdouble _tmp47_;
		_tmp44_ = node_get_tree_bbox (node);
		_tmp45_ = _tmp44_;
		_tmp46_ = node_bounds_get_width (_tmp45_);
		_tmp47_ = _tmp46_;
		_tmp37_ = _tmp47_;
	}
	node_set_tree_size (node, _tmp37_);
	_g_free0 (o);
	_g_free0 (t);
	_g_free0 (n);
}

static void
export_opml_class_init (ExportOPMLClass * klass,
                        gpointer klass_data)
{
	export_opml_parent_class = g_type_class_peek_parent (klass);
	((ExportClass *) klass)->export = (gboolean (*) (Export*, const gchar*, MindMap*)) export_opml_real_export;
	((ExportClass *) klass)->import = (gboolean (*) (Export*, const gchar*, MindMap*)) export_opml_real_import;
}

static void
export_opml_instance_init (ExportOPML * self,
                           gpointer klass)
{
}

static GType
export_opml_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ExportOPMLClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) export_opml_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ExportOPML), 0, (GInstanceInitFunc) export_opml_instance_init, NULL };
	GType export_opml_type_id;
	export_opml_type_id = g_type_register_static (TYPE_EXPORT, "ExportOPML", &g_define_type_info, 0);
	return export_opml_type_id;
}

GType
export_opml_get_type (void)
{
	static volatile gsize export_opml_type_id__once = 0;
	if (g_once_init_enter (&export_opml_type_id__once)) {
		GType export_opml_type_id;
		export_opml_type_id = export_opml_get_type_once ();
		g_once_init_leave (&export_opml_type_id__once, export_opml_type_id);
	}
	return export_opml_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;
}

