//flynt-disable renamed-field-breaking-change
//flynt-disable field-type-breaking-change

syntax = "proto3";

//flynt-disable package-matches-structure
package com.wixpress.appservice.api;

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "components_catalog_common.proto";
import "google/protobuf/wrappers.proto";

// Back-office Customization
message BackOfficeCustomization {
  // Hosting platform
  BackOfficeHostingPlatforms hosting_platform = 1 [(wix.api.field_exposure) = INTERNAL];
  // Optional Header customization, if not provided the default header will be used
  Header header = 2;
  // Optional sidebar customization, if not provided the default sidebar will be used
  Sidebar sidebar = 3;
  // Optional list of core appIds to include in the dashboard. If not provided the host default will be used.
  CoreApps core_apps = 4 [(wix.api.field_exposure) = INTERNAL];
}

message CoreApps {
  // List of core appIds to include in the dashboard. Only appIds present in the host's coreAppId list are allowed.
  repeated string core_app_ids = 1 [(wix.api.maxSize) = 500, (wix.api.format) = GUID];
}

enum ElementDisplayOption {
  UNKNOWN_OPTION = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
  REMOVE = 1; 
  CUSTOMIZED = 2;
}

message Header {
  ElementDisplayOption display_option = 1;

  oneof config {
    option (.wix.api.aligned_with_enum) = {
      field: "display_option";
      suffix: "";
    };
    HeaderConfig customized = 2; // Only set if option == CUSTOMIZED
  }
}

// Header configuration, you can provide extensionId or using our platform header
message HeaderConfig {
  oneof header_config {
    PlatformHeaderConfig platform = 1;
    HeaderWidgetConfig widget = 2;
  }
}

// Header widget configuration, provide extensionId
message HeaderWidgetConfig {
  string extension_id = 1 [(wix.api.format) = GUID];
}
// Platform header customization option
message PlatformHeaderConfig {
  // option to customize your header logo
  message Logo {
    // Logo image url
    string image_url = 1 [(wix.api.format) = WEB_URL];
    // Target url, choose where to navigate when clicking on the logo
    google.protobuf.StringValue target_url = 2 [(wix.api.format) = WEB_URL];
  }

  // Header menu dropdown, (popover)
  message MenuDropdown {
    // MenuItem title
    string title = 1  [(wix.api.translatable) = {type: SHORT_TEXT  grouping: "title"}, (wix.api.minLength) = 2, (wix.api.maxLength) = 50];
    // Menu dropdown links
    repeated MenuLink links = 2 [(wix.api.maxSize) = 20];
  }

  // MenuItems links
  message MenuLink {
    // Link title
    string title = 1  [(wix.api.translatable) = {type: SHORT_TEXT  grouping: "title"}, (wix.api.minLength) = 2, (wix.api.maxLength) = 100];
    // Link url
    string url = 2 [(wix.api.format) = WEB_URL];
  }

  message SearchConfig {
    // Weather include platformized search in header or not
    bool visible = 1;
  }

  // Sidebar skin from WDS, dark, light.
  google.protobuf.StringValue theme = 1 [(wix.api.maxLength) = 20];;
    // Header logo
  Logo logo = 2;
  // Header menuItems / Popovers
  repeated MenuDropdown menu_dropdowns = 3 [(wix.api.maxSize) = 10];
  // Header platformized search configuration
  SearchConfig search_config = 4;
}

message Sidebar {
  ElementDisplayOption display_option = 1;

  oneof config {
    option (.wix.api.aligned_with_enum) = {
      field: "display_option";
      suffix: "";
    };
    SidebarConfig customized = 2; // Only set if option == CUSTOMIZED
  }
}

