@php
$extensions = $extensionSettings ?? [];
$analytics = $extensions['analytics'] ?? [];
$adsense = $extensions['adsense'] ?? [];
$facebook = $extensions['facebook'] ?? [];
$microsoft = $extensions['microsoft'] ?? [];
$social = $extensions['social'] ?? [];
$seo = $seoSettings ?? [];
$gdpr = $gdprSettings ?? [];
$gdprEnabled = filter_var($gdpr['gdpr_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
$gdprConsentValue = $gdprConsent ?? null;
$trackingAllowed = ! $gdprEnabled || $gdprConsentValue === 'accepted';
$ogEnabled = filter_var($social['og_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
$siteName = trim((string) ($siteSettings['site_name'] ?? ''));
$fallbackTitle = $siteName !== '' ? $siteName : config('app.name', 'SnapNest');
$metaTitle = trim((string) ($seo['meta_title'] ?? ''));
$metaDescription = trim((string) ($seo['meta_description'] ?? ''));
$metaKeywords = trim((string) ($seo['meta_keywords'] ?? ''));
$metaTitle = $metaTitle !== '' ? $metaTitle : $fallbackTitle;
$ogTitle = trim((string) ($social['og_title'] ?? ''));
$ogDescription = trim((string) ($social['og_description'] ?? ''));
$ogTitle = $ogTitle !== '' ? $ogTitle : $metaTitle;
$ogDescription = $ogDescription !== '' ? $ogDescription : ($metaDescription !== '' ? $metaDescription : $fallbackTitle);
$ogImage = $social['og_image'] ?? null;
$ogImageUrl = '';
if ($ogImage) {
$ogImageUrl = \Illuminate\Support\Str::startsWith($ogImage, ['http://', 'https://'])
? $ogImage
: asset('storage/' . ltrim($ogImage, '/'));
}
$googleEnabled = filter_var($analytics['google_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
$googleMeasurementId = trim((string) ($analytics['google_measurement_id'] ?? ''));
$adsenseEnabled = filter_var($adsense['adsense_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
$adsenseClientId = trim((string) ($adsense['adsense_client_id'] ?? ''));
$pixelEnabled = filter_var($facebook['pixel_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
$pixelId = trim((string) ($facebook['pixel_id'] ?? ''));
$uetEnabled = filter_var($microsoft['uet_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
$uetTagId = trim((string) ($microsoft['uet_tag_id'] ?? ''));
@endphp
@if ($metaTitle !== '')
@endif
@if ($metaDescription !== '')
@endif
@if ($metaKeywords !== '')
@endif
@if ($ogEnabled)
@if ($ogImageUrl)
@endif
@if ($ogImageUrl)
@endif
@endif
@if ($trackingAllowed && $googleEnabled && $googleMeasurementId)
@endif
@if ($trackingAllowed && $adsenseEnabled && $adsenseClientId)
@endif
@if ($trackingAllowed && $pixelEnabled && $pixelId)
@endif
@if ($trackingAllowed && $uetEnabled && $uetTagId)
@endif