import {
  ObjectSubTypeDefinition,
  ObjectTypeDefinition,
} from '../../integration/extension.provider';
import {ObjectTypeName} from '../../services/application.service';
import {
  FOLDER_TYPE,
  REPOSITORY_CATEGORY_TYPE,
} from '../../services/object-tree/object-tree.const';
import {
  CALENDAR_ENTRIES_TYPE,
  CALENDAR_ENTRY_TYPE,
  CALENDAR_PAGE_TYPE,
  CALENDAR_TYPE,
} from '../calendar/calendar.const';
import {PAGE_WITH_GALLERY_TEXT_PARAGRAPH_TYPE} from '../content-image-template/content-image-template.const';
import {POST_TYPE, POST_WITH_GALLERY_TYPE} from '../post/post.const';
import {
  MENU_ENTRY_TYPE,
  OPTIONAL_LABEL_TYPE,
  PAGE_TYPE,
  PARAGRAPH_TYPE,
  PARAGRAPH_WITH_PAGE_LINK,
  TEXT_PARAGRAPH_TYPE,
  WEB_SITE_MENU_ENTRIES_TYPE,
  WEB_SITE_VIEW_TYPE,
  WEB_SITE_WITH_MENU_TEMPLATE_TYPE,
  WEB_SITE_WITH_PARAGRAPHS_TEMPLATE_TYPE,
  WELCOME_PAGE_TYPE,
} from '../web-site/web-site.const';
import {
  PUBLIC_OBJECT_NAME,
  TEMPLATES_OBJECT_NAME,
} from './../../services/object-tree/object-tree.const';
import {
  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 {MAP_ENTRY_TYPE} from './../map/map.const';
import {
  PAGE_WITH_SUB_PAGE_TYPE,
  PARAGRAPH_WITH_TEMPLATE_CHOICE_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,
  ],
  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,
    OPTIONAL_LABEL_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',
          },
        ],
      },
      style: {
        type: 'object',
        title: 'Layout',
        properties: {
          color: {
            type: 'string',
            title: 'Text color',
          },
          backgroundColor: {
            type: 'string',
            title: 'Background color',
          },
        },
      },
    },
  },
  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,
    OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_TYPE.name,
  ],
};

export const ARTIST_WEB_SITE_PARAGRAPH_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSiteParagraph',
  inheritedTypesIds: [
    GALLERY_TEXT_PARAGRAPH_TYPE.name,
    OPTIONAL_LABEL_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,
    CALENDAR_ENTRY_TYPE.name,
    MAP_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,
    PARAGRAPH_WITH_TEMPLATE_CHOICE_TYPE.name,
    OPTIONAL_LABEL_TYPE.name,
  ],
  definition: {
    properties: {},
  },
  contentType: '',
};

export const ARTIST_WEB_SITE_POST_ROOT_TYPE: ObjectTypeDefinition = {
  name: 'ArtistWebSitePostRoot',
  title: 'Content pages',
  inheritedTypesIds: [ARTIST_WEB_SITE_POST_TYPE.name, OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_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,
    OPTIONAL_LABEL_TYPE.name,
  ],
};

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

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

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

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_POST_ROOT_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST_ROOT_TYPE.name,
  name: ARTIST_WEB_SITE_POST_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_POST_ARTIST_WEB_SITE_POST_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: ARTIST_WEB_SITE_POST_TYPE.name,
  subTypeName: ARTIST_WEB_SITE_POST_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,
};
