// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto2";

package cel.expr.conformance.proto2;

import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

option cc_enable_arenas = true;
option go_package = "cel.dev/expr/conformance/proto2";
option java_multiple_files = true;
option java_outer_classname = "TestAllTypesProto";
option java_package = "dev.cel.expr.conformance.proto2";

// This proto includes every type of field in both singular and repeated
// forms.
message TestAllTypes {
  message NestedMessage {
    // The field name "b" fails to compile in proto1 because it conflicts with
    // a local variable named "b" in one of the generated methods.
    // This file needs to compile in proto1 to test backwards-compatibility.
    optional int32 bb = 1;
  }

  enum NestedEnum {
    FOO = 0;
    BAR = 1;
    BAZ = 2;
  }

  // Singular
  optional int32 single_int32 = 1 [default = -32];
  optional int64 single_int64 = 2 [default = -64];
  optional uint32 single_uint32 = 3 [default = 32];
  optional uint64 single_uint64 = 4 [default = 64];
  optional sint32 single_sint32 = 5;
  optional sint64 single_sint64 = 6;
  optional fixed32 single_fixed32 = 7;
  optional fixed64 single_fixed64 = 8;
  optional sfixed32 single_sfixed32 = 9;
  optional sfixed64 single_sfixed64 = 10;
  optional float single_float = 11 [default = 3.0];
  optional double single_double = 12 [default = 6.4];
  optional bool single_bool = 13 [default = true];
  optional string single_string = 14 [default = "empty"];
  optional bytes single_bytes = 15 [default = "none"];

  // Collides with 'in' operator.
  optional bool in = 18;

  // Wellknown.
  optional google.protobuf.Any single_any = 100;
  optional google.protobuf.Duration single_duration = 101;
  optional google.protobuf.Timestamp single_timestamp = 102;
  optional google.protobuf.Struct single_struct = 103;
  optional google.protobuf.Value single_value = 104;
  optional google.protobuf.Int64Value single_int64_wrapper = 105;
  optional google.protobuf.Int32Value single_int32_wrapper = 106;
  optional google.protobuf.DoubleValue single_double_wrapper = 107;
  optional google.protobuf.FloatValue single_float_wrapper = 108;
  optional google.protobuf.UInt64Value single_uint64_wrapper = 109;
  optional google.protobuf.UInt32Value single_uint32_wrapper = 110;
  optional google.protobuf.StringValue single_string_wrapper = 111;
  optional google.protobuf.BoolValue single_bool_wrapper = 112;
  optional google.protobuf.BytesValue single_bytes_wrapper = 113;
  optional google.protobuf.ListValue list_value = 114;
  optional google.protobuf.NullValue null_value = 115;
  optional google.protobuf.NullValue optional_null_value = 116;
  optional google.protobuf.FieldMask field_mask = 117;
  optional google.protobuf.Empty empty = 118;

  // Nested messages
  oneof nested_type {
    NestedMessage single_nested_message = 21;
    NestedEnum single_nested_enum = 22 [default = BAR];
  }
  optional NestedMessage standalone_message = 23;
  optional NestedEnum standalone_enum = 24;

  // Repeated
  repeated int32 repeated_int32 = 31;
  repeated int64 repeated_int64 = 32;
  repeated uint32 repeated_uint32 = 33;
  repeated uint64 repeated_uint64 = 34;
  repeated sint32 repeated_sint32 = 35;
  repeated sint64 repeated_sint64 = 36;
  repeated fixed32 repeated_fixed32 = 37;
  repeated fixed64 repeated_fixed64 = 38;
  repeated sfixed32 repeated_sfixed32 = 39;
  repeated sfixed64 repeated_sfixed64 = 40;
  repeated float repeated_float = 41;
  repeated double repeated_double = 42;
  repeated bool repeated_bool = 43;
  repeated string repeated_string = 44;
  repeated bytes repeated_bytes = 45;

  // Repeated and nested
  repeated NestedMessage repeated_nested_message = 51;
  repeated NestedEnum repeated_nested_enum = 52;
  repeated string repeated_string_piece = 53 [ctype = STRING_PIECE];
  repeated string repeated_cord = 54 [ctype = CORD];
  repeated NestedMessage repeated_lazy_message = 55;

  // Repeated wellknown.
  repeated google.protobuf.Any repeated_any = 120;
  repeated google.protobuf.Duration repeated_duration = 121;
  repeated google.protobuf.Timestamp repeated_timestamp = 122;
  repeated google.protobuf.Struct repeated_struct = 123;
  repeated google.protobuf.Value repeated_value = 124;
  repeated google.protobuf.Int64Value repeated_int64_wrapper = 125;
  repeated google.protobuf.Int32Value repeated_int32_wrapper = 126;
  repeated google.protobuf.DoubleValue repeated_double_wrapper = 127;
  repeated google.protobuf.FloatValue repeated_float_wrapper = 128;
  repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 129;
  repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 130;
  repeated google.protobuf.StringValue repeated_string_wrapper = 131;
  repeated google.protobuf.BoolValue repeated_bool_wrapper = 132;
  repeated google.protobuf.BytesValue repeated_bytes_wrapper = 133;
  repeated google.protobuf.ListValue repeated_list_value = 134;
  repeated google.protobuf.NullValue repeated_null_value = 135;

  // Map
  map<int64, NestedTestAllTypes> map_int64_nested_type = 62;

  map<bool, bool> map_bool_bool = 63;
  map<bool, string> map_bool_string = 64;
  map<bool, bytes> map_bool_bytes = 65;
  map<bool, int32> map_bool_int32 = 66;
  map<bool, int64> map_bool_int64 = 67;
  map<bool, uint32> map_bool_uint32 = 68;
  map<bool, uint64> map_bool_uint64 = 69;
  map<bool, float> map_bool_float = 70;
  map<bool, double> map_bool_double = 71;
  map<bool, NestedEnum> map_bool_enum = 72;
  map<bool, NestedMessage> map_bool_message = 73;
  map<bool, google.protobuf.Duration> map_bool_duration = 228;
  map<bool, google.protobuf.Timestamp> map_bool_timestamp = 229;
  map<bool, google.protobuf.NullValue> map_bool_null_value = 230;
  map<bool, google.protobuf.Any> map_bool_any = 246;
  map<bool, google.protobuf.Struct> map_bool_struct = 247;
  map<bool, google.protobuf.Value> map_bool_value = 248;
  map<bool, google.protobuf.ListValue> map_bool_list_value = 249;
  map<bool, google.protobuf.Int64Value> map_bool_int64_wrapper = 250;
  map<bool, google.protobuf.Int32Value> map_bool_int32_wrapper = 251;
  map<bool, google.protobuf.DoubleValue> map_bool_double_wrapper = 252;
  map<bool, google.protobuf.FloatValue> map_bool_float_wrapper = 253;
  map<bool, google.protobuf.UInt64Value> map_bool_uint64_wrapper = 254;
  map<bool, google.protobuf.UInt32Value> map_bool_uint32_wrapper = 255;
  map<bool, google.protobuf.StringValue> map_bool_string_wrapper = 256;
  map<bool, google.protobuf.BoolValue> map_bool_bool_wrapper = 257;
  map<bool, google.protobuf.BytesValue> map_bool_bytes_wrapper = 258;

  map<int32, bool> map_int32_bool = 74;
  map<int32, string> map_int32_string = 75;
  map<int32, bytes> map_int32_bytes = 76;
  map<int32, int32> map_int32_int32 = 77;
  map<int32, int64> map_int32_int64 = 78;
  map<int32, uint32> map_int32_uint32 = 79;
  map<int32, uint64> map_int32_uint64 = 80;
  map<int32, float> map_int32_float = 81;
  map<int32, double> map_int32_double = 82;
  map<int32, NestedEnum> map_int32_enum = 83;
  map<int32, NestedMessage> map_int32_message = 84;
  map<int32, google.protobuf.Duration> map_int32_duration = 231;
  map<int32, google.protobuf.Timestamp> map_int32_timestamp = 232;
  map<int32, google.protobuf.NullValue> map_int32_null_value = 233;
  map<int32, google.protobuf.Any> map_int32_any = 259;
  map<int32, google.protobuf.Struct> map_int32_struct = 260;
  map<int32, google.protobuf.Value> map_int32_value = 261;
  map<int32, google.protobuf.ListValue> map_int32_list_value = 262;
  map<int32, google.protobuf.Int64Value> map_int32_int64_wrapper = 263;
  map<int32, google.protobuf.Int32Value> map_int32_int32_wrapper = 264;
  map<int32, google.protobuf.DoubleValue> map_int32_double_wrapper = 265;
  map<int32, google.protobuf.FloatValue> map_int32_float_wrapper = 266;
  map<int32, google.protobuf.UInt64Value> map_int32_uint64_wrapper = 267;
  map<int32, google.protobuf.UInt32Value> map_int32_uint32_wrapper = 268;
  map<int32, google.protobuf.StringValue> map_int32_string_wrapper = 269;
  map<int32, google.protobuf.BoolValue> map_int32_bool_wrapper = 270;
  map<int32, google.protobuf.BytesValue> map_int32_bytes_wrapper = 271;

  map<int64, bool> map_int64_bool = 85;
  map<int64, string> map_int64_string = 86;
  map<int64, bytes> map_int64_bytes = 87;
  map<int64, int32> map_int64_int32 = 88;
  map<int64, int64> map_int64_int64 = 89;
  map<int64, uint32> map_int64_uint32 = 90;
  map<int64, uint64> map_int64_uint64 = 91;
  map<int64, float> map_int64_float = 92;
  map<int64, double> map_int64_double = 93;
  map<int64, NestedEnum> map_int64_enum = 94;
  map<int64, NestedMessage> map_int64_message = 95;
  map<int64, google.protobuf.Duration> map_int64_duration = 234;
  map<int64, google.protobuf.Timestamp> map_int64_timestamp = 235;
  map<int64, google.protobuf.NullValue> map_int64_null_value = 236;
  map<int64, google.protobuf.Any> map_int64_any = 272;
  map<int64, google.protobuf.Struct> map_int64_struct = 273;
  map<int64, google.protobuf.Value> map_int64_value = 274;
  map<int64, google.protobuf.ListValue> map_int64_list_value = 275;
  map<int64, google.protobuf.Int64Value> map_int64_int64_wrapper = 276;
  map<int64, google.protobuf.Int32Value> map_int64_int32_wrapper = 277;
  map<int64, google.protobuf.DoubleValue> map_int64_double_wrapper = 278;
  map<int64, google.protobuf.FloatValue> map_int64_float_wrapper = 279;
  map<int64, google.protobuf.UInt64Value> map_int64_uint64_wrapper = 280;
  map<int64, google.protobuf.UInt32Value> map_int64_uint32_wrapper = 281;
  map<int64, google.protobuf.StringValue> map_int64_string_wrapper = 282;
  map<int64, google.protobuf.BoolValue> map_int64_bool_wrapper = 283;
  map<int64, google.protobuf.BytesValue> map_int64_bytes_wrapper = 284;

  map<uint32, bool> map_uint32_bool = 96;
  map<uint32, string> map_uint32_string = 97;
  map<uint32, bytes> map_uint32_bytes = 98;
  map<uint32, int32> map_uint32_int32 = 99;
  map<uint32, int64> map_uint32_int64 = 200;
  map<uint32, uint32> map_uint32_uint32 = 201;
  map<uint32, uint64> map_uint32_uint64 = 202;
  map<uint32, float> map_uint32_float = 203;
  map<uint32, double> map_uint32_double = 204;
  map<uint32, NestedEnum> map_uint32_enum = 205;
  map<uint32, NestedMessage> map_uint32_message = 206;
  map<uint32, google.protobuf.Duration> map_uint32_duration = 237;
  map<uint32, google.protobuf.Timestamp> map_uint32_timestamp = 238;
  map<uint32, google.protobuf.NullValue> map_uint32_null_value = 239;
  map<uint32, google.protobuf.Any> map_uint32_any = 285;
  map<uint32, google.protobuf.Struct> map_uint32_struct = 286;
  map<uint32, google.protobuf.Value> map_uint32_value = 287;
  map<uint32, google.protobuf.ListValue> map_uint32_list_value = 288;
  map<uint32, google.protobuf.Int64Value> map_uint32_int64_wrapper = 289;
  map<uint32, google.protobuf.Int32Value> map_uint32_int32_wrapper = 290;
  map<uint32, google.protobuf.DoubleValue> map_uint32_double_wrapper = 291;
  map<uint32, google.protobuf.FloatValue> map_uint32_float_wrapper = 292;
  map<uint32, google.protobuf.UInt64Value> map_uint32_uint64_wrapper = 293;
  map<uint32, google.protobuf.UInt32Value> map_uint32_uint32_wrapper = 294;
  map<uint32, google.protobuf.StringValue> map_uint32_string_wrapper = 295;
  map<uint32, google.protobuf.BoolValue> map_uint32_bool_wrapper = 296;
  map<uint32, google.protobuf.BytesValue> map_uint32_bytes_wrapper = 297;

  map<uint64, bool> map_uint64_bool = 207;
  map<uint64, string> map_uint64_string = 208;
  map<uint64, bytes> map_uint64_bytes = 209;
  map<uint64, int32> map_uint64_int32 = 210;
  map<uint64, int64> map_uint64_int64 = 211;
  map<uint64, uint32> map_uint64_uint32 = 212;
  map<uint64, uint64> map_uint64_uint64 = 213;
  map<uint64, float> map_uint64_float = 214;
  map<uint64, double> map_uint64_double = 215;
  map<uint64, NestedEnum> map_uint64_enum = 216;
  map<uint64, NestedMessage> map_uint64_message = 217;
  map<uint64, google.protobuf.Duration> map_uint64_duration = 240;
  map<uint64, google.protobuf.Timestamp> map_uint64_timestamp = 241;
  map<uint64, google.protobuf.NullValue> map_uint64_null_value = 242;
  map<uint64, google.protobuf.Any> map_uint64_any = 298;
  map<uint64, google.protobuf.Struct> map_uint64_struct = 299;
  map<uint64, google.protobuf.Value> map_uint64_value = 300;
  map<uint64, google.protobuf.ListValue> map_uint64_list_value = 301;
  map<uint64, google.protobuf.Int64Value> map_uint64_int64_wrapper = 302;
  map<uint64, google.protobuf.Int32Value> map_uint64_int32_wrapper = 303;
  map<uint64, google.protobuf.DoubleValue> map_uint64_double_wrapper = 304;
  map<uint64, google.protobuf.FloatValue> map_uint64_float_wrapper = 305;
  map<uint64, google.protobuf.UInt64Value> map_uint64_uint64_wrapper = 306;
  map<uint64, google.protobuf.UInt32Value> map_uint64_uint32_wrapper = 307;
  map<uint64, google.protobuf.StringValue> map_uint64_string_wrapper = 308;
  map<uint64, google.protobuf.BoolValue> map_uint64_bool_wrapper = 309;
  map<uint64, google.protobuf.BytesValue> map_uint64_bytes_wrapper = 310;

  map<string, bool> map_string_bool = 218;
  map<string, string> map_string_string = 61;
  map<string, bytes> map_string_bytes = 219;
  map<string, int32> map_string_int32 = 220;
  map<string, int64> map_string_int64 = 221;
  map<string, uint32> map_string_uint32 = 222;
  map<string, uint64> map_string_uint64 = 223;
  map<string, float> map_string_float = 224;
  map<string, double> map_string_double = 225;
  map<string, NestedEnum> map_string_enum = 226;
  map<string, NestedMessage> map_string_message = 227;
  map<string, google.protobuf.Duration> map_string_duration = 243;
  map<string, google.protobuf.Timestamp> map_string_timestamp = 244;
  map<string, google.protobuf.NullValue> map_string_null_value = 245;
  map<string, google.protobuf.Any> map_string_any = 311;
  map<string, google.protobuf.Struct> map_string_struct = 312;
  map<string, google.protobuf.Value> map_string_value = 313;
  map<string, google.protobuf.ListValue> map_string_list_value = 314;
  map<string, google.protobuf.Int64Value> map_string_int64_wrapper = 315;
  map<string, google.protobuf.Int32Value> map_string_int32_wrapper = 316;
  map<string, google.protobuf.DoubleValue> map_string_double_wrapper = 317;
  map<string, google.protobuf.FloatValue> map_string_float_wrapper = 318;
  map<string, google.protobuf.UInt64Value> map_string_uint64_wrapper = 319;
  map<string, google.protobuf.UInt32Value> map_string_uint32_wrapper = 320;
  map<string, google.protobuf.StringValue> map_string_string_wrapper = 321;
  map<string, google.protobuf.BoolValue> map_string_bool_wrapper = 322;
  map<string, google.protobuf.BytesValue> map_string_bytes_wrapper = 323;

  oneof kind {
    NestedTestAllTypes oneof_type = 400;
    NestedMessage oneof_msg = 401;
    bool oneof_bool = 402;
  }

  optional group NestedGroup = 403 {
    optional int32 single_id = 404;
    optional string single_name = 405;
  }

  // Field names formerly defined as reserved CEL identifiers.
  optional bool as = 500;
  optional bool break = 501;
  optional bool const = 502;
  optional bool continue = 503;
  optional bool else = 504;
  optional bool for = 505;
  optional bool function = 506;
  optional bool if = 507;
  optional bool import = 508;
  optional bool let = 509;
  optional bool loop = 510;
  optional bool package = 511;
  optional bool namespace = 512;
  optional bool return = 513;
  optional bool var = 514;
  optional bool void = 515;
  optional bool while = 516;

  extensions 1000 to max;
}

// This proto includes a recursively nested message.
message NestedTestAllTypes {
  optional NestedTestAllTypes child = 1;
  optional TestAllTypes payload = 2;
}

// This proto has a required field.
message TestRequired {
  required int32 required_int32 = 1;
}

// This proto tests that global enums are resolved correctly.
enum GlobalEnum {
  GOO = 0;
  GAR = 1;
  GAZ = 2;
}
