{{#let @value as |v|}}

    {{#if (eq "dummy-placeholder" this.format)}}
        {{!-- just so that all following "else if" look the same --}}

    {{else if (or (not this.format) (eq "text" this.format))}}
        <OxiBase::Label
            @text={{v}}
            @tooltip={{if @truncate v}}
            @class="oxi-formatted-text {{if @truncate "oxi-truncate"}} {{@class}}"
        />

    {{else if (eq "raw" this.format)}}
        <OxiBase::Label
            @text={{this.valueStr}}
            @raw={{true}}
            @raw_tooltip={{if @truncate v}}
            @class="oxi-formatted-raw {{if @truncate "oxi-truncate"}} {{@class}}"
        />

    {{else if (eq "subject" this.format)}}
        <OxiBase::Label
            @text={{v}}
            @tooltip={{if @truncate v}}
            @class="oxi-formatted-subject {{if @truncate "oxi-truncate"}} d-inline-flex {{@class}}"
        />

    {{else if (eq "nl2br" this.format)}}
        <span class="oxi-formatted-nl2br {{@class}}">
            {{#each this.valueSplitByNewline as |line|}} {{line}}<br> {{/each}}
        </span>

    {{else if (eq "timestamp" this.format)}}
        <span class="oxi-formatted-timestamp {{@class}}">
            {{this.timestamp}}
        </span>

    {{else if (eq "styled" this.format)}}
        <span class="oxi-formatted-styled styled-{{this.styledValue.style}} {{@class}}">
            {{this.styledValue.label}}
        </span>

    {{else if (eq "certstatus" this.format)}}
        <OxiBase::Label
            @text={{v.label}}
            @raw={{true}}
            @tooltip={{v.tooltip}}
            @class="oxi-formatted-certstatus certstatus-{{lc (try v.value v.label)}} {{@class}}"
        />

    {{else if (eq "link" this.format)}}
        <OxiBase::Formatted::Link @spec={{v}} @class="oxi-formatted-link {{@class}}" />

    {{else if (eq "extlink" this.format)}}
        <a href={{v.page}} target={{try v.target "_blank"}} title={{v.tooltip}} class="oxi-formatted-extlink {{@class}}">
            <OxiBase::Label @text={{v.label}} @raw={{true}} />
        </a>

    {{else if (eq "email" this.format)}}
        {{#each this.valueArray as |val|}}
            <a href="mailto:{{val}}" class="oxi-formatted-email {{@class}}">
                <OxiBase::Label @text={{val}} />
            </a>
            <br/>
        {{/each}}

    {{else if (eq "tooltip" this.format)}}
        {{! "d-inline-flex" prevents labels from taking the whole width and
            tooltips being placed in the "center" from being above the
            whitespace in case of short labels. }}
        <OxiBase::Label
            @text={{v.value}}
            @tooltip={{v.tooltip}}
            @tooltip_page={{v.tooltip_page}}
            @tooltip_page_args={{v.tooltip_page_args}}
            @class="oxi-formatted-tooltip d-inline-flex {{@class}}"
        />

    {{else if (eq "code" this.format)}}
        <code
            title="{{t 'component.oxi_code.copy'}}"
            {{!-- template-lint-disable no-invalid-interactive --}}
            {{on "dblclick" this.selectCode}}
            class="oxi-formatted-code {{@class}}"
        >{{this.valueStr}}</code>

    {{else if (eq "asciidata" this.format)}}
        <OxiBase::Formatted::Asciidata
            @value={{v}}
            @class="oxi-formatted-asciidata {{@class}}"
        />

    {{else if (eq "download" this.format)}}
        <OxiBase::Download
            @type={{v.type}}
            @data={{v.data}}
            @mimeType={{v.mimetype}}
            @fileName={{v.filename}}
            @autoDownload={{v.autodownload}}
            @hide={{v.hide}}
            @class="oxi-formatted-download {{@class}}"
        />

    {{else if (eq "arbitrary" this.format)}}
        <OxiBase::Formatted::Arbitrary
            @value={{v}}
            @class="oxi-formatted-arbitrary"
        />

    {{else if (eq "unilist" this.format)}}
        <dl class="oxi-formatted-unilist {{@class}}">
            {{#each v as |item|}}
                {{#if item.label}}
                    <dt class="pt-1">{{item.label}}</dt>
                {{/if}}
                <dd class="m-0 {{if item.label "ps-3" "pt-1"}}">
                    <OxiBase::Formatted
                        @format={{item.format}}
                        @value={{item.value}}
                        @truncate={{@truncate}}
                    />
                </dd>
            {{/each}}
        </dl>

    {{! legacy list format }}
    {{else if (eq "deflist" this.format)}}
        <dl class="oxi-formatted-deflist {{@class}}">
            {{#each v as |val|}}
                <dt>{{val.label}}</dt>
                {{#each (arrayify val.value) as |ddVal|}}
                    <dd class="m-0">
                        <OxiBase::Formatted::Arbitrary @value={{ddVal}} @raw={{if (eq val.format "raw") true false}} />
                    </dd>
                {{/each}}
            {{/each}}
        </dl>

    {{! legacy list format }}
    {{else if (eq "ullist" this.format)}}
        <ul class="oxi-formatted-ullist list-unstyled {{@class}}">
            {{#each v as |val|}}
                <li>
                    <OxiBase::Formatted::Arbitrary @value={{val}} />
                </li>
            {{/each}}
        </ul>

    {{! legacy list format }}
    {{else if (eq "rawlist" this.format)}}
        <ul class="oxi-formatted-rawlist list-unstyled {{@class}}">
            {{#each v as |val|}} <li><OxiBase::Label @text={{val}} @raw={{true}} /> </li> {{/each}}
        </ul>

    {{! legacy list format }}
    {{else if (eq "linklist" this.format)}}
        <ul class="oxi-formatted-linklist list-unstyled {{@class}}">
            {{#each v as |val|}}
                <li>
                    {{#if (eq val.format "extlink")}}
                        <a href={{val.page}} target={{try val.target "_blank"}} title={{val.tooltip}}>
                            <OxiBase::Label @text={{val.label}} @raw={{true}} />
                        </a>
                    {{else if val.page}}
                        <OxiBase::Formatted::Link @spec={{val}}/>
                    {{else}}
                        <OxiBase::Label @text={{val.label}} @tooltip={{val.tooltip}}/>
                    {{/if}}
                </li>
            {{/each}}
        </ul>

    {{else}}
        (error: unknown field format "{{this.format}}")

    {{/if}}

{{/let}}
