{
  "namespace": "chat",

  // Button Images //

  "down_arrow_image": {
    "type": "image",
    "size": [ 12, 8 ],
    "texture": "textures/ui/chat_down_arrow"
  },
  "keyboard_image": {
    "type": "image",
    "size": [ 9, 7 ],
    "texture": "textures/ui/chat_keyboard"
  },
  "send_image": {
    "type": "image",
    "size": [ 21, 18 ],
    "texture": "textures/ui/chat_send"
  },
  "send_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ 44, 17 ],
    "controls": [
      {
        "send_image_panel": {
          "type": "panel",
          "size": [ "fill", "100%c" ],
          "controls": [
            { "send_image@send_image": {} }
          ]
        }
      },
      {
        "gamepad_x_button": {
          "type": "stack_panel",
          "orientation": "horizontal",
          "size": [ 23, "100%" ],
          "controls": [
            {
              "side_padding": {
                "type": "panel",
                "size": [ 2, "100%" ]
              }
            },
            {
              "gamepad_x_button_image": {
                "type": "panel",
                "controls": [
                  {
                    "icon@common.gamepad_helper_x": {
                      "$icon_description_bind_type": "none"
                    }
                  }
                ]
              }
            }
          ],
          "bindings": [
            {
              "binding_name": "#gamepad_helper_visible",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "keyboard_image_panel": {
    "type": "panel",
    "controls": [
      {
        "keyboard_image@chat.keyboard_image": {
          "bindings": [
            {
              "binding_name": "(not #keyboard_being_used)",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "down_arrow_image@chat.down_arrow_image": {
          "bindings": [
            {
              "binding_name": "#keyboard_being_used",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  // Buttons //

  "small_button@common_buttons.light_content_button": {
    "size": [ 27, 27 ],
    "$pressed_button_name": "button.send",
    "anchor_from": "bottom_right",
    "anchor_to": "bottom_right"
  },

  "keyboard_button@chat.small_button": {
    "$button_content": "chat.keyboard_image_panel",
    "$pressed_button_name": "button.keyboard_toggle",
    "$focus_id": "keyboard_button_focus_id",
    "bindings": [
      {
        "binding_name": "#keyboard_button_focus_override_up",
        "binding_name_override": "#focus_change_up"
      },
      {
        "binding_name": "#keyboard_button_focus_override_down",
        "binding_name_override": "#focus_change_down"
      }
    ]
  },

  "send_button@common_buttons.light_text_form_fitting_button": {
    "$pressed_button_name": "button.send",
    "$anchor": "bottom_right",
    "size": [ "100%c", 27 ],

    "focus_enabled": false,

    "$button_type_panel": "chat.send_panel",
    "bindings": [
      {
        "binding_name": "#send_button_visible",
        "binding_name_override": "#enabled"
      }
    ]
  },

  "hide_toggle@settings_common.option_toggle": {
    "$option_binding_name": "#hide_chat",
    "$option_enabled_binding_name": "#hide_chat_enabled",
    "$toggle_name": "hide_chat"
  },

  // Messages Panel //

  "messages_text": {
    "type": "panel",
    "size": [ "100%", "100%c" ],
    "controls": [
      {
        "text": {
          "type": "label",
          "color": "$chat_text_color",
          "localize": false,
          "size": [ "100%", "default" ],
          "text": "#text",
          "line_padding": "$chat_message_spacing"
        }
      }
    ],
    "bindings": [
      {
        "binding_name": "#chat_visible",
        "binding_name_override": "#visible"
      }
    ]
  },
  "messages_stack_panel": {
    "type": "stack_panel",
    "orientation": "vertical",
    "$scrolling_content_anchor_from": "bottom_left",
    "$scrolling_content_anchor_to": "bottom_left",
    "factory": {
      "name": "messages_factory",
      "max_children_size": 100,
      "control_ids": {
        "chat_screen_messages": "chat_screen_messages@chat.messages_text"
      }
    }
  },
  "messages_scrolling_panel@common.scrolling_panel": {
    "type": "panel",
    "size": [ "100%-2px", "100%-50px" ],
    "anchor_from": "bottom_left",
    "anchor_to": "bottom_left",
    "offset": [ 2, -27 ],
    "$scrolling_content": "chat.messages_stack_panel",
    "$scroll_size": [ 5, "100%-4px" ],
    "$jump_to_bottom_on_update": true,
    "$show_background": false
  },

  // Chat Text Edit //

  "text_edit_box@common.text_edit_box": {
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "fill", 27 ],
    "max_length": 512,
    "$text_box_name": "#message_text_box",
    "$text_edit_box_content_binding_name": "#message_text_box_content",

    // This one thinks it's so important, it gets selected first
    "default_focus_precedence": 1,
    "$focus_id": "text_edit_box_focus_id",
    "$focus_override_right": "keyboard_button_focus_id",
    "$focus_override_left": "host_main_button_focus_id",
    // focus override up and down are controlled with bindings

    "bindings": [
      {
        "binding_type": "$text_edit_box_enabled_binding_type",
        "binding_collection_name": "$text_edit_box_grid_collection_name",
        "binding_name": "$text_box_enabled_binding_name",
        "binding_name_override": "#enabled"
      },
      {
        "binding_name": "#text_edit_box_focus_override_up",
        "binding_name_override": "#focus_change_up"
      },
      {
        "binding_name": "#text_edit_box_focus_override_down",
        "binding_name_override": "#focus_change_down"
      }
    ],

    "button_mappings": [
      // Original Mappings - defined in common.text_edit_box //
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "$text_edit_box_selected_to_button_id",
        "handle_select": true,
        "handle_deselect": true,
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "$text_edit_box_selected_to_button_id",
        "handle_select": false,
        "handle_deselect": true,
        "mapping_type": "global",
        "consume_event": false
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "$text_edit_box_selected_to_button_id",
        "handle_select": true,
        "handle_deselect": false,
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "$text_edit_box_selected_to_button_id",
        "handle_select": false,
        "handle_deselect": true,
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "$text_edit_box_deselected_to_button_id",
        "handle_select": false,
        "handle_deselect": true,
        "mapping_type": "global"
      },
      {
        "to_button_id": "$text_edit_box_hovered_button_id",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "$text_edit_box_clear_from_button_id",
        "to_button_id": "$text_edit_box_clear_to_button_id",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "focused"
      },

      // Extra Mappings //
      {
        "from_button_id": "button.menu_autocomplete",
        "to_button_id": "button.chat_autocomplete",
        "handle_select": true,
        "handle_deselect": false,
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_autocomplete_back",
        "to_button_id": "button.chat_autocomplete_back",
        "handle_select": true,
        "handle_deselect": false,
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_textedit_up",
        "to_button_id": "button.chat_previous_message",
        "handle_select": true,
        "handle_deselect": false,
        "mapping_type": "focused"
      },
      {
        "from_button_id": "button.menu_textedit_down",
        "to_button_id": "button.chat_next_message",
        "handle_select": true,
        "handle_deselect": false,
        "mapping_type": "focused"
      },

      // Controller Mappings //
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.open_chat_settings",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "global",
        // TODO: Always use this binding once the Mute User Story is finished
        "ignored": "$is_publish"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.mute_chat",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "global",
        // TODO: delete this binding once the Mute User Story is finished
        "ignored": "(not $is_publish)"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.send",
        "mapping_type": "global",
        "handle_select": false,
        "handle_deselect": false
      },
      {
        "from_button_id": "button.controller_start",
        "to_button_id": "button.send",
        "mapping_type": "global",
        "handle_select": false,
        "handle_deselect": false
      },
      {
        "from_button_id": "button.controller_autocomplete",
        "to_button_id": "button.chat_autocomplete",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.controller_autocomplete_back",
        "to_button_id": "button.chat_autocomplete_back",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.controller_textedit_up",
        "to_button_id": "button.chat_previous_message",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "focused"
      },
      {
        "from_button_id": "button.controller_textedit_down",
        "to_button_id": "button.chat_next_message",
        "handle_select": false,
        "handle_deselect": false,
        "mapping_type": "focused"
      }
    ]
  },

  // Commands Background //

  "commands_background": {
    "type": "image",
    "size": [ "100%", "100%c" ],
    "texture": "textures/ui/White",
    "color": [ 0.0, 0.0, 0.0 ]
  },

  // Auto Complete //

  "auto_complete_panel_contents_with_item": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    // We have to manually put in the size because item renderer is weird.
    "size": [ "100%", 10 ],

    "controls": [
      {
        "auto_complete_item_renderer@common.item_renderer": {
          "size": [ 9, 9 ],
          "offset": [ -2, -4 ],
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "bindings": [
            {
              "binding_name": "#auto_complete_item",
              "binding_type": "collection",
              "binding_name_override": "#item_id_aux",
              "binding_collection_name": "auto_complete"
            }
          ]
        }
      },
      {
        "text": {
          "type": "label",
          "color": "$chat_text_color",
          "offset": [ 2, 0 ],
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "text": "#text",
          "localize": false,
          "bindings": [
            {
              "binding_type": "collection",
              "binding_name": "#auto_complete_text",
              "binding_name_override": "#text",
              "binding_collection_name": "auto_complete"
            }
          ]
        }
      }
    ]
  },
  "auto_complete_panel": {
    "type": "panel",
    "size": [ "100%", "100%" ],
    "anchor_from": "bottom_left",
    "anchor_to": "bottom_left",
    "controls": [
      {
        "panel": {
          "type": "panel",
          "size": [ "100%", "100%" ],
          "max_size": [ "100%", "100%" ],
          "min_size": [ 0, 0 ],

          "anchor_from": "bottom_left",
          "anchor_to": "bottom_left",
          "controls": [
            {
              "auto_complete_grid": {
                "type": "grid",
                "grid_item_template": "chat.auto_complete_panel_contents_with_item",
                "grid_fill_direction": "vertical",
                "collection_name": "auto_complete",
                "anchor_from": "bottom_left",
                "anchor_to": "bottom_left",
                "size": [ "100%", "100%" ],
                "bindings": [
                  {
                    "binding_name": "#get_grid_size",
                    "binding_type": "collection",
                    "binding_collection_name": "auto_complete"
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  // Commands Stack Panel //

  "commands_panel": {
    "type": "panel",
    "anchor_from": "bottom_left",
    "anchor_to": "bottom_left",
    "offset": [ 0, -27 ],
    "size": [ "100%", "100%-50px" ],
    "controls": [
      {
        "auto_complete_panel@chat.auto_complete_panel": {
          "anchor_from": "bottom_left",
          "anchor_to": "bottom_left"
        }
      }
    ]
  },

  // Chat Bottom Panel //

  "chat_bottom_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "size": [ "100%", 27 ],
    "min_size": [ "100%", 27 ],
    "controls": [
      { "keyboard_button@chat.keyboard_button": {} },
      { "host_main_button@host_options.host_main_button": { "ignored": "$is_pregame" } },
      { "text_box@chat.text_edit_box": {} },
      { "send_button@chat.send_button": { "offset": [ -20, 0 ] } }
    ]
  },

  // Title Bar //

  "title_text": {
    "type": "panel",
    "size": [ "fill", "100%" ],
    "controls": [
      {
        "title_panel": {
          "type": "label",
          "size": [ "default", 10 ],
          "text": "#text",
          "offset": [ 28, -1 ],
          "color": "$title_text_color",
          "layer": 2,
          "bindings": [
            {
              "binding_name": "#chat_title_text",
              "binding_name_override": "#text"
            }
          ]
        }
      }
    ]
  },

  // TODO: When the Mute User Story is done, then this Mute Toggle should be removed
  "mute_text": {
    "type": "panel",
    "size": [ "100%c", "100%" ],
    "controls": [
      {
        "title_panel": {
          "type": "label",
          "size": [ "default", 10 ],
          "text": "chat.mute",
          "offset": [ 2, -1 ],
          "color": "$title_text_color",
          "layer": 2
        }
      }
    ]
  },

  "mute_interaction": {
    "type": "panel",
    "size": [ "100%c", "100%" ],
    "anchor_from": "left_middle",
    "anchor_to": "left_middle",
    "controls": [

      // Yes or No //

      {
        "yes_or_no_panel": {
          "type": "panel",
          "size": [ 24, "100%" ],
          "controls": [
            {
              "yes_or_no_label": {
                "type": "label",
                "size": [ 20, 8 ],
                "offset": [ -20, -2 ],
                "text": "#text",
                "color": "$title_text_color",
                "layer": 2,
                "bindings": [
                  {
                    "binding_name": "#text_chat_hidden",
                    "binding_name_override": "#text"
                  }
                ]
              }
            }
          ]
        }
      },

      // Toggle for Keyboad and Touch //

      {
        "toggle_panel": {
          "type": "panel",
          "size": [ "100%c", "100%c" ],
          "anchor_from": "bottom_left",
          "anchor_to": "bottom_left",
          "controls": [
            {
              "hide_toggle@chat.hide_toggle": {
                "size": [ 32, "100%c" ],
                "offset": [ 20, 1 ],
                "bindings": [
                  {
                    "binding_name": "(not #gamepad_helper_visible)",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "gamepad_y_button": {
          "type": "panel",
          "size": [ 24, 17 ],
          "offset": [ 6, -1 ],
          "controls": [
            {
              "icon@common.gamepad_helper_y": {
                "$icon_description_bind_type": "none"
              }
            }
          ],
          "bindings": [
            {
              "binding_name": "#gamepad_helper_visible",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "back_content_panel": {
    "type": "panel",
    "size": [ "100%c", "100%" ],
    "anchor_from": "left_middle",
    "anchor_to": "left_middle",
    "controls": [
      {
        "back_button@common.back_button": {
          "offset": [ 0, -1 ],
          "$button_text_binding_type": "global",
          "$button_text": "#back_button_text"
        }
      },
      {
        "gamepad_back_helper": {
          "type": "panel",
          "size": [ "100%c", 26 ],
          "offset": [ -4, -1 ],
          "$gamepad_helper_icon_description_text_color": "$light_glyph_default_color",
          "$gamepad_helper_icon_description_shadow": false,
          "controls": [
            {
              "gamepad_helper_button@common.gamepad_helper_b": {
                "$icon_description_bind": "#back_button_text"
              }
            }
          ],
          "bindings": [
            {
              "binding_name": "#is_using_gamepad",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "mute_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%" ],
    "controls": [
      { "mute@chat.mute_text": {} },
      {
        "padding3": {
          "type": "panel",
          "size": [ 16, "100%" ]
        }
      },
      { "mute_interact@chat.mute_interaction": {} }
    ]
  },

  "chat_header": {
    "type": "stack_panel",
    "size": [ "100%", "100%" ],
    "$back_button_text": "controller.buttonTip.back",
    "controls": [
      {
        "top_bar@common_store.store_top_bar": {
          "size": [ "100%", 23 ],
          "controls": [
            {
              "title_stack_panel": {
                "type": "stack_panel",
                "size": [ "100%", 19 ],
                "orientation": "horizontal",
                "controls": [
                  {
                    "padding1": {
                      "type": "panel",
                      "size": [ 2, "100%" ]
                    }
                  },
                  {
                    "back_button_content_panel@chat.back_content_panel": {
                    }
                  },
                  { "title@chat.title_text": {} },
                  {
                    "padding2": {
                      "type": "panel",
                      "size": [ 2, "100%" ]
                    }
                  },
                  { "mute_section@chat.mute_panel": { "ignored": "(not $is_publish)" } },
                  // TODO: Show the chat settings button once the Mute User Story has been finished
                  { "chat_settings_button@chat_settings.chat_settings_button_panel": { "ignored": "$is_publish" } },
                  {
                    "padding4": {
                      "type": "panel",
                      "size": [ 2, "100%" ]
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  ////////////////////////////
  // Main Screen            //
  ////////////////////////////

  "chat_screen@common.base_screen": {
    "close_on_player_hurt": true,
    "$screen_content": "chat.chat_screen_content",
    "$screen_bg_content": "chat.chat_background",
    "button_mappings": [
      {
        "from_button_id": "button.menu_exit",
        "to_button_id": "button.chat_menu_cancel",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.chat_menu_cancel",
        "mapping_type": "global"
      }
    ]
  },

  "chat_screen_content": {
    "type": "panel",
    "controls": [
      { "messages_panel@chat.messages_scrolling_panel": {} },
      { "chat_bottom_panel@chat.chat_bottom_panel": { "layer": 2 } },
      { "chat_top_panel@chat.chat_header": { "layer": 2 } },
      { "autocomplete_commands_panel@chat.commands_panel": { "layer": 3 } },
      { "host_main_panel@host_options.host_panel": { "layer": 4 } },
      { "settings_screen@chat_settings.chat_settings_screen": { "layer": 13 } }
    ]
  },

  "chat_background": {
    "type": "image",
    "size": [ "100%", "100%" ],
    "texture": "textures/ui/White",
    "color": [ 0.0, 0.0, 0.0 ],
    "alpha": 0.5
  },

  ////////////////////////////
  // Standalone window      //
  ////////////////////////////

  "main_stack_panel": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100% - 4px", "100%" ],
    "controls": [
      {
        "messages_scrolling_panel@chat.messages_scrolling_panel": {
          "size": [ "100%-2px", "100%-29px" ]
        }
      },
      {
        "chat_bottom_panel@chat.chat_bottom_panel": {}
      }
    ]
  },

  "main_with_intellisense": {
    "type": "panel",
    "controls": [
      {
        "main_stack@main_stack_panel": {}
      },
      {
        "commands_panel@chat.commands_panel": {
          "size": [ "100%", "100%-29px" ],
          "offset": [ 0, -29 ],
          "layer": 11
        }
      }
    ]
  },

  "dev_console_dialog@common_dialogs.main_panel_no_buttons": {
    "$child_control": "main_with_intellisense",
    "size": [ "100%", "75%" ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle"
  },

  "dev_console_screen@common.base_screen": {
    "$screen_content": "chat.dev_console_dialog",
    "force_render_below": true
  }
}