import {
  ObjectSubTypeDefinition,
  ObjectTypeDefinition,
} from '../../integration/extension.provider';
import {ObjectTypeName} from '../../services/application.service';
import {
  FOLDER_TYPE,
  PUBLIC_OBJECT_NAME,
  REPOSITORY_CATEGORY_TYPE,
  TEMPLATES_OBJECT_NAME,
} from '../../services/object-tree/object-tree.const';
import {
  CALENDAR_ENTRIES_TYPE,
  CALENDAR_ENTRY_TYPE,
  CALENDAR_PAGE_TYPE,
  CALENDAR_TYPE,
} from '../calendar/calendar.const';
import {
  GALLERY_TEXT_PARAGRAPH_TYPE,
  PAGE_WITH_GALLERY_TEXT_PARAGRAPH_TYPE,
  PAGE_WITH_GALLERY_TYPE,
} from '../content-image-template/content-image-template.const';
import {
  DISPLAYED_IMAGE_GALLERY_TYPE,
  IMAGE_GALLERIES_TYPE,
  IMAGE_GALLERY_CONCATENATION_TYPE,
  IMAGE_GALLERY_REFERRER_TYPE,
  IMAGE_GALLERY_TYPE,
} from '../content-image/content-image.const';
import {POST_TYPE, POST_WITH_GALLERY_TYPE} from '../post/post.const';
import {
  HIDDEN_NAME_TYPE,
  OPTIONAL_LABEL_TYPE,
} from '../utils-common/utils-common.const';
import {
  MENU_ENTRY_TYPE,
  PAGE_PARAGRAPH_TYPE,
  PAGE_TYPE,
  PAGE_WITH_SUB_PAGE_TYPE,
  PARAGRAPH_TYPE,
  PARAGRAPH_WITH_PAGE_LINK,
  PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE,
  TEXT_PARAGRAPH_TYPE,
  WEB_SITE_MENU_ENTRIES_TYPE,
  WEB_SITE_VIEW_TYPE,
  WEB_SITE_WITH_LAYOUT_CONFIGURATION_TYPE,
  WEB_SITE_WITH_LAYOUT_TEMPLATE_TYPE,
  WEB_SITE_WITH_MENU_TEMPLATE_TYPE,
  WEB_SITE_WITH_PARAGRAPHS_TEMPLATE_TYPE,
  WELCOME_PAGE_TYPE,
} from '../web-site/web-site.const';
export const ARTIST_WEB_SITE_PROVIDER = 'ArtistWebSiteProvider';
export const ARTIST_WEB_SITE_NAME = 'ArtistWebSiteService';

