{{ $rebuild := .Rebuild }}
<div class="pure-u-1-1">
    <form class="pure-form pure-form-aligned" id="system">
        <fieldset>

            <div class="pure-controls">
                <h5>Identity</h5>
            </div>
            
            <div class="pure-control-group">
                <label for="slug">Slug</label>
                <input name="slug" id="slug" placeholder="" {{ if $rebuild }} readonly="readonly" value="{{ .Slug }}" {{ end }}>
                <span class="pure-form-message-inline">
                    The <code>slug</code> is the primary identifier for the system.
                    It forms part of the domain, and must be unique across this instance of the distillery.
                    Once set, the <code>slug</code> cannot be changed.
                </span>
            </div>
            
            <div class="pure-controls">
                <h5>System Parameters</h5>
            </div>

            <div class="pure-control-group">
                <label for="php">PHP Version</label>
                <select class="pure-select" id="php">
                    {{ $PHP := .System.PHP }}
                    <option {{ if $rebuild }}{{ if eq $PHP "" }}selected{{ end }}{{ else }}selected{{ end }}>Default ({{ .DefaultPHPVersion }})</option>
                    {{ range .PHPVersions }}
                    <option {{ if $rebuild }}{{ if eq $PHP . }}selected{{ end }}{{ end }} value="{{ . }}">{{ . }}</option>
                    {{ end }}
                </select>
                <span class="pure-form-message-inline">
                    The version of <a href="https://www.php.net/releases/" target="_blank" rel="noopener noreferer">PHP</a> to use.
                    The distillery will always pick the latest patch release of the selected minor. 
                    Note that not all PHP versions work with all WissKI versions.
                    Changing the PHP version is possible at any time.
                </span>
            </div>
            <div class="pure-controls">
                <label for="opcacheDevelopment" class="pure-checkbox">
                    <input {{ if $rebuild }}{{ if .System.OpCacheDevelopment }}checked{{end}}{{end}} type="checkbox" id="opcacheDevelopment" />
                    OPcache Development Configuration
                </label>
                <span class="pure-form-message-inline">
                   Toggle the <a href="https://www.php.net/manual/en/book.opcache.php" target="_blank" rel="noopener noreferer">OPcache</a> configuration.
                   <br />
                   By default the distillery enables the <a href="https://www.php.net/manual/en/opcache.installation.php#opcache.installation.recommended" target="_blank" rel="noopener noreferer">recommended settings</a> for production.
                   When checked a more lenient caching approach intended for development is configured.
                   This may lead to a decrease in performance.
                   <br />
                   Changing the configuration is possible at any time. 
                </span>
            </div>

            <div class="pure-control-group">
                <label for="contentsecuritypolicy">Content-Security-Policy</label>
                <input name="contentsecuritypolicy" id="contentsecuritypolicy" list="content-security-policy" {{ if $rebuild }}value="{{ .System.ContentSecurityPolicy }}" {{ end }}>
                <span class="pure-form-message-inline">
                    Set a <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP">Content-Security-Policy</a> header to help to protect against JavaScript injections or unintended use of CDNs.
                    Leave blank to not set a header.
                    <br />
                    Autocomplete will make several suggestions for this field.
                    Changing the header is possible at any time. 
                </span>
            </div>
        
            {{ if not $rebuild }}
                <div class="pure-controls">
                    <h5>Flavor</h5>
                </div>

                <div class="pure-controls">
                    <span class="pure-form-message-inline">
                        Determine the set of module(s) to install for this WissKI. <br />
                        Changing this after installation may not be possible and in any case requires manual intervention.
                    </span>

                    {{ $defaultProfile := .DefaultProfile }}
                    {{ range $name, $description := .Profiles }}
                        <label for="flavor-{{ $name }}" class="pure-radio">
                            <input type="radio" id="flavor-{{ $name }}" name="flavor" value="{{ $name }}" {{ if eq $name $defaultProfile }}checked{{ end }} />
                            <b>{{ $name }}</b>
                            {{ $description }}
                        </label>
                    {{ end }}
                </div>
            {{ end }}
        
            <button type="submit" class="pure-button">{{ if $rebuild }}Rebuild{{ else }}Provision{{ end }}</button>
        </fieldset>
    </form>
</div>

<datalist id="content-security-policy">
    {{ range .ContentSecurityPolicies }}
    <option value="{{ . }}">
    {{ end }}
</datalist>