syntax = "proto3";

package com.wixpress.appservice.api;

import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "components_catalog_data/unified_components/shared.proto";
import "components_catalog_data/unified_components/unified_widget.proto";

// A draggable custom element. Add your custom script and generate ui directly in the viewer
message WebComponentData {
    // A link to a preview image we can render in the editor in place of your component
    string image_preview = 1; // todo: WEB_URL? ask oron
    // Web component size
    Size size = 2;
    // This script url should render temp empty state
    string script_tag = 3 [(wix.api.format) = WEB_URL];
    // Unique tag name to use in order to connect your JS script to your web component
    string tag_name = 4;
    //The settings panel URL for this component
    google.protobuf.StringValue settings_url = 5 [(wix.api.format) = WEB_URL];
    // The editor modal that the user will see
    string modal_title = 6;
    // Settings CTA label
    string connect_label = 7;
    // Dynamic settings(Graphic Floating Properties Panel settings)
    Settings gfpp_settings = 8;
    // Custom element type PAGE / WIDGET
    ElementType type = 9;
    // Boolean to make this component be available for free sites
    bool allowed_for_free_site = 10;
    // A public link to the SEO endpoint
    google.protobuf.StringValue seo_url = 11 [(wix.api.format) = WEB_URL];
    // For case that the widget will be used as page
    google.protobuf.StringValue slug = 12;
    // For case that the widget will be used as page
    bool show_page_in_menu = 13;
    // The details of the selected widget to add
    WidgetDetails widget = 14;
    // Give the option to change the script type
    ScriptType scriptType = 15;
    // Web component default mobile height
    google.protobuf.Int32Value default_mobile_height = 16;
    // Prevent the deletion of the widget when set to true.
    bool essential = 17;
    // Toggle to mark whether the editor should revoke an app that contains this component.
    bool exclude_from_auto_revoke = 18;
    // defines the widget's behaviour in editor page
    WidgetBehavior widget_behavior = 19;
    reserved 20;
    reserved 21;

    enum ScriptType {
        NO_SCRIPT_TYPE = 0;
        MODULE = 1;
    }
    
    enum ElementType {
        WIDGET = 0;
        PAGE = 1;
    }
}

// Web component size
message Size {
    // Height in pixels
    int32 height = 1 [(wix.api.min) = 0, (wix.api.max) = 9999];
    // Width in pixels
    int32 width = 2 [(wix.api.min) = 0, (wix.api.max) = 9999];
}

// Graphic Floating Properties Panel settings
message Settings {
    string active_tab = 1;
    google.protobuf.StringValue fetch_initial_data = 2 [(wix.api.format) = WEB_URL];
    repeated Tab tabs = 3;
}

// Setting tab definition
message Tab {
    string label = 1;
    repeated Container items = 2;
    // hidden tab will not be visible in editor and dev center preview
    bool hidden = 3;
}

// UI definition for tab
message Item {
     oneof data {
        //items
        FontFamilyWithColorPicker font_family_with_color_picker = 1;
        RadioButtonLabeled radio_button_labeled = 2;
        ColorSelectLabeled color_select_labeled = 3;  
        Thumbnails thumbnails = 4;
        SliderLabeled slider_labeled = 5;
        DropDownLabeled drop_down_labeled = 6;
        ToggleLabeled toggle_labeled = 7;
        BarAlignment bar_alignment = 8;
        TextInputLabeled text_input_labeled = 9;
        TextStyle text_style = 10;
    }
}

// UI Container in page
message Container {
    oneof data {
        //containers 
        Main main = 1;
        Section section = 2;
        DrillInListItem drill_in_list_item = 3;
        //items
        Thumbnails thumbnails = 4;
        SliderLabeled slider_labeled = 5;
        DropDownLabeled drop_down_labeled = 6;
        ToggleLabeled toggle_labeled = 7;
        BarAlignment bar_alignment = 8;
        TextInputLabeled text_input_labeled = 9;
        ResetButton reset_button = 10;
        FontFamilyWithColorPicker font_family_with_color_picker = 11;
        RadioButtonLabeled radio_button_labeled = 12;
        ColorSelectLabeled color_select_labeled = 13;  
        TextStyle text_style = 14;
    }
}
// DrillInListItem 3
message DrillInListItem {
    repeated DrillItem items = 1;
    string label = 2;
}
// Main 1
message Main {
    repeated MainPropsData items = 1;
}
// DrillItem
message DrillItem {
   oneof data {
         //containers 
         Section section = 1;
         //items
         RadioButtonLabeled radio_button_labeled = 2;
         ColorSelectLabeled color_select_labeled = 3;  
         Thumbnails thumbnails = 4;
         SliderLabeled slider_labeled = 5;
         DropDownLabeled drop_down_labeled = 6;
         ToggleLabeled toggle_labeled = 7;
         BarAlignment bar_alignment = 8;
         TextInputLabeled text_input_labeled = 9;
         FontFamilyWithColorPicker font_family_with_color_picker = 10;
         TextStyle text_style = 11;
    }
}

