# Apply hacktivism branding to Bonfire instance settings.
# Run on koopa: printf '%s\n' "$(cat apply-branding.exs)" | podman exec -i koopa-bonfire /opt/app/bin/bonfire remote
#
# Instance settings API: https://docs.bonfirenetworks.org/settings_system.html

palette = %{
  "color-base-100" => "#1a1410",
  "color-base-200" => "#221c16",
  "color-base-300" => "#2a2018",
  "color-base-content" => "#fff6e8",
  "color-primary" => "#e8a838",
  "color-primary-content" => "#1a1410",
  "color-secondary" => "#3d3128",
  "color-secondary-content" => "#fff6e8",
  "color-accent" => "#3ecfbf",
  "color-accent-content" => "#0e1c1e",
  "color-neutral" => "#14110e",
  "color-neutral-content" => "#ebe0d0",
  "color-info" => "#2563eb",
  "color-info-content" => "#ffffff",
  "color-success" => "#16a34a",
  "color-success-content" => "#ffffff",
  "color-warning" => "#f0d090",
  "color-warning-content" => "#1a1410",
  "color-error" => "#b91c1c",
  "color-error-content" => "#ffffff",
  "radius-box" => "0.875rem",
  "radius-field" => "0.5rem",
  "radius-selector" => "0.75rem"
}

opts = [skip_boundary_check: true, scope: :instance]

settings = %{
  ui: %{
    theme: %{
      instance_name: "hacktivism bonfire",
      instance_tagline: "hacktivism magician - federated FOSS timeline",
      instance_description:
        "Bonfire on hacktivism.ch — local FOSS posts, gitbot commits, and federation.",
      instance_icon: "/images/hacktivism-logo.svg",
      instance_theme: "dark",
      instance_theme_light: "light",
      preferred: :custom,
      custom_instance: palette
    }
  }
}

case Bonfire.Common.Settings.set(settings, opts) do
  {:ok, _} ->
    IO.puts("ok branding settings applied")

  other ->
    IO.inspect(other, label: "branding settings failed")
end