syntax = "proto3";

package com.wixpress.appservice.api;

import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "components_catalog_common.proto";
import "wix/common/media.proto";
import "components_catalog_data/unified_components/unified_widget.proto";
import "components_catalog_data/unified_components/shared.proto";
import "components_catalog_data/unified_components/component_model.proto";

message CustomElement {
  // Boolean to make custom element in this widget be available for free sites
  bool allowed_for_free_site = 1;
  // The policy the user agreed to
  oneof ConsentCategory  {
    bool essential = 2;
    // Related to performance and other functional measurements.
    bool functional = 3;
    // Related to analytics about how the site is used in order to improve it.
    bool analytics = 4;
    // Related to allowing better customization of the experience to a current visitor.
    bool advertising = 5;
  }
  // CCPA compliance flag.
  bool data_to_third_party = 6;
}

// A widget component in the Wix Blocks.
message StudioWidgetComponentData {
  // Id of the widget
  string studio_widget_id = 1; // todo: maybe add GUID
  // Path to a json which contains the widget data and structure
  string page_json_filename = 2; // todo: maybe add WEB_URL
  // variationId -> widget variation data
  map<string, StudioWidgetVariation> variations = 3;
  //Product display data for this component
  WidgetDisplay widget_display = 4;
  //If it is required to be installed as part of the app
  bool essential = 5;
  // The version of blocks used to build this widget
  string blocks_version = 6;
  //If this component should be stretched in relation to a form factor (desktop, tablet, mobile)
  IsStretched is_stretched = 11;
  //Any margins this page should have in relation to a form factor (desktop, tablet, mobile)
  Margins margins = 12;
  //Any docking this page (horizontal / vertical) should have in relation to a form factor (desktop, tablet, mobile)
  Docking docking = 13;
  //The height of this page in relation to a form factor (desktop, tablet, mobile)
  Height height = 14;
  //The width of this page in relation to a form factor (desktop, tablet, mobile)
  Width width = 15;
  //Optional, static artifact short name, used for BoB application to indicate the relation between the widget and its static artifact
  google.protobuf.StringValue  related_artifact = 16 [(wix.api.field_exposure) = INTERNAL];
  // Properties of installed custom elements
  CustomElement custom_element = 17;
  // ids of nested widgets in this widget
  NestedWidgets nested_widgets = 18;
  reserved 19;
  // Properties of widget's presets
  repeated PresetInfo presets_info = 20;
  // Widget properties that affect the way it behaves during installation in a site.
  InstallationSettings installation_settings = 21;
  // Properties that affect the widget's presence in the editor.
  EditorPresence editor_presence = 22;
  // Base info of component by shared logic of unified components
  BaseInfo base = 23;
  // Unified widget installation settings
  WidgetInstallationSettings installation = 24;
  // if true, ssr will not cache pages that contain this widget
  bool ssr_cache_excluded = 25 [(wix.api.field_exposure) = INTERNAL];
  // The builder component model by shared logic of unified components. Required in oder to create a builder component
  ComponentModel component_model = 26 [(wix.api.field_exposure) = PRIVATE];
  // Optional: The URL of the widget's code bundle
  google.protobuf.StringValue widget_bundle_url = 27 [(wix.api.format) = WEB_URL];
  // The list of slot ids available
  repeated string slot_ids = 28 [(wix.api.field_exposure) = INTERNAL, (wix.api.format) = GUID, (.wix.api.maxSize) = 100, (.wix.api.referenced_entity) = "wix.devcenter.components.v1.component"];
  // Specifying the visibility level and maturity stage
  ExtensionExposure exposure_and_maturity = 29 [(.wix.api.field_exposure) = INTERNAL];
  // if true, when site member is logged in and this widget is in the page - ssr will not cache it
  bool site_members_ssr_cache_excluded = 30 [deprecated = true, (.wix.api.field_deprecated) = {
      replaced_by: "site_members_ssr_caching"
      target_removal_date: "2025-12-31"
  }, (wix.api.field_exposure) = INTERNAL];
  // Controls SSR caching behavior when site members are logged in
  SiteMembersSsrCaching site_members_ssr_caching = 31 [(wix.api.field_exposure) = INTERNAL];
  // Controls MPA Navigation behavior for this studio widget
  MpaNavigation mpa_navigation = 32 [(wix.api.field_exposure) = INTERNAL];
}

// A variation of a blocks widget
message StudioWidgetVariation {
  // Id of the widget variation
  string id = 1;
  // Display name of the variation
  string name = 2;
  // Path to a json which contains the widget variation data and structure
  string page_json_filename = 3; // todo: WEB_URL
}

// Nested widgets
message NestedWidgets {
  // ids of all recursively nested widgets from the same Blocks app
  repeated string internal = 1 [(wix.api.format) = GUID];
}

// Preset Size
message PresetSize {
  // The width of the preset when it's added to the stage
  DisplayValue width = 1;
  // The height of the preset when it's added to the stage
  DisplayValue height = 2;
}

// Preset Info
message PresetInfo {
  // Id of the widget's preset
  string preset_id = 1;
  // Display name of the widget's preset
  string preset_name = 2;
  // The default size used when the preset is added to the stage
  PresetSize default_size = 3;
}

message EditorPresence {
  // Properties that describe the presence of each of the widget's presets
  repeated PresetEditorPresence presets_editor_presence = 1;
}

message PresetEditorPresence {
  // Id of the widget's preset
  string preset_id = 1;
  // Controls whether to show or hide the preset in the Add Panel
  bool show_in_add_panel = 2;
  // Controls whether to show or hide the preset in the Presets Panel
  bool show_in_presets_panel = 3;
  // Optional image to show as the preset's thumbnail in the editor, if left empty an automatic snapshot of the preset will be used
  wix.common.Image wix_media_thumbnail = 4;
  // Another preset id that is a mobile variation of this preset
  string mobile_preset_id = 5;
}
