<html
    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
    data-namespace-typo3-fluid="true"
>

<f:layout name="Module"/>

<f:section name="Before">
    <f:asset.module identifier="@typo3/backend/context-menu.js"/>
    <f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
    <f:asset.module identifier="@typo3/backend/tree/tree-node-toggle.js"/>
    <f:asset.module identifier="@typo3/backend/utility/collapse-state-persister.js"/>
    <f:asset.module identifier="@typo3/backend/utility/collapse-state-search.js"/>

    <f:be.pageRenderer
        addJsInlineLabels="{
            'collapse-state-search.numberOfSearchMatches': 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:panel.header.numberOfSearchMatches'
        }"
    />
    <f:variable name="args" value="{0: 'web', 1: pageUid}" />
    <typo3-immediate-action
        action="TYPO3.Backend.Storage.ModuleStateStorage.update"
        args="{args -> f:format.json() -> f:format.htmlspecialchars()}"
    ></typo3-immediate-action>
</f:section>

<f:section name="Content">

    <h1>
        <f:if condition="{templateTitle}">
            <f:then>
                <f:translate
                    key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.titleWithRecord"
                    arguments="{
                        0: '{templateTitle}'
                    }"
                />
            </f:then>
            <f:else>
                <f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.title" />
            </f:else>
        </f:if>
    </h1>
    <p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.description" /></p>

    <f:comment><!-- General options --></f:comment>
    <f:if condition="{constantAst.children} || {setupAst.children}">
        <f:render
            partial="ActiveOptions"
            arguments="{
                allTemplatesOnPage: allTemplatesOnPage,
                pageUid: pageUid,
                selectedTemplateUid: selectedTemplateUid,
                displayConstantSubstitutions: displayConstantSubstitutions,
                displayComments: displayComments,
                sortAlphabetically: sortAlphabetically
            }"
        />
    </f:if>

    <f:comment><!-- Constants: Conditions and tree --></f:comment>
    <f:if condition="{constantAst.children}">
        <h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:sectionHeadline.constants" /></h2>
        <div class="panel-group">
            <f:render
                partial="ActiveConditions"
                arguments="{
                    pageUid: pageUid,
                    type: 'constant',
                    conditions: constantConditions,
                    conditionActiveCount: constantConditionsActiveCount
                }"
            />
            <f:render
                partial="ActiveTreePanel"
                arguments="{
                    type: 'constant',
                    tree: constantAst,
                    pageUid: pageUid,
                    displayComments: displayComments
                }"
            />
        </div>
    </f:if>

    <f:comment><!-- Setup: Conditions and tree --></f:comment>
    <f:if condition="{setupAst.children}">
        <h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:sectionHeadline.setup" /></h2>
        <div class="panel-group">
            <f:render
                partial="ActiveConditions"
                arguments="{
                    pageUid: pageUid,
                    type: 'setup',
                    conditions: setupConditions,
                    conditionActiveCount: setupConditionsActiveCount,
                    displayConstantSubstitutions: displayConstantSubstitutions
                }"
            />
            <f:render
                partial="ActiveTreePanel"
                arguments="{
                    type: 'setup',
                    tree: setupAst,
                    pageUid: pageUid,
                    displayConstantSubstitutions: displayConstantSubstitutions,
                    displayComments: displayComments
                }"
            />
        </div>
    </f:if>

    <f:if condition="!{constantAst.children} && !{setupAst.children}">
        <f:be.infobox
            message="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:infobox.message.noTypoScriptFound')}"
            state="{f:constant(name: 'TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper::STATE_INFO')}"
        />
    </f:if>
</f:section>

</html>
