synta 0.1.11

ASN.1 parser, decoder, and encoder library with DER/BER support and C FFI
Documentation
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

(() => {
    const darkThemes  = ['ayu', 'navy', 'coal'];
    const lightThemes = ['light', 'rust'];

    const htmlEl   = document.getElementsByTagName('html')[0];
    const classList = htmlEl.classList;

    let isDark = false;
    for (const cls of classList) {
        if (darkThemes.includes(cls)) { isDark = true; break; }
    }

    // Read a CSS custom property from the root element, with an optional fallback.
    function v(name, fallback) {
        const val = getComputedStyle(document.documentElement)
            .getPropertyValue(name).trim();
        return val || fallback || '';
    }

    mermaid.initialize({
        startOnLoad: true,
        theme: 'base',
        themeVariables: {
            // Backgrounds
            background:          v('--bg'),
            mainBkg:             v('--table-header-bg'),
            clusterBkg:          v('--code-bg', v('--table-alternate-bg')),
            edgeLabelBackground: v('--bg'),
            secondaryColor:      v('--quote-bg'),
            tertiaryColor:       v('--code-bg', v('--table-alternate-bg')),

            // Node styling
            primaryColor:        v('--table-header-bg'),
            primaryBorderColor:  v('--table-border-color'),
            primaryTextColor:    v('--fg'),
            nodeTextColor:       v('--fg'),

            // Cluster / subgraph borders
            clusterBorder:       v('--table-border-color'),

            // Edges and labels
            lineColor:           v('--links'),
            titleColor:          v('--fg'),

            // Typography — match the mono font stack from synta.css
            fontFamily: '"JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace',
            fontSize:   '14px',
        },
    });

    // Reload when switching between light and dark so mermaid re-renders
    // with the new CSS variable values.
    for (const darkTheme of darkThemes) {
        const el = document.getElementById(darkTheme);
        if (el) el.addEventListener('click', () => { if (!isDark) window.location.reload(); });
    }
    for (const lightTheme of lightThemes) {
        const el = document.getElementById(lightTheme);
        if (el) el.addEventListener('click', () => { if (isDark) window.location.reload(); });
    }
})();