cask "burp-suite" do
  arch arm: "MacOsArm64", intel: "MacOsx"

  version "2026.3.3"
  sha256 arm:   "d9f0bc695e9b13554c013631c05e3a82c6bda6b7e573b0d606eea22342ef8bd0",
         intel: "380723f86be65bed4c8645adae9badcb817aca7061be652014483f437879cf8c"

  url "https://portswigger-cdn.net/burp/releases/download?product=community&version=#{version}&type=#{arch}",
      verified: "portswigger-cdn.net/burp/releases/"
  name "Burp Suite Community Edition"
  desc "Web security testing toolkit"
  homepage "https://portswigger.net/burp/"

  livecheck do
    url "https://portswigger.net/burp/releases/data"
    strategy :json do |json|
      all_versions = json.dig("ResultSet", "Results")
      next if all_versions.blank?

      all_versions.filter_map do |item|
        item["version"] if
              item["releaseChannels"]&.include?("Stable") &&
              item["categories"]&.include?("Community") &&
              item["builds"]&.any? do |build|
                build["BuildCategoryId"] == "community" &&
                build["BuildCategoryPlatform"] == arch.to_s
              end
      end
    end
  end

  conflicts_with cask: "burp-suite@early-adopter"
  depends_on :macos

  app "Burp Suite Community Edition.app"

  zap trash: "~/.BurpSuite"
end
