// ECO-PANNEAU.FR - _react/ui/_ui_icons.jsx

// 1. - LOGO SVG ET TEXT LOGO
window.pano_LogoSVG = ({ size = 32, className = '' }) => (
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width={size} height={size} className={className}>
        <rect width="100" height="100" rx="20" fill="#1e293b"/>
        <rect x="12" y="12" width="30" height="30" rx="8" stroke="#ffffff" strokeWidth="6" fill="none"/>
        <rect x="21" y="21" width="12" height="12" rx="3" fill="#ffffff"/>
        <rect x="12" y="58" width="30" height="30" rx="8" stroke="#ffffff" strokeWidth="6" fill="none"/>
        <rect x="21" y="67" width="12" height="12" rx="3" fill="#ffffff"/>
        <rect x="58" y="58" width="30" height="30" rx="8" stroke="#ffffff" strokeWidth="6" fill="none"/>
        <rect x="67" y="67" width="12" height="12" rx="3" fill="#ffffff"/>
        <path d="M 88 12 C 58 12 58 42 58 42 C 88 42 88 12 88 12 Z" fill="#a7f3d0" stroke="none"/>
        <path d="M 88 12 C 58 12 58 42 58 42 C 88 42 88 12 88 12 Z" fill="none" stroke="#059669" strokeWidth="6" strokeLinejoin="round" strokeLinecap="round"/>
        <line x1="48" y1="52" x2="60" y2="40" stroke="#059669" strokeWidth="6" strokeLinecap="round"/>
        <path d="M 60 40 L 85 15 M 66 34 L 66 23 M 74 26 L 83 26" stroke="#059669" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"/>
    </svg>
);

window.pano_TextLogo = ({ className = "", colorEco = "text-slate-800" }) => (
    <span className={`whitespace-nowrap font-black tracking-tighter inline-flex items-center ${className}`}>
        <span className={colorEco}>eco</span>
        <span className="text-emerald-600">-panneau</span>
        <span className="text-slate-400 font-bold">.fr</span>
    </span>
);

window.pano_SiteLogo = ({ size = 32, className = "" }) => {
    let shouldBeLink = true;
    
    if (typeof window !== 'undefined') {
        const params = new URLSearchParams(window.location.search);
        const isRiverainOrScan = params.has('scan') || params.has('thread') || params.has('demo');
        
        const isHomePage = !params.has('tab') && !params.has('scan') && !params.has('thread') && !params.has('reg_token') && !params.has('reset_token') && !params.has('del_token') && !params.has('grant_access') && !params.has('delegate');
        
        if (isRiverainOrScan || isHomePage) {
            shouldBeLink = false;
        }
    }
    
    const Wrapper = shouldBeLink ? 'a' : 'div';
    const props = shouldBeLink ? { href: 'https://eco-panneau.fr', title: "Retour à l'accueil" } : {};
    
    const ecoColor = className.includes('text-white') ? 'text-white' : 'text-slate-800';
    
    return (
        <Wrapper {...props} className={`flex items-center gap-2 ${shouldBeLink ? 'hover:opacity-80 transition' : ''} ${className}`}>
            <window.pano_LogoSVG size={size} className="shrink-0" />
            <window.pano_TextLogo colorEco={ecoColor} />
        </Wrapper>
    );
};

// 2. - GÉNÉRATEUR D'ICÔNES DYNAMIQUES ET LOADER
window.pano_LoaderIcon = ({ size = 24, className = '' }) => (
    <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
        <line x1="12" y1="2" x2="12" y2="6"></line>
        <line x1="12" y1="18" x2="12" y2="22"></line>
        <line x1="4.93" y1="4.93" x2="7.76" y2="7.76"></line>
        <line x1="16.24" y1="16.24" x2="19.07" y2="19.07"></line>
        <line x1="2" y1="12" x2="6" y2="12"></line>
        <line x1="18" y1="12" x2="22" y2="12"></line>
        <line x1="4.93" y1="19.07" x2="7.76" y2="16.24"></line>
        <line x1="16.24" y1="4.93" x2="19.07" y2="7.76"></line>
    </svg>
);

window.pano_PinIcon = ({ size = 24, className = '', filled = false, onClick }) => (
    <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill={filled ? "currentColor" : "none"} stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className} onClick={onClick}>
        <line x1="12" y1="17" x2="12" y2="22"></line>
        <path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"></path>
    </svg>
);

window.pano_ShieldIcon = ({ size = 24, className = '', onClick }) => (
    <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className} onClick={onClick}>
        <path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/>
    </svg>
);

window.pano_UsersIcon = ({ size = 24, className = '', onClick }) => (
    <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className} onClick={onClick}>
        <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>
    </svg>
);

// LE NOUVEAU DESIGN DE L'ICÔNE : Bâtiment avec équipe incrustée proprement
window.pano_BuildingTeamIcon = ({ size = 24, className = '', onClick }) => (
    <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className} onClick={onClick}>
        {/* Le bâtiment coupé proprement en bas à droite */}
        <path d="M14 10V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v18h8" />
        <path d="M6 22v-4h4v4" />
        <path d="M6 6h.01" />
        <path d="M10 6h.01" />
        <path d="M6 10h.01" />
        <path d="M10 10h.01" />
        
        {/* L'équipe insérée dans la découpe (Adaptation de l'épaisseur de trait) */}
        <g transform="translate(10, 10) scale(0.6)" strokeWidth="3.33">
            <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/>
            <circle cx="9" cy="7" r="4"/>
            <path d="M22 21v-2a4 4 0 0 0-3-3.87"/>
            <path d="M16 3.13a4 4 0 0 1 0 7.75"/>
        </g>
    </svg>
);

const createIconFromString = (htmlString) => ({ size = 24, className = '', style, onClick, ...props }) => {
    const svgContent = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${htmlString}</svg>`;
    return <span className={`inline-flex shrink-0 items-center justify-center leading-none ${className}`} style={{ width: size, height: size, ...style }} onClick={onClick} {...props} dangerouslySetInnerHTML={{ __html: svgContent }} />;
};

if (window.pano_svgPaths) {
    window.pano_svgPaths.EyeOff = `<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/>`;
    window.pano_svgPaths.Shield = `<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/>`;

    for (const [name, pathStr] of Object.entries(window.pano_svgPaths)) {
        if (!window[`pano_${name}Icon`]) {
            window[`pano_${name}Icon`] = createIconFromString(pathStr);
        }
    }
}

// 3. - GÉNÉRATEUR DE QR CODE
window.pano_NativeQRCode = ({ value, size = 128, padding = 4 }) => {
    if (!window.QRCode) return null;
    const svgStr = new window.QRCode({ content: value, padding, width: size, height: size, join: true }).svg();
    return <div dangerouslySetInnerHTML={{ __html: svgStr }} style={{ display: 'inline-block' }} />;
};

/* EOF ========== [_react/ui/_ui_icons.jsx] */