module(name = "selenium")

bazel_dep(name = "apple_rules_lint", version = "0.4.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.10.0")
bazel_dep(name = "aspect_rules_esbuild", version = "0.21.0")
bazel_dep(name = "aspect_rules_js", version = "2.0.1")
bazel_dep(name = "aspect_rules_ts", version = "3.1.0")
bazel_dep(name = "bazel_features", version = "1.23.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0")
bazel_dep(name = "contrib_rules_jvm", version = "0.27.0")
bazel_dep(name = "platforms", version = "0.0.10")

# Required for the closure rules
bazel_dep(name = "protobuf", version = "29.2", dev_dependency = True, repo_name = "com_google_protobuf")

# Required for rules_rust to import the crates properly
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)

bazel_dep(name = "rules_dotnet", version = "0.17.5")
bazel_dep(name = "rules_java", version = "7.12.4")
bazel_dep(name = "rules_jvm_external", version = "6.6")
bazel_dep(name = "rules_nodejs", version = "6.3.2")
bazel_dep(name = "rules_oci", version = "1.8.0")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "rules_python", version = "0.33.0")
bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "rules_ruby", version = "0.13.0")

linter = use_extension("@apple_rules_lint//lint:extensions.bzl", "linter")
linter.configure(
    name = "java-spotbugs",
    config = "//java:spotbugs-config",
)
linter.configure(
    name = "rust-rustfmt",
    config = "//rust:enable-rustfmt",
)
linter.register(name = "rust-rustfmt")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node.toolchain(node_version = "20.9.0")

pnpm = use_extension(
    "@aspect_rules_js//npm:extensions.bzl",
    "pnpm",
    dev_dependency = True,
)
use_repo(pnpm, "pnpm")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
    name = "npm",
    data = [
        "@//:package.json",
        "@//:pnpm-workspace.yaml",
        "@//javascript/grid-ui:package.json",
        "@//javascript/node/selenium-webdriver:package.json",
    ],
    generate_bzl_library_targets = True,
    npmrc = "//:.npmrc",
    pnpm_lock = "//:pnpm-lock.yaml",
    update_pnpm_lock = True,
    verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

rules_ts_ext = use_extension(
    "@aspect_rules_ts//ts:extensions.bzl",
    "ext",
    dev_dependency = True,
)
rules_ts_ext.deps(
    ts_version = "4.9.5",
)
use_repo(rules_ts_ext, "npm_typescript")

esbuild = use_extension("@aspect_rules_esbuild//esbuild:extensions.bzl", "esbuild")
esbuild.toolchain(esbuild_version = "0.23.0")
use_repo(esbuild, "esbuild_toolchains")

register_toolchains("@esbuild_toolchains//:all")

dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
dotnet.toolchain(dotnet_version = "8.0.203")
use_repo(dotnet, "dotnet_toolchains")

selenium_paket = use_extension("//dotnet:paket.nuget_extension.bzl", "nuget_extension")
use_repo(selenium_paket, "paket.nuget")

register_toolchains("@dotnet_toolchains//:all")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
    name = "java_image_base",
    digest = "sha256:1df9f3e6a2de0544dd04f1840aa811d334045c9126f9e93d8da45448061ad51e",
    image = "gcr.io/distroless/java17",
)
oci.pull(
    name = "firefox_standalone",
    digest = "sha256:b6d8279268b3183d0d33e667e82fec1824298902f77718764076de763673124f",
    image = "index.docker.io/selenium/standalone-firefox",
)
oci.pull(
    name = "chrome_standalone",
    digest = "sha256:1b809a961a0a77787a7cccac74ddc5570b7e89747f925b8469ddb9a6624d4ece",
    image = "index.docker.io/selenium/standalone-chrome",
)
use_repo(oci, "chrome_standalone", "firefox_standalone", "java_image_base")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    is_default = True,
    python_version = "3.9",
)
python.toolchain(python_version = "3.10")
python.toolchain(python_version = "3.11")
python.toolchain(python_version = "3.12")
use_repo(python, "pythons_hub")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

[
    pip.parse(
        hub_name = "py_dev_requirements",
        python_version = version,
        requirements_lock = "//py:requirements_lock.txt",
    )
    for version in [
        "3.9",
        "3.10",
        "3.11",
        "3.12",
    ]
]

