enum bucket_type {
    fill = 1;
    line = 2;
    point = 3;

    background = 15;
}

enum cap_type {
    round_cap = 1;
    butt_cap = 2;
    square_cap = 3;
}

enum join_type {
    miter_join = 1;
    bevel_join = 2;
    round_join = 3;
}

enum winding_type {
    evenodd = 1;
    nonzero = 2;
}

enum property_type {
    null = 1;
    constant = 2;
    stops = 3;
    linear = 4;
}

message value {
    // Exactly one of these values may be present in a valid message
    optional string string_value = 1;
    optional float float_value = 2;
    optional double double_value = 3;
    optional int64 int_value = 4;
    optional uint64 uint_value = 5;
    optional sint64 sint_value = 6;
    optional bool bool_value = 7;

    extensions 8 to max;
}

message bucket {
    required string name = 1;
    required bucket_type type = 2;

    // Specify what data to pull into this bucket
    required string source_name = 3;
    required string source_layer = 4;
    optional string source_field = 5;
    repeated value source_value = 6;

    // Specifies how the geometry for this bucket should be created
    optional cap_type cap = 7;
    optional join_type join = 8;
    optional string font = 9;
    optional float font_size = 10;
}

message layer {
    required string name = 1;
    optional string bucket_name = 2;
    repeated layer child_layer = 3;
}

message property {
    required property_type function = 1;
    repeated float value = 2 [ packed = true ];
}

message fill_style {
    required string layer_name = 1;
    optional property hidden = 2;
    optional winding_type winding = 3 [ default = nonzero ];
    optional property antialias = 4;
    optional fixed32 fill_color = 5 [ default = 0x000000FF ]; // rgba (=> rgb << 8 | 0xFF for opaque!)
    optional fixed32 stroke_color = 6; // if none is specified, no stroke will be painted
    optional property opacity = 7; // values from 0..1
    optional string image = 8;
    // TODO: translate x/y
}

message stroke_style {
    required string layer_name = 1;
    optional property hidden = 2;
    optional fixed32 color = 3 [ default = 0x000000FF ]; // rgba (=> rgb << 8 | 0xFF for opaque!)
    optional property width = 4;
    optional property offset = 5;
    optional property opacity = 6; // values from 0..1
    // line join + line cap are already defined in the
    // TODO: dasharray
    // TODO: image/icon
    // TODO: translate x/y
}

message class {
    required string name = 1;
    repeated fill_style fill = 2;
    repeated stroke_style stroke = 3;
}

// root level object
message style {
    repeated bucket bucket = 1;
    repeated layer layer = 2;
    repeated class class = 3;
}
