{% mbd_token as token %}  {# Still needed for some ids (here and in api_arg.html) #}

{% if verbose %}
	<h3>{{ call.doc_title }}</h3>
	<pre>{{ call.doc_body }}</pre>
{% endif %}

<form id="{{ token }}" class="mbd-api" method="get" action="{{ call.uri }}">
	{% include "mini_buildd/includes/tags/api_args.html" with args=args.mandatory %}

	<input type="submit" value="{{ name }}" title="{{ title }}{{ is_authorized|yesno:', ⚠ Please log in to run this API call ⚠' }}" {{ is_authorized|yesno:',disabled' }}>

	<input name="output" type="hidden" value="{% if output == "snippet" %}page{% else %}{{ output }}{% endif %}">
	{% if call.CONFIRM %}
		<label id="{{ token }}-confirm">Confirm<input type="checkbox" name="confirm" value="{{ call.name }}" required></label>
	{% endif %}
	<script>
		{% if output == "snippet" %}
			{# js call will always explicitly use output=snippet and always ask for confirmation. #}
			$("#{{ token }}-confirm").hide();
			$("#{{ token }}-confirm>input").prop("required", false);
			$("#{{ token }}").attr("onsubmit", "return mbd_api_call(this, '{{ call.name }}', '{{ call.CONFIRM }}');");
		{% endif %}
	</script>

	{% for arg in args.hidden %}
		<input name="{{ arg.identity }}" type="hidden" value="{{ arg.strvalue }}">
	{% endfor %}

	{% if args.optional %}
		<details {{ verbose|yesno:'open,' }}>
			<summary title="Optional arguments"></summary>
			{% include "mini_buildd/includes/tags/api_args.html" with args=args.optional %}
		</details>
	{% endif %}
</form>
