{{ $in0 := .name }}
{{ $name := .name }}
{{ $id := .name }}
{{ $newname := .name }}

{{ if i18n $name }}
  {{ $name = i18n $name }}
{{ end }}

{{ $openname := printf "open%s" $in0 }}
{{- $finale := slice -}}
{{ $pages := where site.RegularPages "Type" "in" site.Params.searchSections }}
{{ if eq .name "tags" }}
  {{ range $pages }}
    {{- if .Params.tags -}}
      {{- $finale = $finale | append .Params.tags -}}
    {{ end }}
  {{ end }}
  {{ $id = $name }}
{{ else }}
  {{ range $pages }}
    {{ range .Param $in0 }}
        {{- $finale = $finale | append . -}}
    {{ end }}
  {{ end }}
  {{ if ne .name "categories" }}
    {{ $cat := "categories" }}
    {{ if i18n $cat }}
      {{ $cat = i18n $cat }}
    {{ end }}
    {{ $id = printf "%s %s" $name $cat }}
  {{ else }}
    {{ $id = $name }}
  {{ end }}
{{ end }}
{{- $finale = $finale | uniq -}}
{{ if eq .expanded "true" }}
  <div style="flex-direction: column;">
    {{ $id }}{{- if eq .mandatory "true" -}}*{{- end -}}
{{ else }}
  {{ partial "orga/generator/partials/expand" (dict "id" $id "name" $openname ) }}
  <div style="flex-direction: column;" class="visibleIf" data-visibleif-rule="{{- $openname }} == 'true'">
{{ end }}
  <fieldset style="max-width: 58.5rem; padding: 0; margin: 0; border-style: none;" id="{{ $in0 }}" name="{{ $in0 }}">
    {{ range sort $finale }}
      {{ $n := . | i18n }}
      {{ if not $n }}
        {{ $n = . }}
      {{ end }}
        <div style="display: flex; flex-direction: row;">
          <input type="checkbox" name="{{ $in0 }}" id="{{ $in0 }}-cat" value="{{ $n }}"><label style="width: 20rem;" for="{{ $in0 }}-cat">{{ strings.FirstUpper $n }}</label>
        </div>
    {{ end }}
  </fieldset>
  {{ if eq .new "true" }}
    {{ partial "orga/generator/partials/input_line" (dict "name" $in0) }}
  {{ end }}
</div>