// Section 2
message Section {
    string label = 1;
}

// Elements =========
// BarAlignment 8
message BarAlignment {
    BarAlignmentSelected selected = 1 [deprecated = true];
    string key = 2;
    string title = 3;
    string description = 4;
    BarAlignmentSelected value = 5;
    repeated Condition conditions = 6;

}
// SliderLabeled 5
message SliderLabeled {
    string key = 1;
    string title = 2;
    string size = 3;
    string placeholder = 4;
    string description = 5;
    int32 minSize = 6;
    int32 maxSize = 7;
}
// Thumbnails 4
message Thumbnails {
    string key = 1;
    string title = 2;
    string value = 3;
    repeated ThumbnailData options = 4;
    ThumbnailsSize size = 5;
    string description = 6;
    repeated Condition conditions = 7;
}
//11
message FontFamilyWithColorPicker {
    string key = 1;
    string title = 2;
    string description = 3;
    FontDefinition value = 4;
    FontDefinition defaultValue = 5;
}
//10
message ResetButton {
    string label = 1;
}
// TextInputLabeled 9
message TextInputLabeled {
    string key = 1;
    string title = 2;
    string placeholder = 3;
    string value = 4;
    string description = 5;
}
// ToggleLabeled 7
message ToggleLabeled {
    string key = 1;
    string title = 2;
    bool value = 3;
    string description = 5;
    repeated Condition conditions = 4;
}

// RichTextWithIllustrationVertical main 1
message RichTextWithIllustrationVertical {
    string key = 1;
    string label = 2;
    string text = 3;
}

// DropDownLabeled 6
message DropDownLabeled {
    string key = 1;
    string title = 2;
    string value = 3;
    repeated string options = 4;
    string description = 5;
    repeated Condition conditions = 6;
}

// RadioButtonLabeled 12
message RadioButtonLabeled {
    string key = 1;
    string title = 2;
    string value = 3;
    repeated string options = 4;
    string description = 5;
    repeated Condition conditions = 6;
}

// ColorSelectLabeled 13
message ColorSelectLabeled {
    string title = 1;
    string key = 2;
    string color = 3 [deprecated = true];
    oneof data {
        ColorDefinition customColor = 4;
    TemplateDefaultColor templateColor = 5;
    };
    ColorDefinition defaultData = 6;
    string description = 7;
}

// TextStyle 14
message TextStyle {
    string key = 1;
    string title = 2;
    string description = 3;
    DefaultTextStyle defaultTextStyle = 4;
    oneof defaultColor {
    ColorDefinition customColor = 5;
    TemplateDefaultColor templateColor = 6;
    };
}

enum DefaultTextStyle {
    TITLE = 0;
    PARAGRAPH = 1;
    LOWER_HIERARCHY_TEXTS = 2;
}

enum TemplateDefaultColor {
    BACKGROUND = 0;
    SECONDARY_TEXTS = 1;
    MAIN_TEXT_AND_ICONS = 2;
    BORDERS_AND_DIVIDERS = 3;
    BUTTONS_AND_LINKS = 4;
}

// DashboardButton main 2
message DashboardButton {
    string title = 1;
    string label = 2;
}

// defintion and enums
message FontDefinition { 
    string font = 1;
    ColorDefinition color = 2;
}
message ColorDefinition {
    string value = 1;
    string opacity = 2;
}

// Structure for thumbnail
message ThumbnailData {
    string value = 1;
    google.protobuf.StringValue src = 2 [(wix.api.format) = WEB_URL];
    google.protobuf.StringValue selected_src = 3 [(wix.api.format) = WEB_URL];
    google.protobuf.StringValue on_hover_src = 4 [(wix.api.format) = WEB_URL];
    string label = 5;
}

enum ThumbnailsSize {
    SMALL = 0;
    MEDIUM = 1;
    LARGE = 2;
    XLARGE = 3;
}
//Bar alignment selected value
enum BarAlignmentSelected {
    ALIGN_LEFT = 0;
    ALIGN_CENTER = 1;
    ALIGN_RIGHT = 2;
}

// MainPropsData
message MainPropsData {
    DashboardButton dashboard_button = 1;
    RichTextWithIllustrationVertical rich_text_with_illustration_vertical = 2;
}

message Condition {
    string value = 1;
    repeated SingleKeyCondition state = 2;

}
message SingleKeyCondition {
    string key = 1;
    string value = 2;
    bool visible = 3;
}

message WidgetDetails {
    google.protobuf.StringValue name = 1;
    google.protobuf.StringValue icon = 2;
    google.protobuf.StringValue description =3;
}

message WidgetBehavior {
    // Toggle whether the widget is removable from the page.
    bool removable = 1;
    // Toggle whether the widget is duplicatable from the page.
    bool duplicatable = 2;
}
