import {HIDDEN_NAME_TYPE} from '../utils-common/utils-common.const';
import {
  ObjectSubTypeDefinition,
  ObjectTypeDefinition,
} from './../../integration/extension.provider';

export const CONTENT_GENERIC_PROVIDER = 'ContentGenericProvider';
export const CONTENT_GENERIC_TEMPLATE = 'ContentGenericTemplate';

export const TEMPLATE_CONFIGURATION_HOLDER_TYPE: ObjectTypeDefinition = {
  name: 'TemplateConfigurationHolder',
};

export const TEMPLATE_VIEW_TYPE: ObjectTypeDefinition = {
  name: 'TemplateView',
  inheritedTypesIds: [TEMPLATE_CONFIGURATION_HOLDER_TYPE.name],
  contentType: 'ContentGenericTemplate',
  definition: {
    properties: {},
  },
  iconView: 'far fa-file-code',
};

export const TEMPLATE_REFERRER_TYPE: ObjectTypeDefinition = {
  name: 'TemplateReferrerType',
};

export const TEMPLATE_CONFIGURATION_TYPE: ObjectTypeDefinition = {
  name: 'TemplateConfiguration',
  inheritedTypesIds: [HIDDEN_NAME_TYPE.name, TEMPLATE_REFERRER_TYPE.name],
  definition: {
    properties: {
      templateObjectTreeId: {
        type: 'string',
        title: 'Template configured',
        default: '',
        required: true,
        oneOfTree: [
          {
            treeType: TEMPLATE_VIEW_TYPE.name,
          },
        ],
      },
      configuration: {
        type: 'object',
        title: 'Template configuration',
        properties: {},
      },
    },
  },
};

export const TEMPLATE_EMBEDDED_CONFIGURATION_TYPE: ObjectTypeDefinition = {
  name: 'TemplateEmbeddedConfiguration',
  title: 'configuration',
  inheritedTypesIds: [TEMPLATE_CONFIGURATION_TYPE.name],
  definition: {
    properties: {
      templateObjectTreeId: {
        required: false,
        'x-schema-form': {
          condition: 'false',
        },
      },
    },
  },
};

export const TEMPLATE_CONFIGURATION_HOLDER_TEMPLATE_CONFIGURATION_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: TEMPLATE_CONFIGURATION_HOLDER_TYPE.name,
  subTypeName: TEMPLATE_CONFIGURATION_TYPE.name,
  tree: true,
  max: 0,
};

export const TEMPLATE_VIEW_TEMPLATE_EMBEDDED_CONFIGURATION_SUBTYPE: ObjectSubTypeDefinition = {
  typeName: TEMPLATE_VIEW_TYPE.name,
  subTypeName: TEMPLATE_EMBEDDED_CONFIGURATION_TYPE.name,
  name: TEMPLATE_CONFIGURATION_TYPE.name,
  tree: true,
  max: 0,
};
