// flynt-disable enum-value-upper-case
syntax = "proto3";

package com.wixpress.appservice.api;

import "wix/api/validations.proto";
import "wix/api/annotations.proto";
import "components_catalog_data/editor_react_component/style.proto";
import "components_catalog_data/editor_react_component/data.proto";
import "components_catalog_data/editor_react_component/behaviors.proto";
import "components_catalog_data/editor_react_component/actions.proto";
import "components_catalog_data/editor_react_component/preset_item.proto";
import "components_catalog_data/editor_react_component/archetype.proto";
import "components_catalog_data/editor_react_component/state.proto";
import "components_catalog_data/editor_react_component/display_filter.proto";
import "components_catalog_data/editor_react_component/display_group.proto";
import "components_catalog_data/editor_react_component/css_property.proto";
import "components_catalog_data/editor_react_component/help_article.proto";
import "google/protobuf/struct.proto";

message ElementTypeEnum {
  enum ElementType {
    UNKNOWN_ElementType = 0;
    inlineElement = 1; // An element that was written as part of the component
    refElement = 2; // An element provided by the Wix ecosystem that we are reusing. These elements must exist in the Wix DEV Center. 
  }
}

message ElementItem {
  // Defines the type of element we are configuring
  ElementTypeEnum.ElementType element_type = 1;
  // A different model definition for each one of the element-type options
  oneof SelectedElementType {
    option (.wix.api.aligned_with_enum) = {
      field: "element_type";
      suffix: "";
    };
    // An new element definition
    InlineElement inline_element = 2;
    // A reference to the used element with overrides
    RefElement ref_element = 3;
  }

  // Whether this element is deprecated
  bool deprecated = 4 [(wix.api.field_exposure) = INTERNAL];
}

message InlineElement {
  // Relative DOM Query selector for this element to the component root. We assume nesting by it's parent elements for CSS Vars scoping.
  string selector  = 1 [(.wix.api.minLength) = 4, (.wix.api.maxLength) = 300];
  // Human friendly name on the editor stage when the component is in interaction with the user
  string display_name = 2 [(.wix.api.maxLength) = 50, (.wix.api.translatable) = {
    type: SHORT_TEXT
  }];
  // style-api of this element, a map of style-items where the key is the style-item name and the value is the style-item definition. These will be manifested as CSS vars in the scope of the component and prefixed with `--` 
  map<string, StyleItem> style = 3;
  // data-api of this element, a map of data-items where the key is the data-item name and the value is the data-item definition
  map<string, DataItem> data = 4;
  // elements-map of this element, a map of inner-elements where the key is the element name and the value is the element definition
  map<string, ElementItem> elements = 5;
  // editor-behaviors-api of this inner-element, will determine which type of editor experiences this inner-element should support
  Behaviors behaviors = 6;
  // Collection of the native actions specified for the concrete component
  Actions actions = 7;
  // Custom actions specified for the component, allowing for flexibility beyond native actions
  map<string, Action> custom_actions = 8;
  // Component presets definition. Canonically useful for different layout or theming 
  map<string, PresetItem> presets = 9;
  reserved 10;
  // The Archetype this component adheres to, to be used for classification by AI models
  ArchetypeEnum.Archetype archetype = 11;
  // A map with definitions of states that this element can be edited in
  map<string, ElementState> states = 12;
  // A reference to a state that needs to be triggered in order for this element to be visible
  VisibleState visible_state = 13;
  // Display filters for the Element, used to define the visibility of inner / ref elements, style items, data items and custom actions in the editor
  // The Element is the first in line to affect the display, Preset and State are after it
  DisplayFilters display_filters = 14;
  reserved 15; // previously used for preset_key
  // Display groups for the element, used to group elements in the editor for better UX
  map<string, DisplayGroupItem> display_groups = 16;
  reserved 17; // reserved for style_overrides: https://github.com/wix-private/devcenter/pull/13102/commits/9b6c104cf3dd4f58e954d9edfeab0dd50de314c8
  // A map of css-properties that this element supports, where the key is the CSS property name and the value is the CSS property definition
  map<string, CssPropertyItem> css_properties = 18;
  // A map of css-custom-properties that this element supports, where the key is the CSS property name and the value is the CSS property definition
  map<string, CssCustomPropertyItem> css_custom_properties = 19;
  // A reference to a help article for this element 
  HelpArticle help_article = 20;
}

message RefInnerElementDefaults {
  // reserving deprecated fields to prevent breaking changes, style was 2
  reserved 1, 2; // previously used for preset_key and style
  reserved "style";
  // The default data for an element
  map<string, google.protobuf.Value> data = 3;
  // The default preset and styles for inner elements
  map<string, RefInnerElementDefaults> elements = 4;
  // A map of default values for the css-properties that this element supports
  map<string, CssPropertyItemDefaults> css_properties = 5;
  // A map of default values for the css-properties that this element supports
  map<string, CssPropertyItemDefaults> css_custom_properties = 6;
}

message RefElement {
  // The type of the referenced element. Must exist in the Wix Dev Center and be fully typed (`appSlug.componentType`).
  string type = 1 [(.wix.api.minLength) = 4, (.wix.api.maxLength) = 100];
  // The override of the used element selector, full path from root
  string selector  = 2 [(.wix.api.minLength) = 4, (.wix.api.maxLength) = 300];
  // The override of the used element displayName
  string display_name = 3 [(.wix.api.maxLength) = 50, (.wix.api.translatable) = {
    type: SHORT_TEXT
  }];
  // The override of the used element style
  map<string, StyleItemOverrides> style = 4;
  // The override of the used element data
  map<string, DataItemOverrides> data = 5;
  // The override of the used element behaviors
  Behaviors behaviors = 6;
  // The override of the used element native actions
  Actions actions = 7;
  // The override of the used element custom actions
  map<string, Action> custom_actions = 8;
  // The resolved element data after merging the DEV intent
  InlineElement resolved_element = 9 [(.wix.api.field_exposure) = INTERNAL];
  // A reference to a state that needs to be triggered in order for this element to be visible
  VisibleState visible_state = 10;
  // This is where you can override the  display filter defined by the original element
  // The override is per field. So you can override: style items, data items, custom actions and elements or just some of them.
  // Any item not overridden will be inherited from the original element
  DisplayFilters display_filters = 11;
  reserved 12; // previously used for preset_key
  // reserving deprecated fields to prevent breaking changes, elements_defaults was 13
  reserved 13; // previously used for elements_defaults
  reserved "elements_defaults";
  // The default style & data for inner elements
  map<string, RefInnerElementDefaults> elements = 14;
  reserved 15; // previously used for elements_defaults
  reserved 16; // reserved for style_overrides
  // A map of definition overrides for the css-properties that this element supports
  map<string, CssPropertyItemDefinitionOverrides> css_properties = 17;
  // A map of definition overrides for the css-custom-properties that this element supports
  map<string, CssPropertyItemDefinitionOverrides> css_custom_properties = 18;
  // A reference to a help article for this element
  HelpArticle help_article = 19;
}

// ElementOverrides is a message that contains the allowed overrides for an element
message ElementOverrides {
  Actions actions = 1; // The override of the used element native actions
  map<string, Action> custom_actions = 2; // The override of the used element custom actions
  DisplayFilters display_filters = 3; // The override of the used element display filters
}