export const ARTIST_WEB_SITE_TEMPLATE_TYPE = {
  name: 'ArtistWebSiteTemplate',
  inheritedTypesIds: [
    WEB_SITE_WITH_MENU_TEMPLATE_TYPE.name,
    WEB_SITE_WITH_PARAGRAPHS_TEMPLATE_TYPE.name,
    WEB_SITE_WITH_LAYOUT_TEMPLATE_TYPE.name,
  ],
  definition: {
    properties: {},
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSite',
  title: 'Artist web site',
  inheritedTypesIds: [
    WEB_SITE_MENU_ENTRIES_TYPE.name,
    WEB_SITE_VIEW_TYPE.name,
    CALENDAR_ENTRIES_TYPE.name,
    HIDDEN_NAME_TYPE.name,
    WEB_SITE_WITH_LAYOUT_CONFIGURATION_TYPE.name,
  ],
  definition: {
    properties: {
      webSiteObjectTreeId: {
        type: 'string',
        oneOfTree: [
          {
            treeType: ARTIST_WEB_SITE_TEMPLATE_TYPE.name,
            namespaceName: TEMPLATES_OBJECT_NAME,
            namespaceType: ObjectTypeName.REPOSITORY_CATEGORY,
            ownerName: PUBLIC_OBJECT_NAME,
            ownerType: ObjectTypeName.REPOSITORY,
          },
          {
            treeType: 'ArtistWebSiteTemplate',
          },
        ],
      },
    },
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_IMAGE_GALLERIES_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteImageGalleries',
  inheritedTypesIds: [
    IMAGE_GALLERIES_TYPE.name,
    MENU_ENTRY_TYPE.name,
    PAGE_TYPE.name,
    PAGE_WITH_SUB_PAGE_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_IMAGE_GALLERY_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteImageGallery',
  inheritedTypesIds: [
    DISPLAYED_IMAGE_GALLERY_TYPE.name,
    MENU_ENTRY_TYPE.name,
    PAGE_TYPE.name,
    PARAGRAPH_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_IMAGE_GALLERY_CONCATENATION_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteImageGalleryConcatenation',
  inheritedTypesIds: [
    IMAGE_GALLERY_CONCATENATION_TYPE.name,
    PAGE_TYPE.name,
    PARAGRAPH_TYPE.name,
    PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
  definition: {
    properties: {
      selectedGalleriesObjectTreeIds: {
        items: {
          enumOfTree: [
            {
              treeType: ARTIST_WEB_SITE_IMAGE_GALLERY_TYPE.name,
            },
          ],
        },
      },
    },
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_IMAGE_GALLERY_REFERRER_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteImageGalleryReferrer',
  inheritedTypesIds: [IMAGE_GALLERY_REFERRER_TYPE.name, HIDDEN_NAME_TYPE.name],
  definition: {
    properties: {
      imageGalleryObjectTreeId: {
        title: 'Image gallery',
        type: 'string',
        oneOfTree: [
          {
            treeType: ARTIST_WEB_SITE_IMAGE_GALLERY_TYPE.name,
          },
        ],
      },
    },
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_WELCOME_PAGE_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteWelcomePage',
  inheritedTypesIds: [
    WELCOME_PAGE_TYPE.name,
    PAGE_WITH_GALLERY_TYPE.name,
    PAGE_WITH_GALLERY_TEXT_PARAGRAPH_TYPE.name,
    ARTIST_WEB_SITE_IMAGE_GALLERY_REFERRER_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_PARAGRAPH_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteParagraph',
  inheritedTypesIds: [
    GALLERY_TEXT_PARAGRAPH_TYPE.name,
    OPTIONAL_LABEL_TYPE.name,
    PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_POST_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost',
  title: 'Page or paragraph content',
  inheritedTypesIds: [
    MENU_ENTRY_TYPE.name,
    PARAGRAPH_TYPE.name,
    PAGE_PARAGRAPH_TYPE.name,
    PAGE_WITH_SUB_PAGE_TYPE.name,
    POST_TYPE.name,
    PAGE_WITH_GALLERY_TEXT_PARAGRAPH_TYPE.name,
    ARTIST_WEB_SITE_IMAGE_GALLERY_REFERRER_TYPE.name,
    POST_WITH_GALLERY_TYPE.name,
    PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
  definition: {
    properties: {},
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_POST1_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost1',
  inheritedTypesIds: [ARTIST_WEB_SITE_POST_TYPE.name],
};
export const ARTIST_WEB_SITE_POST2_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost2',
  inheritedTypesIds: [ARTIST_WEB_SITE_POST_TYPE.name],
};
export const ARTIST_WEB_SITE_POST3_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost3',
  inheritedTypesIds: [ARTIST_WEB_SITE_POST_TYPE.name],
};

export const ARTIST_WEB_SITE_POST_ROOT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePostRoot',
  title: 'Content pages',
  inheritedTypesIds: [ARTIST_WEB_SITE_POST_TYPE.name, HIDDEN_NAME_TYPE.name],
};

export const ARTIST_WEB_SITE_POST1_ROOT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost1Root',
  title: 'First menu content pages',
  inheritedTypesIds: [
    ARTIST_WEB_SITE_POST_ROOT_TYPE.name,
    ARTIST_WEB_SITE_POST1_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_POST2_ROOT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost2Root',
  title: 'Second menu content pages',
  inheritedTypesIds: [
    ARTIST_WEB_SITE_POST_ROOT_TYPE.name,
    ARTIST_WEB_SITE_POST2_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_POST3_ROOT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePost3Root',
  title: 'Third menu content pages',
  inheritedTypesIds: [
    ARTIST_WEB_SITE_POST_ROOT_TYPE.name,
    ARTIST_WEB_SITE_POST3_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_EVENT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteEvent',
  title: 'Evénement',
  inheritedTypesIds: [
    MENU_ENTRY_TYPE.name,
    PARAGRAPH_TYPE.name,
    CALENDAR_ENTRY_TYPE.name,
    PAGE_WITH_SUB_PAGE_TYPE.name,
    POST_TYPE.name,
    PAGE_WITH_GALLERY_TEXT_PARAGRAPH_TYPE.name,
    ARTIST_WEB_SITE_IMAGE_GALLERY_REFERRER_TYPE.name,
    POST_WITH_GALLERY_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
  definition: {
    properties: {},
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_EVENT_ROOT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteEventRoot',
  title: 'Evénements',
  inheritedTypesIds: [ARTIST_WEB_SITE_EVENT_TYPE.name, HIDDEN_NAME_TYPE.name],
};

export const ARTIST_WEB_SITE_WELCOME_PARAGRAPH_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteWelcomeMenuEntry',
  title: 'Menu card content',
  inheritedTypesIds: [
    GALLERY_TEXT_PARAGRAPH_TYPE.name,
    PARAGRAPH_WITH_PAGE_LINK.name,
    PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE.name,
    ARTIST_WEB_SITE_IMAGE_GALLERY_REFERRER_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_CALENDAR_PAGE_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteCalendarPage',
  inheritedTypesIds: [CALENDAR_PAGE_TYPE.name, HIDDEN_NAME_TYPE.name],
};

export const ARTIST_WEB_SITE_CALENDAR_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteCalendar',
  inheritedTypesIds: [
    CALENDAR_TYPE.name,
    PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE.name,
    HIDDEN_NAME_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_POST_GALLERY_TEXT_PARAGRAPH_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_POST_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_PARAGRAPH_TYPE.name,
  name: GALLERY_TEXT_PARAGRAPH_TYPE.name,
};

export const ARTIST_WEB_SITE_EVENT_GALLERY_TEXT_PARAGRAPH_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_EVENT_TYPE.name,
  subTypeName: GALLERY_TEXT_PARAGRAPH_TYPE.name,
  name: GALLERY_TEXT_PARAGRAPH_TYPE.name,
  max: 0,
};

export const FOLDER_ARTIST_WEB_SITE_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: FOLDER_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_TYPE.name,
  name: ARTIST_WEB_SITE_TYPE.name,
  acl: true,
  namespace: true,
  owner: false,
  tree: true,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_IMAGE_GALLERIES_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_IMAGE_GALLERIES_TYPE.name,
  max: 1,
  min: 1,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_WELCOME_PAGE_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_WELCOME_PAGE_TYPE.name,
  name: WELCOME_PAGE_TYPE.name,
  min: 1,
  max: 1,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_POST1_ROOT_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST1_ROOT_TYPE.name,
  name: ARTIST_WEB_SITE_POST1_ROOT_TYPE.name,
  min: 1,
  max: 1,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_POST2_ROOT_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST2_ROOT_TYPE.name,
  name: ARTIST_WEB_SITE_POST2_ROOT_TYPE.name,
  min: 1,
  max: 1,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_POST3_ROOT_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST3_ROOT_TYPE.name,
  name: ARTIST_WEB_SITE_POST3_ROOT_TYPE.name,
  min: 1,
  max: 1,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_EVENT_ROOT_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_EVENT_ROOT_TYPE.name,
  name: ARTIST_WEB_SITE_EVENT_ROOT_TYPE.name,
  min: 1,
  max: 1,
};

export const ARTIST_WEB_SITE_POST1_ARTIST_WEB_SITE_POST1_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_POST1_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST1_TYPE.name,
};
export const ARTIST_WEB_SITE_POST2_ARTIST_WEB_SITE_POST2_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_POST2_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST2_TYPE.name,
};
export const ARTIST_WEB_SITE_POST3_ARTIST_WEB_SITE_POST3_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_POST3_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST3_TYPE.name,
};

export const ARTIST_WEB_SITE_EVENT_ARTIST_WEB_SITE_EVENT_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_EVENT_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_EVENT_TYPE.name,
};

export const CATEGORY_ARTIST_WEB_SITE_TEMPLATE_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: REPOSITORY_CATEGORY_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_TEMPLATE_TYPE.name,
  tree: true,
};

export const ARTIST_WEB_SITE_WELCOME_PAGE_ARTIST_WEB_SITE_WELCOME_MENU_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_WELCOME_PAGE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_WELCOME_PARAGRAPH_TYPE.name,
};

export const ARTIST_WEB_SITE_WELCOME_PAGE_ARTIST_WEB_SITE_PARAGRAPH_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_WELCOME_PAGE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_PARAGRAPH_TYPE.name,
  name: GALLERY_TEXT_PARAGRAPH_TYPE.name,
};

export const ARTIST_WEB_SITE_WELCOME_MENU_TEXT_PARAGRAPH_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_WELCOME_PAGE_TYPE.name,
  subTypeName: TEXT_PARAGRAPH_TYPE.name,
  max: 0,
};

export const ARTIST_WEB_SITE_IMAGE_GALLERIES_ARTIST_WEB_SITE_IMAGE_GALLERY_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_IMAGE_GALLERIES_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_IMAGE_GALLERY_TYPE.name,
  name: IMAGE_GALLERY_TYPE.name,
  tree: true,
};

export const ARTIST_WEB_SITE_IMAGE_GALLERIES_ARTIST_WEB_SITE_IMAGE_GALLERY_CONCATENATION_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_IMAGE_GALLERIES_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_IMAGE_GALLERY_CONCATENATION_TYPE.name,
  name: IMAGE_GALLERY_CONCATENATION_TYPE.name,
  tree: true,
};

export const ARTIST_WEB_SITE_ARTIST_WEB_SITE_CALENDAR_PAGE_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_CALENDAR_PAGE_TYPE.name,
  name: CALENDAR_PAGE_TYPE.name,
  min: 1,
  max: 1,
};
export const ARTIST_WEB_SITE_CALENDAR_PAGE_ARTIST_WEB_SITE_CALENDAR_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_CALENDAR_PAGE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_CALENDAR_TYPE.name,
  name: CALENDAR_TYPE.name,
  min: 1,
  max: 1,
};
