import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// packages/ui/src/internal/layout/zones/DnDevFooter.tsx
/**
 * @fileoverview DnDevFooter Zone Component
 * @description Footer zone with smart defaults.
 *
 * Default layout: Stack(FooterCopyright, FooterLegalLinks, FooterBranding)
 * - Desktop: 2-zone [Copyright] | [Links + Branding]
 * - Mobile: 2-line stacked, centered
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
import { memo } from 'react';
import { Stack } from '@donotdev/components';
import { useBreakpoint, useTranslation, maybeTranslate } from '@donotdev/core';
import { Link } from '../../../routing/Link';
import { FooterBranding } from '../components/footer/FooterBranding';
import { getLegalLinks, } from '../components/footer/useLegalLinks';
/**
 * DnDevFooter - Simple footer: Copyright (left) | LegalLinks + DoNotDev (right)
 *
 * DoNotDev branding is ALWAYS appended and cannot be removed.
 * Footer is automatically configured from app.footer config.
 *
 * Configuration precedence:
 * 1. app.footer === null -> render nothing
 * 2. app.footer.copyright === null -> hide copyright
 * 3. app.footer.copyright === undefined -> default copyright
 * 4. app.footer.copyright === string -> custom copyright
 * 5. LegalLinks from app.footer.legalLinks (defaults if undefined)
 * 6. DoNotDev branding always appended
 *
 * @critical The `<footer>` MUST have `role="contentinfo"` and className `"footer"`.
 * ALL footer CSS in layout-variables.css targets `footer[role='contentinfo']`.
 * This controls: grid placement, height, border, footer-mode scroll behavior,
 * preset-specific visibility (moolti/plain hide footer, blog hides on mobile).
 * DO NOT change role, tag, or className.
 */
function DnDevFooterComponent({ app = {} }) {
    const { t } = useTranslation('dndev');
    const isLaptopOrDesktop = useBreakpoint('isLaptopOrDesktop');
    // Get legal links (defaults or custom) — must be called before any return
    const links = getLegalLinks(app?.footer);
    // Explicit null hides footer
    if (app?.footer === null) {
        return null;
    }
    // Copyright: null = hide, undefined = default, string = custom
    const copyrightConfig = app.footer?.copyright;
    const showCopyright = copyrightConfig !== null;
    const copyrightText = copyrightConfig === undefined
        ? `© ${new Date().getFullYear()} ${app.name || 'App'}. ${t('footer.legal.allRightsReserved')}`
        : copyrightConfig;
    // Desktop/Wide: 2-zone layout [Copyright] | [Links + DoNotDev]
    if (isLaptopOrDesktop) {
        return (_jsx("footer", { role: "contentinfo", className: "footer", children: _jsxs(Stack, { direction: "row", align: "center", justify: "between", gap: "none", children: [showCopyright && (_jsx("div", { style: { display: 'flex', justifyContent: 'flex-start' }, children: _jsx("span", { className: "footer-copyright", children: copyrightText }) })), _jsx("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: _jsxs(Stack, { direction: "row", align: "center", children: [links.map((link) => (_jsx(Link, { path: link.path, style: { fontSize: 'var(--font-size-xs)' }, children: maybeTranslate(t, link.label) }, link.path))), _jsx(FooterBranding, {})] }) })] }) }));
    }
    // Mobile/Tablet: stacked layout
    return (_jsx("footer", { role: "contentinfo", className: "footer", children: _jsxs(Stack, { align: "center", gap: "tight", children: [showCopyright && (_jsx("span", { className: "footer-copyright", children: copyrightText })), _jsxs(Stack, { direction: "row", wrap: "wrap", gap: "tight", justify: "center", align: "center", children: [links.map((link) => (_jsx(Link, { path: link.path, style: { fontSize: 'var(--font-size-xs)' }, children: maybeTranslate(t, link.label) }, link.path))), _jsx(FooterBranding, {})] })] }) }));
}
export const DnDevFooter = memo(DnDevFooterComponent);
