######################################################
##################### MY REALM #######################
######################################################

window = {
	name = "my_realm_window"
	widgetid = "my_realm_window"
	datacontext = "[GetVariableSystem]"
	datacontext = "[GetPlayer]"
	parentanchor = top|right
	allow_outside = yes
	movable = no
	layer = windows_layer

	using = Window_Size_MainTab

	state = {
		name = on_create
		trigger_on_create = yes

		on_start = "[GetVariableSystem.Set( 'bookmark_domain', 'true'  )]"
		on_start = "[GetVariableSystem.Clear( 'bookmark_laws' )]"
		on_start = "[GetVariableSystem.Clear( 'bookmark_subjects' )]"
		on_start = "[GetVariableSystem.Clear( 'bookmark_succession' )]"
		on_start = "[GetVariableSystem.Clear( 'bookmark_republics' )]"
	}

	state = {
		name = _show
		next = refresh_bookmark_tabs

		using = Animation_FadeIn_Quick
		using = Sound_WindowShow_Standard
		using = Window_Position_MainTab
	}

	state = {
		name = _hide
		using = Animation_FadeOut_Quick
		using = Sound_WindowHide_Standard
		using = Window_Position_MainTab_Hide
	}

	state = {
		name = refresh_bookmark_tabs
		on_start = "[GetVariableSystem.Set( 'bookmark_domain', 'true' )]"
		on_start = "[GetVariableSystem.Set( 'bookmark_subjects', 'true' )]"
		on_start = "[GetVariableSystem.Set( 'bookmark_succession', 'true' )]"
		on_start = "[GetVariableSystem.Set( 'bookmark_laws', 'true' )]"
		on_start = "[GetVariableSystem.Set( 'bookmark_republics', 'true' )]"
		on_start = "[GetVariableSystem.ClearIf( 'bookmark_domain', Not( MyRealmWindow.IsActiveTab( 'bookmark_domain' ) ) )]"
		on_start = "[GetVariableSystem.ClearIf( 'bookmark_subjects', Not( MyRealmWindow.IsActiveTab( 'bookmark_subjects' ) ) )]"
		on_start = "[GetVariableSystem.ClearIf( 'bookmark_succession', Not( MyRealmWindow.IsActiveTab( 'bookmark_succession' ) ) )]"
		on_start = "[GetVariableSystem.ClearIf( 'bookmark_laws', Not( MyRealmWindow.IsActiveTab( 'bookmark_laws' ) ) )]"
		on_start = "[GetVariableSystem.ClearIf( 'bookmark_republics', Not( MyRealmWindow.IsActiveTab( 'bookmark_republics' ) ) )]"
	}

	### BOOKMARK SIDE TABS
	widget = {
		position = { -64 220 }
		size = { 100 250 }
		scissor = yes

		allow_outside = yes

		flowcontainer = {
			parentanchor = right|vcenter
			position = { 7 0 }
			direction = vertical
			ignoreinvisible = yes
			allow_outside = yes

			### BOOKMARK TAB DOMAIN
			button_tab_vertical_bookmark = {
				name = "tab_domain" #tutorial uses this
				down = "[GetVariableSystem.Exists( 'bookmark_domain' )]"

				blockoverride "tab_button"
				{
					onclick = "[GetVariableSystem.Set( 'bookmark_domain', 'true' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_subjects' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_succession' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_laws' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_republics' )]"
					onclick = "[MyRealmWindow.SetActiveTab( 'bookmark_domain' )]"
					onclick = "[MyRealmWindow.ResetMapMode]"

					tooltip = "MY_REALM_WINDOW_BOOKMARK_DOMAIN_TT"
				}

				blockoverride = "tab_glow"
				{
					visible = "[GetVariableSystem.Exists( 'bookmark_domain' )]"
				}

				blockoverride "tab_active"
				{
					trigger_when = "[GetVariableSystem.Exists( 'bookmark_domain' )]"
				}

				blockoverride "tab_inactive"
				{
					trigger_when = "[Not( GetVariableSystem.Exists( 'bookmark_domain' ) )]"
				}

				blockoverride "tab_texture"
				{
					texture = "gfx/interface/icons/flat_icons/legend_province_modifier.dds"

					down = "[GetVariableSystem.Exists( 'bookmark_domain' )]"
				}

				blockoverride "tab_frame_texture"
				{
					down = "[GetVariableSystem.Exists( 'bookmark_domain' )]"
				}
			}

			### BOOKMARK TAB SUBJECTS (OR VASSALS)
			button_tab_vertical_bookmark = {
				name = "tutorial_highlight_vassals_tab"
				visible = "[GetPlayer.IsLandedRuler]"
				down = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"

				blockoverride "tab_button"
				{
					onclick = "[GetVariableSystem.Clear( 'bookmark_domain' )]"
					onclick = "[GetVariableSystem.Set( 'bookmark_subjects', 'true' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_republics' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_succession' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_laws' )]"
					onclick = "[MyRealmWindow.SetActiveTab( 'bookmark_subjects' )]"

					tooltip = "MY_REALM_WINDOW_BOOKMARK_SUBJECTS_TT"
				}

				blockoverride = "tab_glow"
				{
					visible = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
				}

				blockoverride "tab_active"
				{
					trigger_when = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
				}

				blockoverride "tab_inactive"
				{
					trigger_when = "[Not( GetVariableSystem.Exists( 'bookmark_subjects' ) )]"
				}

				blockoverride "tab_texture"
				{
					texture = "gfx/interface/icons/flat_icons/clan_contract.dds"

					down = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
				}

				blockoverride "tab_frame_texture"
				{
					down = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
				}
			}

			button_tab_vertical_bookmark = {
				name = "tutorial_highlight_republics_tab"
				visible = "[And(GetPlayer.IsLandedRuler, Or(GetPlayer.GetGovernment.IsType('urbanrepublic_government'),GetPlayer.GetGovernment.IsType('peasantrepublic_government')))]"
				down = "[GetVariableSystem.Exists( 'bookmark_republics' )]"

				blockoverride "tab_button"
				{
					onclick = "[GetVariableSystem.Clear( 'bookmark_domain' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_subjects' )]"
					onclick = "[GetVariableSystem.Set( 'bookmark_republics', 'true' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_succession' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_laws' )]"
					onclick = "[MyRealmWindow.SetActiveTab( 'bookmark_republics' )]"

					tooltip = "MY_REALM_WINDOW_BOOKMARK_REPUBLICS_TT"
				}

				blockoverride = "tab_glow"
				{
					visible = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
				}

				blockoverride "tab_active"
				{
					trigger_when = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
				}

				blockoverride "tab_inactive"
				{
					trigger_when = "[Not( GetVariableSystem.Exists( 'bookmark_republics' ) )]"
				}

				blockoverride "tab_texture"
				{
					texture = "gfx/interface/icons/flat_icons/war_outcome_victory.dds"

					down = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
				}

				blockoverride "tab_frame_texture"
				{
					down = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
				}
			}
			### BOOKMARK TAB LAWS
			button_tab_vertical_bookmark = {
				name = "tutorial_highlight_laws_tab"
				down = "[GetVariableSystem.Exists( 'bookmark_laws' )]"

				blockoverride "tab_button"
				{
					onclick = "[GetVariableSystem.Clear( 'bookmark_domain' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_subjects' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_republics' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_succession' )]"
					onclick = "[GetVariableSystem.Set( 'bookmark_laws', 'true' )]"
					onclick = "[MyRealmWindow.SetActiveTab( 'bookmark_laws' )]"
					onclick = "[MyRealmWindow.ResetMapMode]"

					tooltip = "MY_REALM_WINDOW_BOOKMARK_LAWS_TT"
				}

				blockoverride = "tab_glow"
				{
					visible = "[GetVariableSystem.Exists( 'bookmark_laws' )]"
				}

				blockoverride "tab_active"
				{
					trigger_when = "[GetVariableSystem.Exists( 'bookmark_laws' )]"
				}

				blockoverride "tab_inactive"
				{
					trigger_when = "[Not( GetVariableSystem.Exists( 'bookmark_laws' ) )]"
				}

				blockoverride "tab_texture"
				{
					texture = "gfx/interface/icons/title_actions/add_laws.dds"

					down = "[GetVariableSystem.Exists( 'bookmark_laws' )]"
				}

				blockoverride "tab_frame_texture"
				{
					down = "[GetVariableSystem.Exists( 'bookmark_laws' )]"
				}
			}

			### BOOKMARK TAB SUCCESSION
			button_tab_vertical_bookmark = {
				name = "tutorial_highlight_succession_tab"
				down = "[GetVariableSystem.Exists( 'bookmark_succession' )]"

				blockoverride "tab_button"
				{
					onclick = "[GetVariableSystem.Clear( 'bookmark_domain' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_subjects' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_republics' )]"
					onclick = "[GetVariableSystem.Set( 'bookmark_succession', 'true' )]"
					onclick = "[GetVariableSystem.Clear( 'bookmark_laws' )]"
					onclick = "[MyRealmWindow.SetActiveTab( 'bookmark_succession' )]"
					onclick = "[MyRealmWindow.ResetMapMode]"

					tooltip = "MY_REALM_WINDOW_BOOKMARK_SUCCESSION_TT"
				}

				blockoverride = "tab_glow"
				{
					visible = "[GetVariableSystem.Exists( 'bookmark_succession' )]"
				}

				blockoverride "tab_active"
				{
					trigger_when = "[GetVariableSystem.Exists( 'bookmark_succession' )]"
				}

				blockoverride "tab_inactive"
				{
					trigger_when = "[Not( GetVariableSystem.Exists( 'bookmark_succession' ) )]"
				}

				blockoverride "tab_texture"
				{
					texture = "gfx/interface/icons/flat_icons/heir.dds"

					down = "[GetVariableSystem.Exists( 'bookmark_succession' )]"
				}

				blockoverride "tab_frame_texture"
				{
					down = "[GetVariableSystem.Exists( 'bookmark_succession' )]"
				}
			}
		}
	}

	### Solution to make tabs look like they are layered under main tab window without code support since Maintab background seems to be set in by code somehow
	icon = {
		position = { 22 195 }
		size = { 14 260 }
		texture = "gfx/interface/component_tiles/tab_group_edge.dds"
		alpha = 0.95
		texture_density = 2
	}

	margin_widget = {
		size = { 100% 100% }
		margin = { 0 30 }
		margin_right = 13

		widget = {
			size = { 100% 100% }

			### WINDOW CONTENT
			vbox = {
				widgetid = "realm_panel_contents" #tutorial uses this

				using = Window_Margins

				header_pattern = {
					layoutpolicy_horizontal = expanding

					header_text = {
						visible = "[GetVariableSystem.Exists( 'bookmark_domain' )]"
						parentanchor = top|hcenter
						position = { 0 8 }

						text = "MY_REALM_WINDOW_HEADER"
						align = nobaseline
					}

					header_text = {
						visible = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
						parentanchor = top|hcenter
						position = { 0 8 }

						text = "MY_REALM_WINDOW_BODY_TITLE_SUBJECTS"
						align = nobaseline
					}

					header_text = {
						visible = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
						parentanchor = top|hcenter
						position = { 0 8 }

						text = "MY_REALM_WINDOW_BODY_TITLE_REPUBLICS"
						align = nobaseline
					}
					header_text = {
						datacontext = "[MyRealmWindow.GetKurultaiSuccession]"
						visible = "[GetVariableSystem.Exists( 'bookmark_succession' )]"
						parentanchor = top|hcenter
						position = { 0 8 }

						text = "MY_REALM_WINDOW_BODY_TITLE_SUCCESSION"
						align = nobaseline
					}

					header_text = {
						visible = "[GetVariableSystem.Exists( 'bookmark_laws' )]"
						parentanchor = top|hcenter
						position = { 0 8 }

						text = "MY_REALM_WINDOW_BODY_TITLE_LAWS"
						align = nobaseline
					}

					blockoverride "header_text" {}

					blockoverride "button_close"
					{
						onclick = "[MyRealmWindow.Close]"
					}
				}

				### Default Header
				widget_my_realm_header = {
					datacontext = "[GetPlayer]"
					visible = "[Not( IsLandlessAdventurer( Character ) )]"

					blockoverride "show_overlord"
					{
						visible = "[Character.HasOverlord]"
					}

					blockoverride "show_diarchy" {}
				}

				### Adventurer Header
				widget_my_realm_header = {
					datacontext = "[GetPlayer]"
					visible = "[IsLandlessAdventurer( Character )]"

					blockoverride "header_subtitle"
					{
						vbox = {
							spacing = 2

							text_single = {
								name = "realm_type_adv"
								text = "you_are_an_adventurer_tt"
								align = nobaseline
							}

							text_single = {
								text = "MY_REALM_WINDOW_DOMICILE_LOCATION"
								align = nobaseline
							}
						}
					}
				}

				## MY_REALM BODY HEADERS
				vbox = {
					layoutpolicy_horizontal = expanding

					vbox_my_realm_subjects_top = {
						visible = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
					}
					vbox_my_realm_republics_top = {
						visible = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
					}

					mandala_laws = {
						visible = "[And(GetPlayer.GetGovernment.IsType( 'mandala_government' ), GetVariableSystem.Exists( 'bookmark_laws' ))]"
					}

					vbox_my_realm_laws_top = {
						visible = "[GetVariableSystem.Exists( 'bookmark_laws' ) ]"
					}

					vbox_my_realm_succession_body_top = {
						datacontext = "[MyRealmWindow.GetKurultaiSuccession]"
						visible = "[And( GetVariableSystem.Exists( 'bookmark_succession' ), Not( KurultaiSuccession.IsValid ) )]"
					}
				}

				### MY_REALM MAIN CONTENTS / BODY
				scrollbox = {
					name = "my_realm_body"
					datacontext = "[MyRealmWindow.GetCharacter]"

					layoutpolicy_horizontal = expanding
					layoutpolicy_vertical = expanding

					background = {
						visible = "[IsLandlessAdventurer( GetPlayer )]"
						texture = "gfx/interface/skinned/illustrations/camp_bg.dds"
						fittype = end
						alpha = 0.5
						framesize = { 1500 848 }

						using = Mask_Rough_Edges

						modify_texture = {
							texture = "gfx/interface/component_masks/mask_fade_corner.dds"
							blend_mode = alphamultiply
						}
					}

					background = {
						visible = "[IsNomad( GetPlayer )]"
						texture = "gfx/interface/illustrations/event_scenes/mpo_camp_steppe.dds"
						fittype = end
						alpha = 0.5

						using = Mask_Rough_Edges

						modify_texture = {
							texture = "gfx/interface/component_masks/mask_fade_corner.dds"
							blend_mode = alphamultiply
						}
					}

					blockoverride "scrollbox_margins" {
						margin = { 0 5 }
						margin_left = 10
						margin_right = 10
					}

					blockoverride "scrollbox_content"
					{
						vbox_my_realm_domain_body = {
							widgetid = "my_realm_domain_body" #ra_merit_governor_holdings_open uses this
							visible = "[GetVariableSystem.Exists( 'bookmark_domain' )]"
						}

						vbox_my_realm_subjects_body = {
							visible = "[GetVariableSystem.Exists( 'bookmark_subjects' )]"
						}
						vbox_my_realm_republics_body = {
							visible = "[GetVariableSystem.Exists( 'bookmark_republics' )]"
						}

						vbox_my_realm_succession_body = {
							visible = "[GetVariableSystem.Exists( 'bookmark_succession' )]"
						}

						vbox_my_realm_laws_body = {
							visible = "[GetVariableSystem.Exists( 'bookmark_laws' )]"
						}
					}
				}

				### MY_REALM FOOTER STATS
				hbox_my_realm_footer_stats = {
					visible = "[And( Not( MyRealmWindow.IsPrimaryTitleTitular ), Or( GetVariableSystem.Exists( 'bookmark_domain' ), GetVariableSystem.Exists( 'bookmark_subjects' ), GetVariableSystem.Exists( 'bookmark_republics' ) ) )]"
				}
			}
		}
	}
}

