cc_library(
    name = "common_util",
    hdrs = [
        "common_util.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "http_util",
    srcs = ["http_util.cc"],
    hdrs = [
        "http_util.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":common_util",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/strings:str_format",
        "@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics",
    ],
)

cc_library(
    name = "http_util_nullvm",
    srcs = ["http_util.cc"],
    hdrs = [
        "http_util.h",
    ],
    visibility = ["//visibility:public"],
    copts = ["-DNULL_PLUGIN"],
    deps = [
        ":common_util",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/strings:str_format",
        "@proxy_wasm_cpp_host//:lib",
    ],
)


cc_library(
    name = "crypto_util",
    srcs = [
        "crypto_util.cc",
        "crypt_blowfish.c",
        "base64.h",
    ],
    hdrs = [
        "crypto_util.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":common_util",
        ":json_util",
        "@com_google_absl//absl/strings",
        "@boringssl//:ssl",
    ],
)

cc_library(
    name = "rule_util",
    hdrs = [
        "route_rule_matcher.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":common_util",
        ":http_util",
    ],
)

cc_library(
    name = "rule_util_nullvm",
    hdrs = [
        "route_rule_matcher.h",
    ],
    visibility = ["//visibility:public"],
    copts = ["-DNULL_PLUGIN"],
    deps = [
        ":common_util",
        ":http_util_nullvm",
    ],
)


cc_library(
    name = "regex_util",
    hdrs = [
        "regex.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":common_util",
        "@com_googlesource_code_re2//:re2",
    ],
)

# genrule(
#     name = "nlohmann_json_hpp",
#     srcs = ["@com_github_nlohmann_json_single_header//file"],
#     outs = ["nlohmann_json.hpp"],
#     cmd = "cp $< $@",
#     visibility = ["//visibility:public"],
# )

cc_library(
    name = "json_util",
    srcs = ["json_util.cc"],
    hdrs = [
        "json_util.h",
        "nlohmann_json.hpp",
    ],
    copts = ["-UNULL_PLUGIN"],
    visibility = ["//visibility:public"],
    deps = [
        ":common_util",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:optional",
    ],
)

exports_files([
    "base64.h",
    "json_util.cc",
    "json_util.h",
])
