| ```javascript | |
| import React, { useState } from 'react'; | |
| import { | |
| ArrowLeftIcon, | |
| ArrowRightIcon, | |
| ArrowPathIcon, | |
| MicrophoneIcon, | |
| MagnifyingGlassIcon | |
| } from '@heroicons/react/24/outline'; | |
| const AddressBar = ({ activeTab, updateTab, addTab, setCurrentPage }) => { | |
| const [inputValue, setInputValue] = useState(activeTab?.url || ''); | |
| const [isListening, setIsListening] = useState(false); | |
| const handleKeyDown = (e) => { | |
| if (e.key === 'Enter') { | |
| handleSubmit(); | |
| } | |
| }; | |
| const handleSubmit = () => { | |
| let url = inputValue.trim(); | |
| // If it looks like a search query, redirect to Google search | |
| if (!url.includes('.') && url.split(' ').length > 0) { | |
| url = `https://www.google.com/search?q=${encodeURIComponent(url)}`; | |
| } | |
| // If no protocol specified, add https:// | |
| else if (!url.startsWith('http://') && !url.startsWith('https://')) { | |
| url = `https://${url}`; | |
| } | |
| updateTab(activeTab.id, { url }); | |
| setInputValue(url); | |
| }; | |
| const handleVoiceSearch = () => { | |
| if ('webkitSpeechRecognition' in window) { | |
| const recognition = new window |