<%# locals: (category:, origin: nil) %>
<% is_selected = category.id === @selected_category&.id %>

<%= content_tag :div, class: ["filterable-item flex justify-between items-center border-none rounded-lg px-2 py-1 group w-full", { "bg-gray-25": is_selected }], data: { filter_name: category.name } do %>
  <%= button_to account_transaction_path(@transaction.entry.account, @transaction.entry, account_entry: { origin: origin,entryable_type: "Account::Transaction", entryable_attributes: { id: @transaction.id, category_id: category.id } }), method: :patch, data: { turbo_frame: dom_id(@transaction.entry) }, class: "flex w-full items-center gap-1.5 cursor-pointer" do %>
    <span class="w-5 h-5">
      <%= lucide_icon("check", class: "w-5 h-5 text-gray-500") if is_selected %>
    </span>
    <%= render partial: "categories/badge", locals: { category: category } %>
  <% end %>

  <%= contextual_menu do %>
    <div class="w-48 p-1 text-sm leading-6 text-gray-900 bg-white shadow-lg shrink rounded-xl ring-1 ring-gray-900/5">
      <%= link_to edit_category_path(category),
            class: "block w-full py-2 px-3 space-x-2 text-gray-900 hover:bg-gray-50 flex items-center rounded-lg",
            data: { turbo_frame: :modal } do %>
        <%= lucide_icon "pencil-line", class: "w-5 h-5 text-gray-500" %>

        <span><%= t(".edit") %></span>
      <% end %>

      <%= link_to new_category_deletion_path(category),
            class: "block w-full py-2 px-3 space-x-2 text-red-600 hover:bg-red-50 flex items-center rounded-lg",
            data: { turbo_frame: :modal } do %>
        <%= lucide_icon "trash-2", class: "w-5 h-5" %>

        <span><%= t(".delete") %></span>
      <% end %>
    </div>
  <% end %>
<% end %>
