import os

filepath = 'src/app/map/MapUI.tsx'
with open(filepath, 'r') as f:
    content = f.read()

route_line_html = """
      {searchedLocation && selectedProperty && (
        <Polyline 
          positions={[searchedLocation, [selectedProperty.latitude, selectedProperty.longitude]]} 
          pathOptions={{ color: '#3b82f6', weight: 4, dashArray: '10, 10', opacity: 0.8 }} 
        />
      )}
"""

if "pathOptions={{ color:" not in content:
    content = content.replace(
        '     </MapContainer>',
        route_line_html + '     </MapContainer>'
    )

with open(filepath, 'w') as f:
    f.write(content)
print("Directions line added properly.")
