(function(window, document) { 'use strict'; var SCOPE = 'RelaysLoader'; var activeHost = null; var SB_URL = 'https://pnvmcckptqftinwlzixi.supabase.co'; var SB_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBudm1jY2twdHFmdGlud2x6aXhpIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc5OTA4NTQsImV4cCI6MjA4MzU2Njg1NH0.33Yfhr9IxsHXLFIkaa3iBX-GNR0-0dEK6azn5Ojmm6g'; // CSS var WIDGET_CSS = ` .widget-wrapper { font-family: 'Inter', sans-serif; color: #374151; box-sizing: border-box; } .widget-wrapper * { box-sizing: border-box; } .launcher-btn { position: fixed; bottom: 20px; right: 20px; width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; transition: transform 0.2s; z-index: 2147483647; } .launcher-btn:hover { transform: scale(1.05); } .launcher-icon { width: 28px; height: 28px; fill: white; } .chat-window { position: fixed; bottom: 100px; right: 20px; width: 380px; max-width: calc(100vw - 40px); height: 600px; max-height: calc(100vh - 120px); background: white; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.15); display: flex; flex-direction: column; opacity: 0; transform: translateY(20px) scale(0.95); pointer-events: none; transition: all 0.2s; z-index: 2147483646; } .chat-window.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; } .chat-header { padding: 20px; color: white; display: flex; align-items: center; gap: 12px; flex-shrink: 0; } .header-icon { width: 42px; height: 42px; background: rgba(255,255,255,0.2); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1; } .header-info h3 { margin: 0; font-size: 16px; font-weight: 700; } .header-info p { margin: 0; font-size: 12px; opacity: 0.9; } .nav-tabs { display: flex; background: #f3f4f6; padding: 4px; border-bottom: 1px solid #e5e7eb; } .nav-btn { flex: 1; padding: 10px; border: none; background: transparent; font-size: 13px; font-weight: 600; color: #6b7280; cursor: pointer; border-radius: 6px; } .nav-btn.active { background: white; color: #111827; box-shadow: 0 1px 2px rgba(0,0,0,0.05); } .nav-btn.hidden { display: none; } .chat-body { flex: 1; overflow-y: auto; background: #fff; position: relative; display: flex; flex-direction: column; } .view-section { padding: 20px; display: none; flex: 1; flex-direction: column; } .view-section.active { display: flex; } .msg-list { flex: 1; overflow-y: auto; padding-bottom: 10px; } .chat-msg { margin-bottom: 12px; max-width: 85%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; } .msg-bot { background: #f3f4f6; color: #1f2937; border-bottom-left-radius: 2px; } .msg-user { background: #4F46E5; color: white; border-bottom-right-radius: 2px; margin-left: auto; } .chat-input-area { margin-top: auto; display: flex; gap: 8px; border-top: 1px solid #e5e7eb; padding-top: 15px; } .chat-input { flex: 1; padding: 10px; border: 1px solid #e5e7eb; border-radius: 20px; outline: none; font-size: 14px; } .send-btn { background: transparent; border: none; cursor: pointer; color: #4F46E5; font-weight: bold; } .cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-weight: bold; font-size: 14px; } .cal-nav { background: #f3f4f6; border: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; } .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 16px; } .cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 13px; border-radius: 6px; cursor: pointer; } .cal-day:hover:not(.empty) { background: #f3f4f6; } .cal-day.selected { background: #4F46E5; color: white; } .time-slots { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; max-height: 150px; overflow-y: auto; } .time-slot { padding: 8px; text-align: center; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 12px; cursor: pointer; } .time-slot.selected { border-color: #4F46E5; background: #eef2ff; color: #4F46E5; } .form-group { margin-bottom: 12px; } .form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; } .form-input { width: 100%; padding: 10px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 14px; } .primary-btn { width: 100%; padding: 12px; background: #4F46E5; color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; margin-top: 10px; transition: opacity 0.2s; } .primary-btn:disabled { opacity: 0.5; cursor: not-allowed; } .success-view { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; animation: fadeIn 0.3s; } .success-icon { width: 48px; height: 48px; background: #dcfce7; color: #166534; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 15px; font-size: 24px; } .success-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; } .success-msg { font-size: 14px; color: #6b7280; margin-bottom: 20px; } .text-link { color: #4F46E5; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; } @keyframes fadeIn { from{opacity:0} to{opacity:1} } `; var InternalWidget = { root: null, config: {}, state: { view: 'chat', isOpen: false, messages: [], currentDate: new Date(), selectedDate: null, selectedTime: null, takenSlots: [], successState: null }, mount: function(root, config) { this.root = root; this.config = config; // Default view logic if(config.enableChat !== false) this.state.view = 'chat'; else if(config.enableBooking !== false) this.state.view = 'booking'; else if(config.enableContact !== false) this.state.view = 'contact'; if(this.state.messages.length === 0) { this.state.messages = [{ text: config.chatbotResponses?.default || "Hi! How can we help?", sender: 'bot' }]; } this.render(); }, render: function() { var c = this.config; var s = this.state; var color = c.primaryColor || '#4F46E5'; var chatIcon = ``; var closeIcon = ``; this.root.innerHTML = `
`; this.attachEvents(); }, // --- HELPERS --- renderSuccess: function(title, sub) { return `