<h3>ejabberd (XMPP)</h3>
<ul role="list">
  <%= render FormElements::FieldsetToggleComponent.new(
    form: f,
    attribute: :ejabberd_enabled,
    enabled: Setting.ejabberd_enabled?,
    title: "Enable ejabberd integration",
    description: "ejabberd configuration present and features enabled"
  ) %>
<% if Setting.ejabberd_enabled? %>
  <%= render FormElements::FieldsetResettableSettingComponent.new(
        key: :ejabberd_api_url,
        title: "API URL"
      ) %>
  <%= render FormElements::FieldsetResettableSettingComponent.new(
        key: :ejabberd_admin_url,
        title: "Admin URL"
      ) %>
</ul>
<h3 class="mt-10">User default settings</h3>
<ul role="list">
  <%= render FormElements::FieldsetComponent.new(
        title: "Default rooms",
        description: "Add these default rooms to new users' bookmarks"
      ) do %>
    <%= f.text_area :xmpp_default_rooms,
          value: Setting.xmpp_default_rooms.join("\n"),
          placeholder: "Welcome <welcome@kosmos.chat>\nKosmos <kosmos@kosmos.chat>",
          class: "h-24 w-full" %>
  <% end %>
  <%= render FormElements::FieldsetToggleComponent.new(
    form: f,
    attribute: :xmpp_autojoin_default_rooms,
    enabled: Setting.xmpp_autojoin_default_rooms?,
    title: "Auto-join default rooms",
    description: "Automatically join above default rooms in chat clients"
  ) %>
  <%= render FormElements::FieldsetResettableSettingComponent.new(
        key: :ejabberd_buddy_roster,
        title: "Contact roster name",
        description: "Used when exchanging contacts after signup from invitation"
      ) %>
</ul>
<h3 class="mt-10">Notifications</h3>
<ul role="list">
  <%= render FormElements::FieldsetComponent.new(
        title: "From address",
        description: "Address (JID) of the account notifications are sent from",
        resettable: Setting.get_field(:xmpp_notifications_from_address)[:default] != Setting.xmpp_notifications_from_address
      ) do %>
    <%= f.text_field :xmpp_notifications_from_address,
      value: Setting.xmpp_notifications_from_address,
      data: {
        :'default-value' => Setting.get_field(:xmpp_notifications_from_address)[:default]
      },
      class: "w-full" %>
  <% end %>
<% end %>
</ul>
