import { GraphQLBoolean, GraphQLFloat, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLString } from 'graphql';

import { createModuleNameFromMetaUrl } from '../../../_helpers/common';

export const PAYLOAD_NAME = createModuleNameFromMetaUrl(import.meta.url);

export default new GraphQLInputObjectType({
  name: PAYLOAD_NAME,
  fields: {
    id: {
      type: GraphQLString,
    },
    name: {
      type: GraphQLString,
    },
    salesforceId: {
      type: GraphQLString,
    },
    type: {
      type: GraphQLString,
    },
    accountManager: {
      type: GraphQLString,
    },
    accountManagerEmail: {
      type: GraphQLString,
    },
    publisherDemand: {
      type: GraphQLBoolean,
    },
    adServingFeeBusinessModel: {
      type: GraphQLString,
    },
    adServingFeeDisplay: {
      type: GraphQLFloat,
    },
    adServingFeeVideo: {
      type: GraphQLFloat,
    },
    salesManager: {
      type: GraphQLString,
    },
    customLogoUrl: {
      type: GraphQLString,
    },
    avatarUrl: {
      type: GraphQLString,
    },
    avatar: {
      type: new GraphQLInputObjectType({
        name: `${PAYLOAD_NAME}accountsAvatar`,
        fields: {
          base64Url: {
            type: GraphQLString,
          },
          mimeType: {
            type: GraphQLString,
          },
        },
      }),
    },
    customLoadingMessage: {
      type: GraphQLString,
    },
    customLoginPageUrl: {
      type: GraphQLString,
    },
    subdomain: {
      type: GraphQLString,
    },
    publisherRevShare: {
      type: GraphQLInt,
    },
    expenses: {
      type: GraphQLInt,
    },
    usersLimit: {
      type: GraphQLInt,
    },
    videoDuplicatesBy: {
      type: GraphQLString,
    },
    accountsFeatures: {
      type: new GraphQLList(
        new GraphQLInputObjectType({
          name: `${PAYLOAD_NAME}accountsFeatures`,
          fields: {
            id: {
              type: GraphQLInt,
            },
            value: {
              type: GraphQLBoolean,
            },
          },
        }),
      ),
    },
    accountDashboards: {
      type: new GraphQLInputObjectType({
        name: `${PAYLOAD_NAME}accountDashboards`,
        fields: {
          general: {
            type: new GraphQLList(
              new GraphQLInputObjectType({
                name: `${PAYLOAD_NAME}accountDashboardsGeneral`,
                fields: {
                  id: {
                    type: GraphQLInt,
                  },
                  uiName: {
                    type: GraphQLString,
                  },
                  enabled: {
                    type: GraphQLBoolean,
                  },
                  order: {
                    type: GraphQLInt,
                  },
                  tooltip: {
                    type: new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}accountDashboardsGeneralTooltip`,
                      fields: {
                        info: {
                          type: GraphQLString,
                        },
                        link: {
                          type: GraphQLString,
                        },
                        linkTitle: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  },
                },
              }),
            ),
          },
          custom: {
            type: new GraphQLList(
              new GraphQLInputObjectType({
                name: `${PAYLOAD_NAME}accountDashboardsCustom`,
                fields: {
                  id: {
                    type: GraphQLInt,
                  },
                  uiName: {
                    type: GraphQLString,
                  },
                  enabled: {
                    type: GraphQLBoolean,
                  },
                  order: {
                    type: GraphQLInt,
                  },
                  lookerReportId: {
                    type: GraphQLString,
                  },
                  icon: {
                    type: GraphQLString,
                  },
                  tooltip: {
                    type: new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}accountDashboardsCustomTooltip`,
                      fields: {
                        info: {
                          type: GraphQLString,
                        },
                        link: {
                          type: GraphQLString,
                        },
                        linkTitle: {
                          type: GraphQLString,
                        },
                      },
                    }),
                  },
                  publisherCustomAnalytics: {
                    type: new GraphQLInputObjectType({
                      name: `${PAYLOAD_NAME}accountDashboardsCustomPublisherCustomAnalytics`,
                      fields: {
                        accountId: {
                          type: GraphQLInt,
                        },
                        action: {
                          type: GraphQLString,
                        },
                        analyticsId: {
                          type: GraphQLInt,
                        },
                        id: {
                          type: GraphQLInt,
                        },
                        publisherId: {
                          type: GraphQLInt,
                        },
                        publisherIds: {
                          type: new GraphQLList(GraphQLInt),
                        },
                      },
                    }),
                  },
                },
              }),
            ),
          },
        },
      }),
    },
  },
});
