cask "astah-uml" do
  on_arm do
    version "12.0.0,4fa570"
    sha256 "196b62798f78453cd220382dd9167972802e36ace4962183e39a6741b41a3044"

    url "https://cdn.change-vision.com/files/astah-uml-#{version.csv.first.dots_to_underscores}-#{version.csv.second}-MacOs-aarch64.dmg",
        verified: "cdn.change-vision.com/files/"

    livecheck do
      url "https://members.change-vision.com/download/files/astah_UML/latest/mac_pkg"
      regex(/astah[._-]uml[._-]v?(\d+(?:[._]\d+)+)[._-](\h+)[._-]MacOs.*?\.dmg/i)
      strategy :header_match do |headers, regex|
        match = headers["location"]&.match(regex)
        next if match.blank?

        "#{match[1].tr("_", ".")},#{match[2]}"
      end
    end

    pkg "astah uml aarch64 ver #{version.csv.first.dots_to_underscores}.pkg"
  end
  on_intel do
    version "10.1.0,9ceee1"
    sha256 "919592fdecfc26d1e2ebd798960f9e1bacd013145036552f703aeec2c4b27fdf"

    url "https://cdn.change-vision.com/files/astah-uml-#{version.csv.first.dots_to_underscores}-#{version.csv.second}-MacOs.dmg",
        verified: "cdn.change-vision.com/files/"

    livecheck do
      skip "Legacy version"
    end

    pkg "astah uml ver #{version.csv.first.dots_to_underscores}.pkg"
  end

  name "Change Vision Astah UML"
  desc "UML diagramming tool with mind mapping"
  homepage "https://astah.net/products/astah-uml/"

  depends_on :macos

  uninstall pkgutil: "com.change-vision.astah.uml"

  zap trash: "~/Library/Preferences/com.change-vision.astah.uml.plist"
end
