<?xml version="1.0"?>
<!--
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="hyva_theme_system" translate="label" type="text" sortOrder="900"
                 showInDefault="1" showInWebsite="1" showInStore="1">
            <label>System</label>
            <tab>hyva_themes</tab>
            <resource>Magento_Config::config_system</resource>
            <group id="minification" translate="label" sortOrder="20" showInDefault="1"
                   showInWebsite="1" showInStore="1">
                <label>Response Minification</label>
                <field id="enabled" translate="label comment" type="select" sortOrder="5"
                       showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment>Minify HTML and inline JS in frontend responses using a Node.js daemon.</comment>
                    <config_path>hyva_minification/general/enabled</config_path>
                </field>
                <field id="daemon_status" translate="label" sortOrder="7"
                       showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Minification Daemon</label>
                    <frontend_model>Hyva\Minification\Block\Adminhtml\System\Config\DaemonStatus</frontend_model>
                </field>
                <field id="daemon_management" translate="label comment" type="select" sortOrder="8"
                       showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Daemon Management</label>
                    <frontend_model>Hyva\Minification\Block\Adminhtml\System\Config\DaemonManagementField</frontend_model>
                    <source_model>Hyva\Minification\Model\Config\Source\DaemonManagement</source_model>
                    <comment><![CDATA[<strong>Off</strong> — The daemon must be started manually.<br/><strong>Cron</strong> — A cron job checks every minute and starts the daemon if it is not running.<br/><strong>Start on-demand</strong> — The daemon is started automatically on the first request that needs it.]]></comment>
                    <config_path>hyva_minification/general/daemon_management</config_path>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>
                <field id="merge_inline_js" translate="label comment" type="select" sortOrder="20"
                       showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Merge Inline JavaScript</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[Merge all inline scripts into a single script tag before &lt;/body&gt;. Reduces the number of CSP hashes in the Content-Security-Policy header. Only applies to pages served from the full-page cache. Works independently of minification.]]></comment>
                    <config_path>hyva_minification/general/merge_inline_js</config_path>
                </field>
                <field id="connect_timeout_ms" translate="label comment" type="text" sortOrder="60"
                       showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Connection Timeout (ms)</label>
                    <validate>validate-digits</validate>
                    <comment>How long to wait for a connection to the daemon before falling back to unminified response.</comment>
                    <config_path>hyva_minification/general/connect_timeout_ms</config_path>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>
                <field id="read_timeout_ms" translate="label comment" type="text" sortOrder="70"
                       showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Read Timeout (ms)</label>
                    <validate>validate-digits</validate>
                    <comment>How long to wait for the daemon to return the minified response.</comment>
                    <config_path>hyva_minification/general/read_timeout_ms</config_path>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>
                <field id="dev_shell_fallback_enabled" translate="label comment" type="select" sortOrder="80"
                       showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Shell Fallback (Developer Mode)</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[When the daemon is unreachable, fall back to shelling out to <code>node</code> for minification. Only takes effect in developer mode. Slower than the daemon but requires no separate process.]]></comment>
                    <config_path>hyva_minification/general/dev_shell_fallback_enabled</config_path>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>
            </group>
        </section>
    </system>
</config>
