@php use App\Models\ChatSetting; use Illuminate\Support\Facades\Storage; try { $chat = ChatSetting::getSettings(); } catch (\Throwable $e) { $chat = null; } if (!$chat) { $chat = new \stdClass(); $chat->is_enabled = true; $chat->branding = []; $chat->integrations = []; $chat->behavior = []; $chat->ai = ['is_enabled' => true]; $chat->provider = 'whatsapp'; } // Use actual setting // $chat->is_enabled = true; // Removed hardcoded override $branding = $chat->branding ?? []; $integrations = $chat->integrations ?? []; $behavior = $chat->behavior ?? []; $provider = $chat->provider ?? 'whatsapp'; $colors = $branding['colors'] ?? []; $primaryColor = $colors['primary'] ?? '#6366f1'; $secondaryColor = $colors['secondary'] ?? '#4f46e5'; $textColor = $colors['text'] ?? '#ffffff'; $bgColor = $colors['background'] ?? '#ffffff'; $windowTextColor = $colors['window_text'] ?? '#1e293b'; $inputBorderColor = $colors['input_border'] ?? '#e2e8f0'; $closeBtnColor = $colors['close_button'] ?? '#94a3b8'; $position = $branding['position'] ?? 'right'; $marginSide = $branding['margin'] ?? 24; $marginBottom = $branding['margin_bottom'] ?? 24; $btnSize = $branding['button_size'] ?? 64; $iconSize = $branding['icon_size'] ?? 32; $borderRadius = $branding['border_radius'] ?? 16; $inputRadius = $branding['input_radius'] ?? 12; $fontSize = $branding['font_size'] ?? 14; $closeSize = $branding['close_size'] ?? 20; $closeIcon = $branding['close_icon'] ?? 'x'; $animations = $branding['animations'] ?? ['type' => 'slide', 'hover' => 'scale']; $animType = $animations['type'] ?? 'slide'; $hoverFx = $animations['hover'] ?? 'scale'; $headerShow = $branding['header_show'] ?? true; // Prepare Provider URLs $chatUrl = '#'; if ($provider === 'whatsapp') { $wa = $integrations['whatsapp'] ?? []; $chatUrl = 'https://wa.me/' . preg_replace('/[^0-9]/', '', $wa['phone'] ?? '1234567890') . (!empty($wa['message']) ? '?text=' . urlencode($wa['message']) : ''); } elseif ($provider === 'telegram') { $chatUrl = 'https://t.me/' . ($integrations['telegram']['username'] ?? 'support'); } elseif ($provider === 'messenger') { $chatUrl = 'https://m.me/' . ($integrations['messenger']['page_id'] ?? 'support'); } $showOnMobile = $behavior['show_on_mobile'] ?? true; $showOnDesktop = $behavior['show_on_desktop'] ?? true; $delay = ($behavior['delay'] ?? 3) * 1000; $autoOpen = $behavior['auto_open'] ?? false; // AI is now the default chat mode $aiEnabled = $chat->ai['is_enabled'] ?? true; @endphp @if($chat->is_enabled)
{{-- Chat Window --}}
@if($headerShow) {{-- Header --}}
@if(!empty($branding['logo'])) {{ $branding['title'] ?? 'Support' }} Logo @else
šŸ’¬
@endif

{{ $branding['title'] ?? 'Support' }}

Online

{{ $branding['welcome_message'] ?? 'How can we help?' }}

@else

{{ $branding['title'] ?? 'Support' }}

@endif {{-- Body --}}
@if($aiEnabled)
{{-- Default greeting --}}
Hello! šŸ‘‹ What issue or question can I help you with?
{{-- Dynamic Messages --}} {{-- Typing Indicator --}}
@else {{-- AI is disabled - widget will not show. This section should never render. --}} @endif
Powered by {{ config('app.name') }}
{{-- Launcher Button (Cinema Expanded Architecture) --}}
@if($provider === 'tawk' && !empty($integrations['tawk']['property_id'])) {{-- Tawk.to direct script injection --}} @if(!empty($integrations['tawk']['script'])) {!! $integrations['tawk']['script'] !!} @else @endif @endif @if($provider === 'custom' && !empty($integrations['custom']['html'])) {!! $integrations['custom']['html'] !!} @endif @endif