######################################################
################ TYPES AND TEMPLATES #################
######################################################

template My_Realm_Cell_Size
{
	min_width = 95
	max_width = 95
}

types MyRealmWindow
{
	type my_realm_coa_tiny_item = coa_title_tiny_crown
	{
		datacontext = "[TitleItem.GetTitle]"
		parentanchor = left|vcenter
		using = tooltip_ne

		icon_title_has_laws_status = {}

		icon = {
			name = "is_nomad"
			visible = "[TitleItem.GetTitle.IsNomad]"
			parentanchor = bottom|right
			position = { 5 0 }
			size = { 25 25 }
			texture = "gfx/interface/icons/title_status/icon_title_nomad.dds"
		}
	}

	type widget_my_realm_header = widget_header_with_picture {
		layoutpolicy_horizontal = expanding

		blockoverride "header_text" {
			text = "[GetPlayer.GetPrimaryTitle.GetNameNoTooltip|U]"
		}

		blockoverride "size" {
			size = { 100% 130 }
		}

		blockoverride "header_size"
		{
			size = { 100% 40 }
		}

		blockoverride "header_position" {
			position = { 0 -12 }
		}

		blockoverride "header_background_visibility" {
			visible = no
		}

		blockoverride header_pattern_visibility {
			visible = no
		}

		blockoverride header_label_visibility {
			visible = yes
		}

		blockoverride "illustration_texture" {
			texture = "gfx/interface/skinned/illustrations/header_illustrations/header_my_realm.dds"

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_vertical_up.dds"
				blend_mode = alphamultiply
			}
		}

		blockoverride "button_close"
		{
			visible = no
		}

		vbox = {
			parentanchor = center
			margin_top = 36
			max_width = 350

			### MY_REALM HEADER CENTER
			vbox = {
				layoutpolicy_horizontal = expanding
				layoutpolicy_vertical = expanding

				### SUBTITLE
				vbox = {
					block "header_subtitle"
					{
						hbox = {
							datacontext = "[GetPlayer.GetActiveLawInGroupWithFlag( 'realm_law' )]"

							### AUTHORITY ICON
							authority_icon = {}

							hbox = {
								margin_left = 5
								spacing = 15

								text_single = {
									name = "realm_type"
									text = "MY_REALM_WINDOW_TYPE"
									max_width = 160
									align = nobaseline
								}

								text_single = {
									text = "REALM_WINDOW_SIZE"
									align = nobaseline
									max_width = 140
									tooltip = "REALM_WINDOW_SIZE_TT"
								}
							}
						}

						vbox = {
							spacing = -8
							margin_bottom = 12

							## OVERLORD INFO
							vbox = {
								name = "overlord"
								margin_top = -8

								block "show_overlord"
								{
									visible = no
								}

								hbox = {
									datacontext = "[MyRealmWindow.GetCharacter.GetOverlord]"
									spacing = 4

									button_icon_highlight = {
										visible = "[Not(IsNomad( Character ))]"
										datacontext = "[Character.GetActiveLawInGroupWithFlag( 'realm_law' )]"
										size = { 32 32 }
										texture = "[Law.GetIcon]"
										tooltipwidget = { general_law_tooltip = {} }
										using = tooltip_ws
									}

									icon = {
										visible = "[IsNomad( Character )]"
										datacontext = "[Character.GetActiveLawInGroupWithFlag( 'realm_law' )]"
										size = { 32 32 }
										texture = "[Law.GetIcon]"
										tooltipwidget = { general_law_tooltip = {} }
										using = tooltip_ws
									}

									text_single = {
										visible = "[GetPlayer.HasSuzerain]"
										text = "MY_REALM_WINDOW_SUZERAIN_NAME"
										align = nobaseline
										max_width = 280
									}

									text_single = {
										visible = "[GetPlayer.HasLiege]"
										text = "MY_REALM_WINDOW_LIEGE_NAME"
										align = nobaseline
										max_width = 280
									}

									coa_realm_tiny_crown = {}
								}
							}

							## REGENCY / DIARCHY
							hbox = {
								datacontext = "[MyRealmWindow.GetCharacter]"
								layoutpolicy_horizontal = expanding

								background = {
									texture = "gfx/interface/component_tiles/tile_title_bg_01.dds"
									spriteType = Corneredtiled
									spriteborder = { 40 8 }
									texture_density = 2

									margin = { 40 -3 }
									margin_left = 10

									modify_texture = {
										name = "mask"
										texture = "gfx/interface/component_masks/mask_fade_horizontal_middle_thick.dds"
										spriteType = Corneredstretched
										spriteborder = { 0 0 }
										blend_mode = alphamultiply
										mirror = horizontal
									}
								}

								block "show_diarchy"
								{
									visible = no
								}

								spacing = 10

								expand = {}

								button_round = {
									name = "open_future_diarchy_tutorial_uses_this"
									widgetid = "open_future_diarchy_tutorial_uses_this"
									size = { 32 32 }

									onclick = "[ToggleGameViewData( 'diarchy', Character.GetID )]"
									tooltip = "DIARCHY_WINDOW_OPEN_TOOLTIP"

									button_icon = {
										parentanchor = center
										position = { 0 -1 }
										size = { 24 24 }
										alwaystransparent = yes
										texture = "gfx/interface/window_regency/scale_of_power.dds"
									}
								}

								hbox = {
									datacontext = "[Character.GetDiarchy]"

									text_single = {
										visible = "[Diarchy.IsValid]"

										text = "DIARCHY_WINDOW_STATUS_ACTIVE_DIARCHY"
										align = nobaseline
										max_width = 400
									}

									text_single = {
										visible = "[Not( Diarchy.IsValid )]"

										text = "DIARCHY_WINDOW_STATUS_INACTIVE_DIARCHY"
										align = nobaseline
										margin_right = 10
									}
								}

								expand = {}

							}
						}
					}
				}

				### BELOW SUBTITLE

				expand = {}
			}
		}

		### HEADER LEFT WIDGET
		widget = {
			size = { 64 99 }
			allow_outside = yes

			### COAT OF ARMS
			coa_realm_medium_crown = {
				position = { 30 0 }
			}
		}

		### HEADER RIGHT WIDGET
		widget = {
			datacontext = "[MyRealmWindow.GetKurultaiSuccession]"
			visible = "[KurultaiSuccession.IsValid]"
			parentanchor = right|vcenter
			position = { -25 0 }
			size = { 84 84 }
			allow_outside = yes
			name = "kurultai_succession_stability"

			tooltipwidget = {
				widget_kurultai_succession_tooltip = {}
			}

			### KURULTAI SUCCESSION ICON PEACEFUL
			widget = {
				visible = "[KurultaiSuccession.IsStable]"
				parentanchor = center
				size = { 84 84 }

				icon = {
					parentanchor = center
					size = { 84 84 }
					texture = "gfx/interface/window_realm/succession_icon_background_peaceful.dds"
				}

				icon_flat_standard = {
					parentanchor = center
					size = { 60 60 }
					texture = "gfx/interface/icons/flat_icons/succession_peaceful.dds"
				}
			}

			### KURULTAI SUCCESSION ICON CHAOTIC
			widget = {
				visible = "[Not( KurultaiSuccession.IsStable )]"
				parentanchor = center
				size = { 84 84 }

				icon = {
					parentanchor = center
					size = { 84 84 }
					texture = "gfx/interface/window_realm/succession_icon_background_chaotic.dds"
				}

				icon_flat_standard_red = {
					parentanchor = center
					size = { 60 60 }
					texture = "gfx/interface/icons/flat_icons/succession_chaotic.dds"
				}
			}
		}
	}

	type hbox_my_realm_footer_stats = hbox {
		datacontext = "[MyRealmWindow.GetCharacter]"
		layoutpolicy_horizontal = expanding

		margin = { 10 0 }
		margin_top = 15
		margin_bottom = 5

		expand = {
			visible = "[Not( Character.HasOverlord )]"
		}

		### YOUR INCOME
		vbox = {
			layoutpolicy_vertical = expanding
			margin_left = 10

			hbox = {
				layoutpolicy_horizontal = expanding

				text_label_left = {
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_YOUR_INCOME"
				}
				expand = {}
			}

			hbox = {
				layoutpolicy_horizontal = expanding
				margin_right = 15
				min_height = 25

				expand = {}

				### SUBJECT / VASSAL LABEL
				hbox = {
					layoutpolicy_horizontal = expanding

					using = My_Realm_Cell_Size

					expand = {}

					text_single = {
						text = "MY_REALM_WINDOW_FROM_VASSALS"
						align = nobaseline|right
						max_width = 70
					}
				}

				### TRIBUTARY LABEL
				hbox = {
					layoutpolicy_horizontal = expanding

					using = My_Realm_Cell_Size

					expand = {}

					text_single = {
						text = "MY_REALM_WINDOW_FROM_TRIBUTARIES"
						align = nobaseline|right
						max_width = 90
					}
				}

				### DOMAIN LABEL
				hbox = {
					layoutpolicy_horizontal = expanding
					spacing = 2

					using = My_Realm_Cell_Size

					expand = {}

					warning_icon = {
						visible = "[MyRealmWindow.IsOverDomainLimit]"
						size = { 25 25 }

						tooltip = "[Character.GetDomainLimitTooltip]"
					}

					text_single = {
						text = "MY_REALM_WINDOW_FROM_HOLDINGS"
						align = nobaseline|right
						max_width = 70
					}
				}
			}

			### TAXES
			hbox_realm_stats_row = {
				margin_right = 15

				blockoverride "icon_tooltip"
				{
					tooltip = "MY_REALM_WINDOW_TAXES"
				}

				blockoverride "icon_texture"
				{
					texture = "gfx/interface/icons/icon_gold.dds"
				}

				blockoverride "cell_subjects"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetVassalsIncome]"
						}
					}
				}

				blockoverride "cell_tributaries"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetTributariesIncome]"
						}
					}
				}

				blockoverride "cell_domain"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetDomainIncome]"
						}
					}
				}
			}

			### LEVIES
			hbox_realm_stats_row = {
				margin_right = 15

				blockoverride "icon_tooltip"
				{
					tooltip = "MY_REALM_WINDOW_LEVIES"
				}

				blockoverride "icon_texture"
				{
					texture = "gfx/interface/icons/icon_levies.dds"
				}

				blockoverride "cell_subjects"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetVassalsLevy]"
						}
					}
				}

				blockoverride "cell_tributaries"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetTributariesLevy]"
						}
					}
				}

				blockoverride "cell_domain"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetDomainLevy]"
						}
					}
				}
			}

			### HERD
			hbox_realm_stats_row = {
				visible = "[IsNomad( Character )]"
				margin_right = 15

				blockoverride "icon_tooltip"
				{
					tooltip = "MY_REALM_WINDOW_HERD"
				}

				blockoverride "icon_texture"
				{
					texture = "gfx/interface/icons/icon_herd.dds"
				}

				blockoverride "cell_subjects"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetVassalsHerd]"
						}
					}
				}

				blockoverride "cell_tributaries"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetTributariesHerd]"
						}
					}
				}

				blockoverride "cell_domain"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetDomainHerd]"
						}
					}
				}
			}

			### BARTER GOODS
			hbox_realm_stats_row = {
				visible = "[Character.HasBarterGoods]"
				margin_right = 15

				blockoverride "icon_tooltip"
				{
					tooltip = "MY_REALM_WINDOW_BARTER_GOODS"
				}

				blockoverride "icon_texture"
				{
					texture = "gfx/interface/icons/icon_barter.dds"
				}

				blockoverride "cell_subjects"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetVassalsBarterGoods]"
						}
					}
				}

				blockoverride "cell_tributaries"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetTributariesBarterGoods]"
						}
					}
				}

				blockoverride "cell_domain"
				{
					cell_value_text = {
						blockoverride "cell_value_datacontext"
						{
							datacontext = "[MyRealmWindow.GetDomainBarterGoods]"
						}
					}
				}
			}

			expand = {}
		}

		### TO LIEGE
		vbox = {
			visible = "[Character.HasOverlord]"
			layoutpolicy_vertical = expanding
			margin_left = 10

			text_label_left = {
				layoutpolicy_horizontal = expanding

				text = "[SelectLocalization(Character.HasSuzerain, 'MY_REALM_WINDOW_FROM_TO_SUZERAIN', 'MY_REALM_WINDOW_FROM_TO_LIEGE')]"
			}

			hbox = {
				layoutpolicy_horizontal = expanding
				min_height = 25

				### LIEGE NAME
				text_single = {
					layoutpolicy_horizontal = expanding
					max_width = 170

					text = "[Character.GetOverlord.GetShortUIName]"
					align = nobaseline
				}

				expand = {}
			}

			### TAXES TO LIEGE
			hbox = {
				layoutpolicy_horizontal = expanding

				vbox = {
					hbox_realm_stats_row = {
						margin_right = 15

						blockoverride "icon_tooltip"
						{
							tooltip = "MY_REALM_WINDOW_TAXES"
						}

						blockoverride "icon_texture"
						{
							texture = "gfx/interface/icons/icon_gold.dds"
						}

						blockoverride "cell_subjects"
						{
							visible = no
						}

						blockoverride "cell_tributaries" {
							visible = no
						}

						blockoverride "cell_domain"
						{
							cell_value_text = {
								blockoverride "cell_value_datacontext"
								{
									datacontext = "[MyRealmWindow.GetIncomeTax]"
								}

								blockoverride "cell_value_tooltip"
								{
									tooltipwidget = {
										tooltip_my_realm_to_liege = {}
									}
								}
							}
						}
					}

					### LEVIES TO LIEGE
					hbox_realm_stats_row = {
						visible = "[Not( IsNomad( Character ) )]"
						margin_right = 15

						blockoverride "icon_tooltip"
						{
							tooltip = "MY_REALM_WINDOW_LEVIES"
						}

						blockoverride "icon_texture"
						{
							texture = "gfx/interface/icons/icon_levies.dds"
						}

						blockoverride "cell_subjects"
						{
							visible = no
						}

						blockoverride "cell_tributaries" {
							visible = no
						}

						blockoverride "cell_domain"
						{
							cell_value_text = {
								blockoverride "cell_value_datacontext"
								{
									datacontext = "[MyRealmWindow.GetLevyTax]"
								}

								blockoverride "cell_value_tooltip"
								{
									tooltipwidget = {
										tooltip_my_realm_to_liege = {}
									}
								}
							}
						}
					}

					### HERD TO LIEGE
					hbox_realm_stats_row = {
						visible = "[IsNomad( Character )]"
						margin_right = 15

						blockoverride "icon_tooltip"
						{
							tooltip = "MY_REALM_WINDOW_HERD"
						}

						blockoverride "icon_texture"
						{
							texture = "gfx/interface/icons/icon_herd.dds"
						}

						blockoverride "cell_subjects"
						{
							visible = no
						}

						blockoverride "cell_tributaries" {
							visible = no
						}

						blockoverride "cell_domain"
						{
							cell_value_text = {
								blockoverride "cell_value_datacontext"
								{
									datacontext = "[MyRealmWindow.GetHerdTax]"
								}

								blockoverride "cell_value_tooltip"
								{
									tooltipwidget = {
										tooltip_my_realm_to_liege = {}
									}
								}
							}
						}
					}

					### BARTER GOODS TO LIEGE
					hbox_realm_stats_row = {
						visible = "[Character.HasBarterGoods]"
						margin_right = 15

						blockoverride "icon_tooltip"
						{
							tooltip = "MY_REALM_WINDOW_BARTER_GOODS"
						}

						blockoverride "icon_texture"
						{
							texture = "gfx/interface/icons/icon_barter.dds"
						}

						blockoverride "cell_subjects"
						{
							visible = no
						}

						blockoverride "cell_tributaries" {
							visible = no
						}

						blockoverride "cell_domain"
						{
							cell_value_text = {
								blockoverride "cell_value_datacontext"
								{
									datacontext = "[MyRealmWindow.GetBarterGoodsTax]"
								}

								blockoverride "cell_value_tooltip"
								{
									tooltipwidget = {
										tooltip_my_realm_to_liege = {}
									}
								}
							}
						}
					}

					expand = {}
				}

				### BUTTONS ( TO LIEGE )
				vbox = {
					### MODIFY YOUR VASSAL CONTRACT
					button_round = {
						datacontext = "[MyRealmWindow.GetCharacter.GetLiege]"
						datacontext = "[MyRealmWindow.GetCharacter.GetVassalContract]"
						visible = "[Character.IsPlayerInteractionShown( 'vassal_modify_vassal_contract_interaction' )]"

						onclick = "[Character.OpenPlayerInteraction('vassal_modify_vassal_contract_interaction')]"
						tooltip = "[Character.GetPlayerInteractionTooltip('vassal_modify_vassal_contract_interaction')]"
						using = tooltip_se

						button_feudal_contract = {
							parentanchor = center
							alwaystransparent = yes
							size = { 30 30 }
						}
					}

					### MODIFY YOUR ADMIN VASSAL CONTRACT
					button_round = {
						datacontext = "[MyRealmWindow.GetCharacter.GetLiege]"
						datacontext = "[MyRealmWindow.GetCharacter.GetVassalContract]"
						visible = "[Character.IsPlayerInteractionShown( 'admin_vassal_modify_vassal_contract_interaction' )]"

						onclick = "[Character.OpenPlayerInteraction('admin_vassal_modify_vassal_contract_interaction')]"
						tooltip = "[Character.GetPlayerInteractionTooltip('admin_vassal_modify_vassal_contract_interaction')]"
						using = tooltip_se

						button_add_laws = {
							parentanchor = center
							alwaystransparent = yes
						}
					}

					### MODIFY TRIBUTARY CONTRACT
					button_round = {
						datacontext = "[MyRealmWindow.GetCharacter.GetSuzerain]"
						visible = "[GetPlayer.HasSuzerain]"

						onclick = "[Character.OpenPlayerInteraction('subject_modify_tributary_contract_interaction')]"
						tooltip = "[Character.GetPlayerInteractionTooltip('subject_modify_tributary_contract_interaction')]"
						using = tooltip_se

						button_feudal_contract = {
							parentanchor = center
							alwaystransparent = yes
						}
					}

					### BREAK FREE OF SUZERAIN
					button_round = {
						datacontext = "[MyRealmWindow.GetCharacter.GetSuzerain]"
						visible = no

						onclick = "[Character.OpenPlayerInteraction('cease_paying_tribute_interaction')]"
						enabled = "[Character.IsPlayerInteractionValid('cease_paying_tribute_interaction')]"

						tooltip = "[Character.GetPlayerInteractionTooltip('cease_paying_tribute_interaction')]"

						button_icon = {
							parentanchor = center
							alwaystransparent = yes
							position = { 1 -1 }
							size = { 40 40 }

							texture = "gfx/interface/icons/faction_type/liberty_faction.dds"
						}
					}
				}
				expand = {}
			}
		}

		expand = {
			visible = "[Not( Character.HasOverlord )]"
		}
	}

	type hbox_realm_stats_row = hbox {
		layoutpolicy_horizontal = expanding

		background = {
			margin = { -5 -5 }
			using = Background_Area
		}

		icon = {
			size = { 30 30 }

			block "icon_texture" {}
		}

		expand = {}

		### SUBJECT / VASSAL STATS
		hbox = {
			using = My_Realm_Cell_Size

			block "cell_subjects" {}
		}

		### TRIBUTARY STATS
		hbox = {
			using = My_Realm_Cell_Size

			block "cell_tributaries" {}
		}

		### DOMAIN STATS
		hbox = {
			using = My_Realm_Cell_Size

			block "cell_domain" {}
		}
	}

	type cell_value_text = text_single {
		using = My_Realm_Cell_Size
		align = right|nobaseline

		block "cell_value_datacontext"
		{
			datacontext = "[MyRealmWindow.GetDomainIncome]"
		}

		text = "[ValueBreakdown.GetValue]"

		block "cell_value_tooltip"
		{
			tooltipwidget = {
				widget_gold_breakdown_tooltip = {
					blockoverride "income"
					{
						visible = no
					}
				}
			}
		}
	}

	type vbox_my_realm_laws_top = vbox {
		name = "realm_laws"
		widgetid = "realm_panel_top_laws"
		datacontext = "[GetPlayer]"
		datamodel = "[MyRealmWindow.GetRealmLaws]"
		layoutpolicy_horizontal = expanding

		divider_light = {
			layoutpolicy_horizontal = expanding
		}

		item = {
			vbox = {
				name = "realm_law_group" #tutorial uses this
				datacontext = "[GuiLawGroup.GetLawGroup]"
				visible = "[And( GuiLawGroup.GetLawGroup.HasFlag( 'realm_law' ), GuiLawGroup.IsAvailable )]"
				margin_top = 10
				spacing = 10

				text_label_center = {
					visible = "[IsLandlessAdventurer( Character )]"
					text = "[camp_purpose|E]"
				}

				text_label_center = {
					visible = "[And(GuiLawGroup.GetLawGroup.HasFlag( 'realm_law_no_number' ), Not(IsLandlessAdventurer( Character )) )]"
					datacontext = "[GuiLawGroup.GetCurrentLevel.GetLaw]"
					text = "MY_REALM_WINDOW_LAW_NAME"
				}

				text_label_center = {
					visible = "[And(Not( GuiLawGroup.GetLawGroup.HasFlag( 'realm_law_no_number' )), Not(IsLandlessAdventurer( Character )) )]"
					datacontext = "[GuiLawGroup.GetCurrentLevel.GetLaw]"
					text = "MY_REALM_WINDOW_LAW_NAME_AND_LEVEL"
				}

				### REGULAR LAW ITEMS
				fixedgridbox = {
					name = "regular_law_items"
					visible = "[And( Not( IsLandlessAdventurer( Character ) ), Or(Not( IsNomad( Character ) ), Not( GuiLawGroup.GetLawGroup.HasFlag( 'dominance_law' ) ) ) )]"

					addcolumn = 55
					addrow = 55
					flipdirection = yes
					layoutanchor = bottomleft

					datamodel = "[GuiLawGroup.GetLaws]"

					item = {
						button_realm_law = {}
					}
				}

				### ADVENTURER LAW ITEMS
				fixedgridbox = {
					name = "camp_purpose_items"
					visible = "[IsLandlessAdventurer( Character )]"

					addcolumn = 170
					addrow = 170
					datamodel_wrap = 3
					flipdirection = yes

					datamodel = "[GuiLawGroup.GetLaws]"

					item = {
						widget_realm_law_camp_purpose = {}
					}
				}

				### NOMAD LAW ITEMS
				fixedgridbox = {
					name = "nomad_dominance_items"
					visible = "[And( IsNomad( Character ), GuiLawGroup.GetLawGroup.HasFlag( 'dominance_law' ) )]"

					addcolumn = 78
					addrow = 80
					setitemsizefromcell = yes
					datamodel_wrap = 5
					flipdirection = yes
					layoutanchor = bottomleft

					datamodel = "[GuiLawGroup.GetLaws]"

					item = {
						button_realm_law_nomad_dominance = {
							datacontext = "[GuiLawGroup.GetLevelByIndex( PdxGuiWidget.GetIndexInDataModel ).GetLaw]"
						}
					}
				}

				spacer = {
					visible = "[IsNomad( Character )]"
					size = { 0 5 }
				}

				spacer = {
					visible = "[GetPlayer.GetGovernment.IsType( 'mandala_government' )]"
					size = { 0 3 }
				}
			}
		}
	}

	type icon_my_realm_law = icon {
		size = { 42 42 }
		alwaystransparent = yes

		texture = "[Law.GetIcon]"

		modify_texture = {
			visible = "[And( Not( IsNomad( Character ) ), Not( IsLandlessAdventurer( Character ) ) )]"
			texture = "gfx/interface/colors/colors_textured.dds"
			blend_mode = add
			framesize = { 96 96 }
			spritetype = corneredtiled
		}
	}

	type button_realm_law = icon_button_decorative {
		datacontext = "[GuiLaw.GetLaw]"
		size = { 55 55 }

		alwaystransparent = "[GuiLaw.IsEnacted]"

		down = "[GuiLaw.IsEnacted]"
		onclick = "[GuiLaw.Enact]"
		enabled = "[Or( GuiLaw.CanEnact, GuiLaw.IsEnacted )]"

		tooltipwidget = {
			pass_law_tooltip = {}
		}
		using = tooltip_sw

		icon_button_decorative = {
			size = { 54 54 }
			parentanchor = center
			alwaystransparent = yes
		}

		button_icon = {
			visible = "[Not( GuiLaw.IsEnacted )]"
			size = { 42 42 }
			parentanchor = center
			alwaystransparent = yes

			texture = "[Law.GetIcon]"
		}

		icon = {
			visible = "[And( GuiLaw.IsEnacted , Not( GuiLaw.CanEnact ) )]"
			parentanchor = center
			size = { 42 42 }
			texture = "[Law.GetIcon]"
			alwaystransparent = yes

			using = Master_Button_Modify_Texture

			blockoverride "master_color_frame" {
				frame = 2
			}
		}
	}

	type mandala_laws = vbox {
		name = "mandala emperor laws"
		layoutpolicy_vertical = expanding

		block "crown_laws" {}

		widget = {
			size =  { 450 150 }
			scissor = yes

			widget = {
				size =  { 450 150 }
				block "mandala_laws_position" {}

				vbox = {
					datacontext = "[GetPlayer]"
					datamodel = "[MyRealmWindow.GetRealmLaws]"

					item = {
						vbox = {
							datacontext = "[GuiLawGroup.GetLawGroup]"
							visible = "[And( GuiLawGroup.GetLawGroup.HasFlag( 'mandala_law' ), GuiLawGroup.IsAvailable )]"
							margin_top = 10
							spacing = 7

							text_label_center = {
								visible = "[GuiLawGroup.GetLawGroup.HasFlag( 'realm_law_no_number' )]"
								datacontext = "[GuiLawGroup.GetCurrentLevel.GetLaw]"
								text = "MY_REALM_WINDOW_LAW_NAME"
							}

							text_label_center = {
								visible = "[Not( GuiLawGroup.GetLawGroup.HasFlag( 'realm_law_no_number' ) )]"
								datacontext = "[GuiLawGroup.GetCurrentLevel.GetLaw]"
								text = "MY_REALM_WINDOW_LAW_NAME_AND_LEVEL"
							}

							### MANDALA LAW ITEMS
							fixedgridbox = {
								name = "mandala_dominance_items"
								visible = "[GetPlayer.GetGovernment.IsType( 'mandala_government' )]"

								addcolumn = 100
								addrow = 100
								setitemsizefromcell = yes
								datamodel_wrap = 4
								flipdirection = yes
								layoutanchor = bottomleft

								datamodel = "[GuiLawGroup.GetLaws]"

								item = {
									button_mandala_realm_law = {}
								}
							}

							spacer = {
								visible = "[GetPlayer.GetGovernment.IsType( 'mandala_government' )]"
								size = { 0 3 }
							}
						}
					}
				}
			}
		}
	}

	type button_mandala_realm_law = button_round {
		datacontext = "[GuiLaw.GetLaw]"
		size = { 100 100 }

		alwaystransparent = "[GuiLaw.IsEnacted]"

		down = "[GuiLaw.IsEnacted]"
		onclick = "[GuiLaw.Enact]"
		enabled = "[Or( GuiLaw.CanEnact, GuiLaw.IsEnacted )]"

		tooltipwidget = {
			pass_law_tooltip = {}
		}
		using = tooltip_sw


		icon = {
			size = { 90 90 }
			texture = "gfx/interface/buttons/button_lifestyles_base.dds"
			parentanchor = center
			alwaystransparent = yes
		}

		highlight_icon = {
			visible = "[GuiLaw.IsEnacted]"
			parentanchor = center
			size = { 100 100 }

			texture = "gfx/interface/buttons/button_round_frame.dds"

			modify_texture = {
				texture = "gfx/interface/colors/gold.dds"
			}
		}

		button_icon = {
			visible = "[Not( GuiLaw.IsEnacted )]"
			size = { 90 90 }
			parentanchor = center
			alwaystransparent = yes
			texture = "[Law.GetIcon]"
		}

		icon = {
			visible = "[And( GuiLaw.IsEnacted , Not( GuiLaw.CanEnact ) )]"
			parentanchor = center
			size = { 100 100 }
			texture = "[Law.GetIcon]"
			alwaystransparent = yes

			using = Master_Button_Modify_Texture

			blockoverride "master_color_frame" {
				frame = 2
			}
		}
	}

	type widget_realm_law_camp_purpose = widget {
		datacontext = "[GuiLaw.GetLaw]"
		size = { 160 160 }

		tooltipwidget = {
			pass_law_tooltip = {
				blockoverride "concept_link" {
					text = "[camp_purpose|E]"
				}
			}
		}

		# easier to mouse around the grid
		tooltip_offset = { 0 40 }

		using = tooltip_ws

		button_standard_clean = {
			name = "camp_purpose_button"
			size = { 160 160 }
			alwaystransparent = "[GuiLaw.IsEnacted]"

			enabled = "[Or(GuiLaw.CanEnact, GuiLaw.IsEnacted)]"
			down = "[GuiLaw.IsEnacted]"
			onclick = "[GuiLaw.Enact]"

			background = {
				texture = "gfx/interface/component_tiles/tile_vignette_3px.dds"
				spriteType = Corneredtiled
				spriteborder = { 5 5 }
				margin = { -2 -2 }
			}

			icon = {
				size = { 160 160 }
				texture = "[Law.GetIcon]"
			}

			widget = {
				parentanchor = bottom
				size = { 100% 30 }

				background = {
					using = Background_Area_Dark
				}

				text_single = {
					visible = "[Not(GuiLaw.IsEnacted)]"
					parentanchor = center
					position = { 3 -2 }

					text = "PASS_LAW_TOOLTIP_TITLE"
					default_format = "#weak"
					max_width = 150

					margin = { 5 0 }
				}

				text_single = {
					visible = "[GuiLaw.IsEnacted]"
					parentanchor = center
					position = { 3 -2 }

					text = "ADVENTURER_LAW_SELECTED"
					default_format = "#high;EMP"
					max_width = 150

					margin = { 5 0 }
				}
			}

			selection_glow = {
				visible = "[GuiLaw.IsEnacted]"
			}
		}
	}

	type button_realm_law_nomad_dominance = button {
		size = { 100 100 }
		allow_outside = yes

		down = "[GuiLaw.IsEnacted]"
		onclick = "[GuiLaw.Enact]"
		enabled = "[Or( GuiLaw.CanEnact, GuiLaw.IsEnacted )]"

		tooltipwidget = {
			pass_law_tooltip = {}
		}

		using = tooltip_ws

		icon = {
			visible = "[GuiLaw.IsEnacted]"
			parentanchor = center
			size = { 72 72 }

			texture = "gfx/interface/icons/flat_icons/circle.dds"

			using = Animation_Glow_Pulse

			glow = {
				glow_radius = 13
				using = Glow_Standard
				using = Color_Bright_Yellow
			}
		}

		icon_round_button_base = {
			parentanchor = center
			size = { 72 72 }
		}

		highlight_icon = {
			visible = "[GuiLaw.IsEnacted]"
			parentanchor = center
			size = { 84 84 }

			texture = "gfx/interface/window_realm/dominance_frame_active.dds"
		}

		highlight_icon = {
			visible = "[And( GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)4'), Not( GuiLaw.IsEnacted ) )]"
			parentanchor = center
			position = { 1 1 }
			size = { 77 77 }

			texture = "gfx/interface/window_realm/dominance_frame_gurkhan_inactive.dds"
		}

		highlight_icon = {
			visible = "[And( GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)4'), GuiLaw.IsEnacted )]"
			parentanchor = center
			position = { 1 1 }
			size = { 77 77 }

			texture = "gfx/interface/window_realm/dominance_frame_gurkhan_active.dds"
		}

		highlight_icon = {
			parentanchor = center
			size = { 72 72 }
			texture = "[Law.GetIcon]"
		}

		icon_flat_standard_ash = {
			visible = "[And( GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)4'), Not( MyRealmWindow.IsGurkhan ) )]"
			parentanchor = top|right
			position = { 3 -3 }
			size = { 30 30 }

			texture = "gfx/interface/window_activities/tournament/contest_selection_locked_icon.dds"

			glow = {
				glow_radius = 2
				using = Color_Black

				glow_generation_rules = {
					glow_alpha_mask = 0
					glow_blur_passes = 10
					glow_texture_downscale = 2.5f
					glow_ignore_inside_pixels = yes
				}
			}
		}

		widget = {
			parentanchor = hcenter|bottom
			position = { 0 3 }
			size = { 68 16 }
			allow_outside = yes

			flowcontainer = {
				parentanchor = vcenter
				position = { 5 0 }
				spacing = 2
				allow_outside = yes
				visible = "[GuiLawGroup.GetLawGroup.HasFlag( 'dominance_law' )]"

				widget = {
					size = { 10 10 }

					dominance_pip = {
						parentanchor = center
					}

					dominance_pip_on = {
						visible = "[GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)0')]"
						parentanchor = center
					}
				}

				widget = {
					size = { 10 10 }

					dominance_pip = {
						parentanchor = center
					}

					dominance_pip_on = {
						visible = "[GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)1')]"
						parentanchor = center
					}
				}

				widget = {
					size = { 10 10 }

					dominance_pip = {
						parentanchor = center
					}

					dominance_pip_on = {
						visible = "[GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)2')]"
						parentanchor = center
					}
				}

				widget = {
					size = { 10 10 }

					dominance_pip = {
						parentanchor = center
					}

					dominance_pip_on = {
						visible = "[GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)3')]"
						parentanchor = center
					}
				}

				widget = {
					size = { 10 10 }

					dominance_pip = {
						parentanchor = center
					}

					dominance_pip_on = {
						visible = "[GreaterThanOrEqualTo_int32( Law.GetIndexInLawGroup, '(int32)4')]"
						parentanchor = center
					}
				}
			}

			icon = {
				size = { 68 16 }
				texture = "gfx/interface/window_realm/dominance_bar_frame.dds"
			}
		}
	}

	type vbox_kurultai_inherited_titles_group_foldout = vbox {
		layoutpolicy_horizontal = expanding
		margin = { 10 0 }

		oncreate = "[BindFoldOutContext]"
		oncreate = "[PdxGuiFoldOut.Unfold]"

		button_expandable_toggle_field = {
			blockoverride "text"
			{
				text = "MY_REALM_WINDOW_PARTITION_SHARE"
			}
		}

		vbox = {
			visible = "[PdxGuiFoldOut.IsUnfolded]"
			layoutpolicy_horizontal = expanding
			margin_top = 5

			overlappingitembox = {
				name = "partition_share_box"
				datamodel = "[MyRealmWindow.GetMyPartitionShare]"
				layoutpolicy_horizontal = expanding
				size = { 460 44 }
				spacing = 5

				item = {
					coa_title_tiny_crown = {
						datacontext = "[TitleItem.GetTitle]"

						using = tooltip_ne
					}
				}
			}
		}
	}

	type vbox_kurultai_group_foldout = vbox {
		layoutpolicy_horizontal = expanding
		margin = { 10 0 }

		oncreate = "[BindFoldOutContext]"
		oncreate = "[PdxGuiFoldOut.Unfold]"

		button_expandable_toggle_field = {
			blockoverride "text"
			{
				text = "MY_REALM_WINDOW_KURULTAI_ELECTORS"
				max_width = 510
			}
		}

		vbox = {
			visible = "[PdxGuiFoldOut.IsUnfolded]"
			layoutpolicy_horizontal = expanding
			margin_bottom = 5

			fixedgridbox = {
				layoutpolicy_horizontal = expanding
				layoutpolicy_vertical = expanding

				addcolumn = 85
				addrow = 90
				setitemsizefromcell = yes
				datamodel_wrap = 6
				flipdirection = yes

				datamodel = "[KurultaiSuccession.GetElectors]"

				item = {
					portrait_head_small = {
						blockoverride "glow_visible"
						{
							visible = no
						}
					}
				}
			}
		}
	}

	type vbox_succession_content_kurultai = vbox {
		layoutpolicy_horizontal = expanding

		background = {
			visible = "[KurultaiSuccession.IsStable]"

			texture = "gfx/interface/window_realm/succession_pattern_peaceful.dds"
			alpha = 0.1
			spritetype = corneredtiled
			texture_density = 2
			using = Color_Blue
			using = Mask_Rough_Edges


			margin = { -5 0 }
			margin_top = -68

			modify_texture = {
				texture = "gfx/interface/component_overlay/seamless_noise.dds"
				alpha = 0.1
				blend_mode = overlay
				spritetype = corneredtiled
				texture_density = 2
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_scratches.dds"
				alpha = 0.9
				blend_mode = alphamultiply
				spritetype = corneredtiled
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_scratches.dds"
				alpha = 0.9
				blend_mode = alphamultiply
				spritetype = corneredtiled
				mirror = horizontal
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_horizontal_extended.dds"
				blend_mode = alphamultiply
				mirror = horizontal
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
				blend_mode = alphamultiply
			}
		}

		background = {
			visible = "[Not( KurultaiSuccession.IsStable )]"

			texture = "gfx/interface/window_realm/succession_pattern_chaotic.dds"
			alpha = 0.1
			mirror = horizontal
			spritetype = corneredtiled
			texture_density = 2
			using = Color_Red
			using = Mask_Rough_Edges

			margin = { -5 0 }
			margin_top = -68

			modify_texture = {
				texture = "gfx/interface/component_overlay/seamless_noise.dds"
				blend_mode = overlay
				spritetype = corneredtiled
				texture_density = 2
				alpha = 0.1
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_scratches.dds"
				alpha = 0.9
				blend_mode = alphamultiply
				spritetype = corneredtiled
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_scratches.dds"
				alpha = 0.9
				blend_mode = alphamultiply
				spritetype = corneredtiled
				mirror = horizontal
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_horizontal_extended.dds"
				blend_mode = alphamultiply
				mirror = horizontal
			}

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
				blend_mode = alphamultiply
			}
		}

		### STATUS BANNER
		hbox = {
			layoutpolicy_horizontal = expanding

			tooltipwidget = {
				widget_kurultai_succession_tooltip = {}
			}

			### STABLE SUCCESSION
			widget = {
				visible = "[KurultaiSuccession.IsStable]"
				size = { 550 84 }

				icon = {
					parentanchor = vcenter
					size = { 550 64 }
					texture = "gfx/interface/window_realm/succession_banner_peaceful.dds"
				}

				widget = {
					parentanchor = left|vcenter
					position = { 12 0 }
					size = { 84 84 }

					icon = {
						parentanchor = center
						size = { 84 84 }
						texture = "gfx/interface/window_realm/succession_icon_background_peaceful.dds"
					}

					icon_flat_standard = {
						parentanchor = center
						size = { 60 60 }
						texture = "gfx/interface/icons/flat_icons/succession_peaceful.dds"
					}
				}

				text_single = {
					layoutpolicy_vertical = expanding
					parentanchor = left|vcenter
					position = { 100 -2 }

					text = "MY_REALM_WINDOW_KURULTAI_STABLE"
					max_width = 400
					using = Font_Size_Medium
				}
			}

			### CHAOTIC SUCCESSION
			widget = {
				visible = "[Not( KurultaiSuccession.IsStable )]"
				size = { 550 84 }

				icon = {
					parentanchor = vcenter
					size = { 550 64 }
					texture = "gfx/interface/window_realm/succession_banner_chaotic.dds"
				}

				widget = {
					parentanchor = left|vcenter
					position = { 12 0 }
					size = { 84 84 }

					icon = {
						parentanchor = center
						size = { 84 84 }
						texture = "gfx/interface/window_realm/succession_icon_background_chaotic.dds"
					}

					icon_flat_standard_red = {
						parentanchor = center
						size = { 60 60 }
						texture = "gfx/interface/icons/flat_icons/succession_chaotic.dds"
					}
				}

				text_single = {
					layoutpolicy_vertical = expanding
					parentanchor = left|vcenter
					position = { 100 -2 }

					text = "MY_REALM_WINDOW_KURULTAI_CHAOTIC"
					max_width = 400
					using = Font_Size_Medium
				}
			}
		}

		### HEIR INFO
		hbox = {
			datacontext = "[MyRealmWindow.GetCharacter.GetPlayerHeir]"
			visible = "[Character.IsValid]"
			layoutpolicy_horizontal = expanding

			vbox = {
				layoutpolicy_horizontal = expanding
				layoutpolicy_vertical = expanding
				margin = { 15 0 }

				text_label_left = {
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_KURULTAI_PREFERRED"
					using = Font_Size_Medium
					max_width = 360
				}

				text_single = {
					margin_top = 10
					layoutpolicy_horizontal = expanding

					text = "[Character.GetUINameNoTooltip]"
					align = nobaseline
					default_format = "#high"
					max_width = 360
					using = Font_Size_Medium
				}

				text_single = {
					layoutpolicy_horizontal = expanding

					text = "MRW_YOUR_PLAYER_HEIR"
					default_format = "#weak"
					max_width = 360
				}

				text_single = {
					visible = "[Not( KurultaiSuccession.IsStable )]"
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_KURULTAI_CHAOS_WARNING"
					max_width = 360
				}

				### CHANGE HEIR BUTTON
				hbox = {
					layoutpolicy_horizontal = expanding

					margin_top = 20

					button_standard = {
						size = { 150 32 }
						text = "MY_REALM_WINDOW_DESIGNATE_HEIR"

						enabled = "[MyRealmWindow.CanDesignateHeir]"
						onclick = "[OpenDesignateHeirWindow]"

						tooltip = "MRW_DESIGNATE_HEIR_TT"
					}

					expand = {}
				}

				expand = {}
			}

			expand = {}

			portrait_torso = {
				blockoverride "portrait_status_icons" {}
				blockoverride "opinion_box" {}
			}
		}

		### KURULTAI PROGRESS BAR
		vbox = {
			visible = "[GreaterThan_int32( KurultaiSuccession.GetVoteCount, '(int32)0' )]"
			layoutpolicy_horizontal = expanding
			margin = { 15 0 }
			margin_bottom = 5

			hbox = {
				layoutpolicy_horizontal = expanding
				spacing = 10

				text_single = {
					text = "MY_REALM_WINDOW_KURULTAI_APPROVES"
					align = nobaseline
					max_width = 150
				}

				progressbar_standard = {
					name = "kurultai_votes"
					layoutpolicy_horizontal = expanding
					size = { 200 20 }

					using = Animation_ShowHide_Standard

					max = "[IntToFloat( KurultaiSuccession.GetVoteCount )]"
					value = "[IntToFloat( KurultaiSuccession.GetObedientCount )]"
				}

				text_single = {
					text = "MY_REALM_WINDOW_KURULTAI_OPPOSES"
					align = nobaseline
					max_width = 150
				}
			}

			text_multi = {
				text = "MY_REALM_WINDOW_KURULTAI_OBEDIENT"
				autoresize = yes
				align = center
				default_format = "#italic"
				max_width = 500
				margin = { 0 5 }
			}
		}
	}

	type widget_kurultai_succession_tooltip = widget
	{
		alwaystransparent = no
		using = GeneralTooltipSetup

		widget = {
			name = "background"
			alwaystransparent = no
			size = { 100% 100% }
			using = DefaultTooltipBackground
		}

		vbox = {
			set_parent_size_to_minimum = yes
			margin = { 20 0 }
			margin_top = 5
			margin_bottom = 20
			spacing = 20

			### HEADER
			hbox = {
				layoutpolicy_horizontal = expanding
				spacing = 10

				background = {
					using = Background_Header
				}

				background = {
					using = Background_Header_Pattern
				}

				icon = {
					visible = "[KurultaiSuccession.IsStable]"
					size = { 60 60 }
					texture = "gfx/interface/icons/succession_peaceful.dds"
				}

				icon = {
					visible = "[Not( KurultaiSuccession.IsStable )]"
					size = { 60 60 }
					texture = "gfx/interface/icons/succession_chaotic.dds"
				}

				text_single = {
					visible = "[KurultaiSuccession.IsStable]"

					text = "MY_REALM_WINDOW_KURULTAI_STABLE"
					align = nobaseline
					default_format = "#bold"
					using = Font_Size_Medium
				}

				text_single = {
					visible = "[Not( KurultaiSuccession.IsStable )]"

					text = "MY_REALM_WINDOW_KURULTAI_CHAOTIC"
					align = nobaseline
					default_format = "#bold"
					using = Font_Size_Medium
				}

				expand = {}

				text_single = {
					text = "[succession|E]"
				}
			}

			### SUB HEADER
			vbox = {
				layoutpolicy_horizontal = expanding

				text_multi = {
					visible = "[KurultaiSuccession.IsStable]"
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_KURULTAI_STABLE_TOOLTIP_HEADER"
					autoresize = yes
					minimumsize = { 100 -1 }
					maximumsize = { 500 300 }
				}

				text_multi = {
					visible = "[Not( KurultaiSuccession.IsStable )]"
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_KURULTAI_CHAOTIC_TOOLTIP_HEADER"
					autoresize = yes
					minimumsize = { 100 -1 }
					maximumsize = { 500 300 }
				}
			}

			divider_light = {
				layoutpolicy_horizontal = expanding
			}

			text_multi = {
				layoutpolicy_horizontal = expanding

				text = "[KurultaiSuccession.GetStatusTooltip]"
				autoresize = yes
				fontsize = 16
				fontsize_min = 12
				minimumsize = { 100 -1 }
				maximumsize = { 500 300 }
			}

			divider_light = {
				layoutpolicy_horizontal = expanding
			}

			vbox = {
				layoutpolicy_horizontal = expanding

				text_multi = {
					visible = "[KurultaiSuccession.IsStable]"
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_KURULTAI_STABLE_TOOLTIP_FOOTER"
					autoresize = yes
					minimumsize = { 100 -1 }
					maximumsize = { 500 300 }
				}

				text_multi = {
					visible = "[Not( KurultaiSuccession.IsStable )]"
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_KURULTAI_CHAOTIC_TOOLTIP_FOOTER"
					autoresize = yes
					minimumsize = { 100 -1 }
					maximumsize = { 500 300 }
				}
			}
		}
	}

	type vbox_my_realm_succession_title_lost_item = vbox {
		datacontext = "[TitleSuccessionItem.GetHeir]"
		layoutpolicy_horizontal = expanding

		margin = { 16 8 }
		margin_bottom = 15

		background = {
			using = Background_Frame
		}

		hbox = {
			layoutpolicy_horizontal = expanding

			vbox = {
				layoutpolicy_horizontal = expanding

				text_single = {
					name = "heir_name"
					visible = "[Character.IsValid]"

					text = "MY_REALM_WINDOW_TITLES_LOST_LABEL"
					layoutpolicy_horizontal = expanding
					autoresize = no
				}

				text_single = {
					name = "heir_not_your_dynasty"
					visible = "[And( Character.IsValid, Not( ObjectsEqual( Character.GetHouse.GetDynasty.Self, GetPlayer.GetHouse.GetDynasty.Self ) ) )]"

					text = "MY_REALM_WINDOW_HEIR_NOT_MY_DYNASTY"
					using = Font_Size_Small
					layoutpolicy_horizontal = expanding
					autoresize = no
				}

				text_single = {
					name = "heir_share"
					datacontext = "[GetPlayer]"
					visible = "[DataModelHasItems( TitleSuccessionItem.GetPartitionTitles )]"
					
					text = "MY_REALM_WINDOW_SUCCESSION_LAW_AND_DESC"
					default_format = "#weak"
					layoutpolicy_horizontal = expanding
					autoresize = no
				}
			}

			expand = {}

			fixedgridbox = {
				name = "titles_box"
				datamodel = "[TitleSuccessionItem.GetPartitionTitles]"
				visible = "[DataModelHasItems( TitleSuccessionItem.GetPartitionTitles )]"

				addcolumn = 36
				addrow = 60
				maxhorizontalslots = 7
				flipdirection = yes

				item = {
					widget = {
						size = { 36 60 }
						datacontext = "[TitleItem.GetTitle]"

						coa_title_tiny_crown = {
							
							using = tooltip_ne
							parentanchor = center
						}

						icon_title_has_laws_status = {}
					}
				}
			}

			fixedgridbox = {
				name = "exception_box"
				datamodel = "[TitleSuccessionItem.GetExceptionTitles]"
				visible = "[DataModelHasItems( TitleSuccessionItem.GetExceptionTitles )]"

				addcolumn = 36
				addrow = 45
				maxhorizontalslots = 7
				flipdirection = yes

				item = {
					container = {
						datacontext = "[TitleItem.GetTitle]"
						coa_title_tiny_crown = {
							using = tooltip_ne
						}

						icon_title_has_laws_status = {}
					}
				}
			}

			text_single = {
				name = "required_government_label"
				visible = "[DataModelHasItems( TitleSuccessionItem.GetRequiredGovernmentTitles )]"
				layoutpolicy_horizontal = expanding

				text = "MY_REALM_WINDOW_REQUIRED_GOVERNMENT_TITLES"
			}

			text_single = {
				name = "required_government_warning"
				visible = "[DataModelHasItems( TitleSuccessionItem.GetRequiredGovernmentTitles )]"
				layoutpolicy_horizontal = expanding

				text = "MY_REALM_WINDOW_REQUIRED_GOVERNMENT_TITLES_WARNING"
				using = Font_Size_Small
			}

			fixedgridbox = {
				name = "required_government_box"
				datamodel = "[TitleSuccessionItem.GetRequiredGovernmentTitles]"
				visible = "[DataModelHasItems( TitleSuccessionItem.GetRequiredGovernmentTitles )]"

				addcolumn = 36
				addrow = 45
				maxhorizontalslots = 7
				flipdirection = yes


				item = {
					container = {
						datacontext = "[TitleItem.GetTitle]"
						coa_title_tiny_crown = {
							using = tooltip_ne
						}

						icon_title_has_laws_status = {}
					}
				}
			}
		}
	}

	type icon_title_succession = icon {
		size = { 25 25 }
		texture = "gfx/interface/icons/title_status/icon_title_law.dds"
	}

	type icon_title_has_laws_status = icon_title_succession {
		name = "has_laws"
		visible = "[Title.HasLaws]"

		parentanchor = bottom|right
		position = { 5 0 }
	}

	type vbox_succession_content_default = vbox {
		layoutpolicy_horizontal = expanding
		layoutpolicy_vertical = expanding
		spacing = 10

		hbox = {
			name = "current_heir"

			# vassals in merit governments don't really care that your heir inherits your province, it is all transient anyway, so no need to show the warning

			visible = "[And( And( Not(GetPlayer.GetGovernment.HasRule( 'merit' )), Not(GetPlayer.IsIndependentRuler)), And( MyRealmWindow.HasHeir, Not( ObjectsEqual( MyRealmWindow.GetCharacter.GetPlayerHeir, MyRealmWindow.GetCharacter.GetPrimaryTitle.GetHeir.Self ) ) ) )]"


			layoutpolicy_horizontal = expanding
			margin_bottom = 5

			background = {
				using =  Background_Area_Dark
				alpha = 0.8

				modify_texture = {
					texture = "gfx/interface/component_masks/mask_fade_horizontal.dds"
					blend_mode = alphamultiply
					mirror = horizontal
				}
			}

			vbox = {
				layoutpolicy_vertical = expanding
				layoutpolicy_horizontal = expanding

				margin = { 5 0 }
				margin_top = 5

				text_single = {
					name = "not_primary_heir"
					layoutpolicy_horizontal = expanding

					text = "MY_REALM_WINDOW_NOT_PRIMARY_HEIR"
					align = nobaseline
				}

				expand = {}
			}
		}

		##### FROM REALM'S PARTITION #####
		vbox = {
			layoutpolicy_horizontal = expanding
			
			vbox = {
				name = "their_partition_share"
				visible = "[And( MyRealmWindow.HasPartition, DataModelHasItems( MyRealmWindow.GetMyPartitionShare ) )]"
				layoutpolicy_horizontal = expanding

				margin_left = 5

				hbox = {
					layoutpolicy_horizontal = expanding

					text_label_left = {
						layoutpolicy_horizontal = expanding
						text = "MY_REALM_WINDOW_SUCCESSION_TITLES_INHERITED"
						max_width = 500
					}

					expand = {}
				}

				overlappingitembox = {
					name = "partition_share_box"
					datamodel = "[MyRealmWindow.GetMyPartitionShare]"
					layoutpolicy_horizontal = expanding
					size = { 460 65 }
					spacing = 5

					item = {
						coa_title_tiny_crown = {
							datacontext = "[TitleItem.GetTitle]"
							using = tooltip_ne
						}
					}
				}
			}

			vbox = {
				name = "title_succession"
				visible = "[DataModelHasItems(MyRealmWindow.GetTitleSuccession)]"
				layoutpolicy_horizontal = expanding
				margin = { 5 0 }

				oncreate = "[BindFoldOutContext]"
				oncreate = "[PdxGuiFoldOut.Unfold]"

				button_expandable_toggle_field = {
					blockoverride "text"
					{
						text = "MY_REALM_WINDOW_TITLES_LOST_ON_SUCCESSION"
						default_format = "#X"
					}
				}

				vbox = {
					datamodel = "[MyRealmWindow.GetTitleSuccession]"
					visible = "[PdxGuiFoldOut.IsUnfolded]"
					layoutpolicy_horizontal = expanding

					item = {
						vbox_my_realm_succession_title_lost_item = {}
					}
				}
			}

			vbox = {
				name = "exceptions"
				visible = "[DataModelHasItems( MyRealmWindow.GetSuccessionExceptions )]"
				layoutpolicy_horizontal = expanding
				layoutpolicy_vertical = growing
				margin_left = 5

				hbox = {
					layoutpolicy_horizontal = expanding

					text_label_left = {
						layoutpolicy_horizontal = expanding
						text = "MY_REALM_WINDOW_EXCEPTIONS"
						max_width = 520
					}

					expand = {}
				}

				vbox = {
					name = "exceptions_box"
					datamodel = "[MyRealmWindow.GetSuccessionExceptions]"
					layoutpolicy_horizontal = expanding


					item = {
						hbox = {
							layoutpolicy_horizontal = expanding
							margin = { 8 8 }

							datacontext = "[TitleItem.GetTitle]"

							background = {
								using = Background_Area
							}

							widget = {
								size = { 75 0 }
								layoutpolicy_vertical = expanding

								coa_title_small_crown = {
									position = { 0 -16 }
									parentanchor = center
								}
							}

							vbox = {
								layoutpolicy_horizontal = expanding
								layoutpolicy_vertical = expanding

								spacing = 2

								text_label_left = {
									layoutpolicy_horizontal = expanding
									autoresize = no

									text = "[Title.GetNameNoTooltip]"
								}

								hbox = {
									layoutpolicy_horizontal = expanding

									icon_title_succession = {}

									text_single = {
										layoutpolicy_horizontal = expanding

										text = "[Title.GetTitleLawsTooltip]"
										align = nobaseline
										autoresize = no
									}
								}

								expand = {}
							}

							vbox = {
								portrait_head_small = {
									datacontext = "[Title.GetHeir]"
								}

								text_label_center = {
									text = "[heir|E]"
								}
							}

							
						}
					}

				}	
			}
		}

		vbox = {
			name = "line_of_succession"
			visible = "[MyRealmWindow.HasSingleHeir]"
			layoutpolicy_horizontal = expanding
			layoutpolicy_vertical = growing
			margin = { 5 0 }
			spacing = 10

			hbox = {
				layoutpolicy_horizontal = expanding

				text_label_left = {
					name = "line_of_succession_label"
					layoutpolicy_horizontal = expanding
					text = "MY_REALM_WINDOW_LINE_OF_SUCCESSION"
				}

				expand = {}
			}

			dynamicgridbox = {
				name = "line_of_succession_box"
				datamodel = "[MyRealmWindow.GetLineOfSuccession]"
				layoutpolicy_horizontal = expanding

				item = {
					hbox = {
						datacontext = "[LineOfSuccessionItem.GetCharacter]"
						maximumsize = { -1 100 }
						margin_left = 10
						margin_bottom = 5

						background = {
							using = Background_Area_With_Header
						}

						vbox = {
							layoutpolicy_vertical = growing
							margin_bottom = 5
							spacing = 2

							hbox_character_view_name_age_health = {
								blockoverride "name_text"
								{
									text = "MY_REALM_WINDOW_LINE_OF_SUCCESSION_ORDERED_NAME"
								}

								blockoverride "health_margin" {
									margin_left = 4
								}
							}

							spacer = {
								size = { 10 3 }
							}

							hbox = {
								layoutpolicy_horizontal = expanding

								text_single = {
									name = "character_relation_to_you"
									text = "[Character.GetRelationToString( GetPlayer )]"
									align = nobaseline
									fontsize_min = 13
									max_width = 300

									tooltip = "EXTENDED_RELATIONS_TOOLTIP"
								}

								expand = {}
							}

							hbox_traits_list_small = {
								name = "traits_list"
								datacontext = "[LineOfSuccessionItem.GetTraitArrays]"
							}

							text_single = {
								name = "vassal_stances_that_prefer"
								visible = "[And( Not( IsLandlessAdventurer( GetPlayer ) ), Not( StringIsEmpty( MyRealmWindow.GetCharacter.GetVassalStancesThatPrefer( Character.Self ) ) ) )]"
								layoutpolicy_horizontal = expanding

								text = "MRW_HEIR_PREFERRED"
								autoresize = no
								using = Font_Size_Medium
							}

							expand = {}
						}

						expand = {}

						vbox = {
							layoutpolicy_vertical = expanding

							portrait_shoulders = {
								name = "heir_portrait"

								blockoverride "portrait_button" {
									using = tooltip_ws
								}
							}

							expand = {}
						}
					}
				}
			}
		}

		expand = {}
	}

	type tooltip_my_realm_to_liege = container_my_realm_window_contribution_tooltip {
		datacontext = "[MyRealmWindow.GetCharacter]"

		blockoverride "contribution_tooltip_header"
		{
			text = "[SelectLocalization(Character.HasSuzerain, 'MRW_TT_TAXES_TO_MY_SUZERAIN', 'MRW_TT_TAXES_TO_MY_LIEGE')]"
		}

		blockoverride "contribution_tooltip_content_suffix" {}
	}

	type container_my_realm_window_contribution_tooltip = container {
		alwaystransparent = no

		using = GeneralTooltipSetup
		using = DefaultTooltipBackground

		widget_gold_breakdown_tooltip = {
			layoutpolicy_horizontal = expanding

			blockoverride "margins"
			{
				margin = { 15 10 }
				margin_bottom = 5
				spacing = 15
			}

			blockoverride "income"
			{
				visible = no
			}

			blockoverride "background" {}

			blockoverride "extra_info"
			{
				block "contribution_tooltip_content_suffix" {
					text_single = {
						visible = "[Character.IsTheocraticLessee]"

						text = "MY_REALM_WINDOW_CONTRIBUTION_TO_THEOCRATIC_LIEGE"
						default_format = "#weak"
						multiline = yes
						maximumsize = { 300 -1 }
					}
				}

				text_single = {
					layoutpolicy_horizontal = expanding
					margin_bottom = 10

					block "contribution_tooltip_header"
					{
						align = left
					}
				}
			}
		}
	}

	type vbox_my_realm_domain_body = vbox {
		layoutpolicy_horizontal = expanding
		margin_top = 5
		spacing = 20

		using = Animation_Tab_Switch

		vbox = {
			visible = "[Character.HasDomicile]"

			layoutpolicy_horizontal = expanding
			margin_top = 10
			spacing = 10

			text_label_center = {
				text = "[Character.GetDomicile.GetYourDomicileText]"
				default_format = "#low"
				using = Font_Size_Medium
			}

			vbox_domicile_button = {}
		}

		datamodel = "[MyRealmWindow.GetDomainItems]"

		item = {
			vbox = {
				name = "duchy_group"
				layoutpolicy_horizontal = expanding

				hbox = {
					spacing = 5

					background = {
						margin_top = -10
						margin_bottom = -5
						margin_left = 20
						margin_right = 40

						texture = "gfx/interface/component_tiles/tile_title_bg_01.dds"
						spriteType = Corneredtiled
						spriteborder = { 40 8 }
						texture_density = 2

						modify_texture = {
							name = "mask"
							texture = "gfx/interface/component_masks/mask_fade_horizontal_middle_thick.dds"
							spriteType = Corneredstretched
							spriteborder = { 0 0 }
							blend_mode = alphamultiply
						}
					}

					coa_title_tiny_crown = {
						datacontext = "[DuchyGroup.GetDuchy]"

						using = tooltip_ws
					}

					text_single = {
						text = "[DuchyGroup.GetDuchy.GetNameNoTooltip|U]"
						default_format = "#low"
						max_width = 420
						using = Font_Size_Medium
					}
				}

				vbox = {
					name = "county_group"
					datamodel = "[DuchyGroup.GetCounties]"
					layoutpolicy_horizontal = expanding

					spacing = 20

					item = {

						vbox = {
							datacontext = "[CountyGroup.GetCounty]"
							datacontext = "[CountyGroup.GetCapitalProvince.GetCounty]"

							layoutpolicy_horizontal = expanding

							hbox = {
								datacontext = "[CountyGroup.AccessBreakdowns]"
								layoutpolicy_horizontal = expanding

								margin_left = 5
								margin_right = 10
								spacing = 7

								coa_title_tiny = {}

								text_single = {
									layoutpolicy_horizontal = expanding
									text = "[Title.GetNameNoTooltip]"
									max_width = 180
								}

								expand = {}

								text_single = {
									text = "[development|E]: [County.GetDevelopmentLevel|V]"
									max_width = 140

									tooltipwidget = {
										county_development_tooltip_container = {}
									}
								}

								text_single = {
									name = "tutorial_highlight_control"
									text = "[CountyGroup.GetCountyControlColored]"
									max_width = 130

									tooltipwidget = {
										county_control_tooltip_container = {}
									}
								}
							}

							vbox = {
								datamodel = "[CountyGroup.GetHoldings]"
								layoutpolicy_horizontal = expanding
								margin_left = 10
								margin_right = 10
								margin_bottom = 5
								spacing = 3

								item = {
									vbox = {
										name = "holding_realm_list_item" #ra_merit_governor_holdings_list uses this

										datacontext = "[HoldingItem.GetHolding]"
										layoutpolicy_horizontal = expanding

										background = {
											texture = "[HoldingItem.GetHolding.GetIllustration]"
											alpha = 0.7
											fittype = centercrop

											modify_texture = {
												texture = "gfx/interface/component_masks/mask_fade_horizontal.dds"
												blend_mode = alphamultiply
											}

											modify_texture = {
												texture = "gfx/interface/component_overlay/overlay_effect.dds"
												blend_mode = overlay
											}
										}

										button_standard_clean = {
											layoutpolicy_horizontal = expanding
											size = { 0 80 }

											onclick = "[HoldingItem.OnClick]"

											tooltipwidget = { holding_tooltip_click = {} }

											background = {
												visible = "[Holding.IsSelected]"
												using = Background_Button_Illustration
											}

											using = Background_Vignette_Button
											using = Holding_Mouse_Entry

											vbox = {
												margin = { 10 2 }

												hbox = {
													name = "holding_header"
													layoutpolicy_horizontal = expanding
													spacing = 6

													hbox = {
														spacing = 6

														background = {
															texture = "gfx/interface/component_tiles/tile_title_bg_01.dds"
															spriteType = Corneredtiled
															spriteborder = { 40 8 }
															texture_density = 2

															margin_left = 15
															margin_right = 25
															margin_top = 0
															margin_bottom = 5

															modify_texture = {
																name = "mask"
																texture = "gfx/interface/component_masks/mask_fade_horizontal.dds"
																blend_mode = alphamultiply
																mirror = horizontal
															}
														}

														icon = {
															name = "realm_capital_icon"
															visible = "[HoldingItem.IsRealmCapital]"
															size = { 25 25 }
															texture = "gfx/interface/icons/icon_capital.dds"
															framesize = { 60 60 }
															frame = 2

															tooltip = "REALM_CAPITAL_TOOLTIP"
														}

														text_single = {
															text = "MY_REALM_WINDOW_HOLDING_NAME"
														}
													}

													expand = {}

													text_single = {
														text = "MY_REALM_WINDOW_HOLDING_TAX"
														alwaystransparent = yes
														default_format = "#high"

														tooltip = "[Holding.GetTaxTooltip]"
													}

													text_single = {
														visible = "[Holding.GetHolder.HasBarterGoods]"
														text = "MY_REALM_WINDOW_HOLDING_BARTER_GOODS"
														alwaystransparent = yes
														default_format = "#high"

														tooltip = "[Holding.GetBarterGoodsIncomeTooltip]"
													}

													text_single = {
														text = "MY_REALM_WINDOW_HOLDING_LEVY"
														alwaystransparent = yes
														default_format = "#high"

														tooltip = "[Holding.GetLeviesTooltip]"
													}
												}

												hbox = {
													name = "holding_buildings"
													layoutpolicy_horizontal = expanding
													minimumsize = { 0 40 }

													vbox = {
														tooltip = "MY_REALM_WINDOW_BUILDING_CONSTRUCTION_TT"
														using = tooltip_ne

														text_single = {
															text = "[HoldingItem.GetStatusText]"
															align = nobaseline
														}

														hbox = {
															layoutpolicy_horizontal = expanding

															progressbar_standard = {
																name = "building_progressbar"
																visible = "[HoldingItem.GetHolding.IsConstructionInProgress]"
																layoutpolicy_horizontal = expanding
																alwaystransparent = yes

																maximumsize = { -1 15 }
																value = "[HoldingItem.GetHolding.GetConstructionProgress]"
																direction = horizontal
															}

															expand = {}
														}
													}

													text_single = {
														visible = "[HoldingItem.GetHolding.CanConstructAnyBuilding(GetPlayer)]"
														layoutpolicy_horizontal = expanding

														text = "MY_REALM_WINDOW_CONSTRUCT_BUILDING"
														default_format = "#P"
													}

													expand = {}
												}
											}
										}
									}
								}
							}

							vbox = {
								visible = "[DataModelHasItems(CountyGroup.GetEmptyHoldings)]"
								layoutpolicy_horizontal = expanding

								spacing = 5
								margin_left = 10
								margin_right = 10

								button_group = {
									layoutpolicy_horizontal = expanding

									onclick = "[CountyGroup.ToggleExpanded]"

									flowcontainer = {
										spacing = 5

										widget = {
											size = { 18 22 }

											button_expand = {
												parentanchor = center
												frame = "[Select_int32( CountyGroup.IsExpanded, '(int32)2', '(int32)1' )]"
											}
										}

										text_single = {
											text = "ME_REALM_WINDOW_EMPTY_HOLDINGS"
											default_format = "#low"
											align = nobaseline
										}
									}
								}

								expand = {}

								vbox = {
									datamodel = "[CountyGroup.GetEmptyHoldings]"
									visible = "[CountyGroup.IsExpanded]"
									layoutpolicy_horizontal = expanding

									margin_left = 23
									margin_bottom = 5
									spacing = 4

									item = {
										vbox = {
											datacontext = "[HoldingItem.GetHolding]"
											layoutpolicy_horizontal = expanding

											button_standard = {
												datacontext = "[HoldingItem.GetHolding]"
												layoutpolicy_horizontal = expanding
												layoutpolicy_vertical = expanding
												minimumsize = { 0 45 }

												onclick = "[HoldingItem.OnClick]"
												down = "[Holding.IsSelected]"

												using = Holding_Mouse_Entry

												tooltipwidget = {
													holding_tooltip_click = {}
												}

												using = tooltip_ne

												widget = {
													parentanchor = right|top
													position = { -2 2 }
													size = { 350 41 }
													scissor = yes

													icon = {
														name = "illustration"
														parentanchor = right|top
														size = { 180 90 }
														texture = "[HoldingItem.GetHolding.GetProvince.GetTerrain.GetIllustration]"
														alpha = 0.4
														mirror = horizontal

														modify_texture = {
															texture = "gfx/interface/component_masks/mask_fade_horizontal_extended.dds"
															blend_mode = alphamultiply
														}
													}
												}

												icon = {
													parentanchor = center
													size = { 99% 92% }

													texture = "gfx/interface/component_tiles/tile_vignette_3px.dds"
													spriteType = Corneredtiled
													spriteborder = { 5 5 }
												}

												hbox = {
													margin = { 10 0 }

													vbox = {
														layoutpolicy_vertical = expanding
														margin_top = 2

														text_single = {
															text = "[HoldingItem.GetBarony.GetNameNoTierNoTooltip]"
														}

														expand = {}
													}

													expand = {}

													vbox = {
														visible = "[HoldingItem.GetHolding.IsConstructionInProgress]"
														layoutpolicy_vertical = expanding

														margin = { 0 4 }

														text_single = {
															layoutpolicy_horizontal = expanding
															text = "[HoldingItem.GetStatusText]"

															align = nobaseline
														}

														expand = {}

														hbox = {
															layoutpolicy_horizontal = expanding
															margin_bottom = 3

															progressbar_standard = {
																name = "building_progressbar"
																alwaystransparent = yes
																direction = horizontal
																size = { 180 12 }
																value = "[HoldingItem.GetHolding.GetConstructionProgress]"
															}
														}
													}

													vbox = {
														layoutpolicy_vertical = expanding
														margin_top = 2

														text_label_right = {
															visible = "[HoldingItem.GetHolding.CanConstructAnyBuilding(GetPlayer)]"
															layoutpolicy_vertical = fixed
															text = "MY_REALM_WINDOW_CONSTRUCT_HOLDING"
															default_format = "#P"
														}

														expand = {}
													}
												}
											}
										}
									}
								}
							}

							expand = {}
						}
					}
				}
			}
		}
	}

	type vbox_my_realm_subjects_top = vbox {
		widgetid = "tab_vassals"
		layoutpolicy_horizontal = expanding

		divider_light = {
			layoutpolicy_horizontal = expanding
		}

		vbox = {
			layoutpolicy_horizontal = expanding

			margin = { 15 5 }
			margin_bottom = 10
			spacing = 5

			hbox = {
				layoutpolicy_horizontal = expanding

				text_single = {
					text = "MY_REALM_WINDOW_VASSAL_OPINION"
					max_width = 180

					tooltip = "MY_REALM_WINDOW_VASSAL_OPINION_TT"
				}

				expand = {}

				hbox = {
					tooltip = "[GetPlayer.GetDreadBreakdown]"

					icon = {
						name = "dread_icon"
						size = { 30 30 }
						texture = "gfx/interface/icons/icon_dread.dds"
					}

					text_single = {
						name = "dread_name"
						text = "[dread|E]: [GetPlayer.GetDread|0]"
						default_format = "#high"
						max_width = 90
					}
				}

				expand = {}

				hbox = {
					name = "tutorial_highlight_vassal_limit"
					spacing = 4

					tooltip = "[Character.GetVassalLimitTooltip]"

					background = {
						visible = "[GreaterThan_int32( Character.GetNumVassalsTowardsLimit, Character.GetVassalLimit )]"
						using = Status_Bad
					}

					icon = {
						size = { 30 30 }
						texture = "gfx/interface/icons/icon_vassal.dds"
					}

					text_single = {
						text = "MY_REALM_WINDOW_VASSAL_LIMIT"
						max_width = 130
					}

					text_single = {
						text = "MY_REALM_WINDOW_VASSAL_LIMIT_VALUE"
						max_width = 50
					}
				}
			}

			hbox = {
				layoutpolicy_horizontal = expanding
				spacing = 10

				text_single = {
					text = MY_REALM_WINDOW_VASSAL_STANCES
					align = nobaseline
					max_width = 100
				}

				hbox = {
					datamodel = "[GetAllVassalStances]"
					spacing = 5

					item = {
						text_single = {
							visible = "[NotEqualTo_int32( MyRealmWindow.GetNumVassalsWithStance( VassalStance.Self ), '(int32)0' )]"
							text = "MY_REALM_WINDOW_VASSAL_STANCE_COUNT"
							align = nobaseline
							fonttintcolor = "[GetOpinionTint(FixedPointToInt(VassalStance.GetModifierValueFor( MyRealmWindow.GetCharacter )))]"
							margin = { 0 2 }
							margin_left = 5
							margin_right = 10

							using = Background_Area_Border

							tooltip = "MY_REALM_WINDOW_VASSAL_STANCE_COUNT_TT"

							max_width = 56

						}
					}
				}

				expand = {}
			}
		}

		hbox = {
			name = "vassal_filters_container"
			layoutpolicy_horizontal = expanding
			spacing = 30

			dropdown_menu_standard = {
				name = "government_filters_dropdown"

				blockoverride "dropdown_properties"
				{
					datamodel = "[MyRealmWindow.GetGovernmentTypeFilters]"

					onselectionchanged = "[MyRealmWindow.SelectActiveGovernmentTypeFilter]"
					selectedindex = "[MyRealmWindow.GetActiveGovernmentTypeFilterIndex]"
				}

				blockoverride "dropdown_active_item_properties"
				{
					text = "MRW_GOVERNMENT_FILTER"

					tooltip = "MRW_GOVERNMENT_FILTER_DROPDOWN_TT"
				}

				blockoverride "dropdown_item_properties"
				{
					text = "MRW_GOVERNMENT_FILTER"

					tooltip = "MRW_GOVERNMENT_FILTER_TT"
				}
			}

			dropdown_menu_standard = {
				name = "vassal_stance_filters_dropdown"

				blockoverride "dropdown_properties"
				{
					datamodel = "[MyRealmWindow.GetVassalStanceFilters]"

					onselectionchanged = "[MyRealmWindow.SelectActiveVassalStanceFilter]"
					selectedindex = "[MyRealmWindow.GetActiveVassalStanceFilterIndex]"
				}

				blockoverride "dropdown_active_item_properties"
				{
					text = "MRW_VASSAL_STANCE_FILTER"

					tooltip = "MRW_VASSAL_STANCE_FILTER_DROPDOWN_TT"
				}

				blockoverride "dropdown_item_properties"
				{
					text = "MRW_VASSAL_STANCE_FILTER"

					tooltip = "MRW_VASSAL_STANCE_FILTER_TT"
				}
			}
		}

		text_single = {
			name = "government_filter_label"
			visible = "[MyRealmWindow.HasActiveGovernmentTypeFilter]"
			text = "[MyRealmWindow.GetActiveGovernmentTypeFilter.GetVassalsLabel]"
			margin_bottom = 10
		}
	}

	type vbox_my_realm_subjects_body = vbox {
		layoutpolicy_horizontal = expanding
		layoutpolicy_vertical = expanding

		margin = { 0 10 }

		using = Animation_Tab_Switch

		fixedgridbox = {
			datacontext = "[MyRealmWindow.GetPowerfulVassals]"
			datamodel = "[CharacterSelectionList.GetList]"
			visible = "[And( Not( CharacterSelectionList.IsBuildingList ), Not( IsDataModelEmpty( CharacterSelectionList.GetList ) ) )]"
			layoutpolicy_horizontal = expanding
			layoutpolicy_vertical = expanding

			addcolumn = 538
			addrow = 176
			setitemsizefromcell = yes

			item = {
				widget_vassal_list_item = {
					datacontext = "[CharacterListItem.GetCharacter]"
					datacontext = "[MyRealmWindow.GetVassalInfo( Character.Self )]"
					datacontext = "[MyRealmWindowVassalItem.GetContract]"

					background = {
						using = Background_Frame
					}
				}
			}
		}

		fixedgridbox = {
			datacontext = "[MyRealmWindow.GetTributaries]"
			datamodel = "[CharacterSelectionList.GetList]"
			visible = "[And( Not( CharacterSelectionList.IsBuildingList ), Not( IsDataModelEmpty( CharacterSelectionList.GetList ) ) )]"
			layoutpolicy_horizontal = expanding

			addcolumn = 538
			addrow = 176
			setitemsizefromcell = yes

			item = {
				widget_vassal_list_item = {
					name = tutorial_highlight_vassal
					datacontext = "[CharacterListItem.GetCharacter]"
					datacontext = "[MyRealmWindow.GetVassalInfo( Character.Self )]"
					datacontext = "[MyRealmWindowVassalItem.GetContract]"
				}
			}
		}

		fixedgridbox = {
			datacontext = "[MyRealmWindow.GetRegularVassals]"
			datamodel = "[CharacterSelectionList.GetList]"
			visible = "[And( Not( CharacterSelectionList.IsBuildingList ), Not( IsDataModelEmpty( CharacterSelectionList.GetList ) ) )]"
			layoutpolicy_horizontal = expanding

			addcolumn = 538
			addrow = 185
			setitemsizefromcell = yes

			item = {
				widget_vassal_list_item = {
					name = tutorial_highlight_vassal
					datacontext = "[CharacterListItem.GetCharacter]"
					datacontext = "[MyRealmWindow.GetVassalInfo( Character.Self )]"
					datacontext = "[MyRealmWindowVassalItem.GetContract]"
				}
			}
		}

		text_single = {
			visible = "[EqualTo_int32( MyRealmWindow.GetVassalCount, '(int32)0' )]"
			layoutpolicy_vertical = expanding

			text = "MY_REALM_WINDOW_SUBJECTS_NO_SUBJECTS"
			default_format = "#weak"
		}

		expand = {}
	}

	type vbox_my_realm_republics_top = vbox {
		widgetid = "tab_republics"
		layoutpolicy_horizontal = expanding

		divider_light = {
			layoutpolicy_horizontal = expanding
		}

		vbox = {
			layoutpolicy_horizontal = expanding

			margin = { 15 5 }
			margin_bottom = 15
			spacing = 5

			vbox = {
				layoutpolicy_horizontal = expanding
				spacing = 10

				text_single = {
					text = "Important Factors in Elections and Tax:"
					align = nobaseline
					max_width = 500
				}
			}
			hbox = {
				layoutpolicy_horizontal = expanding

				portrait_head_small = {}
				
				hbox = {
					visible = "[Character.GetGovernment.IsType('urbanrepublic_government'))]"
					spacing = 3
					expand = {}
					icon = {
						name = "icon_influence"
						size = { 30 30 }
						texture = "[Character.GetInfluenceLevelTexture]"
					}
					text_single = {
						name = "influence"
						text = "[Character.GetInfluence|0]"
						default_format = "#high"
						align = center|nobaseline
						fontsize_min = 12
						max_width = 50
					}
					expand = {}
				}
				hbox = {
					spacing = 3
					expand = {}
					icon = {
						name = "prestige_icon"
						size = { 30 30 }
						texture = "[Character.GetPrestigeLevelTexture]"
					}
					text_single = {
						name = "influence"
						text = "[Character.GetPrestige|0]"
						default_format = "#high"
						align = center|nobaseline
						fontsize_min = 12
						max_width = 50
					}
					expand = {}
				}
				hbox = {
					spacing = 3
					expand = {}
					icon = {
						name = "icon_piety"
						size = { 30 30 }
						texture = "[Character.GetPietyLevelTexture]"
					}
					text_single = {
						name = "piety"
						text = "[Character.GetPiety|0]"
						default_format = "#high"
						align = center|nobaseline
						fontsize_min = 12
						max_width = 50
					}
					expand = {}
				}
				hbox = {
					spacing = 3
					expand = {}
					icon = {
						name = "icon_dynasty_prestige"
						size = { 30 30 }
						texture = "[Character.GetDynasty.GetDynastyPrestigeLevelTexture]"
					}
					text_single = {
						name = "dynasty_prestige"
						text = "[Character.GetDynasty.GetPrestige|0]"
						default_format = "#high"
						align = center|nobaseline
						fontsize_min = 12
						max_width = 50
					}
					expand = {}
				}
				widget = {
					size = { 50 50 }
						coa_house_medium = {
						datacontext = "[Character.GetHouse]"
						parentanchor = center
					}
				}
			}

			hbox = {
				layoutpolicy_horizontal = expanding
				spacing = 10

				text_single = {
					text = MY_REALM_WINDOW_VASSAL_STANCES
					align = nobaseline
					max_width = 100
				}

				hbox = {
					datamodel = "[GetAllVassalStances]"
					spacing = 5

					item = {
						text_single = {
							visible = "[NotEqualTo_int32( MyRealmWindow.GetNumVassalsWithStance( VassalStance.Self ), '(int32)0' )]"
							text = "MY_REALM_WINDOW_VASSAL_STANCE_COUNT"
							align = nobaseline
							fonttintcolor = "[GetOpinionTint(FixedPointToInt(VassalStance.GetModifierValueFor( MyRealmWindow.GetCharacter )))]"
							margin = { 0 2 }
							margin_left = 5
							margin_right = 10

							using = Background_Area_Border

							tooltip = "MY_REALM_WINDOW_VASSAL_STANCE_COUNT_TT"

							max_width = 56

						}
					}
				}

				expand = {}
			}
		}


		text_single = {
			name = "government_filter_label"
			visible = "[MyRealmWindow.HasActiveGovernmentTypeFilter]"
			text = "[MyRealmWindow.GetActiveGovernmentTypeFilter.GetVassalsLabel]"
			margin_bottom = 10
		}
	}
	type vbox_my_realm_republics_body = vbox {
		layoutpolicy_horizontal = expanding
		layoutpolicy_vertical = expanding

		margin = { 0 10 }

		using = Animation_Tab_Switch

		fixedgridbox = {
			datacontext = "[MyRealmWindow.GetPowerfulVassals]"
			datamodel = "[CharacterSelectionList.GetList]"
			visible = "[And( Not( CharacterSelectionList.IsBuildingList ), Not( IsDataModelEmpty( CharacterSelectionList.GetList ) ) )]"
			layoutpolicy_horizontal = expanding
			layoutpolicy_vertical = expanding

			addcolumn = 538
			addrow = 176
			setitemsizefromcell = yes

			item = {
				widget_republic_vassal_list_item = {
					datacontext = "[CharacterListItem.GetCharacter]"
					datacontext = "[MyRealmWindow.GetVassalInfo( Character.Self )]"
					datacontext = "[MyRealmWindowVassalItem.GetContract]"

					background = {
						using = Background_Frame
					}
				}
			}
		}

		fixedgridbox = {
			datacontext = "[MyRealmWindow.GetRegularVassals]"
			datamodel = "[CharacterSelectionList.GetList]"
			visible = "[And( Not( CharacterSelectionList.IsBuildingList ), Not( IsDataModelEmpty( CharacterSelectionList.GetList ) ) )]"
			layoutpolicy_horizontal = expanding

			addcolumn = 538
			addrow = 185
			setitemsizefromcell = yes

			item = {
				widget_republic_vassal_list_item = {
					name = tutorial_highlight_vassal
					datacontext = "[CharacterListItem.GetCharacter]"
					datacontext = "[MyRealmWindow.GetVassalInfo( Character.Self )]"
					datacontext = "[MyRealmWindowVassalItem.GetContract]"
				}
			}
		}

		expand = {}
	}
	type vbox_my_realm_succession_body_top = vbox {
		layoutpolicy_horizontal = expanding
		margin_bottom = 5

		text_single = {
			visible = "[MyRealmWindow.HasHeir]"
			margin = { 0 4 }

			text = "MRW_YOUR_PLAYER_HEIR"
			align = nobaseline
			default_format = "#I"
			max_width = 500
		}

		text_single = {
			name = "no_heir_warning"
			visible = "[Not( MyRealmWindow.HasHeir )]"
			margin = { 0 4 }

			text = "MY_REALM_WINDOW_NO_HEIR_FLAVOR"
			align = nobaseline
		}

		hbox = {
			layoutpolicy_horizontal = expanding
			allow_outside = yes
			margin = { 10 0 }

			### HEIR INFO
			vbox = {
				layoutpolicy_horizontal = expanding
				layoutpolicy_vertical = expanding
				margin_left = 10
				spacing = 2

				text_label_left = {
					layoutpolicy_horizontal = expanding
					text = "game_concept_player_heir"
					align = nobaseline
					using = Font_Size_Medium

					margin = { 0 2 }
				}

				text_single = {
					visible = "[MyRealmWindow.HasHeir]"
					layoutpolicy_horizontal = expanding

					text = "[MyRealmWindow.GetCharacter.GetPlayerHeir.GetUINameNoTooltip]"
					default_format = "#low"
					max_width = 415
					using = Font_Size_Medium
				}

				text_single = {
					name = "vassal_stances_that_prefer"
					datacontext = "[MyRealmWindow.GetCharacter.GetPlayerHeir]"
					visible = "[And( Not( IsLandlessAdventurer( GetPlayer ) ), And( MyRealmWindow.HasHeir, Not( StringIsEmpty( MyRealmWindow.GetCharacter.GetVassalStancesThatPrefer( Character.Self ) ) ) ) )]"
					layoutpolicy_horizontal = expanding
					autoresize = no

					text = "MY_REALM_WINDOW_SUCCESSION_PREFERRED_BY"
					default_format = "#weak"
				}

				hbox = {
					visible = [MyRealmWindow.HasHeir]
					layoutpolicy_horizontal = expanding
					margin = { 5 5 }

					text_single = {
						datacontext = "[MyRealmWindow.GetCharacter.GetPlayerHeir]"

						text = "[MyRealmWindow.GetCharacter.GetVassalStancesThatPrefer( Character.Self )]"
						align = nobaseline
						using = Font_Size_Medium

						layoutpolicy_horizontal = expanding
						autoresize = no
					}
				}

				hbox = {
					layoutpolicy_horizontal = expanding
					margin_top = 2

					button_standard = {
						size = { 150 32 }

						text = "MY_REALM_WINDOW_SUCCESSION_DESIGNATE_HEIR"

						enabled = "[MyRealmWindow.CanDesignateHeir]"
						onclick = "[OpenDesignateHeirWindow]"

						tooltip = "MRW_DESIGNATE_HEIR_TT"
					}

					expand = {}
				}

				expand = {}
			}

			portrait_shoulders = {
				datacontext = "[MyRealmWindow.GetCharacter.GetPlayerHeir]"
				visible = "[Character.IsValid]"
				allow_outside = yes

				blockoverride "glow_visible"
				{
					visible = no
				}
			}
		}
	}

	type vbox_my_realm_succession_body = vbox {
		name = "tab_succession"
		widgetid = "tab_succession"
		datacontext = "[MyRealmWindow.GetKurultaiSuccession]"

		layoutpolicy_horizontal = expanding
		layoutpolicy_vertical = expanding

		using = Animation_Tab_Switch

		vbox = {
			layoutpolicy_horizontal = expanding

			vbox_succession_content_kurultai = {
				visible = "[KurultaiSuccession.IsValid]"
			}

			vbox_succession_content_default = {
				visible = "[Not( KurultaiSuccession.IsValid )]"
			}
		}

		vbox_kurultai_group_foldout = {
			visible = "[And( KurultaiSuccession.IsValid, Not( IsDataModelEmpty( KurultaiSuccession.GetElectors ) ) )]"
		}

		vbox_kurultai_inherited_titles_group_foldout = {
			visible = "[KurultaiSuccession.IsValid]"
		}

		expand = {}
	}

	type widget_my_realm_law_item = widget {
		datacontext = "[GuiLawGroup]"
		size = { 246 62 }

		background = {
			using = Background_Area
		}

		hbox = {
			margin = { 10 0 }

			vbox = {
				text_single = {
					layoutpolicy_horizontal = expanding
					raw_text = "[GuiLawGroup.GetLawGroup.GetNameSingular]:"
					align = nobaseline
					max_width = 170
				}

				text_single = {
					layoutpolicy_horizontal = expanding
					text = "[GuiLawGroup.GetCurrentLevel.GetLaw.GetName]"
					align = nobaseline
					default_format = "#high"
					max_width = 170
				}
			}

			expand = {}

			button_round = {
				datacontext = "[GuiLawGroup.GetLawGroup]"
				visible = "[Not( LawGroup.HasFlag( 'treasury_budget_law' ) )]"
				enabled = "[LawGroup.CanRulerChange(GetPlayer)]"
				tooltip_when_disabled = "[GuiLawGroup.GetCanChangeTooltip]"
				size = { 30 30 }

				button_change = {
					size = { 24 24 }
					parentanchor = center
					onclick = "[OpenSuccessionLawChangeWindow( GuiLawGroup.Self )]"
				}
			}
		}
	}

	type vbox_law_item = vbox {
		layoutpolicy_horizontal = expanding
		spacing = 8

		text_label_center = {
			block "item_title"
			{
				text = "MY_REALM_WINDOW_LAWS_REALM_LAWS"
			}
		}

		text_multi = {
			block "item_desc"
			{
				visible = no
			}
			align = nobaseline
			default_format = "#weak"
			autoresize = yes
			max_width = 500
		}

		flowcontainer = {
			datamodel = "[MyRealmWindow.GetRealmLaws]"
			ignoreinvisible = yes
			wrap_count = 2

			item = {
				widget_my_realm_law_item = {
					block "show_law"
					{
						visible = "[And( GuiLawGroup.IsAvailable, Not( GuiLawGroup.GetLawGroup.HasFlag( 'realm_law' ) ))]"
					}
				}
			}
		}
	}

	type vbox_election_title_law_item = vbox {
		datacontext = "[TitleItem.GetTitle]"
		layoutpolicy_horizontal = expanding

		background = {
			using = Background_Frame
		}

		hbox = {
			layoutpolicy_horizontal = expanding

			margin = { 10 0 }
			margin_top = 2
			margin_bottom = 4
			spacing = 10

			container = {
				my_realm_coa_tiny_item = {}
			}

			text_single = {
				layoutpolicy_horizontal = expanding

				text = "[Title.GetTitleLawsTooltip]"
				align = nobaseline
			}

			expand = {}

			button_round = {
				visible = "[Not( ObjectsEqual( Title.Self, Character.GetPrimaryTitle.Self ) )]"

				button_election_vote = {
					parentanchor = center

					onclick = "[OpenSuccessionElectionWindowForTitle(Title.Self)]"
					tooltip = "MY_REALM_WINDOW_VOTE_TOOLTIP"
				}
			}
		}
	}

	type vbox_my_realm_laws_body = vbox {
		using = Animation_Tab_Switch

		### LAWS TOP AND PROGRESS BAR
		vbox = {
			visible = "[And( And( GreaterThan_int32( MyRealmWindow.GetPowerfulVassalLawVoteCount, '(int32)0' ), Not( IsNomad( GetPlayer ) ) ), Not( GetPlayer.GetGovernment.HasRule( 'deny_powerful_vassal' )))]"
			margin_top = 15
			spacing = 5

			text_multi = {
				text = "MY_REALM_WINDOW_LAWS_PROGRESS_BAR_DESC"
				align = center|nobaseline
				autoresize = yes
				default_format = "#I"
				max_width = 500
			}

			text_single = {
				text = "MY_REALM_WINDOW_LAWS_PROGRESS_BAR_TITLE"
				align = nobaseline
				max_width = 500
			}

			### POWERFUL VASSALS PROGRESS BAR
			vbox = {
				layoutpolicy_horizontal = expanding
				margin = { 20 0 }

				hbox = {
					layoutpolicy_horizontal = expanding
					spacing = 10

					text_single = {
						text = "MY_REALM_WINDOW_LAWS_PROGRESS_BAR_APPROVES"
						align = nobaseline
						max_width = 150
					}

					progressbar_standard = {
						layoutpolicy_horizontal = expanding
						size = { 140 20 }

						using = Animation_ShowHide_Standard

						max = "[IntToFloat( MyRealmWindow.GetPowerfulVassalLawVoteCount )]"
						value = "[IntToFloat( MyRealmWindow.GetPowerfulVassalLawApproves )]"
					}

					text_single = {
						text = "MY_REALM_WINDOW_LAWS_PROGRESS_BAR_OPPOSES"
						align = nobaseline
						max_width = 150
					}
				}
			}
		}

		### KURULTAI PROGRESS BAR
		vbox = {
			datacontext = "[MyRealmWindow.GetKurultaiSuccession]"
			visible = "[And( GreaterThan_int32( KurultaiSuccession.GetVoteCount, '(int32)0' ), IsNomad( GetPlayer ) )]"
			layoutpolicy_horizontal = expanding

			margin_top = 15

			hbox = {
				layoutpolicy_horizontal = expanding
				spacing = 10

				text_single = {
					text = "MY_REALM_WINDOW_KURULTAI_APPROVES"
					align = nobaseline
					max_width = 150
				}

				progressbar_standard = {
					name = "kurultai_votes"
					layoutpolicy_horizontal = expanding
					size = { 200 20 }

					using = Animation_ShowHide_Standard

					max = "[IntToFloat( KurultaiSuccession.GetVoteCount )]"
					value = "[IntToFloat( KurultaiSuccession.GetObedientCount )]"
				}

				text_single = {
					text = "MY_REALM_WINDOW_KURULTAI_OPPOSES"
					align = nobaseline
					max_width = 150
				}
			}

			text_multi = {
				text = "MY_REALM_WINDOW_KURULTAI_OBEDIENT"
				autoresize = yes
				default_format = "#italic"
				align = center
				max_width = 500
				margin = { 0 5 }
			}
		}

		vbox = {
			layoutpolicy_horizontal = expanding
			margin_top = 10
			spacing = 18

			### REALM LAWS (except the flag 'realm_law' as those are reserved for Crown Authority)
			vbox_law_item = {
				blockoverride "item_title"
				{
					visible = no
				}

				blockoverride "show_law"
				{
					visible = "[And( GuiLawGroup.IsAvailable, Or( GuiLawGroup.GetLawGroup.HasFlag( 'succession_order_laws' ), Or( GuiLawGroup.GetLawGroup.HasFlag( 'succession_gender_laws' ), GuiLawGroup.GetLawGroup.HasFlag( 'imperial_policy' ) ) ) )]"
				}
			}

			### PRIMARY TITLE ELECTION (if exists)
			flowcontainer = {
				name = "primary_title_election"
				datacontext = "[GetPlayer]"
				datamodel = "[MyRealmWindow.GetTitlesCanVote]"
				visible = "[MyRealmWindow.CanVote]"

				ignoreinvisible = yes

				item = {
					button_standard = {
						datacontext = "[TitleItem.GetTitle]"
						visible = "[ObjectsEqual( Title.Self, Character.GetPrimaryTitle.Self )]"
						text = "MY_REALM_WINDOW_VOTE"

						onclick = "[OpenSuccessionElectionWindowForTitle(Title.Self)]"

						tooltip = "MY_REALM_WINDOW_VOTE_TOOLTIP"
					}
				}
			}

			#### ELECTIONS BUTTON
			vbox = {
				visible = "[MyRealmWindow.CanVote]"
				layoutpolicy_horizontal = expanding

				text_label_left = {
					layoutpolicy_horizontal = expanding
					text = "MY_REALM_WINDOW_LAWS_SPECIFIC_SUCCESSION_LAWS"
				}

				vbox = {
					name = "elections"
					datacontext = "[GetPlayer]"
					datamodel = "[MyRealmWindow.GetTitlesCanVote]"
					layoutpolicy_horizontal = expanding
					ignoreinvisible = yes

					margin_top = 5

					item = {
						vbox_election_title_law_item = {
							visible = "[Not( ObjectsEqual( Title.Self, Character.GetPrimaryTitle.Self ) )]"
						}
					}
				}
			}

			### PROVINCIAL LAWS
			vbox_law_item = {
				datacontext = "[GetPlayer]"
				visible = "[ProvincialLawCharacter( Character )]"

				blockoverride "item_title"
				{
					text = "MY_REALM_WINDOW_LAWS_PROVINCIAL_LAWS"
				}

				blockoverride "item_desc"
				{
					text = "MY_REALM_WINDOW_LAWS_PROVINCIAL_LAWS_DESC"
				}

				blockoverride "show_law"
				{
					visible = "[And( GuiLawGroup.IsAvailable, GuiLawGroup.GetLawGroup.HasFlag( 'admin_law' ) )]"

					enabled = "[Not( Character.HasOverlord )]"

					tooltip_when_disabled = "MY_REALM_WINDOW_LAWS_PROVINCIAL_LAWS_DESC_DISABLED"
				}
			}

			### TREASURY BUDGET LAWS
			vbox_law_item = {
				datacontext = "[GetPlayer]"
				visible = "[And( Character.IsIndependentRuler, Character.HasTreasury )]"

				blockoverride "item_title"
				{
					text = "MY_REALM_WINDOW_LAWS_TREASURY_BUDGET_LAWS"
				}

				blockoverride "show_law"
				{
					visible = "[And( GuiLawGroup.IsAvailable, GuiLawGroup.GetLawGroup.HasFlag( 'treasury_budget_law' ) )]"

					enabled = "[Not( Character.HasOverlord )]"

					tooltip_when_disabled = "MY_REALM_WINDOW_LAWS_TREASURY_BUDGET_LAWS_DESC_DISABLED"
				}
			}

			button_standard = {
				visible = "[And( Character.IsIndependentRuler, Character.HasTreasury )]"
				size = { 320 44 }

				onclick = "[OpenGameViewData( 'treasury_budget_change', GetPlayer.Self )]"

				hbox = {
					layoutpolicy_horizontal = expanding
					spacing = 12

					expand = {}

					icon = {
						size = { 32 32 }
						texture = "gfx/interface/icons/icon_imperial_treasury.dds"
					}

					text_single = {
						text = "MY_REALM_WINDOW_MANAGE_TREASURY_BUDGET"
						align = nobaseline
						default_format = "#clickable"
					}
					expand = {}
				}
			}
		}
	}

	type authority_icon = vbox {
		hbox = {
			visible = "[IsNomad( Character )]"

			icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)0')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/dominance_01.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)1')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/dominance_02.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)2')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/dominance_03.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)3')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/dominance_04.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)4')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/dominance_05.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}
		}

		hbox = {
			visible = "[And(Not(IsNomad( Character )),Not(Character.GetGovernment.HasGovernmentFlag( 'government_is_tribal' )))]"

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)0')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/crown_authority_0.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)1')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/crown_authority_1.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)2')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/crown_authority_2.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)3')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/crown_authority_3.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}
		}

		hbox = {
			visible = "[Character.GetGovernment.HasGovernmentFlag( 'government_is_tribal' )]"

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)0')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/tribal_authority_0.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)1')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/tribal_authority_1.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)2')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/tribal_authority_2.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}

			button_icon = {
				visible = "[EqualTo_int32( Law.GetIndexInLawGroup, '(int32)3')]"
				size = { 30 30 }
				texture = "gfx/interface/icons/laws/tribal_authority_3.dds"

				tooltipwidget = {
					general_law_tooltip = {}
				}
			}
		}
	}
}