// Backoffice sidebar castomization options
message SidebarConfig {
  enum SidebarDataType {
    UNKNOWN_TYPE = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
    CATEGORY = 1;
    PAGE = 2;
    SEPARATOR = 3;
  }

  // Represents page item in the sidebar
  message Page {
    string page_id = 1 [(wix.api.format) = GUID];
  }

  // Represents sidebar category of root level
  message FirstLevelCategory {
    option (.wix.api.unique) = {field: "category_id"};
    // Category id, should be unique
    string category_id = 1 [(wix.api.minLength) = 4 ,(wix.api.maxLength) = 36];
    // Category label
    string label = 2 [(wix.api.translatable) = {type: SHORT_TEXT  grouping: "title"}, (wix.api.minLength) = 2, (wix.api.maxLength) = 50];
    // Category icon, supported only on root level, will be ignores otherwise
    // [Wix Design System icon](https://www.wix-pages.com/wix-design-system-employees/?path=/story/foundations-icons--icons).
    // Use the full size key. The icon will be rendered in an appropriate size.
    google.protobuf.StringValue icon = 3  [(wix.api.minLength) = 3, (wix.api.maxLength) = 50];
    // Category children, consist of pages, separators or categories, categories can be a child only on root level
    repeated SidebarChildItem children = 4 [(wix.api.maxSize) = 100];
  }

  // Represents sidebar category of second level
  message SecondLevelCategory {
    option (.wix.api.unique) = {field: "category_id"};
    // Category id, should be unique
    string category_id = 1 [(wix.api.format) = GUID];
    // Category label
    string label = 2 [(wix.api.translatable) = {type: SHORT_TEXT  grouping: "title"}, (wix.api.minLength) = 2, (wix.api.maxLength) = 50];
    // Category children, consist of pages, separators or categories, categories can be a child only on root level
    repeated SidebarSecondLevelChildItem children = 3 [(wix.api.maxSize) = 100];
  }

  // Root level sidebar item, can be category or separator (when not setting category)
  message SidebarRootItem {
    SidebarDataType type = 1;
    oneof item {
      option (.wix.api.aligned_with_enum) = {
        field: "type";
        suffix: "";
      };
      FirstLevelCategory category = 2;
    }
  }

  // First Inner level of sidebar item, can contain pages or separators or categories
  // For separator no need to set item
  message SidebarChildItem {
    SidebarDataType type = 1;
    oneof item {
      option (.wix.api.aligned_with_enum) = {
        field: "type";
        suffix: "";
      };
      SecondLevelCategory category = 2;
      Page page = 3;
    }
  }

  // Second Inner level of sidebar item, can contain pages or separators
// For separator no need to set item
  message SidebarSecondLevelChildItem {
    SidebarDataType type = 1;
    oneof item {
      option (.wix.api.aligned_with_enum) = {
        field: "type";
        suffix: "";
      };
      Page page = 2;
    }
  }

  // Option to supply extension that will be shown in the sidebar
  message SidebarWidgetConfig {
    google.protobuf.StringValue extension_id = 1 [(wix.api.format) = GUID];
  }

  // Sidebar widget configuration
  message SidebarWidget {
    // Widget display option
    ElementDisplayOption display_option = 1;

    oneof config {
      option (.wix.api.aligned_with_enum) = {
        field: "display_option";
        suffix: "";
      };
      SidebarWidgetConfig customized = 2; // Only set if option == CUSTOMIZED
    }
  }

  // List of root sidebar items, categories or separators, if empty default sidebar will be shown
  repeated SidebarRootItem sidebar_items = 1 [(wix.api.maxSize) = 100];
  // Sidebar skin from WDS, dark, light.
  google.protobuf.StringValue theme = 2 [(wix.api.maxLength) = 20];
  // Option to override sidebar header with customize extension
  SidebarWidget sidebar_header = 3;
  // Option to override sidebar footer with customize extension
  SidebarWidget sidebar_footer = 4;
  // List of sidebar entities that cannot be hidden by a restricted customization extension
  repeated BackOfficeCustomizationSidebarEntity non_removable_sidebar_entities = 5 [(wix.api.maxSize) = 200];
  // ID of the top-level category where pages of private apps will be added
  google.protobuf.StringValue category_id_for_private_app_pages = 6 [(wix.api.maxLength) = 50];
}


