/** * Calendar Agent Specific Functions */ class CalendarAgent { constructor() { this.totalActions = 0; this.init(); } init() { Utils.time.updateLastUpdated('lastSync'); this.initializeEventListeners(); } initializeEventListeners() { Utils.events.onEnterKey('calendarCommand', () => this.executeCalendarCommand()); } setCalendarCommand(command) { Utils.form.setInputValue('calendarCommand', command); this.executeCalendarCommand(); } async executeCalendarCommand() { const command = Utils.form.getInputValue('calendarCommand'); if (!command) { Utils.toast.warning('Please enter a command'); return; } Utils.button.setLoading('calendarAiBtn', 'Processing...', 'fa-spinner fa-spin'); try { // Simulate AI processing await new Promise(resolve => setTimeout(resolve, 1500)); const response = this.generateCalendarAIResponse(command); Utils.modal.showAI(response); this.updateCalendarStats(); Utils.time.updateLastUpdated('lastSync'); } catch (error) { Utils.toast.error('Error processing command: ' + error.message); } finally { Utils.button.restore('calendarAiBtn', 'Execute', 'fa-robot'); Utils.form.clearInput('calendarCommand'); } } generateCalendarAIResponse(command) { const lowerCommand = command.toLowerCase(); if (lowerCommand.includes('schedule') && lowerCommand.includes('meeting')) { return `

📅 Schedule Meeting

✅ Optimal Time Found

Best time for all attendees: Tomorrow 3:30 PM - 4:30 PM

5 attendees available
Conference Room B reserved
Zoom link generated
📋 Meeting Details

Title: Team Strategy Discussion

Duration: 1 hour

Attendees: Sarah, John, Mike, Lisa, David

Agenda: Q1 planning and resource allocation

`; } return `

🤖 Calendar AI Response

Processing your request: "${command}"

I can help you with:

`; } updateCalendarStats() { Utils.stats.increment('aiScheduled'); this.totalActions++; } // Quick action functions scheduleMeeting() { Utils.modal.showAI(`

📅 Schedule New Meeting

`); } findFreeTime() { this.updateCalendarStats(); Utils.toast.info('🔍 Found 3 optimal time slots this week for your requirements'); } blockFocusTime() { this.updateCalendarStats(); Utils.toast.success('🧠 Protected 2-hour focus block scheduled for tomorrow 10-12 AM'); } optimizeSchedule() { if (confirm('Let AI optimize your schedule for maximum productivity?')) { this.updateCalendarStats(); Utils.toast.success('✨ Schedule optimized! Moved 3 meetings to create better focus blocks and reduced meeting fragmentation by 40%.'); } } } // Initialize Calendar Agent when DOM is loaded document.addEventListener('DOMContentLoaded', function() { window.calendarAgent = new CalendarAgent(); // Make functions globally available for onclick handlers window.executeCalendarCommand = () => calendarAgent.executeCalendarCommand(); window.setCalendarCommand = (cmd) => calendarAgent.setCalendarCommand(cmd); window.scheduleMeeting = () => calendarAgent.scheduleMeeting(); window.findFreeTime = () => calendarAgent.findFreeTime(); window.blockFocusTime = () => calendarAgent.blockFocusTime(); window.optimizeSchedule = () => calendarAgent.optimizeSchedule(); window.closeAIModal = () => Utils.modal.hideAI(); window.goHome = () => Utils.navigation.goHome(); });