use_repo(pip, "py_dev_requirements")

register_toolchains("@pythons_hub//:all")

# https://github.com/bazelbuild/rules_jvm_external/pull/1079
archive_override(
    module_name = "rules_jvm_external",
    integrity = "sha256-yS8Qes1PLbYbe10b1WSgl0Auqn/1Wlxg8O3wSr7a/Sg=",
    patch_strip = 1,
    patches = ["//java:rules_jvm_external_javadoc.patch"],
    strip_prefix = "rules_jvm_external-f572a26116c7ef71d8842dd056c2605782f7be8d",
    urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/f572a26116c7ef71d8842dd056c2605782f7be8d.tar.gz"],
)

java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
use_repo(
    java_toolchains,
    "remote_java_tools",
    "remote_java_tools_darwin_arm64",
    "remote_java_tools_darwin_x86_64",
    "remote_java_tools_linux",
    "remote_java_tools_windows",
    "remotejdk17_linux",
    "remotejdk17_linux_s390x",
    "remotejdk17_macos",
    "remotejdk17_macos_aarch64",
    "remotejdk17_win",
    "remotejdk17_win_arm64",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
    name = "maven",
    artifacts = [
        "com.beust:jcommander:1.82",
        "com.github.javaparser:javaparser-core:3.26.3",
        "com.github.spotbugs:spotbugs:4.9.0",
        "com.github.stephenc.jcip:jcip-annotations:1.0-1",
        "com.google.code.gson:gson:2.11.0",
        "com.google.guava:guava:33.4.0-jre",
        "com.google.auto:auto-common:1.2.2",
        "com.google.auto.service:auto-service:1.1.1",
        "com.google.auto.service:auto-service-annotations:1.1.1",
        "com.google.googlejavaformat:google-java-format:jar:1.25.2",
        "com.graphql-java:graphql-java:22.3",
        "dev.failsafe:failsafe:3.3.2",
        "io.grpc:grpc-context:1.69.0",
        "io.lettuce:lettuce-core:6.5.2.RELEASE",
        "io.netty:netty-buffer",
        "io.netty:netty-codec-http",
        "io.netty:netty-codec-http2",
        "io.netty:netty-common",
        "io.netty:netty-handler",
        "io.netty:netty-handler-proxy",
        "io.netty:netty-transport",
        "io.opentelemetry:opentelemetry-api",
        "io.opentelemetry:opentelemetry-context",
        "io.opentelemetry:opentelemetry-exporter-logging",
        "io.opentelemetry:opentelemetry-sdk",
        "io.opentelemetry:opentelemetry-sdk-common",
        "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure",
        "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi",
        "io.opentelemetry:opentelemetry-sdk-testing",
        "io.opentelemetry:opentelemetry-sdk-trace",
        "io.opentelemetry.semconv:opentelemetry-semconv:1.28.0-alpha",
        "it.ozimov:embedded-redis:0.7.3",
        "net.bytebuddy:byte-buddy:1.15.11",
        "org.htmlunit:htmlunit-core-js:4.7.0",
        "org.apache.commons:commons-exec:1.4.0",
        "org.apache.logging.log4j:log4j-core:2.24.3",
        "org.assertj:assertj-core:3.27.2",
        "org.bouncycastle:bcpkix-jdk18on:1.79",
        "org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5",
        "org.hsqldb:hsqldb:2.7.4",
        "org.jspecify:jspecify:1.0.0",
        "org.junit.jupiter:junit-jupiter-api",
        "org.junit.jupiter:junit-jupiter-engine",
        "org.junit.jupiter:junit-jupiter-params",
        "org.junit.platform:junit-platform-launcher",
        "org.junit.platform:junit-platform-reporting",
        "org.junit.platform:junit-platform-commons",
        "org.junit.platform:junit-platform-engine",
        "org.mockito:mockito-core:5.15.2",
        "org.redisson:redisson:3.41.0",
        "org.slf4j:slf4j-api:2.0.16",
        "org.slf4j:slf4j-jdk14:2.0.16",
        "org.tomlj:tomlj:1.1.1",
        "org.zeromq:jeromq:0.6.0",
    ],
    boms = [
        "io.opentelemetry:opentelemetry-bom:1.46.0",
        "io.netty:netty-bom:4.1.117.Final",
        "org.junit:junit-bom:5.11.4",
    ],
    excluded_artifacts = [
        "org.hamcrest:hamcrest-all",  # Replaced by hamcrest 2
        "org.hamcrest:hamcrest-core",
        "io.netty:netty-all",  # Depend on the actual things you need
    ],
    fail_if_repin_required = True,
    fail_on_missing_checksum = True,
    fetch_sources = True,
    lock_file = "//java:maven_install.json",
    repositories = [
        "https://repo1.maven.org/maven2",
    ],
    resolver = "maven",
    strict_visibility = True,
)
use_repo(maven, "maven", "unpinned_maven")

ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby")
ruby.toolchain(
    name = "ruby",
    msys2_packages = [
        "curl",
        "libyaml",
    ],
    version_file = "//:rb/.ruby-version",
)
ruby.bundle_fetch(
    name = "bundle",
    srcs = [
        "//:rb/lib/selenium/devtools/version.rb",
        "//:rb/lib/selenium/webdriver/version.rb",
        "//:rb/selenium-devtools.gemspec",
        "//:rb/selenium-webdriver.gemspec",
    ],
    gem_checksums = {
        "activesupport-7.2.2.1": "842bcbf8a92977f80fb4750661a237cf5dd4fdd442066b3c35e88afb488647f5",
        "addressable-2.8.7": "462986537cf3735ab5f3c0f557f14155d778f4b43ea4f485a9deb9c8f7c58232",
        "ast-2.4.2": "1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12",
        "base64-0.2.0": "0f25e9b21a02a0cc0cea8ef92b2041035d39350946e8789c562b2d1a3da01507",
        "benchmark-0.4.0": "0f12f8c495545e3710c3e4f0480f63f06b4c842cc94cec7f33a956f5180e874a",
        "bigdecimal-3.1.9": "2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc",
        "bigdecimal-3.1.9-java": "dd9b8f7c870664cd9538a1325ce385ba57a6627969177258c4f0e661a7be4456",
        "concurrent-ruby-1.3.5": "813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6",
        "connection_pool-2.5.0": "233b92f8d38e038c1349ccea65dd3772727d669d6d2e71f9897c8bf5cd53ebfc",
        "crack-1.0.0": "c83aefdb428cdc7b66c7f287e488c796f055c0839e6e545fec2c7047743c4a49",
        "csv-3.3.2": "6ff0c135e65e485d1864dde6c1703b60d34cc9e19bed8452834a0b28a519bd4e",
        "curb-1.0.6": "b369434efa91dc7310d72a74f8a228a5b920e3d5a89b0a3097e4c6a905af6eb2",
        "date-3.4.1": "bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f",
        "debug-1.10.0": "11e28ca74875979e612444104f3972bd5ffb9e79179907d7ad46dba44bd2e7a4",
        "diff-lcs-1.5.1": "273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe",
        "drb-2.2.1": "e9d472bf785f558b96b25358bae115646da0dbfd45107ad858b0bc0d935cb340",
        "ffi-1.17.1-arm64-darwin": "a8e04f79d375742c54ee7f9fff4b4022b87200a4ec0eb082128d3b6559e67b4d",
        "ffi-1.17.1-java": "2546e11f9592e2b9b6de49eb96d2a378da47b0bb8469d5cbc9881a55c0d55da7",
        "ffi-1.17.1-x64-mingw-ucrt": "da79a832aee7ccd3635b4ec5e8a1927aed786e7ea03f2e33e2c06ea4fcece4a0",
        "ffi-1.17.1-x86_64-linux-gnu": "8c0ade2a5d19f3672bccfe3b58e016ae5f159e3e2e741c856db87fcf07c903d0",
        "fileutils-1.7.3": "57271e854b694a87755d76f836f5c57b2c9538ebbaf4b2154bb66addf15eb5da",
        "git-1.19.1": "b0a422d9f6517353c48a330d6114de4db9e0c82dbe7202964a1d9f1fbc827d70",
        "hashdiff-1.1.2": "2c30eeded6ed3dce8401d2b5b99e6963fe5f14ed85e60dd9e33c545a44b71a77",
        "i18n-1.14.6": "dc229a74f5d181f09942dd60ab5d6e667f7392c4ee826f35096db36d1fe3614c",
        "io-console-0.8.0": "cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2",
        "io-console-0.8.0-java": "3cc6fd5c66e587145c1fdf8dc40c2e3d851e90722a5d0cc3f38da352f06fe1bd",
        "irb-1.14.3": "c457f1f2f1438ae9ce5c5be3981ae2138dec7fb894c7d73777eeeb0a6c0d0752",
        "jar-dependencies-0.4.1": "b2df2f1ecbff15334ce20ea7fdd5b8d8161faab67761ff72c7647d728e40d387",
        "json-2.9.1": "d2bdef4644052fad91c1785d48263756fe32fcac08b96a20bb15840e96550d11",
        "json-2.9.1-java": "88de8c79b54fee6ae1b4854bc48b8d7089f524cbacaf4596df24f86b10896ee8",
        "language_server-protocol-3.17.0.3": "3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f",
        "listen-3.9.0": "db9e4424e0e5834480385197c139cb6b0ae0ef28cc13310cfd1ca78377d59c67",
        "logger-1.6.5": "c3cfe56d01656490ddd103d38b8993d73d86296adebc5f58cefc9ec03741e56b",
        "minitest-5.25.4": "9cf2cae25ac4dfc90c988ebc3b917f53c054978b673273da1bd20bcb0778f947",
        "parallel-1.26.3": "d86babb7a2b814be9f4b81587bf0b6ce2da7d45969fab24d8ae4bf2bb4d4c7ef",
        "parser-3.3.7.0": "7449011771e3e7881297859b849de26a6f4fccd515bece9520a87e7d2116119b",
        "psych-5.2.2": "a4a9477c85d3e858086c38cf64e7096abe40d1b1eed248b01020dec0ff9906ab",
        "psych-5.2.2-java": "dae010e0bbc01e03da5c42cf538705759fb592f42eb9e06baf9bce932c2d7c4e",
        "public_suffix-6.0.1": "61d44e1cab5cbbbe5b31068481cf16976dd0dc1b6b07bd95617ef8c5e3e00c6f",
        "racc-1.8.1": "4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f",
        "racc-1.8.1-java": "54f2e6d1e1b91c154013277d986f52a90e5ececbe91465d29172e49342732b98",
        "rack-2.2.10": "e4a5ee3f8f2ba45614a4498114d6dc7da1c51a0f0dd810d891906ea71d3aa72b",
        "rainbow-3.1.1": "039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a",
        "rake-13.2.1": "46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d",
        "rb-fsevent-0.11.2": "43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe",
        "rb-inotify-0.11.1": "a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e",
        "rbs-3.8.1": "2b6ce37952e267e1d3ad330aabfadbdceac234193a60cc18f25a8f75fa949c1d",
        "rchardet-1.9.0": "26889486cdd83b378652baf7603f71d93e431bb11bc237b4cd8c65151af4a590",
        "rdoc-6.11.0": "bec66fb9b019be64f7ba7d2cd2aecb283a3a01fef23a95b33e2349c6d1aa0040",
        "regexp_parser-2.10.0": "cb6f0ddde88772cd64bff1dbbf68df66d376043fe2e66a9ef77fcb1b0c548c61",
        "reline-0.6.0": "57620375dcbe56ec09bac7192bfb7460c716bbf0054dc94345ecaa5438e539d2",
        "rexml-3.4.0": "efbea1efba7fa151158e0ee1e643525834da2d8eb4cf744aa68f6480bc9804b2",
        "rspec-3.13.0": "d490914ac1d5a5a64a0e1400c1d54ddd2a501324d703b8cfe83f458337bab993",
        "rspec-core-3.13.2": "94fbda6e4738e478f1c7532b7cc241272fcdc8b9eac03a97338b1122e4573300",
        "rspec-expectations-3.13.3": "0e6b5af59b900147698ea0ff80456c4f2e69cac4394fbd392fbd1ca561f66c58",
        "rspec-mocks-3.13.2": "2327335def0e1665325a9b617e3af9ae20272741d80ac550336309a7c59abdef",
        "rspec-support-3.13.2": "cea3a2463fd9b84b9dcc9685efd80ea701aa8f7b3decb3b3ce795ed67737dbec",
        "rubocop-1.70.0": "96751f8440b36a0ac6e9a8ab596900803118d83d6b83f2037bf8b3d7a5bc440e",
        "rubocop-ast-1.37.0": "9513ac88aaf113d04b52912533ffe46475de1362d4aa41141b51b2455827c080",
        "rubocop-capybara-2.21.0": "5d264efdd8b6c7081a3d4889decf1451a1cfaaec204d81534e236bc825b280ab",
        "rubocop-factory_bot-2.26.1": "8de13cd4edcee5ca800f255188167ecef8dbfc3d1fae9f15734e9d2e755392aa",
        "rubocop-performance-1.23.1": "f22f86a795f5e6a6180aac2c6fc172534b173a068d6ed3396d6460523e051b82",
        "rubocop-rake-0.6.0": "56b6f22189af4b33d4f4e490a555c09f1281b02f4d48c3a61f6e8fe5f401d8db",
        "rubocop-rspec-2.31.0": "2bae19388d78e1ceace44cd95fd34f3209f4ef20cac1b168d0a1325cbba3d672",
        "rubocop-rspec_rails-2.29.1": "4ae95abbe9ca5a9b6d8be14e50d230fb5b6ba033b05d4c0981b5b76fc44988e4",
        "ruby-progressbar-1.13.0": "80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33",
        "rubyzip-2.4.1": "8577c88edc1fde8935eb91064c5cb1aef9ad5494b940cf19c775ee833e075615",
        "securerandom-0.4.1": "cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1",
        "steep-1.5.3": "7c6302a4d5932d0a46176ebc79766e52b853c223a85525aa2f8911e345123b85",
        "stringio-3.1.2": "204f1828f85cdb39d57cac4abc6dc44b04505a223f131587f2e20ae3729ba131",
        "strscan-3.1.2": "5529ff36c95fe752b8489f2e6c7f4f230fd9904e0b24fdc6e0833436c63ee2e3",
        "strscan-3.1.2-java": "4e9379df974b1af28d1bc1bc845ebb7e2bb21a7f9948ac99e1a8c5479881ecec",
        "terminal-table-3.0.2": "f951b6af5f3e00203fb290a669e0a85c5dd5b051b3b023392ccfd67ba5abae91",
        "tzinfo-2.0.6": "8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b",
        "unicode-display_width-2.6.0": "12279874bba6d5e4d2728cef814b19197dbb10d7a7837a869bab65da943b7f5a",
        "webmock-3.24.0": "be01357f6fc773606337ca79f3ba332b7d52cbe5c27587671abc0572dbec7122",
        "webrick-1.9.1": "b42d3c94f166f3fb73d87e9b359def9b5836c426fc8beacf38f2184a21b2a989",
        "websocket-1.2.11": "b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737",
        "yard-0.9.37": "a6e910399e78e613f80ba9add9ba7c394b1a935f083cccbef82903a3d2a26992",
    },
    gemfile = "//:rb/Gemfile",
    gemfile_lock = "//:rb/Gemfile.lock",
)
use_repo(ruby, "bundle", "ruby", "ruby_toolchains")

register_toolchains("@ruby_toolchains//:all")

selenium_manager_artifacts = use_extension("//common:selenium_manager.bzl", "selenium_manager_artifacts")
use_repo(
    selenium_manager_artifacts,
    "download_sm_linux",
    "download_sm_macos",
    "download_sm_windows",
)

pin_browsers_extension = use_extension("//common:repositories.bzl", "pin_browsers_extension")
use_repo(
    pin_browsers_extension,
    "linux_beta_firefox",
    "linux_chrome",
    "linux_chromedriver",
    "linux_edge",
    "linux_edgedriver",
    "linux_firefox",
    "linux_geckodriver",
    "mac_beta_firefox",
    "mac_chrome",
    "mac_chromedriver",
    "mac_edge",
    "mac_edgedriver",
    "mac_firefox",
    "mac_geckodriver",
)

local_drivers = use_repo_rule("//common/private:drivers.bzl", "local_drivers")

local_drivers(name = "local_drivers")
