<%!-- Identity --%>
{t("Identity")}
<.input
field={@form[:name]}
type="text"
label={t("Name")}
placeholder={t("e.g. North sector 5 GHz")}
required
/>
<.input
field={@form[:site_id]}
type="select"
label={t("Site")}
prompt={t("Select a site")}
options={Enum.map(@sites, &{&1.name, &1.id})}
required
/>
<.input
:if={@devices != []}
field={@form[:device_id]}
type="select"
label={t("Attach to device (optional)")}
prompt={t("No specific device")}
options={Enum.map(@devices, &{device_label(&1), &1.id})}
/>
{t("This site has no devices yet — coverage will not be attached to a specific device.")}
<.input
field={@form[:antenna_slug]}
type="select"
label={t("Antenna")}
prompt={t("Select an antenna")}
options={@antenna_options}
required
/>
<%!-- Radio location: draggable marker on a Leaflet map. --%>
{t("Radio location")}
{t("Drag the marker to where the radio is mounted. Defaults to the site's coordinates.")}
{radio_marker_lat(@form, @sites)}, {radio_marker_lon(@form, @sites)}
({t("override")})
<.input field={@form[:latitude_override]} type="hidden" />
<.input field={@form[:longitude_override]} type="hidden" />
<%!-- Radio --%>
{t("Radio")}
<.input
field={@form[:frequency_ghz]}
type="number"
label={t("Frequency (GHz)")}
step="0.001"
min="0.7"
max="90"
required
/>
<.input
field={@form[:tx_power_dbm]}
type="number"
label={t("TX power (dBm)")}
step="0.1"
min="-10"
max="50"
required
/>
<.input
field={@form[:radius_mi]}
type="number"
label={t("Range (mi)")}
step="0.1"
min="0.3"
max="25"
required
/>
<%!-- Mounting --%>
{t("Mounting")}
<.input
field={@form[:height_agl_ft]}
type="number"
label={t("Height above ground (ft)")}
step="1"
min="3"
max="650"
required
/>
<.input
field={@form[:azimuth_deg]}
type="number"
label={t("Azimuth (°, true north)")}
step="1"
min="0"
max="360"
required
/>
<.input
field={@form[:downtilt_deg]}
type="number"
label={t("Tilt (°, positive = down)")}
step="0.1"
min="-10"
max="30"
/>
<%!-- Foliage --%>
<.link
navigate={~p"/coverage"}
class="btn border border-gray-300 bg-transparent dark:border-gray-600"
>
{t("Cancel")}
<.button type="submit" variant="primary">
{if @live_action == :new, do: t("Create coverage"), else: t("Save changes")}