import type { INodeTypeDescription } from 'n8n-workflow';

export const nodeTypeTwitterV1 = {
	displayName: 'X (Formerly Twitter)',
	name: 'n8n-nodes-base.twitter',
	group: ['output'],
	subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
	description: 'Consume Twitter API',
	defaultVersion: 2,
	version: 1,
	defaults: { name: 'Twitter' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [{ name: 'twitterOAuth1Api', required: true }],
	properties: [
		{
			displayName: 'Resource',
			name: 'resource',
			type: 'options',
			noDataExpression: true,
			options: [
				{ name: 'Direct Message', value: 'directMessage' },
				{ name: 'Tweet', value: 'tweet' },
			],
			default: 'tweet',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['directMessage'] } },
			options: [
				{
					name: 'Create',
					value: 'create',
					description: 'Create a direct message',
					action: 'Create a direct message',
				},
			],
			default: 'create',
		},
		{
			displayName: 'User ID',
			name: 'userId',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['create'], resource: ['directMessage'] } },
			description: 'The ID of the user who should receive the direct message',
		},
		{
			displayName: 'Text',
			name: 'text',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['create'], resource: ['directMessage'] } },
			description:
				'The text of your Direct Message. URL encode as necessary. Max length of 10,000 characters.',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['create'], resource: ['directMessage'] } },
			options: [
				{
					displayName: 'Attachment',
					name: 'attachment',
					type: 'string',
					default: 'data',
					description:
						'Name of the binary property which contain data that should be added to the direct message as attachment',
				},
			],
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['tweet'] } },
			options: [
				{
					name: 'Create',
					value: 'create',
					description: 'Create or reply a tweet',
					action: 'Create a tweet',
				},
				{
					name: 'Delete',
					value: 'delete',
					description: 'Delete a tweet',
					action: 'Delete a tweet',
				},
				{ name: 'Like', value: 'like', description: 'Like a tweet', action: 'Like a tweet' },
				{
					name: 'Retweet',
					value: 'retweet',
					description: 'Retweet a tweet',
					action: 'Retweet a tweet',
				},
				{
					name: 'Search',
					value: 'search',
					description: 'Search tweets',
					action: 'Search for tweets',
				},
			],
			default: 'create',
		},
		{
			displayName: 'Text',
			name: 'text',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['create'], resource: ['tweet'] } },
			description:
				'The text of the status update. URL encode as necessary. t.co link wrapping will affect character counts.',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['create'], resource: ['tweet'] } },
			options: [
				{
					displayName: 'Attachments',
					name: 'attachments',
					type: 'string',
					default: 'data',
					description:
						'Name of the binary properties which contain data which should be added to tweet as attachment. Multiple ones can be comma-separated.',
				},
				{
					displayName: 'Display Coordinates',
					name: 'displayCoordinates',
					type: 'boolean',
					default: false,
					description:
						'Whether or not to put a pin on the exact coordinates a Tweet has been sent from',
				},
				{
					displayName: 'In Reply to Tweet',
					name: 'inReplyToStatusId',
					type: 'string',
					default: '',
					description: 'The ID of an existing status that the update is in reply to',
				},
				{
					displayName: 'Location',
					name: 'locationFieldsUi',
					type: 'fixedCollection',
					placeholder: 'Add Location',
					default: {},
					description: 'Subscriber location information.n',
					options: [
						{
							name: 'locationFieldsValues',
							displayName: 'Location',
							values: [
								{
									displayName: 'Latitude',
									name: 'latitude',
									type: 'string',
									required: true,
									description: 'The location latitude',
									default: '',
								},
								{
									displayName: 'Longitude',
									name: 'longitude',
									type: 'string',
									required: true,
									description: 'The location longitude',
									default: '',
								},
							],
						},
					],
				},
				{
					displayName: 'Possibly Sensitive',
					name: 'possiblySensitive',
					type: 'boolean',
					default: false,
					description:
						'Whether you are uploading Tweet media that might be considered sensitive content such as nudity, or medical procedures',
				},
			],
		},
		{
			displayName: 'Tweet ID',
			name: 'tweetId',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['delete'], resource: ['tweet'] } },
			description: 'The ID of the tweet to delete',
		},
		{
			displayName: 'Search Text',
			name: 'searchText',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['search'], resource: ['tweet'] } },
			description:
				'A UTF-8, URL-encoded search query of 500 characters maximum, including operators. Queries may additionally be limited by complexity. Check the searching examples <a href="https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators">here</a>.',
		},
		{
			displayName: 'Return All',
			name: 'returnAll',
			type: 'boolean',
			displayOptions: { show: { operation: ['search'], resource: ['tweet'] } },
			default: false,
			description: 'Whether to return all results or only up to a given limit',
		},
		{
			displayName: 'Limit',
			name: 'limit',
			type: 'number',
			displayOptions: {
				show: { operation: ['search'], resource: ['tweet'], returnAll: [false] },
			},
			typeOptions: { minValue: 1 },
			default: 50,
			description: 'Max number of results to return',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['search'], resource: ['tweet'] } },
			options: [
				{
					displayName: 'Include Entities',
					name: 'includeEntities',
					type: 'boolean',
					default: false,
					description: 'Whether the entities node will be included',
				},
				{
					displayName: 'Language Name or ID',
					name: 'lang',
					type: 'options',
					typeOptions: { loadOptionsMethod: 'getLanguages' },
					default: '',
					description:
						'Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
				},
				{
					displayName: 'Location',
					name: 'locationFieldsUi',
					type: 'fixedCollection',
					placeholder: 'Add Location',
					default: {},
					description: 'Subscriber location information.n',
					options: [
						{
							name: 'locationFieldsValues',
							displayName: 'Location',
							values: [
								{
									displayName: 'Latitude',
									name: 'latitude',
									type: 'string',
									required: true,
									description: 'The location latitude',
									default: '',
								},
								{
									displayName: 'Longitude',
									name: 'longitude',
									type: 'string',
									required: true,
									description: 'The location longitude',
									default: '',
								},
								{
									displayName: 'Radius',
									name: 'radius',
									type: 'options',
									options: [
										{ name: 'Milles', value: 'mi' },
										{ name: 'Kilometers', value: 'km' },
									],
									required: true,
									description:
										'Returns tweets by users located within a given radius of the given latitude/longitude',
									default: '',
								},
								{
									displayName: 'Distance',
									name: 'distance',
									type: 'number',
									typeOptions: { minValue: 0 },
									required: true,
									default: '',
								},
							],
						},
					],
				},
				{
					displayName: 'Result Type',
					name: 'resultType',
					type: 'options',
					options: [
						{
							name: 'Mixed',
							value: 'mixed',
							description: 'Include both popular and real time results in the response',
						},
						{
							name: 'Recent',
							value: 'recent',
							description: 'Return only the most recent results in the response',
						},
						{
							name: 'Popular',
							value: 'popular',
							description: 'Return only the most popular results in the response',
						},
					],
					default: 'mixed',
					description: 'Specifies what type of search results you would prefer to receive',
				},
				{
					displayName: 'Tweet Mode',
					name: 'tweetMode',
					type: 'options',
					options: [
						{ name: 'Compatibility', value: 'compat' },
						{ name: 'Extended', value: 'extended' },
					],
					default: 'compat',
					description:
						'When the extended mode is selected, the response contains the entire untruncated text of the Tweet',
				},
				{
					displayName: 'Until',
					name: 'until',
					type: 'dateTime',
					default: '',
					description: 'Returns tweets created before the given date',
				},
			],
		},
		{
			displayName: 'Tweet ID',
			name: 'tweetId',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['like'], resource: ['tweet'] } },
			description: 'The ID of the tweet',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['like'], resource: ['tweet'] } },
			options: [
				{
					displayName: 'Include Entities',
					name: 'includeEntities',
					type: 'boolean',
					default: false,
					description: 'Whether the entities will be omitted',
				},
			],
		},
		{
			displayName: 'Tweet ID',
			name: 'tweetId',
			type: 'string',
			required: true,
			default: '',
			displayOptions: { show: { operation: ['retweet'], resource: ['tweet'] } },
			description: 'The ID of the tweet',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['retweet'], resource: ['tweet'] } },
			options: [
				{
					displayName: 'Trim User',
					name: 'trimUser',
					type: 'boolean',
					default: false,
					description:
						'Whether each tweet returned in a timeline will include a user object including only the status authors numerical ID',
				},
			],
		},
	],
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Twitter/x.svg',
	codex: {
		categories: ['Marketing'],
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.twitter/' },
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/twitter' }],
		},
		alias: ['Tweet', 'Twitter', 'X', 'X API'],
	},
} satisfies INodeTypeDescription;

export const nodeTypeTwitterV2 = {
	displayName: 'X (Formerly Twitter)',
	name: 'n8n-nodes-base.twitter',
	group: ['output'],
	subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
	description: 'Post, like, and search tweets, send messages, search users, and add users to lists',
	defaultVersion: 2,
	version: 2,
	defaults: { name: 'X' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [{ name: 'twitterOAuth2Api', required: true }],
	properties: [
		{
			displayName: 'Resource',
			name: 'resource',
			type: 'options',
			noDataExpression: true,
			options: [
				{
					name: 'Direct Message',
					value: 'directMessage',
					description: 'Send a direct message to a user',
				},
				{ name: 'List', value: 'list', description: 'Add a user to a list' },
				{ name: 'Tweet', value: 'tweet', description: 'Create, like, search, or delete a tweet' },
				{ name: 'User', value: 'user', description: 'Search users by username' },
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'tweet',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['directMessage'] } },
			options: [
				{
					name: 'Create',
					value: 'create',
					description: 'Send a direct message to a user',
					action: 'Create Direct Message',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'create',
		},
		{
			displayName: 'User',
			name: 'user',
			type: 'resourceLocator',
			default: { mode: 'username', value: '' },
			required: true,
			description: 'The user you want to send the message to',
			displayOptions: { show: { operation: ['create'], resource: ['directMessage'] } },
			modes: [
				{
					displayName: 'By Username',
					name: 'username',
					type: 'string',
					validation: [],
					placeholder: 'e.g. n8n',
					url: '',
				},
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 1068479892537384960',
					url: '',
				},
			],
		},
		{
			displayName: 'Text',
			name: 'text',
			type: 'string',
			required: true,
			default: '',
			typeOptions: { rows: 2 },
			displayOptions: { show: { operation: ['create'], resource: ['directMessage'] } },
			description:
				'The text of the direct message. URL encoding is required. Max length of 10,000 characters.',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['create'], resource: ['directMessage'] } },
			options: [
				{
					displayName: 'Attachment ID',
					name: 'attachments',
					type: 'string',
					default: '',
					placeholder: '1664279886239010824',
					description: 'The attachment ID to associate with the message',
				},
			],
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['list'] } },
			options: [
				{
					name: 'Add Member',
					value: 'add',
					description: 'Add a member to a list',
					action: 'Add Member to List',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'add',
		},
		{
			displayName: 'List',
			name: 'list',
			type: 'resourceLocator',
			default: { mode: 'id', value: '' },
			required: true,
			description: 'The list you want to add the user to',
			displayOptions: { show: { operation: ['add'], resource: ['list'] } },
			modes: [
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 99923132',
					url: '',
				},
				{
					displayName: 'By URL',
					name: 'url',
					type: 'string',
					validation: [],
					placeholder: 'e.g. https://twitter.com/i/lists/99923132',
					url: '',
				},
			],
		},
		{
			displayName: 'User',
			name: 'user',
			type: 'resourceLocator',
			default: { mode: 'username', value: '' },
			required: true,
			description: 'The user you want to add to the list',
			displayOptions: { show: { operation: ['add'], resource: ['list'] } },
			modes: [
				{
					displayName: 'By Username',
					name: 'username',
					type: 'string',
					validation: [],
					placeholder: 'e.g. n8n',
					url: '',
				},
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 1068479892537384960',
					url: '',
				},
			],
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['tweet'] } },
			options: [
				{
					name: 'Create',
					value: 'create',
					description: 'Create, quote, or reply to a tweet',
					action: 'Create Tweet',
				},
				{
					name: 'Delete',
					value: 'delete',
					description: 'Delete a tweet',
					action: 'Delete Tweet',
				},
				{ name: 'Like', value: 'like', description: 'Like a tweet', action: 'Like Tweet' },
				{
					name: 'Retweet',
					value: 'retweet',
					description: 'Retweet a tweet',
					action: 'Retweet Tweet',
				},
				{
					name: 'Search',
					value: 'search',
					description: 'Search for tweets from the last seven days',
					action: 'Search Tweets',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'create',
		},
		{
			displayName: 'Text',
			name: 'text',
			type: 'string',
			typeOptions: { rows: 2 },
			default: '',
			required: true,
			displayOptions: { show: { operation: ['create'], resource: ['tweet'] } },
			description:
				'The text of the status update. URLs must be encoded. Links wrapped with the t.co shortener will affect character count',
		},
		{
			displayName: 'Options',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['create'], resource: ['tweet'] } },
			options: [
				{
					displayName: 'Location ID',
					name: 'location',
					type: 'string',
					placeholder: '4e696bef7e24d378',
					default: '',
					description: 'Location information for the tweet',
				},
				{
					displayName: 'Media ID',
					name: 'attachments',
					type: 'string',
					default: '',
					placeholder: '1664279886239010824',
					description: 'The attachment ID to associate with the message',
				},
				{
					displayName: 'Quote a Tweet',
					name: 'inQuoteToStatusId',
					type: 'resourceLocator',
					default: { mode: 'id', value: '' },
					description: 'The tweet being quoted',
					modes: [
						{
							displayName: 'By ID',
							name: 'id',
							type: 'string',
							validation: [],
							placeholder: 'e.g. 1187836157394112513',
							url: '',
						},
						{
							displayName: 'By URL',
							name: 'url',
							type: 'string',
							validation: [],
							placeholder: 'e.g. https://twitter.com/n8n_io/status/1187836157394112513',
							url: '',
						},
					],
				},
				{
					displayName: 'Reply to Tweet',
					name: 'inReplyToStatusId',
					type: 'resourceLocator',
					default: { mode: 'id', value: '' },
					description: 'The tweet being replied to',
					modes: [
						{
							displayName: 'By ID',
							name: 'id',
							type: 'string',
							validation: [],
							placeholder: 'e.g. 1187836157394112513',
							url: '',
						},
						{
							displayName: 'By URL',
							name: 'url',
							type: 'string',
							validation: [],
							placeholder: 'e.g. https://twitter.com/n8n_io/status/1187836157394112513',
							url: '',
						},
					],
				},
			],
		},
		{
			displayName: 'Locations are not supported due to Twitter V2 API limitations',
			name: 'noticeLocation',
			type: 'notice',
			displayOptions: { show: { '/additionalFields.location': [''] } },
			default: '',
		},
		{
			displayName: 'Attachements are not supported due to Twitter V2 API limitations',
			name: 'noticeAttachments',
			type: 'notice',
			displayOptions: { show: { '/additionalFields.attachments': [''] } },
			default: '',
		},
		{
			displayName: 'Tweet',
			name: 'tweetDeleteId',
			type: 'resourceLocator',
			default: { mode: 'id', value: '' },
			required: true,
			description: 'The tweet to delete',
			displayOptions: { show: { resource: ['tweet'], operation: ['delete'] } },
			modes: [
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 1187836157394112513',
					url: '',
				},
				{
					displayName: 'By URL',
					name: 'url',
					type: 'string',
					validation: [],
					placeholder: 'e.g. https://twitter.com/n8n_io/status/1187836157394112513',
					url: '',
				},
			],
		},
		{
			displayName: 'Tweet',
			name: 'tweetId',
			type: 'resourceLocator',
			default: { mode: 'id', value: '' },
			required: true,
			description: 'The tweet to like',
			displayOptions: { show: { operation: ['like'], resource: ['tweet'] } },
			modes: [
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 1187836157394112513',
					url: '',
				},
				{
					displayName: 'By URL',
					name: 'url',
					type: 'string',
					validation: [],
					placeholder: 'e.g. https://twitter.com/n8n_io/status/1187836157394112513',
					url: '',
				},
			],
		},
		{
			displayName: 'Search Term',
			name: 'searchText',
			type: 'string',
			required: true,
			default: '',
			placeholder: 'e.g. automation',
			displayOptions: { show: { operation: ['search'], resource: ['tweet'] } },
			description:
				'A UTF-8, URL-encoded search query of 500 characters maximum, including operators. Queries may additionally be limited by complexity. Check the searching examples <a href="https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators">here</a>.',
		},
		{
			displayName: 'Return All',
			name: 'returnAll',
			type: 'boolean',
			default: false,
			description: 'Whether to return all results or only up to a given limit',
			displayOptions: { show: { resource: ['tweet'], operation: ['search'] } },
		},
		{
			displayName: 'Limit',
			name: 'limit',
			type: 'number',
			default: 50,
			description: 'Max number of results to return',
			typeOptions: { minValue: 1 },
			displayOptions: {
				show: { resource: ['tweet'], operation: ['search'], returnAll: [false] },
			},
		},
		{
			displayName: 'Options',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { operation: ['search'], resource: ['tweet'] } },
			options: [
				{
					displayName: 'Sort Order',
					name: 'sortOrder',
					type: 'options',
					options: [
						{ name: 'Recent', value: 'recency' },
						{ name: 'Relevant', value: 'relevancy' },
					],
					description: 'The order in which to return results',
					default: 'recency',
				},
				{
					displayName: 'After',
					name: 'startTime',
					type: 'dateTime',
					default: '',
					description:
						"Tweets before this date will not be returned. This date must be within the last 7 days if you don't have Academic Research access.",
				},
				{
					displayName: 'Before',
					name: 'endTime',
					type: 'dateTime',
					default: '',
					description:
						"Tweets after this date will not be returned. This date must be within the last 7 days if you don't have Academic Research access.",
				},
				{
					displayName: 'Tweet Fields',
					name: 'tweetFieldsObject',
					type: 'multiOptions',
					options: [
						{ name: 'Attachments', value: 'attachments' },
						{ name: 'Author ID', value: 'author_id' },
						{ name: 'Context Annotations', value: 'context_annotations' },
						{ name: 'Conversation ID', value: 'conversation_id' },
						{ name: 'Created At', value: 'created_at' },
						{ name: 'Edit Controls', value: 'edit_controls' },
						{ name: 'Entities', value: 'entities' },
						{ name: 'Geo', value: 'geo' },
						{ name: 'ID', value: 'id' },
						{ name: 'In Reply To User ID', value: 'in_reply_to_user_id' },
						{ name: 'Lang', value: 'lang' },
						{ name: 'Non Public Metrics', value: 'non_public_metrics' },
						{ name: 'Public Metrics', value: 'public_metrics' },
						{ name: 'Organic Metrics', value: 'organic_metrics' },
						{ name: 'Promoted Metrics', value: 'promoted_metrics' },
						{ name: 'Possibly Sensitive', value: 'possibly_sensitive' },
						{ name: 'Referenced Tweets', value: 'referenced_tweets' },
						{ name: 'Reply Settings', value: 'reply_settings' },
						{ name: 'Source', value: 'source' },
						{ name: 'Text', value: 'text' },
						{ name: 'Withheld', value: 'withheld' },
					],
					default: [],
					description:
						'The fields to add to each returned tweet object. Default fields are: ID, text, edit_history_tweet_ids.',
				},
			],
		},
		{
			displayName: 'Tweet',
			name: 'tweetId',
			type: 'resourceLocator',
			default: { mode: 'id', value: '' },
			required: true,
			description: 'The tweet to retweet',
			displayOptions: { show: { operation: ['retweet'], resource: ['tweet'] } },
			modes: [
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 1187836157394112513',
					url: '',
				},
				{
					displayName: 'By URL',
					name: 'url',
					type: 'string',
					validation: [],
					placeholder: 'e.g. https://twitter.com/n8n_io/status/1187836157394112513',
					url: '',
				},
			],
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['user'] } },
			options: [
				{
					name: 'Get',
					value: 'searchUser',
					description: 'Retrieve a user by username',
					action: 'Get User',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'searchUser',
		},
		{
			displayName: 'User',
			name: 'user',
			type: 'resourceLocator',
			default: { mode: 'username', value: '' },
			required: true,
			description: 'The user you want to search',
			displayOptions: {
				show: { operation: ['searchUser'], resource: ['user'] },
				hide: { me: [true] },
			},
			modes: [
				{
					displayName: 'By Username',
					name: 'username',
					type: 'string',
					validation: [],
					placeholder: 'e.g. n8n',
					url: '',
				},
				{
					displayName: 'By ID',
					name: 'id',
					type: 'string',
					validation: [],
					placeholder: 'e.g. 1068479892537384960',
					url: '',
				},
			],
		},
		{
			displayName: 'Me',
			name: 'me',
			type: 'boolean',
			displayOptions: { show: { operation: ['searchUser'], resource: ['user'] } },
			default: false,
			description: 'Whether you want to search the authenticated user',
		},
	],
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Twitter/x.svg',
	codex: {
		categories: ['Marketing'],
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.twitter/' },
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/twitter' }],
		},
		alias: ['Tweet', 'Twitter', 'X', 'X API'],
	},
} satisfies INodeTypeDescription;

export const nodeTypeReadImapV1 = {
	displayName: 'Email Trigger (IMAP)',
	name: 'n8n-nodes-base.emailReadImap',
	icon: 'fa:inbox',
	group: ['trigger'],
	description: 'Triggers the workflow when a new email is received',
	defaultVersion: 2,
	version: 1,
	eventTriggerDescription: 'Waiting for you to receive an email',
	defaults: { name: 'Email Trigger (IMAP)', color: '#44AA22' },
	triggerPanel: {
		header: '',
		executionsHelp: {
			inactive:
				"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Once you're happy with your workflow</b>, <a data-key='activate'>activate</a> it. Then every time an email is received, the workflow will execute. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.",
			active:
				"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Your workflow will also execute automatically</b>, since it's activated. Every time an email is received, this node will trigger an execution. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.",
		},
		activationHint:
			"Once you’ve finished building your workflow, <a data-key='activate'>activate</a> it to have it also listen continuously (you just won’t see those executions here).",
	},
	inputs: [],
	outputs: ['main'],
	credentials: [{ name: 'imap', required: true, testedBy: 'imapConnectionTest' }],
	properties: [
		{ displayName: 'Mailbox Name', name: 'mailbox', type: 'string', default: 'INBOX' },
		{
			displayName: 'Action',
			name: 'postProcessAction',
			type: 'options',
			options: [
				{ name: 'Mark as Read', value: 'read' },
				{ name: 'Nothing', value: 'nothing' },
			],
			default: 'read',
			description:
				'What to do after the email has been received. If "nothing" gets selected it will be processed multiple times.',
		},
		{
			displayName: 'Download Attachments',
			name: 'downloadAttachments',
			type: 'boolean',
			default: false,
			displayOptions: { show: { format: ['simple'] } },
			description:
				'Whether attachments of emails should be downloaded. Only set if needed as it increases processing.',
		},
		{
			displayName: 'Format',
			name: 'format',
			type: 'options',
			options: [
				{
					name: 'RAW',
					value: 'raw',
					description:
						'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used',
				},
				{
					name: 'Resolved',
					value: 'resolved',
					description:
						'Returns the full email with all data resolved and attachments saved as binary data',
				},
				{
					name: 'Simple',
					value: 'simple',
					description:
						'Returns the full email; do not use if you wish to gather inline attachments',
				},
			],
			default: 'simple',
			description: 'The format to return the message in',
		},
		{
			displayName: 'Property Prefix Name',
			name: 'dataPropertyAttachmentsPrefixName',
			type: 'string',
			default: 'attachment_',
			displayOptions: { show: { format: ['resolved'] } },
			description:
				'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"',
		},
		{
			displayName: 'Property Prefix Name',
			name: 'dataPropertyAttachmentsPrefixName',
			type: 'string',
			default: 'attachment_',
			displayOptions: { show: { format: ['simple'], downloadAttachments: [true] } },
			description:
				'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			options: [
				{
					displayName: 'Custom Email Rules',
					name: 'customEmailConfig',
					type: 'string',
					default: '["UNSEEN"]',
					description:
						'Custom email fetching rules. See <a href="https://github.com/mscdex/node-imap">node-imap</a>\'s search function for more details.',
				},
				{
					displayName: 'Ignore SSL Issues',
					name: 'allowUnauthorizedCerts',
					type: 'boolean',
					default: false,
					description: 'Whether to connect even if SSL certificate validation is not possible',
				},
				{
					displayName: 'Force Reconnect',
					name: 'forceReconnect',
					type: 'number',
					default: 60,
					description: 'Sets an interval (in minutes) to force a reconnection',
				},
			],
		},
	],
	codex: {
		categories: ['Communication', 'Core Nodes'],
		subcategories: { 'Core Nodes': ['Other Trigger Nodes'] },
		resources: {
			primaryDocumentation: [
				{
					url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.emailimap/',
				},
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/imap' }],
		},
	},
} satisfies INodeTypeDescription;

export const nodeTypeReadImapV2 = {
	displayName: 'Email Trigger (IMAP)',
	name: 'n8n-nodes-base.emailReadImap',
	icon: 'fa:inbox',
	group: ['trigger'],
	description: 'Triggers the workflow when a new email is received',
	defaultVersion: 2,
	version: 2,
	eventTriggerDescription: 'Waiting for you to receive an email',
	defaults: { name: 'Email Trigger (IMAP)', color: '#44AA22' },
	triggerPanel: {
		header: '',
		executionsHelp: {
			inactive:
				"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Once you're happy with your workflow</b>, <a data-key='activate'>activate</a> it. Then every time an email is received, the workflow will execute. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.",
			active:
				"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Your workflow will also execute automatically</b>, since it's activated. Every time an email is received, this node will trigger an execution. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.",
		},
		activationHint:
			"Once you’ve finished building your workflow, <a data-key='activate'>activate</a> it to have it also listen continuously (you just won’t see those executions here).",
	},
	inputs: [],
	outputs: ['main'],
	credentials: [{ name: 'imap', required: true, testedBy: 'imapConnectionTest' }],
	properties: [
		{ displayName: 'Mailbox Name', name: 'mailbox', type: 'string', default: 'INBOX' },
		{
			displayName: 'Action',
			name: 'postProcessAction',
			type: 'options',
			options: [
				{ name: 'Mark as Read', value: 'read' },
				{ name: 'Nothing', value: 'nothing' },
			],
			default: 'read',
			description:
				'What to do after the email has been received. If "nothing" gets selected it will be processed multiple times.',
		},
		{
			displayName: 'Download Attachments',
			name: 'downloadAttachments',
			type: 'boolean',
			default: false,
			displayOptions: { show: { format: ['simple'] } },
			description:
				'Whether attachments of emails should be downloaded. Only set if needed as it increases processing.',
		},
		{
			displayName: 'Format',
			name: 'format',
			type: 'options',
			options: [
				{
					name: 'RAW',
					value: 'raw',
					description:
						'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used',
				},
				{
					name: 'Resolved',
					value: 'resolved',
					description:
						'Returns the full email with all data resolved and attachments saved as binary data',
				},
				{
					name: 'Simple',
					value: 'simple',
					description:
						'Returns the full email; do not use if you wish to gather inline attachments',
				},
			],
			default: 'simple',
			description: 'The format to return the message in',
		},
		{
			displayName: 'Property Prefix Name',
			name: 'dataPropertyAttachmentsPrefixName',
			type: 'string',
			default: 'attachment_',
			displayOptions: { show: { format: ['resolved'] } },
			description:
				'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"',
		},
		{
			displayName: 'Property Prefix Name',
			name: 'dataPropertyAttachmentsPrefixName',
			type: 'string',
			default: 'attachment_',
			displayOptions: { show: { format: ['simple'], downloadAttachments: [true] } },
			description:
				'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			options: [
				{
					displayName: 'Custom Email Rules',
					name: 'customEmailConfig',
					type: 'string',
					default: '["UNSEEN"]',
					description:
						'Custom email fetching rules. See <a href="https://github.com/mscdex/node-imap">node-imap</a>\'s search function for more details.',
				},
				{
					displayName: 'Force Reconnect Every Minutes',
					name: 'forceReconnect',
					type: 'number',
					default: 60,
					description: 'Sets an interval (in minutes) to force a reconnection',
				},
			],
		},
	],
	codex: {
		categories: ['Communication', 'Core Nodes'],
		subcategories: { 'Core Nodes': ['Other Trigger Nodes'] },
		resources: {
			primaryDocumentation: [
				{
					url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.emailimap/',
				},
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/imap' }],
		},
	},
} satisfies INodeTypeDescription;

export const nodeTypeNextCloudV1 = {
	displayName: 'Nextcloud',
	name: 'n8n-nodes-base.nextCloud',
	group: ['input'],
	version: 1,
	subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
	description: 'Access data on Nextcloud',
	defaults: { name: 'Nextcloud' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [
		{
			name: 'nextCloudApi',
			required: true,
			displayOptions: { show: { authentication: ['accessToken'] } },
		},
		{
			name: 'nextCloudOAuth2Api',
			required: true,
			displayOptions: { show: { authentication: ['oAuth2'] } },
		},
	],
	properties: [
		{
			displayName: 'Authentication',
			name: 'authentication',
			type: 'options',
			options: [
				{ name: 'Access Token', value: 'accessToken' },
				{ name: 'OAuth2', value: 'oAuth2' },
			],
			default: 'accessToken',
		},
		{
			displayName: 'Resource',
			name: 'resource',
			type: 'options',
			noDataExpression: true,
			options: [
				{ name: 'File', value: 'file' },
				{ name: 'Folder', value: 'folder' },
				{ name: 'User', value: 'user' },
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'file',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['file'] } },
			options: [
				{ name: 'Copy', value: 'copy', description: 'Copy a file', action: 'Copy a file' },
				{
					name: 'Delete',
					value: 'delete',
					description: 'Delete a file',
					action: 'Delete a file',
				},
				{
					name: 'Download',
					value: 'download',
					description: 'Download a file',
					action: 'Download a file',
				},
				{ name: 'Move', value: 'move', description: 'Move a file', action: 'Move a file' },
				{ name: 'Share', value: 'share', description: 'Share a file', action: 'Share a file' },
				{
					name: 'Upload',
					value: 'upload',
					description: 'Upload a file',
					action: 'Upload a file',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'upload',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['folder'] } },
			options: [
				{ name: 'Copy', value: 'copy', description: 'Copy a folder', action: 'Copy a folder' },
				{
					name: 'Create',
					value: 'create',
					description: 'Create a folder',
					action: 'Create a folder',
				},
				{
					name: 'Delete',
					value: 'delete',
					description: 'Delete a folder',
					action: 'Delete a folder',
				},
				{
					name: 'List',
					value: 'list',
					description: 'Return the contents of a given folder',
					action: 'List a folder',
				},
				{ name: 'Move', value: 'move', description: 'Move a folder', action: 'Move a folder' },
				{
					name: 'Share',
					value: 'share',
					description: 'Share a folder',
					action: 'Share a folder',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'create',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['user'] } },
			options: [
				{
					name: 'Create',
					value: 'create',
					description: 'Invite a user to a NextCloud organization',
					action: 'Create a user',
				},
				{
					name: 'Delete',
					value: 'delete',
					description: 'Delete a user',
					action: 'Delete a user',
				},
				{
					name: 'Get',
					value: 'get',
					description: 'Retrieve information about a single user',
					action: 'Get a user',
				},
				{
					name: 'Get Many',
					value: 'getAll',
					description: 'Retrieve a list of users',
					action: 'Get many users',
				},
				{
					name: 'Update',
					value: 'update',
					description: 'Edit attributes related to a user',
					action: 'Update a user',
				},
				{ name: 'Custom API Call', value: '__CUSTOM_API_CALL__' },
			],
			default: 'create',
		},
		{
			displayName: 'From Path',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['copy'], resource: ['file', 'folder'] } },
			placeholder: '/invoices/original.txt',
			description: 'The path of file or folder to copy. The path should start with "/".',
		},
		{
			displayName: 'To Path',
			name: 'toPath',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['copy'], resource: ['file', 'folder'] } },
			placeholder: '/invoices/copy.txt',
			description: 'The destination path of file or folder. The path should start with "/".',
		},
		{
			displayName: 'Delete Path',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['delete'], resource: ['file', 'folder'] } },
			placeholder: '/invoices/2019/invoice_1.pdf',
			description:
				'The path to delete. Can be a single file or a whole folder. The path should start with "/".',
		},
		{
			displayName: 'From Path',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['move'], resource: ['file', 'folder'] } },
			placeholder: '/invoices/old_name.txt',
			description: 'The path of file or folder to move. The path should start with "/".',
		},
		{
			displayName: 'To Path',
			name: 'toPath',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['move'], resource: ['file', 'folder'] } },
			placeholder: '/invoices/new_name.txt',
			description: 'The new path of file or folder. The path should start with "/".',
		},
		{
			displayName: 'File Path',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['download'], resource: ['file'] } },
			placeholder: '/invoices/2019/invoice_1.pdf',
			description:
				'The file path of the file to download. Has to contain the full path. The path should start with "/".',
		},
		{
			displayName: 'Binary Property',
			name: 'binaryPropertyName',
			type: 'string',
			default: 'data',
			required: true,
			displayOptions: { show: { operation: ['download'], resource: ['file'] } },
			description: 'Name of the binary property to which to write the data of the read file',
		},
		{
			displayName: 'File Path',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['upload'], resource: ['file'] } },
			placeholder: '/invoices/2019/invoice_1.pdf',
			description:
				'The absolute file path of the file to upload. Has to contain the full path. The parent folder has to exist. Existing files get overwritten.',
		},
		{
			displayName: 'Binary Data',
			name: 'binaryDataUpload',
			type: 'boolean',
			default: false,
			required: true,
			displayOptions: { show: { operation: ['upload'], resource: ['file'] } },
		},
		{
			displayName: 'File Content',
			name: 'fileContent',
			type: 'string',
			default: '',
			displayOptions: {
				show: { binaryDataUpload: [false], operation: ['upload'], resource: ['file'] },
			},
			placeholder: '',
			description: 'The text content of the file to upload',
		},
		{
			displayName: 'Binary Property',
			name: 'binaryPropertyName',
			type: 'string',
			default: 'data',
			required: true,
			displayOptions: {
				show: { binaryDataUpload: [true], operation: ['upload'], resource: ['file'] },
			},
			placeholder: '',
			description:
				'Name of the binary property which contains the data for the file to be uploaded',
		},
		{
			displayName: 'File Path',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['share'], resource: ['file', 'folder'] } },
			placeholder: '/invoices/2019/invoice_1.pdf',
			description:
				'The file path of the file to share. Has to contain the full path. The path should start with "/".',
		},
		{
			displayName: 'Share Type',
			name: 'shareType',
			type: 'options',
			displayOptions: { show: { operation: ['share'], resource: ['file', 'folder'] } },
			options: [
				{ name: 'Circle', value: 7 },
				{ name: 'Email', value: 4 },
				{ name: 'Group', value: 1 },
				{ name: 'Public Link', value: 3 },
				{ name: 'User', value: 0 },
			],
			default: 0,
			description: 'The share permissions to set',
		},
		{
			displayName: 'Circle ID',
			name: 'circleId',
			type: 'string',
			displayOptions: {
				show: { resource: ['file', 'folder'], operation: ['share'], shareType: [7] },
			},
			default: '',
			description: 'The ID of the circle to share with',
		},
		{
			displayName: 'Email',
			name: 'email',
			type: 'string',
			placeholder: 'name@email.com',
			displayOptions: {
				show: { resource: ['file', 'folder'], operation: ['share'], shareType: [4] },
			},
			default: '',
			description: 'The Email address to share with',
		},
		{
			displayName: 'Group ID',
			name: 'groupId',
			type: 'string',
			displayOptions: {
				show: { resource: ['file', 'folder'], operation: ['share'], shareType: [1] },
			},
			default: '',
			description: 'The ID of the group to share with',
		},
		{
			displayName: 'User',
			name: 'user',
			type: 'string',
			displayOptions: {
				show: { resource: ['file', 'folder'], operation: ['share'], shareType: [0] },
			},
			default: '',
			description: 'The user to share with',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			displayOptions: { show: { resource: ['file', 'folder'], operation: ['share'] } },
			options: [
				{
					displayName: 'Password',
					name: 'password',
					type: 'string',
					typeOptions: { password: true },
					displayOptions: {
						show: { '/resource': ['file', 'folder'], '/operation': ['share'], '/shareType': [3] },
					},
					default: '',
					description: 'Optional search string',
				},
				{
					displayName: 'Permissions',
					name: 'permissions',
					type: 'options',
					options: [
						{ name: 'All', value: 31 },
						{ name: 'Create', value: 4 },
						{ name: 'Delete', value: 8 },
						{ name: 'Read', value: 1 },
						{ name: 'Update', value: 2 },
					],
					default: 1,
					description: 'The share permissions to set',
				},
			],
		},
		{
			displayName: 'Folder',
			name: 'path',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { operation: ['create'], resource: ['folder'] } },
			placeholder: '/invoices/2019',
			description:
				'The folder to create. The parent folder has to exist. The path should start with "/".',
		},
		{
			displayName: 'Folder Path',
			name: 'path',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['list'], resource: ['folder'] } },
			placeholder: '/invoices/2019/',
			description: 'The path of which to list the content. The path should start with "/".',
		},
		{
			displayName: 'Username',
			name: 'userId',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { resource: ['user'], operation: ['create'] } },
			placeholder: 'john',
			description: 'Username the user will have',
		},
		{
			displayName: 'Email',
			name: 'email',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { resource: ['user'], operation: ['create'] } },
			placeholder: 'john@email.com',
			description: 'The email of the user to invite',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			default: {},
			displayOptions: { show: { resource: ['user'], operation: ['create'] } },
			options: [
				{
					displayName: 'Display Name',
					name: 'displayName',
					type: 'string',
					default: '',
					description: 'The display name of the user to invite',
				},
			],
		},
		{
			displayName: 'Username',
			name: 'userId',
			type: 'string',
			default: '',
			required: true,
			displayOptions: { show: { resource: ['user'], operation: ['delete', 'get', 'update'] } },
			placeholder: 'john',
			description: 'Username the user will have',
		},
		{
			displayName: 'Return All',
			name: 'returnAll',
			type: 'boolean',
			displayOptions: { show: { resource: ['user'], operation: ['getAll'] } },
			default: false,
			description: 'Whether to return all results or only up to a given limit',
		},
		{
			displayName: 'Limit',
			name: 'limit',
			type: 'number',
			displayOptions: { show: { resource: ['user'], operation: ['getAll'], returnAll: [false] } },
			typeOptions: { minValue: 1, maxValue: 100 },
			default: 50,
			description: 'Max number of results to return',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			displayOptions: { show: { resource: ['user'], operation: ['getAll'] } },
			options: [
				{
					displayName: 'Search',
					name: 'search',
					type: 'string',
					default: '',
					description: 'Optional search string',
				},
				{
					displayName: 'Offset',
					name: 'offset',
					type: 'number',
					default: '',
					description: 'Optional offset value',
				},
			],
		},
		{
			displayName: 'Update Fields',
			name: 'updateFields',
			type: 'fixedCollection',
			typeOptions: { multipleValues: false },
			placeholder: 'Add Option',
			default: {},
			displayOptions: { show: { resource: ['user'], operation: ['update'] } },
			options: [
				{
					displayName: 'Fields',
					name: 'field',
					values: [
						{
							displayName: 'Key',
							name: 'key',
							type: 'options',
							default: 'email',
							options: [
								{
									name: 'Address',
									value: 'address',
									description: 'The new address for the user',
								},
								{
									name: 'Display Name',
									value: 'displayname',
									description: 'The new display name for the user',
								},
								{ name: 'Email', value: 'email', description: 'The new email for the user' },
								{
									name: 'Password',
									value: 'password',
									description: 'The new password for the user',
								},
								{
									name: 'Twitter',
									value: 'twitter',
									description: 'The new twitter handle for the user',
								},
								{
									name: 'Website',
									value: 'website',
									description: 'The new website for the user',
								},
							],
							description: 'Key of the updated attribute',
						},
						{
							displayName: 'Value',
							name: 'value',
							type: 'string',
							default: '',
							description: 'Value of the updated attribute',
						},
					],
				},
			],
		},
	],
	codex: {
		categories: ['Data & Storage'],
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.nextcloud/' },
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/nextCloud' }],
		},
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/NextCloud/nextcloud.svg',
} satisfies INodeTypeDescription;

export const nodeTypeTelegramV1 = {
	displayName: 'Telegram',
	name: 'n8n-nodes-base.telegram',
	group: ['output'],
	version: [1, 1.1],
	subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
	description: 'Sends data to Telegram',
	defaults: { name: 'Telegram' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [{ name: 'telegramApi', required: true }],
	properties: [
		{
			displayName: 'Resource',
			name: 'resource',
			type: 'options',
			noDataExpression: true,
			options: [
				{ name: 'Chat', value: 'chat' },
				{ name: 'Callback', value: 'callback' },
				{ name: 'File', value: 'file' },
				{ name: 'Message', value: 'message' },
			],
			default: 'message',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['chat'] } },
			options: [
				{
					name: 'Get',
					value: 'get',
					description: 'Get up to date information about a chat',
					action: 'Get a chat',
				},
				{
					name: 'Get Administrators',
					value: 'administrators',
					description: 'Get the Administrators of a chat',
					action: 'Get all administrators in a chat',
				},
				{
					name: 'Get Member',
					value: 'member',
					description: 'Get the member of a chat',
					action: 'Get a member in a chat',
				},
				{
					name: 'Leave',
					value: 'leave',
					description: 'Leave a group, supergroup or channel',
					action: 'Leave a chat',
				},
				{
					name: 'Set Description',
					value: 'setDescription',
					description: 'Set the description of a chat',
					action: 'Set description on a chat',
				},
				{
					name: 'Set Title',
					value: 'setTitle',
					description: 'Set the title of a chat',
					action: 'Set a title on a chat',
				},
			],
			default: 'get',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['callback'] } },
			options: [
				{
					name: 'Answer Query',
					value: 'answerQuery',
					description: 'Send answer to callback query sent from inline keyboard',
					action: 'Answer Query a callback',
				},
				{
					name: 'Answer Inline Query',
					value: 'answerInlineQuery',
					description: 'Send answer to callback query sent from inline bot',
					action: 'Answer an inline query callback',
				},
			],
			default: 'answerQuery',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['file'] } },
			options: [{ name: 'Get', value: 'get', description: 'Get a file', action: 'Get a file' }],
			default: 'get',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['message'] } },
			options: [
				{
					name: 'Delete Chat Message',
					value: 'deleteMessage',
					description: 'Delete a chat message',
					action: 'Delete a chat message',
				},
				{
					name: 'Edit Message Text',
					value: 'editMessageText',
					description: 'Edit a text message',
					action: 'Edit a test message',
				},
				{
					name: 'Pin Chat Message',
					value: 'pinChatMessage',
					description: 'Pin a chat message',
					action: 'Pin a chat message',
				},
				{
					name: 'Send Animation',
					value: 'sendAnimation',
					description: 'Send an animated file',
					action: 'Send an animated file',
				},
				{
					name: 'Send Audio',
					value: 'sendAudio',
					description: 'Send a audio file',
					action: 'Send an audio file',
				},
				{
					name: 'Send Chat Action',
					value: 'sendChatAction',
					description: 'Send a chat action',
					action: 'Send a chat action',
				},
				{
					name: 'Send Document',
					value: 'sendDocument',
					description: 'Send a document',
					action: 'Send a document',
				},
				{
					name: 'Send Location',
					value: 'sendLocation',
					description: 'Send a location',
					action: 'Send a location',
				},
				{
					name: 'Send Media Group',
					value: 'sendMediaGroup',
					description: 'Send group of photos or videos to album',
					action: 'Send a media group message',
				},
				{
					name: 'Send Message',
					value: 'sendMessage',
					description: 'Send a text message',
					action: 'Send a text message',
				},
				{
					name: 'Send Photo',
					value: 'sendPhoto',
					description: 'Send a photo',
					action: 'Send a photo message',
				},
				{
					name: 'Send Sticker',
					value: 'sendSticker',
					description: 'Send a sticker',
					action: 'Send a sticker',
				},
				{
					name: 'Send Video',
					value: 'sendVideo',
					description: 'Send a video',
					action: 'Send a video',
				},
				{
					name: 'Unpin Chat Message',
					value: 'unpinChatMessage',
					description: 'Unpin a chat message',
					action: 'Unpin a chat message',
				},
			],
			default: 'sendMessage',
		},
		{
			displayName: 'Chat ID',
			name: 'chatId',
			type: 'string',
			default: '',
			displayOptions: {
				show: {
					operation: [
						'administrators',
						'deleteMessage',
						'get',
						'leave',
						'member',
						'pinChatMessage',
						'setDescription',
						'setTitle',
						'sendAnimation',
						'sendAudio',
						'sendChatAction',
						'sendDocument',
						'sendLocation',
						'sendMessage',
						'sendMediaGroup',
						'sendPhoto',
						'sendSticker',
						'sendVideo',
						'unpinChatMessage',
					],
					resource: ['chat', 'message'],
				},
			},
			required: true,
			description:
				'Unique identifier for the target chat or username of the target channel (in the format @channelusername)',
		},
		{
			displayName: 'Message ID',
			name: 'messageId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['deleteMessage'], resource: ['message'] } },
			required: true,
			description: 'Unique identifier of the message to delete',
		},
		{
			displayName: 'Message ID',
			name: 'messageId',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['pinChatMessage', 'unpinChatMessage'], resource: ['message'] },
			},
			required: true,
			description: 'Unique identifier of the message to pin or unpin',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { operation: ['pinChatMessage'], resource: ['message'] } },
			default: {},
			options: [
				{
					displayName: 'Disable Notification',
					name: 'disable_notification',
					type: 'boolean',
					default: false,
					description:
						'Whether to send a notification to all chat members about the new pinned message',
				},
			],
		},
		{
			displayName: 'User ID',
			name: 'userId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['member'], resource: ['chat'] } },
			required: true,
			description: 'Unique identifier of the target user',
		},
		{
			displayName: 'Description',
			name: 'description',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['setDescription'], resource: ['chat'] } },
			required: true,
			description: 'New chat description, 0-255 characters',
		},
		{
			displayName: 'Title',
			name: 'title',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['setTitle'], resource: ['chat'] } },
			required: true,
			description: 'New chat title, 1-255 characters',
		},
		{
			displayName: 'Query ID',
			name: 'queryId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['answerQuery'], resource: ['callback'] } },
			required: true,
			description: 'Unique identifier for the query to be answered',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { operation: ['answerQuery'], resource: ['callback'] } },
			default: {},
			options: [
				{
					displayName: 'Cache Time',
					name: 'cache_time',
					type: 'number',
					typeOptions: { minValue: 0 },
					default: 0,
					description:
						'The maximum amount of time in seconds that the result of the callback query may be cached client-side',
				},
				{
					displayName: 'Show Alert',
					name: 'show_alert',
					type: 'boolean',
					default: false,
					description:
						'Whether an alert will be shown by the client instead of a notification at the top of the chat screen',
				},
				{
					displayName: 'Text',
					name: 'text',
					type: 'string',
					default: '',
					description:
						'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.',
				},
				{
					displayName: 'URL',
					name: 'url',
					type: 'string',
					default: '',
					description: "URL that will be opened by the user's client",
				},
			],
		},
		{
			displayName: 'Query ID',
			name: 'queryId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['answerInlineQuery'], resource: ['callback'] } },
			required: true,
			description: 'Unique identifier for the answered query',
		},
		{
			displayName: 'Results',
			name: 'results',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['answerInlineQuery'], resource: ['callback'] } },
			required: true,
			description: 'A JSON-serialized array of results for the inline query',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { operation: ['answerInlineQuery'], resource: ['callback'] } },
			default: {},
			options: [
				{
					displayName: 'Cache Time',
					name: 'cache_time',
					type: 'number',
					typeOptions: { minValue: 0 },
					default: 0,
					description:
						'The maximum amount of time in seconds that the result of the callback query may be cached client-side',
				},
				{
					displayName: 'Show Alert',
					name: 'show_alert',
					type: 'boolean',
					default: false,
					description:
						'Whether an alert will be shown by the client instead of a notification at the top of the chat screen',
				},
				{
					displayName: 'Text',
					name: 'text',
					type: 'string',
					default: '',
					description:
						'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.',
				},
				{
					displayName: 'URL',
					name: 'url',
					type: 'string',
					default: '',
					description: "URL that will be opened by the user's client",
				},
			],
		},
		{
			displayName: 'File ID',
			name: 'fileId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['get'], resource: ['file'] } },
			required: true,
			description: 'The ID of the file',
		},
		{
			displayName: 'Download',
			name: 'download',
			type: 'boolean',
			displayOptions: { show: { operation: ['get'], resource: ['file'] } },
			default: true,
			description: 'Whether to download the file',
		},
		{
			displayName: 'Message Type',
			name: 'messageType',
			type: 'options',
			displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
			options: [
				{ name: 'Inline Message', value: 'inlineMessage' },
				{ name: 'Message', value: 'message' },
			],
			default: 'message',
			description: 'The type of the message to edit',
		},
		{
			displayName: 'Chat ID',
			name: 'chatId',
			type: 'string',
			default: '',
			displayOptions: {
				show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
			},
			required: true,
			description:
				'Unique identifier for the target chat or username of the target channel (in the format @channelusername). To find your chat ID ask @get_id_bot.',
		},
		{
			displayName: 'Binary Data',
			name: 'binaryData',
			type: 'boolean',
			default: false,
			required: true,
			displayOptions: {
				show: {
					operation: [
						'sendAnimation',
						'sendAudio',
						'sendDocument',
						'sendPhoto',
						'sendVideo',
						'sendSticker',
					],
					resource: ['message'],
				},
			},
			description: 'Whether the data to upload should be taken from binary field',
		},
		{
			displayName: 'Binary Property',
			name: 'binaryPropertyName',
			type: 'string',
			default: 'data',
			required: true,
			displayOptions: {
				show: {
					operation: [
						'sendAnimation',
						'sendAudio',
						'sendDocument',
						'sendPhoto',
						'sendVideo',
						'sendSticker',
					],
					resource: ['message'],
					binaryData: [true],
				},
			},
			placeholder: '',
			description: 'Name of the binary property that contains the data to upload',
		},
		{
			displayName: 'Message ID',
			name: 'messageId',
			type: 'string',
			default: '',
			displayOptions: {
				show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
			},
			required: true,
			description: 'Unique identifier of the message to edit',
		},
		{
			displayName: 'Inline Message ID',
			name: 'inlineMessageId',
			type: 'string',
			default: '',
			displayOptions: {
				show: {
					messageType: ['inlineMessage'],
					operation: ['editMessageText'],
					resource: ['message'],
				},
			},
			required: true,
			description: 'Unique identifier of the inline message to edit',
		},
		{
			displayName: 'Reply Markup',
			name: 'replyMarkup',
			displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
			type: 'options',
			options: [
				{ name: 'None', value: 'none' },
				{ name: 'Inline Keyboard', value: 'inlineKeyboard' },
			],
			default: 'none',
			description: 'Additional interface options',
		},
		{
			displayName: 'Animation',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendAnimation'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Animation to send. Pass a file_id to send an animation that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get an animation from the Internet.',
		},
		{
			displayName: 'Audio',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendAudio'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Audio file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.',
		},
		{
			displayName: 'Action',
			name: 'action',
			type: 'options',
			displayOptions: { show: { operation: ['sendChatAction'], resource: ['message'] } },
			options: [
				{ name: 'Find Location', value: 'find_location', action: 'Find location' },
				{ name: 'Record Audio', value: 'record_audio', action: 'Record audio' },
				{ name: 'Record Video', value: 'record_video', action: 'Record video' },
				{ name: 'Record Video Note', value: 'record_video_note', action: 'Record video note' },
				{ name: 'Typing', value: 'typing', action: 'Typing a message' },
				{ name: 'Upload Audio', value: 'upload_audio', action: 'Upload audio' },
				{ name: 'Upload Document', value: 'upload_document', action: 'Upload document' },
				{ name: 'Upload Photo', value: 'upload_photo', action: 'Upload photo' },
				{ name: 'Upload Video', value: 'upload_video', action: 'Upload video' },
				{ name: 'Upload Video Note', value: 'upload_video_note', action: 'Upload video note' },
			],
			default: 'typing',
			description:
				'Type of action to broadcast. Choose one, depending on what the user is about to receive. The status is set for 5 seconds or less (when a message arrives from your bot).',
		},
		{
			displayName: 'Document',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendDocument'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Document to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.',
		},
		{
			displayName: 'Latitude',
			name: 'latitude',
			type: 'number',
			default: 0,
			typeOptions: { numberPrecision: 10, minValue: -90, maxValue: 90 },
			displayOptions: { show: { operation: ['sendLocation'], resource: ['message'] } },
			description: 'Location latitude',
		},
		{
			displayName: 'Longitude',
			name: 'longitude',
			type: 'number',
			typeOptions: { numberPrecision: 10, minValue: -180, maxValue: 180 },
			default: 0,
			displayOptions: { show: { operation: ['sendLocation'], resource: ['message'] } },
			description: 'Location longitude',
		},
		{
			displayName: 'Media',
			name: 'media',
			type: 'fixedCollection',
			displayOptions: { show: { operation: ['sendMediaGroup'], resource: ['message'] } },
			description: 'The media to add',
			placeholder: 'Add Media',
			typeOptions: { multipleValues: true },
			default: {},
			options: [
				{
					displayName: 'Media',
					name: 'media',
					values: [
						{
							displayName: 'Type',
							name: 'type',
							type: 'options',
							options: [
								{ name: 'Photo', value: 'photo' },
								{ name: 'Video', value: 'video' },
							],
							default: 'photo',
							description: 'The type of the media to add',
						},
						{
							displayName: 'Media File',
							name: 'media',
							type: 'string',
							default: '',
							description:
								'Media to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass an HTTP URL for Telegram to get a file from the Internet.',
						},
						{
							displayName: 'Additional Fields',
							name: 'additionalFields',
							type: 'collection',
							placeholder: 'Add Field',
							default: {},
							options: [
								{
									displayName: 'Caption',
									name: 'caption',
									type: 'string',
									default: '',
									description: 'Caption text to set, 0-1024 characters',
								},
								{
									displayName: 'Parse Mode',
									name: 'parse_mode',
									type: 'options',
									options: [
										{ name: 'Markdown (Legacy)', value: 'Markdown' },
										{ name: 'MarkdownV2', value: 'MarkdownV2' },
										{ name: 'HTML', value: 'HTML' },
									],
									default: 'HTML',
									description: 'How to parse the text',
								},
							],
						},
					],
				},
			],
		},
		{
			displayName: 'Text',
			name: 'text',
			type: 'string',
			required: true,
			default: '',
			displayOptions: {
				show: { operation: ['editMessageText', 'sendMessage'], resource: ['message'] },
			},
			description: 'Text of the message to be sent',
		},
		{
			displayName: 'Photo',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendPhoto'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Photo to send. Pass a file_id to send a photo that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a photo from the Internet.',
		},
		{
			displayName: 'Sticker',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendSticker'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Sticker to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a .webp file from the Internet.',
		},
		{
			displayName: 'Video',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendVideo'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Video file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.',
		},
		{
			displayName: 'Reply Markup',
			name: 'replyMarkup',
			displayOptions: {
				show: {
					operation: [
						'sendAnimation',
						'sendDocument',
						'sendMessage',
						'sendPhoto',
						'sendSticker',
						'sendVideo',
						'sendAudio',
						'sendLocation',
					],
					resource: ['message'],
				},
			},
			type: 'options',
			options: [
				{ name: 'Force Reply', value: 'forceReply' },
				{ name: 'Inline Keyboard', value: 'inlineKeyboard' },
				{ name: 'None', value: 'none' },
				{ name: 'Reply Keyboard', value: 'replyKeyboard' },
				{ name: 'Reply Keyboard Remove', value: 'replyKeyboardRemove' },
			],
			default: 'none',
			description: 'Additional interface options',
		},
		{
			displayName: 'Force Reply',
			name: 'forceReply',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { replyMarkup: ['forceReply'], resource: ['message'] } },
			default: {},
			options: [
				{
					displayName: 'Force Reply',
					name: 'force_reply',
					type: 'boolean',
					default: false,
					description:
						'Whether to show reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply',
				},
				{
					displayName: 'Selective',
					name: 'selective',
					type: 'boolean',
					default: false,
					description: 'Whether to force reply from specific users only',
				},
			],
		},
		{
			displayName: 'Inline Keyboard',
			name: 'inlineKeyboard',
			placeholder: 'Add Keyboard Row',
			description: 'Adds an inline keyboard that appears right next to the message it belongs to',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: { show: { replyMarkup: ['inlineKeyboard'], resource: ['message'] } },
			default: {},
			options: [
				{
					displayName: 'Rows',
					name: 'rows',
					values: [
						{
							displayName: 'Row',
							name: 'row',
							type: 'fixedCollection',
							description: 'The value to set',
							placeholder: 'Add Button',
							typeOptions: { multipleValues: true },
							default: {},
							options: [
								{
									displayName: 'Buttons',
									name: 'buttons',
									values: [
										{
											displayName: 'Text',
											name: 'text',
											type: 'string',
											default: '',
											description: 'Label text on the button',
										},
										{
											displayName: 'Additional Fields',
											name: 'additionalFields',
											type: 'collection',
											placeholder: 'Add Field',
											default: {},
											options: [
												{
													displayName: 'Callback Data',
													name: 'callback_data',
													type: 'string',
													default: '',
													description:
														'Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes',
												},
												{
													displayName: 'Pay',
													name: 'pay',
													type: 'boolean',
													default: false,
													description: 'Whether to send a Pay button',
												},
												{
													displayName: 'Switch Inline Query Current Chat',
													name: 'switch_inline_query_current_chat',
													type: 'string',
													default: '',
													description:
														"If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field.Can be empty, in which case only the bot’s username will be inserted",
												},
												{
													displayName: 'Switch Inline Query',
													name: 'switch_inline_query',
													type: 'string',
													default: '',
													description:
														'If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.',
												},
												{
													displayName: 'URL',
													name: 'url',
													type: 'string',
													default: '',
													description: 'HTTP or tg:// URL to be opened when button is pressed',
												},
											],
										},
									],
								},
							],
						},
					],
				},
			],
		},
		{
			displayName: 'Reply Keyboard',
			name: 'replyKeyboard',
			placeholder: 'Add Reply Keyboard Row',
			description: 'Adds a custom keyboard with reply options',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: { show: { replyMarkup: ['replyKeyboard'] } },
			default: {},
			options: [
				{
					displayName: 'Rows',
					name: 'rows',
					values: [
						{
							displayName: 'Row',
							name: 'row',
							type: 'fixedCollection',
							description: 'The value to set',
							placeholder: 'Add Button',
							typeOptions: { multipleValues: true },
							default: {},
							options: [
								{
									displayName: 'Buttons',
									name: 'buttons',
									values: [
										{
											displayName: 'Text',
											name: 'text',
											type: 'string',
											default: '',
											description:
												'Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.',
										},
										{
											displayName: 'Additional Fields',
											name: 'additionalFields',
											type: 'collection',
											placeholder: 'Add Field',
											default: {},
											options: [
												{
													displayName: 'Request Contact',
													name: 'request_contact',
													type: 'boolean',
													default: false,
													description:
														"Whether the user's phone number will be sent as a contact when the button is pressed.Available in private chats only",
												},
												{
													displayName: 'Request Location',
													name: 'request_location',
													type: 'boolean',
													default: false,
													description: "Whether the user's request_location",
												},
											],
										},
									],
								},
							],
						},
					],
				},
			],
		},
		{
			displayName: 'Reply Keyboard Options',
			name: 'replyKeyboardOptions',
			type: 'collection',
			placeholder: 'Add Option',
			displayOptions: { show: { replyMarkup: ['replyKeyboard'] } },
			default: {},
			options: [
				{
					displayName: 'Resize Keyboard',
					name: 'resize_keyboard',
					type: 'boolean',
					default: false,
					description:
						'Whether to request clients to resize the keyboard vertically for optimal fit',
				},
				{
					displayName: 'One Time Keyboard',
					name: 'one_time_keyboard',
					type: 'boolean',
					default: false,
					description: "Whether to request clients to hide the keyboard as soon as it's been used",
				},
				{
					displayName: 'Selective',
					name: 'selective',
					type: 'boolean',
					default: false,
					description: 'Whether to show the keyboard to specific users only',
				},
			],
		},
		{
			displayName: 'Reply Keyboard Remove',
			name: 'replyKeyboardRemove',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { replyMarkup: ['replyKeyboardRemove'] } },
			default: {},
			options: [
				{
					displayName: 'Remove Keyboard',
					name: 'remove_keyboard',
					type: 'boolean',
					default: false,
					description: 'Whether to request clients to remove the custom keyboard',
				},
				{
					displayName: 'Selective',
					name: 'selective',
					type: 'boolean',
					default: false,
					description: 'Whether to force reply from specific users only',
				},
			],
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: {
				show: {
					operation: [
						'editMessageText',
						'sendAnimation',
						'sendAudio',
						'sendDocument',
						'sendLocation',
						'sendMessage',
						'sendMediaGroup',
						'sendPhoto',
						'sendSticker',
						'sendVideo',
					],
					resource: ['message'],
				},
			},
			default: {},
			options: [
				{
					displayName: 'Append n8n Attribution',
					name: 'appendAttribution',
					type: 'boolean',
					default: true,
					description:
						'Whether to include the phrase “This message was sent automatically with n8n” to the end of the message',
					displayOptions: { show: { '/operation': ['sendMessage'] } },
				},
				{
					displayName: 'Caption',
					name: 'caption',
					type: 'string',
					displayOptions: {
						show: {
							'/operation': [
								'sendAnimation',
								'sendAudio',
								'sendDocument',
								'sendPhoto',
								'sendVideo',
							],
						},
					},
					default: '',
					description: 'Caption text to set, 0-1024 characters',
				},
				{
					displayName: 'Disable Notification',
					name: 'disable_notification',
					type: 'boolean',
					default: false,
					displayOptions: { hide: { '/operation': ['editMessageText'] } },
					description:
						'Whether to send the message silently. Users will receive a notification with no sound.',
				},
				{
					displayName: 'Disable WebPage Preview',
					name: 'disable_web_page_preview',
					type: 'boolean',
					displayOptions: { show: { '/operation': ['editMessageText', 'sendMessage'] } },
					default: false,
					description: 'Whether to disable link previews for links in this message',
				},
				{
					displayName: 'Duration',
					name: 'duration',
					type: 'number',
					typeOptions: { minValue: 0 },
					displayOptions: { show: { '/operation': ['sendAnimation', 'sendAudio', 'sendVideo'] } },
					default: 0,
					description: 'Duration of clip in seconds',
				},
				{
					displayName: 'File Name',
					name: 'fileName',
					type: 'string',
					default: '',
					displayOptions: {
						show: {
							'/operation': [
								'sendAnimation',
								'sendAudio',
								'sendDocument',
								'sendPhoto',
								'sendVideo',
								'sendSticker',
							],
							'/resource': ['message'],
							'/binaryData': [true],
						},
					},
					placeholder: 'image.jpeg',
				},
				{
					displayName: 'Height',
					name: 'height',
					type: 'number',
					typeOptions: { minValue: 0 },
					displayOptions: { show: { '/operation': ['sendAnimation', 'sendVideo'] } },
					default: 0,
					description: 'Height of the video',
				},
				{
					displayName: 'Parse Mode',
					name: 'parse_mode',
					type: 'options',
					options: [
						{ name: 'Markdown (Legacy)', value: 'Markdown' },
						{ name: 'MarkdownV2', value: 'MarkdownV2' },
						{ name: 'HTML', value: 'HTML' },
					],
					displayOptions: {
						show: {
							'/operation': [
								'editMessageText',
								'sendAnimation',
								'sendAudio',
								'sendMessage',
								'sendPhoto',
								'sendVideo',
								'sendDocument',
							],
						},
					},
					default: 'HTML',
					description: 'How to parse the text',
				},
				{
					displayName: 'Performer',
					name: 'performer',
					type: 'string',
					displayOptions: { show: { '/operation': ['sendAudio'] } },
					default: '',
					description: 'Name of the performer',
				},
				{
					displayName: 'Reply To Message ID',
					name: 'reply_to_message_id',
					type: 'number',
					displayOptions: { hide: { '/operation': ['editMessageText'] } },
					default: 0,
					description: 'If the message is a reply, ID of the original message',
				},
				{
					displayName: 'Message Thread ID',
					name: 'message_thread_id',
					type: 'number',
					displayOptions: {
						show: {
							'/operation': [
								'sendAnimation',
								'sendAudio',
								'sendChatAction',
								'sendDocument',
								'sendLocation',
								'sendMediaGroup',
								'sendMessage',
								'sendPhoto',
								'sendSticker',
								'sendVideo',
							],
						},
					},
					default: 0,
					description: 'The unique identifier of the forum topic',
				},
				{
					displayName: 'Title',
					name: 'title',
					type: 'string',
					displayOptions: { show: { '/operation': ['sendAudio'] } },
					default: '',
					description: 'Title of the track',
				},
				{
					displayName: 'Thumbnail',
					name: 'thumb',
					type: 'string',
					displayOptions: {
						show: { '/operation': ['sendAnimation', 'sendAudio', 'sendDocument', 'sendVideo'] },
					},
					default: '',
					description:
						'Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.',
				},
				{
					displayName: 'Width',
					name: 'width',
					type: 'number',
					typeOptions: { minValue: 0 },
					displayOptions: { show: { '/operation': ['sendAnimation', 'sendVideo'] } },
					default: 0,
					description: 'Width of the video',
				},
			],
		},
	],
	codex: {
		categories: ['Communication'],
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.telegram/' },
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/telegram' }],
		},
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Telegram/telegram.svg',
} satisfies INodeTypeDescription;

export const nodeTypeTelegramV1_1 = {
	displayName: 'Telegram',
	name: 'n8n-nodes-base.telegram',
	group: ['output'],
	version: [1, 1.1],
	subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
	description: 'Sends data to Telegram',
	defaults: { name: 'Telegram' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [{ name: 'telegramApi', required: true }],
	properties: [
		{
			displayName: 'Resource',
			name: 'resource',
			type: 'options',
			noDataExpression: true,
			options: [
				{ name: 'Chat', value: 'chat' },
				{ name: 'Callback', value: 'callback' },
				{ name: 'File', value: 'file' },
				{ name: 'Message', value: 'message' },
			],
			default: 'message',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['chat'] } },
			options: [
				{
					name: 'Get',
					value: 'get',
					description: 'Get up to date information about a chat',
					action: 'Get a chat',
				},
				{
					name: 'Get Administrators',
					value: 'administrators',
					description: 'Get the Administrators of a chat',
					action: 'Get all administrators in a chat',
				},
				{
					name: 'Get Member',
					value: 'member',
					description: 'Get the member of a chat',
					action: 'Get a member in a chat',
				},
				{
					name: 'Leave',
					value: 'leave',
					description: 'Leave a group, supergroup or channel',
					action: 'Leave a chat',
				},
				{
					name: 'Set Description',
					value: 'setDescription',
					description: 'Set the description of a chat',
					action: 'Set description on a chat',
				},
				{
					name: 'Set Title',
					value: 'setTitle',
					description: 'Set the title of a chat',
					action: 'Set a title on a chat',
				},
			],
			default: 'get',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['callback'] } },
			options: [
				{
					name: 'Answer Query',
					value: 'answerQuery',
					description: 'Send answer to callback query sent from inline keyboard',
					action: 'Answer Query a callback',
				},
				{
					name: 'Answer Inline Query',
					value: 'answerInlineQuery',
					description: 'Send answer to callback query sent from inline bot',
					action: 'Answer an inline query callback',
				},
			],
			default: 'answerQuery',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['file'] } },
			options: [{ name: 'Get', value: 'get', description: 'Get a file', action: 'Get a file' }],
			default: 'get',
		},
		{
			displayName: 'Operation',
			name: 'operation',
			type: 'options',
			noDataExpression: true,
			displayOptions: { show: { resource: ['message'] } },
			options: [
				{
					name: 'Delete Chat Message',
					value: 'deleteMessage',
					description: 'Delete a chat message',
					action: 'Delete a chat message',
				},
				{
					name: 'Edit Message Text',
					value: 'editMessageText',
					description: 'Edit a text message',
					action: 'Edit a test message',
				},
				{
					name: 'Pin Chat Message',
					value: 'pinChatMessage',
					description: 'Pin a chat message',
					action: 'Pin a chat message',
				},
				{
					name: 'Send Animation',
					value: 'sendAnimation',
					description: 'Send an animated file',
					action: 'Send an animated file',
				},
				{
					name: 'Send Audio',
					value: 'sendAudio',
					description: 'Send a audio file',
					action: 'Send an audio file',
				},
				{
					name: 'Send Chat Action',
					value: 'sendChatAction',
					description: 'Send a chat action',
					action: 'Send a chat action',
				},
				{
					name: 'Send Document',
					value: 'sendDocument',
					description: 'Send a document',
					action: 'Send a document',
				},
				{
					name: 'Send Location',
					value: 'sendLocation',
					description: 'Send a location',
					action: 'Send a location',
				},
				{
					name: 'Send Media Group',
					value: 'sendMediaGroup',
					description: 'Send group of photos or videos to album',
					action: 'Send a media group message',
				},
				{
					name: 'Send Message',
					value: 'sendMessage',
					description: 'Send a text message',
					action: 'Send a text message',
				},
				{
					name: 'Send Photo',
					value: 'sendPhoto',
					description: 'Send a photo',
					action: 'Send a photo message',
				},
				{
					name: 'Send Sticker',
					value: 'sendSticker',
					description: 'Send a sticker',
					action: 'Send a sticker',
				},
				{
					name: 'Send Video',
					value: 'sendVideo',
					description: 'Send a video',
					action: 'Send a video',
				},
				{
					name: 'Unpin Chat Message',
					value: 'unpinChatMessage',
					description: 'Unpin a chat message',
					action: 'Unpin a chat message',
				},
			],
			default: 'sendMessage',
		},
		{
			displayName: 'Chat ID',
			name: 'chatId',
			type: 'string',
			default: '',
			displayOptions: {
				show: {
					operation: [
						'administrators',
						'deleteMessage',
						'get',
						'leave',
						'member',
						'pinChatMessage',
						'setDescription',
						'setTitle',
						'sendAnimation',
						'sendAudio',
						'sendChatAction',
						'sendDocument',
						'sendLocation',
						'sendMessage',
						'sendMediaGroup',
						'sendPhoto',
						'sendSticker',
						'sendVideo',
						'unpinChatMessage',
					],
					resource: ['chat', 'message'],
				},
			},
			required: true,
			description:
				'Unique identifier for the target chat or username of the target channel (in the format @channelusername)',
		},
		{
			displayName: 'Message ID',
			name: 'messageId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['deleteMessage'], resource: ['message'] } },
			required: true,
			description: 'Unique identifier of the message to delete',
		},
		{
			displayName: 'Message ID',
			name: 'messageId',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['pinChatMessage', 'unpinChatMessage'], resource: ['message'] },
			},
			required: true,
			description: 'Unique identifier of the message to pin or unpin',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { operation: ['pinChatMessage'], resource: ['message'] } },
			default: {},
			options: [
				{
					displayName: 'Disable Notification',
					name: 'disable_notification',
					type: 'boolean',
					default: false,
					description:
						'Whether to send a notification to all chat members about the new pinned message',
				},
			],
		},
		{
			displayName: 'User ID',
			name: 'userId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['member'], resource: ['chat'] } },
			required: true,
			description: 'Unique identifier of the target user',
		},
		{
			displayName: 'Description',
			name: 'description',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['setDescription'], resource: ['chat'] } },
			required: true,
			description: 'New chat description, 0-255 characters',
		},
		{
			displayName: 'Title',
			name: 'title',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['setTitle'], resource: ['chat'] } },
			required: true,
			description: 'New chat title, 1-255 characters',
		},
		{
			displayName: 'Query ID',
			name: 'queryId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['answerQuery'], resource: ['callback'] } },
			required: true,
			description: 'Unique identifier for the query to be answered',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { operation: ['answerQuery'], resource: ['callback'] } },
			default: {},
			options: [
				{
					displayName: 'Cache Time',
					name: 'cache_time',
					type: 'number',
					typeOptions: { minValue: 0 },
					default: 0,
					description:
						'The maximum amount of time in seconds that the result of the callback query may be cached client-side',
				},
				{
					displayName: 'Show Alert',
					name: 'show_alert',
					type: 'boolean',
					default: false,
					description:
						'Whether an alert will be shown by the client instead of a notification at the top of the chat screen',
				},
				{
					displayName: 'Text',
					name: 'text',
					type: 'string',
					default: '',
					description:
						'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.',
				},
				{
					displayName: 'URL',
					name: 'url',
					type: 'string',
					default: '',
					description: "URL that will be opened by the user's client",
				},
			],
		},
		{
			displayName: 'Query ID',
			name: 'queryId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['answerInlineQuery'], resource: ['callback'] } },
			required: true,
			description: 'Unique identifier for the answered query',
		},
		{
			displayName: 'Results',
			name: 'results',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['answerInlineQuery'], resource: ['callback'] } },
			required: true,
			description: 'A JSON-serialized array of results for the inline query',
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { operation: ['answerInlineQuery'], resource: ['callback'] } },
			default: {},
			options: [
				{
					displayName: 'Cache Time',
					name: 'cache_time',
					type: 'number',
					typeOptions: { minValue: 0 },
					default: 0,
					description:
						'The maximum amount of time in seconds that the result of the callback query may be cached client-side',
				},
				{
					displayName: 'Show Alert',
					name: 'show_alert',
					type: 'boolean',
					default: false,
					description:
						'Whether an alert will be shown by the client instead of a notification at the top of the chat screen',
				},
				{
					displayName: 'Text',
					name: 'text',
					type: 'string',
					default: '',
					description:
						'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.',
				},
				{
					displayName: 'URL',
					name: 'url',
					type: 'string',
					default: '',
					description: "URL that will be opened by the user's client",
				},
			],
		},
		{
			displayName: 'File ID',
			name: 'fileId',
			type: 'string',
			default: '',
			displayOptions: { show: { operation: ['get'], resource: ['file'] } },
			required: true,
			description: 'The ID of the file',
		},
		{
			displayName: 'Download',
			name: 'download',
			type: 'boolean',
			displayOptions: { show: { operation: ['get'], resource: ['file'] } },
			default: true,
			description: 'Whether to download the file',
		},
		{
			displayName: 'Message Type',
			name: 'messageType',
			type: 'options',
			displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
			options: [
				{ name: 'Inline Message', value: 'inlineMessage' },
				{ name: 'Message', value: 'message' },
			],
			default: 'message',
			description: 'The type of the message to edit',
		},
		{
			displayName: 'Chat ID',
			name: 'chatId',
			type: 'string',
			default: '',
			displayOptions: {
				show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
			},
			required: true,
			description:
				'Unique identifier for the target chat or username of the target channel (in the format @channelusername). To find your chat ID ask @get_id_bot.',
		},
		{
			displayName: 'Binary Data',
			name: 'binaryData',
			type: 'boolean',
			default: false,
			required: true,
			displayOptions: {
				show: {
					operation: [
						'sendAnimation',
						'sendAudio',
						'sendDocument',
						'sendPhoto',
						'sendVideo',
						'sendSticker',
					],
					resource: ['message'],
				},
			},
			description: 'Whether the data to upload should be taken from binary field',
		},
		{
			displayName: 'Binary Property',
			name: 'binaryPropertyName',
			type: 'string',
			default: 'data',
			required: true,
			displayOptions: {
				show: {
					operation: [
						'sendAnimation',
						'sendAudio',
						'sendDocument',
						'sendPhoto',
						'sendVideo',
						'sendSticker',
					],
					resource: ['message'],
					binaryData: [true],
				},
			},
			placeholder: '',
			description: 'Name of the binary property that contains the data to upload',
		},
		{
			displayName: 'Message ID',
			name: 'messageId',
			type: 'string',
			default: '',
			displayOptions: {
				show: { messageType: ['message'], operation: ['editMessageText'], resource: ['message'] },
			},
			required: true,
			description: 'Unique identifier of the message to edit',
		},
		{
			displayName: 'Inline Message ID',
			name: 'inlineMessageId',
			type: 'string',
			default: '',
			displayOptions: {
				show: {
					messageType: ['inlineMessage'],
					operation: ['editMessageText'],
					resource: ['message'],
				},
			},
			required: true,
			description: 'Unique identifier of the inline message to edit',
		},
		{
			displayName: 'Reply Markup',
			name: 'replyMarkup',
			displayOptions: { show: { operation: ['editMessageText'], resource: ['message'] } },
			type: 'options',
			options: [
				{ name: 'None', value: 'none' },
				{ name: 'Inline Keyboard', value: 'inlineKeyboard' },
			],
			default: 'none',
			description: 'Additional interface options',
		},
		{
			displayName: 'Animation',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendAnimation'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Animation to send. Pass a file_id to send an animation that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get an animation from the Internet.',
		},
		{
			displayName: 'Audio',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendAudio'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Audio file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.',
		},
		{
			displayName: 'Action',
			name: 'action',
			type: 'options',
			displayOptions: { show: { operation: ['sendChatAction'], resource: ['message'] } },
			options: [
				{ name: 'Find Location', value: 'find_location', action: 'Find location' },
				{ name: 'Record Audio', value: 'record_audio', action: 'Record audio' },
				{ name: 'Record Video', value: 'record_video', action: 'Record video' },
				{ name: 'Record Video Note', value: 'record_video_note', action: 'Record video note' },
				{ name: 'Typing', value: 'typing', action: 'Typing a message' },
				{ name: 'Upload Audio', value: 'upload_audio', action: 'Upload audio' },
				{ name: 'Upload Document', value: 'upload_document', action: 'Upload document' },
				{ name: 'Upload Photo', value: 'upload_photo', action: 'Upload photo' },
				{ name: 'Upload Video', value: 'upload_video', action: 'Upload video' },
				{ name: 'Upload Video Note', value: 'upload_video_note', action: 'Upload video note' },
			],
			default: 'typing',
			description:
				'Type of action to broadcast. Choose one, depending on what the user is about to receive. The status is set for 5 seconds or less (when a message arrives from your bot).',
		},
		{
			displayName: 'Document',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendDocument'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Document to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.',
		},
		{
			displayName: 'Latitude',
			name: 'latitude',
			type: 'number',
			default: 0,
			typeOptions: { numberPrecision: 10, minValue: -90, maxValue: 90 },
			displayOptions: { show: { operation: ['sendLocation'], resource: ['message'] } },
			description: 'Location latitude',
		},
		{
			displayName: 'Longitude',
			name: 'longitude',
			type: 'number',
			typeOptions: { numberPrecision: 10, minValue: -180, maxValue: 180 },
			default: 0,
			displayOptions: { show: { operation: ['sendLocation'], resource: ['message'] } },
			description: 'Location longitude',
		},
		{
			displayName: 'Media',
			name: 'media',
			type: 'fixedCollection',
			displayOptions: { show: { operation: ['sendMediaGroup'], resource: ['message'] } },
			description: 'The media to add',
			placeholder: 'Add Media',
			typeOptions: { multipleValues: true },
			default: {},
			options: [
				{
					displayName: 'Media',
					name: 'media',
					values: [
						{
							displayName: 'Type',
							name: 'type',
							type: 'options',
							options: [
								{ name: 'Photo', value: 'photo' },
								{ name: 'Video', value: 'video' },
							],
							default: 'photo',
							description: 'The type of the media to add',
						},
						{
							displayName: 'Media File',
							name: 'media',
							type: 'string',
							default: '',
							description:
								'Media to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass an HTTP URL for Telegram to get a file from the Internet.',
						},
						{
							displayName: 'Additional Fields',
							name: 'additionalFields',
							type: 'collection',
							placeholder: 'Add Field',
							default: {},
							options: [
								{
									displayName: 'Caption',
									name: 'caption',
									type: 'string',
									default: '',
									description: 'Caption text to set, 0-1024 characters',
								},
								{
									displayName: 'Parse Mode',
									name: 'parse_mode',
									type: 'options',
									options: [
										{ name: 'Markdown (Legacy)', value: 'Markdown' },
										{ name: 'MarkdownV2', value: 'MarkdownV2' },
										{ name: 'HTML', value: 'HTML' },
									],
									default: 'HTML',
									description: 'How to parse the text',
								},
							],
						},
					],
				},
			],
		},
		{
			displayName: 'Text',
			name: 'text',
			type: 'string',
			required: true,
			default: '',
			displayOptions: {
				show: { operation: ['editMessageText', 'sendMessage'], resource: ['message'] },
			},
			description: 'Text of the message to be sent',
		},
		{
			displayName: 'Photo',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendPhoto'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Photo to send. Pass a file_id to send a photo that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a photo from the Internet.',
		},
		{
			displayName: 'Sticker',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendSticker'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Sticker to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a .webp file from the Internet.',
		},
		{
			displayName: 'Video',
			name: 'file',
			type: 'string',
			default: '',
			displayOptions: {
				show: { operation: ['sendVideo'], resource: ['message'], binaryData: [false] },
			},
			description:
				'Video file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.',
		},
		{
			displayName: 'Reply Markup',
			name: 'replyMarkup',
			displayOptions: {
				show: {
					operation: [
						'sendAnimation',
						'sendDocument',
						'sendMessage',
						'sendPhoto',
						'sendSticker',
						'sendVideo',
						'sendAudio',
						'sendLocation',
					],
					resource: ['message'],
				},
			},
			type: 'options',
			options: [
				{ name: 'Force Reply', value: 'forceReply' },
				{ name: 'Inline Keyboard', value: 'inlineKeyboard' },
				{ name: 'None', value: 'none' },
				{ name: 'Reply Keyboard', value: 'replyKeyboard' },
				{ name: 'Reply Keyboard Remove', value: 'replyKeyboardRemove' },
			],
			default: 'none',
			description: 'Additional interface options',
		},
		{
			displayName: 'Force Reply',
			name: 'forceReply',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { replyMarkup: ['forceReply'], resource: ['message'] } },
			default: {},
			options: [
				{
					displayName: 'Force Reply',
					name: 'force_reply',
					type: 'boolean',
					default: false,
					description:
						'Whether to show reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply',
				},
				{
					displayName: 'Selective',
					name: 'selective',
					type: 'boolean',
					default: false,
					description: 'Whether to force reply from specific users only',
				},
			],
		},
		{
			displayName: 'Inline Keyboard',
			name: 'inlineKeyboard',
			placeholder: 'Add Keyboard Row',
			description: 'Adds an inline keyboard that appears right next to the message it belongs to',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: { show: { replyMarkup: ['inlineKeyboard'], resource: ['message'] } },
			default: {},
			options: [
				{
					displayName: 'Rows',
					name: 'rows',
					values: [
						{
							displayName: 'Row',
							name: 'row',
							type: 'fixedCollection',
							description: 'The value to set',
							placeholder: 'Add Button',
							typeOptions: { multipleValues: true },
							default: {},
							options: [
								{
									displayName: 'Buttons',
									name: 'buttons',
									values: [
										{
											displayName: 'Text',
											name: 'text',
											type: 'string',
											default: '',
											description: 'Label text on the button',
										},
										{
											displayName: 'Additional Fields',
											name: 'additionalFields',
											type: 'collection',
											placeholder: 'Add Field',
											default: {},
											options: [
												{
													displayName: 'Callback Data',
													name: 'callback_data',
													type: 'string',
													default: '',
													description:
														'Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes',
												},
												{
													displayName: 'Pay',
													name: 'pay',
													type: 'boolean',
													default: false,
													description: 'Whether to send a Pay button',
												},
												{
													displayName: 'Switch Inline Query Current Chat',
													name: 'switch_inline_query_current_chat',
													type: 'string',
													default: '',
													description:
														"If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field.Can be empty, in which case only the bot’s username will be inserted",
												},
												{
													displayName: 'Switch Inline Query',
													name: 'switch_inline_query',
													type: 'string',
													default: '',
													description:
														'If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.',
												},
												{
													displayName: 'URL',
													name: 'url',
													type: 'string',
													default: '',
													description: 'HTTP or tg:// URL to be opened when button is pressed',
												},
											],
										},
									],
								},
							],
						},
					],
				},
			],
		},
		{
			displayName: 'Reply Keyboard',
			name: 'replyKeyboard',
			placeholder: 'Add Reply Keyboard Row',
			description: 'Adds a custom keyboard with reply options',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: { show: { replyMarkup: ['replyKeyboard'] } },
			default: {},
			options: [
				{
					displayName: 'Rows',
					name: 'rows',
					values: [
						{
							displayName: 'Row',
							name: 'row',
							type: 'fixedCollection',
							description: 'The value to set',
							placeholder: 'Add Button',
							typeOptions: { multipleValues: true },
							default: {},
							options: [
								{
									displayName: 'Buttons',
									name: 'buttons',
									values: [
										{
											displayName: 'Text',
											name: 'text',
											type: 'string',
											default: '',
											description:
												'Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.',
										},
										{
											displayName: 'Additional Fields',
											name: 'additionalFields',
											type: 'collection',
											placeholder: 'Add Field',
											default: {},
											options: [
												{
													displayName: 'Request Contact',
													name: 'request_contact',
													type: 'boolean',
													default: false,
													description:
														"Whether the user's phone number will be sent as a contact when the button is pressed.Available in private chats only",
												},
												{
													displayName: 'Request Location',
													name: 'request_location',
													type: 'boolean',
													default: false,
													description: "Whether the user's request_location",
												},
											],
										},
									],
								},
							],
						},
					],
				},
			],
		},
		{
			displayName: 'Reply Keyboard Options',
			name: 'replyKeyboardOptions',
			type: 'collection',
			placeholder: 'Add Option',
			displayOptions: { show: { replyMarkup: ['replyKeyboard'] } },
			default: {},
			options: [
				{
					displayName: 'Resize Keyboard',
					name: 'resize_keyboard',
					type: 'boolean',
					default: false,
					description:
						'Whether to request clients to resize the keyboard vertically for optimal fit',
				},
				{
					displayName: 'One Time Keyboard',
					name: 'one_time_keyboard',
					type: 'boolean',
					default: false,
					description: "Whether to request clients to hide the keyboard as soon as it's been used",
				},
				{
					displayName: 'Selective',
					name: 'selective',
					type: 'boolean',
					default: false,
					description: 'Whether to show the keyboard to specific users only',
				},
			],
		},
		{
			displayName: 'Reply Keyboard Remove',
			name: 'replyKeyboardRemove',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: { show: { replyMarkup: ['replyKeyboardRemove'] } },
			default: {},
			options: [
				{
					displayName: 'Remove Keyboard',
					name: 'remove_keyboard',
					type: 'boolean',
					default: false,
					description: 'Whether to request clients to remove the custom keyboard',
				},
				{
					displayName: 'Selective',
					name: 'selective',
					type: 'boolean',
					default: false,
					description: 'Whether to force reply from specific users only',
				},
			],
		},
		{
			displayName: 'Additional Fields',
			name: 'additionalFields',
			type: 'collection',
			placeholder: 'Add Field',
			displayOptions: {
				show: {
					operation: [
						'editMessageText',
						'sendAnimation',
						'sendAudio',
						'sendDocument',
						'sendLocation',
						'sendMessage',
						'sendMediaGroup',
						'sendPhoto',
						'sendSticker',
						'sendVideo',
					],
					resource: ['message'],
				},
			},
			default: {},
			options: [
				{
					displayName: 'Append n8n Attribution',
					name: 'appendAttribution',
					type: 'boolean',
					default: true,
					description:
						'Whether to include the phrase “This message was sent automatically with n8n” to the end of the message',
					displayOptions: { show: { '/operation': ['sendMessage'] } },
				},
				{
					displayName: 'Caption',
					name: 'caption',
					type: 'string',
					displayOptions: {
						show: {
							'/operation': [
								'sendAnimation',
								'sendAudio',
								'sendDocument',
								'sendPhoto',
								'sendVideo',
							],
						},
					},
					default: '',
					description: 'Caption text to set, 0-1024 characters',
				},
				{
					displayName: 'Disable Notification',
					name: 'disable_notification',
					type: 'boolean',
					default: false,
					displayOptions: { hide: { '/operation': ['editMessageText'] } },
					description:
						'Whether to send the message silently. Users will receive a notification with no sound.',
				},
				{
					displayName: 'Disable WebPage Preview',
					name: 'disable_web_page_preview',
					type: 'boolean',
					displayOptions: { show: { '/operation': ['editMessageText', 'sendMessage'] } },
					default: false,
					description: 'Whether to disable link previews for links in this message',
				},
				{
					displayName: 'Duration',
					name: 'duration',
					type: 'number',
					typeOptions: { minValue: 0 },
					displayOptions: { show: { '/operation': ['sendAnimation', 'sendAudio', 'sendVideo'] } },
					default: 0,
					description: 'Duration of clip in seconds',
				},
				{
					displayName: 'File Name',
					name: 'fileName',
					type: 'string',
					default: '',
					displayOptions: {
						show: {
							'/operation': [
								'sendAnimation',
								'sendAudio',
								'sendDocument',
								'sendPhoto',
								'sendVideo',
								'sendSticker',
							],
							'/resource': ['message'],
							'/binaryData': [true],
						},
					},
					placeholder: 'image.jpeg',
				},
				{
					displayName: 'Height',
					name: 'height',
					type: 'number',
					typeOptions: { minValue: 0 },
					displayOptions: { show: { '/operation': ['sendAnimation', 'sendVideo'] } },
					default: 0,
					description: 'Height of the video',
				},
				{
					displayName: 'Parse Mode',
					name: 'parse_mode',
					type: 'options',
					options: [
						{ name: 'Markdown (Legacy)', value: 'Markdown' },
						{ name: 'MarkdownV2', value: 'MarkdownV2' },
						{ name: 'HTML', value: 'HTML' },
					],
					displayOptions: {
						show: {
							'/operation': [
								'editMessageText',
								'sendAnimation',
								'sendAudio',
								'sendMessage',
								'sendPhoto',
								'sendVideo',
								'sendDocument',
							],
						},
					},
					default: 'HTML',
					description: 'How to parse the text',
				},
				{
					displayName: 'Performer',
					name: 'performer',
					type: 'string',
					displayOptions: { show: { '/operation': ['sendAudio'] } },
					default: '',
					description: 'Name of the performer',
				},
				{
					displayName: 'Reply To Message ID',
					name: 'reply_to_message_id',
					type: 'number',
					displayOptions: { hide: { '/operation': ['editMessageText'] } },
					default: 0,
					description: 'If the message is a reply, ID of the original message',
				},
				{
					displayName: 'Message Thread ID',
					name: 'message_thread_id',
					type: 'number',
					displayOptions: {
						show: {
							'/operation': [
								'sendAnimation',
								'sendAudio',
								'sendChatAction',
								'sendDocument',
								'sendLocation',
								'sendMediaGroup',
								'sendMessage',
								'sendPhoto',
								'sendSticker',
								'sendVideo',
							],
						},
					},
					default: 0,
					description: 'The unique identifier of the forum topic',
				},
				{
					displayName: 'Title',
					name: 'title',
					type: 'string',
					displayOptions: { show: { '/operation': ['sendAudio'] } },
					default: '',
					description: 'Title of the track',
				},
				{
					displayName: 'Thumbnail',
					name: 'thumb',
					type: 'string',
					displayOptions: {
						show: { '/operation': ['sendAnimation', 'sendAudio', 'sendDocument', 'sendVideo'] },
					},
					default: '',
					description:
						'Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.',
				},
				{
					displayName: 'Width',
					name: 'width',
					type: 'number',
					typeOptions: { minValue: 0 },
					displayOptions: { show: { '/operation': ['sendAnimation', 'sendVideo'] } },
					default: 0,
					description: 'Width of the video',
				},
			],
		},
	],
	codex: {
		categories: ['Communication'],
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.telegram/' },
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/telegram' }],
		},
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Telegram/telegram.svg',
} satisfies INodeTypeDescription;

export const nodeTypeShopifyTriggerV1 = {
	displayName: 'Shopify Trigger',
	name: 'n8n-nodes-base.shopifyTrigger',
	group: ['trigger'],
	version: 1,
	subtitle: '={{$parameter["event"]}}',
	description: 'Handle Shopify events via webhooks',
	defaults: { name: 'Shopify Trigger' },
	inputs: [],
	outputs: ['main'],
	credentials: [
		{
			name: 'shopifyApi',
			required: true,
			displayOptions: { show: { authentication: ['apiKey'] } },
		},
		{
			name: 'shopifyAccessTokenApi',
			required: true,
			displayOptions: { show: { authentication: ['accessToken'] } },
		},
		{
			name: 'shopifyOAuth2Api',
			required: true,
			displayOptions: { show: { authentication: ['oAuth2'] } },
		},
	],
	webhooks: [{ name: 'default', httpMethod: 'POST', responseMode: 'onReceived', path: 'webhook' }],
	properties: [
		{
			displayName: 'Authentication',
			name: 'authentication',
			type: 'options',
			options: [
				{ name: 'Access Token', value: 'accessToken' },
				{ name: 'OAuth2', value: 'oAuth2' },
				{ name: 'API Key', value: 'apiKey' },
			],
			default: 'apiKey',
		},
		{
			displayName: 'Trigger On',
			name: 'topic',
			type: 'options',
			default: '',
			options: [
				{ name: 'App Uninstalled', value: 'app/uninstalled' },
				{ name: 'Cart Created', value: 'carts/create' },
				{ name: 'Cart Updated', value: 'carts/update' },
				{ name: 'Checkout Created', value: 'checkouts/create' },
				{ name: 'Checkout Delete', value: 'checkouts/delete' },
				{ name: 'Checkout Update', value: 'checkouts/update' },
				{ name: 'Collection Created', value: 'collections/create' },
				{ name: 'Collection Deleted', value: 'collections/delete' },
				{ name: 'Collection Listings Added', value: 'collection_listings/add' },
				{ name: 'Collection Listings Removed', value: 'collection_listings/remove' },
				{ name: 'Collection Listings Updated', value: 'collection_listings/update' },
				{ name: 'Collection Updated', value: 'collections/update' },
				{ name: 'Customer Created', value: 'customers/create' },
				{ name: 'Customer Deleted', value: 'customers/delete' },
				{ name: 'Customer Disabled', value: 'customers/disable' },
				{ name: 'Customer Enabled', value: 'customers/enable' },
				{ name: 'Customer Groups Created', value: 'customer_groups/create' },
				{ name: 'Customer Groups Deleted', value: 'customer_groups/delete' },
				{ name: 'Customer Groups Updated', value: 'customer_groups/update' },
				{ name: 'Customer Updated', value: 'customers/update' },
				{ name: 'Draft Orders Created', value: 'draft_orders/create' },
				{ name: 'Draft Orders Deleted', value: 'draft_orders/delete' },
				{ name: 'Draft Orders Updated', value: 'draft_orders/update' },
				{ name: 'Fulfillment Created', value: 'fulfillments/create' },
				{ name: 'Fulfillment Events Created', value: 'fulfillment_events/create' },
				{ name: 'Fulfillment Events Deleted', value: 'fulfillment_events/delete' },
				{ name: 'Fulfillment Updated', value: 'fulfillments/update' },
				{ name: 'Inventory Items Created', value: 'inventory_items/create' },
				{ name: 'Inventory Items Deleted', value: 'inventory_items/delete' },
				{ name: 'Inventory Items Updated', value: 'inventory_items/update' },
				{ name: 'Inventory Levels Connected', value: 'inventory_levels/connect' },
				{ name: 'Inventory Levels Disconnected', value: 'inventory_levels/disconnect' },
				{ name: 'Inventory Levels Updated', value: 'inventory_levels/update' },
				{ name: 'Locale Created', value: 'locales/create' },
				{ name: 'Locale Updated', value: 'locales/update' },
				{ name: 'Location Created', value: 'locations/create' },
				{ name: 'Location Deleted', value: 'locations/delete' },
				{ name: 'Location Updated', value: 'locations/update' },
				{ name: 'Order Cancelled', value: 'orders/cancelled' },
				{ name: 'Order Created', value: 'orders/create' },
				{ name: 'Order Fulfilled', value: 'orders/fulfilled' },
				{ name: 'Order Paid', value: 'orders/paid' },
				{ name: 'Order Partially Fulfilled', value: 'orders/partially_fulfilled' },
				{ name: 'Order Transactions Created', value: 'order_transactions/create' },
				{ name: 'Order Updated', value: 'orders/updated' },
				{ name: 'Orders Deleted', value: 'orders/delete' },
				{ name: 'Product Created', value: 'products/create' },
				{ name: 'Product Deleted', value: 'products/delete' },
				{ name: 'Product Listings Added', value: 'product_listings/add' },
				{ name: 'Product Listings Removed', value: 'product_listings/remove' },
				{ name: 'Product Listings Updated', value: 'product_listings/update' },
				{ name: 'Product Updated', value: 'products/update' },
				{ name: 'Refund Created', value: 'refunds/create' },
				{ name: 'Shop Updated', value: 'shop/update' },
				{ name: 'Tender Transactions Created', value: 'tender_transactions/create' },
				{ name: 'Theme Created', value: 'themes/create' },
				{ name: 'Theme Deleted', value: 'themes/delete' },
				{ name: 'Theme Published', value: 'themes/publish' },
				{ name: 'Theme Updated', value: 'themes/update' },
			],
		},
	],
	codex: {
		categories: ['Sales'],
		resources: {
			primaryDocumentation: [
				{
					url: 'https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.shopifytrigger/',
				},
			],
			credentialDocumentation: [{ url: 'https://docs.n8n.io/credentials/shopify' }],
		},
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Shopify/shopify.svg',
} satisfies INodeTypeDescription;

export const nodeTypeHttpRequestV1 = {
	displayName: 'HTTP Request',
	name: 'n8n-nodes-base.httpRequest',
	group: ['output'],
	subtitle: '={{$parameter["requestMethod"] + ": " + $parameter["url"]}}',
	description: 'Makes an HTTP request and returns the response data',
	defaultVersion: 4.1,
	version: 1,
	defaults: { name: 'HTTP Request', color: '#2200DD' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [
		{
			name: 'httpBasicAuth',
			required: true,
			displayOptions: { show: { authentication: ['basicAuth'] } },
		},
		{
			name: 'httpDigestAuth',
			required: true,
			displayOptions: { show: { authentication: ['digestAuth'] } },
		},
		{
			name: 'httpHeaderAuth',
			required: true,
			displayOptions: { show: { authentication: ['headerAuth'] } },
		},
		{
			name: 'httpQueryAuth',
			required: true,
			displayOptions: { show: { authentication: ['queryAuth'] } },
		},
		{
			name: 'oAuth1Api',
			required: true,
			displayOptions: { show: { authentication: ['oAuth1'] } },
		},
		{
			name: 'oAuth2Api',
			required: true,
			displayOptions: { show: { authentication: ['oAuth2'] } },
		},
	],
	properties: [
		{
			displayName: 'Authentication',
			name: 'authentication',
			type: 'options',
			options: [
				{ name: 'Basic Auth', value: 'basicAuth' },
				{ name: 'Digest Auth', value: 'digestAuth' },
				{ name: 'Header Auth', value: 'headerAuth' },
				{ name: 'None', value: 'none' },
				{ name: 'OAuth1', value: 'oAuth1' },
				{ name: 'OAuth2', value: 'oAuth2' },
				{ name: 'Query Auth', value: 'queryAuth' },
			],
			default: 'none',
			description: 'The way to authenticate',
		},
		{
			displayName: 'Request Method',
			name: 'requestMethod',
			type: 'options',
			options: [
				{ name: 'DELETE', value: 'DELETE' },
				{ name: 'GET', value: 'GET' },
				{ name: 'HEAD', value: 'HEAD' },
				{ name: 'OPTIONS', value: 'OPTIONS' },
				{ name: 'PATCH', value: 'PATCH' },
				{ name: 'POST', value: 'POST' },
				{ name: 'PUT', value: 'PUT' },
			],
			default: 'GET',
			description: 'The request method to use',
		},
		{
			displayName: 'URL',
			name: 'url',
			type: 'string',
			default: '',
			placeholder: 'http://example.com/index.html',
			description: 'The URL to make the request to',
			required: true,
		},
		{
			displayName: 'Ignore SSL Issues',
			name: 'allowUnauthorizedCerts',
			type: 'boolean',
			default: false,
			description:
				'Whether to download the response even if SSL certificate validation is not possible',
		},
		{
			displayName: 'Response Format',
			name: 'responseFormat',
			type: 'options',
			options: [
				{ name: 'File', value: 'file' },
				{ name: 'JSON', value: 'json' },
				{ name: 'String', value: 'string' },
			],
			default: 'json',
			description: 'The format in which the data gets returned from the URL',
		},
		{
			displayName: 'Property Name',
			name: 'dataPropertyName',
			type: 'string',
			default: 'data',
			required: true,
			displayOptions: { show: { responseFormat: ['string'] } },
			description: 'Name of the property to which to write the response data',
		},
		{
			displayName: 'Binary Property',
			name: 'dataPropertyName',
			type: 'string',
			default: 'data',
			required: true,
			displayOptions: { show: { responseFormat: ['file'] } },
			description: 'Name of the binary property to which to write the data of the read file',
		},
		{
			displayName: 'JSON/RAW Parameters',
			name: 'jsonParameters',
			type: 'boolean',
			default: false,
			description:
				'Whether the query and/or body parameter should be set via the value-key pair UI or JSON/RAW',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			options: [
				{
					displayName: 'Batch Interval',
					name: 'batchInterval',
					type: 'number',
					typeOptions: { minValue: 0 },
					default: 1000,
					description: 'Time (in milliseconds) between each batch of requests. 0 for disabled.',
				},
				{
					displayName: 'Batch Size',
					name: 'batchSize',
					type: 'number',
					typeOptions: { minValue: -1 },
					default: 50,
					description:
						'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.',
				},
				{
					displayName: 'Body Content Type',
					name: 'bodyContentType',
					type: 'options',
					displayOptions: { show: { '/requestMethod': ['PATCH', 'POST', 'PUT'] } },
					options: [
						{ name: 'JSON', value: 'json' },
						{ name: 'RAW/Custom', value: 'raw' },
						{ name: 'Form-Data Multipart', value: 'multipart-form-data' },
						{ name: 'Form Urlencoded', value: 'form-urlencoded' },
					],
					default: 'json',
					description: 'Content-Type to use to send body parameters',
				},
				{
					displayName: 'Full Response',
					name: 'fullResponse',
					type: 'boolean',
					default: false,
					description: 'Whether to return the full response data instead of only the body',
				},
				{
					displayName: 'Follow All Redirects',
					name: 'followAllRedirects',
					type: 'boolean',
					default: false,
					description: 'Whether to follow non-GET HTTP 3xx redirects',
				},
				{
					displayName: 'Follow GET Redirect',
					name: 'followRedirect',
					type: 'boolean',
					default: true,
					description: 'Whether to follow GET HTTP 3xx redirects',
				},
				{
					displayName: 'Ignore Response Code',
					name: 'ignoreResponseCode',
					type: 'boolean',
					default: false,
					description: 'Whether to succeeds also when status code is not 2xx',
				},
				{
					displayName: 'MIME Type',
					name: 'bodyContentCustomMimeType',
					type: 'string',
					default: '',
					placeholder: 'text/xml',
					description: 'Specify the mime type for raw/custom body type',
					displayOptions: { show: { '/requestMethod': ['PATCH', 'POST', 'PUT'] } },
				},
				{
					displayName: 'Proxy',
					name: 'proxy',
					type: 'string',
					default: '',
					placeholder: 'http://myproxy:3128',
					description: 'HTTP proxy to use',
				},
				{
					displayName: 'Split Into Items',
					name: 'splitIntoItems',
					type: 'boolean',
					default: false,
					description: 'Whether to output each element of an array as own item',
					displayOptions: { show: { '/responseFormat': ['json'] } },
				},
				{
					displayName: 'Timeout',
					name: 'timeout',
					type: 'number',
					typeOptions: { minValue: 1 },
					default: 10000,
					description:
						'Time in ms to wait for the server to send response headers (and start the response body) before aborting the request',
				},
				{
					displayName: 'Use Querystring',
					name: 'useQueryString',
					type: 'boolean',
					default: false,
					description:
						'Whether you need arrays to be serialized as foo=bar&foo=baz instead of the default foo[0]=bar&foo[1]=baz',
				},
			],
		},
		{
			displayName: 'Send Binary Data',
			name: 'sendBinaryData',
			type: 'boolean',
			displayOptions: {
				show: { jsonParameters: [true], requestMethod: ['PATCH', 'POST', 'PUT'] },
			},
			default: false,
			description: 'Whether binary data should be send as body',
		},
		{
			displayName: 'Binary Property',
			name: 'binaryPropertyName',
			type: 'string',
			required: true,
			default: 'data',
			displayOptions: {
				hide: { sendBinaryData: [false] },
				show: { jsonParameters: [true], requestMethod: ['PATCH', 'POST', 'PUT'] },
			},
			description:
				'Name of the binary property which contains the data for the file to be uploaded. For Form-Data Multipart, they can be provided in the format: <code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2</code>',
		},
		{
			displayName: 'Body Parameters',
			name: 'bodyParametersJson',
			type: 'json',
			displayOptions: {
				hide: { sendBinaryData: [true] },
				show: { jsonParameters: [true], requestMethod: ['PATCH', 'POST', 'PUT', 'DELETE'] },
			},
			default: '',
			description: 'Body parameters as JSON or RAW',
		},
		{
			displayName: 'Body Parameters',
			name: 'bodyParametersUi',
			placeholder: 'Add Parameter',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: {
				show: { jsonParameters: [false], requestMethod: ['PATCH', 'POST', 'PUT', 'DELETE'] },
			},
			description: 'The body parameter to send',
			default: {},
			options: [
				{
					name: 'parameter',
					displayName: 'Parameter',
					values: [
						{
							displayName: 'Name',
							name: 'name',
							type: 'string',
							default: '',
							description: 'Name of the parameter',
						},
						{
							displayName: 'Value',
							name: 'value',
							type: 'string',
							default: '',
							description: 'Value of the parameter',
						},
					],
				},
			],
		},
		{
			displayName: 'Headers',
			name: 'headerParametersJson',
			type: 'json',
			displayOptions: { show: { jsonParameters: [true] } },
			default: '',
			description: 'Header parameters as JSON or RAW',
		},
		{
			displayName: 'Headers',
			name: 'headerParametersUi',
			placeholder: 'Add Header',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: { show: { jsonParameters: [false] } },
			description: 'The headers to send',
			default: {},
			options: [
				{
					name: 'parameter',
					displayName: 'Header',
					values: [
						{
							displayName: 'Name',
							name: 'name',
							type: 'string',
							default: '',
							description: 'Name of the header',
						},
						{
							displayName: 'Value',
							name: 'value',
							type: 'string',
							default: '',
							description: 'Value to set for the header',
						},
					],
				},
			],
		},
		{
			displayName: 'Query Parameters',
			name: 'queryParametersJson',
			type: 'json',
			displayOptions: { show: { jsonParameters: [true] } },
			default: '',
			description: 'Query parameters as JSON (flat object)',
		},
		{
			displayName: 'Query Parameters',
			name: 'queryParametersUi',
			placeholder: 'Add Parameter',
			type: 'fixedCollection',
			typeOptions: { multipleValues: true },
			displayOptions: { show: { jsonParameters: [false] } },
			description: 'The query parameter to send',
			default: {},
			options: [
				{
					name: 'parameter',
					displayName: 'Parameter',
					values: [
						{
							displayName: 'Name',
							name: 'name',
							type: 'string',
							default: '',
							description: 'Name of the parameter',
						},
						{
							displayName: 'Value',
							name: 'value',
							type: 'string',
							default: '',
							description: 'Value of the parameter',
						},
					],
				},
			],
		},
		{
			displayName:
				"You can view the raw requests this node makes in your browser's developer console",
			name: 'infoMessage',
			type: 'notice',
			default: '',
		},
	],
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/HttpRequest/httprequest.svg',
	codex: {
		categories: ['Development', 'Core Nodes'],
		subcategories: { 'Core Nodes': ['Helpers'] },
		resources: {
			primaryDocumentation: [
				{
					url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/',
				},
			],
		},
		alias: ['API', 'Request', 'URL', 'Build', 'cURL'],
	},
} satisfies INodeTypeDescription;

export const nodeTypeRespondToWebhookV1 = {
	displayName: 'Respond to Webhook',
	name: 'n8n-nodes-base.respondToWebhook',
	group: ['transform'],
	version: 1,
	description: 'Returns data for Webhook',
	defaults: { name: 'Respond to Webhook' },
	inputs: ['main'],
	outputs: ['main'],
	credentials: [],
	properties: [
		{
			displayName:
				'Verify that the "Webhook" node\'s "Respond" parameter is set to "Using Respond to Webhook Node". <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.respondtowebhook/" target="_blank">More details',
			name: 'generalNotice',
			type: 'notice',
			default: '',
		},
		{
			displayName: 'Respond With',
			name: 'respondWith',
			type: 'options',
			options: [
				{
					name: 'All Incoming Items',
					value: 'allIncomingItems',
					description: 'Respond with all input JSON items',
				},
				{
					name: 'Binary File',
					value: 'binary',
					description: 'Respond with incoming file binary data',
				},
				{
					name: 'First Incoming Item',
					value: 'firstIncomingItem',
					description: 'Respond with the first input JSON item',
				},
				{ name: 'JSON', value: 'json', description: 'Respond with a custom JSON body' },
				{ name: 'No Data', value: 'noData', description: 'Respond with an empty body' },
				{
					name: 'Redirect',
					value: 'redirect',
					description: 'Respond with a redirect to a given URL',
				},
				{ name: 'Text', value: 'text', description: 'Respond with a simple text message body' },
			],
			default: 'firstIncomingItem',
			description: 'The data that should be returned',
		},
		{
			displayName:
				'When using expressions, note that this node will only run for the first item in the input data',
			name: 'webhookNotice',
			type: 'notice',
			displayOptions: { show: { respondWith: ['json', 'text'] } },
			default: '',
		},
		{
			displayName: 'Redirect URL',
			name: 'redirectURL',
			type: 'string',
			required: true,
			displayOptions: { show: { respondWith: ['redirect'] } },
			default: '',
			placeholder: 'e.g. http://www.n8n.io',
			description: 'The URL to redirect to',
			validateType: 'url',
		},
		{
			displayName: 'Response Body',
			name: 'responseBody',
			type: 'json',
			displayOptions: { show: { respondWith: ['json'] } },
			default: '{\n  "myField": "value"\n}',
			typeOptions: { rows: 4 },
			description: 'The HTTP response JSON data',
		},
		{
			displayName: 'Response Body',
			name: 'responseBody',
			type: 'string',
			displayOptions: { show: { respondWith: ['text'] } },
			typeOptions: { rows: 2 },
			default: '',
			placeholder: 'e.g. Workflow completed',
			description: 'The HTTP response text data',
		},
		{
			displayName: 'Response Data Source',
			name: 'responseDataSource',
			type: 'options',
			displayOptions: { show: { respondWith: ['binary'] } },
			options: [
				{
					name: 'Choose Automatically From Input',
					value: 'automatically',
					description: 'Use if input data will contain a single piece of binary data',
				},
				{
					name: 'Specify Myself',
					value: 'set',
					description: 'Enter the name of the input field the binary data will be in',
				},
			],
			default: 'automatically',
		},
		{
			displayName: 'Input Field Name',
			name: 'inputFieldName',
			type: 'string',
			required: true,
			default: 'data',
			displayOptions: { show: { respondWith: ['binary'], responseDataSource: ['set'] } },
			description: 'The name of the node input field with the binary data',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			options: [
				{
					displayName: 'Response Code',
					name: 'responseCode',
					type: 'number',
					typeOptions: { minValue: 100, maxValue: 599 },
					default: 200,
					description: 'The HTTP response code to return. Defaults to 200.',
				},
				{
					displayName: 'Response Headers',
					name: 'responseHeaders',
					placeholder: 'Add Response Header',
					description: 'Add headers to the webhook response',
					type: 'fixedCollection',
					typeOptions: { multipleValues: true },
					default: {},
					options: [
						{
							name: 'entries',
							displayName: 'Entries',
							values: [
								{
									displayName: 'Name',
									name: 'name',
									type: 'string',
									default: '',
									description: 'Name of the header',
								},
								{
									displayName: 'Value',
									name: 'value',
									type: 'string',
									default: '',
									description: 'Value of the header',
								},
							],
						},
					],
				},
				{
					displayName: 'Put Response in Field',
					name: 'responseKey',
					type: 'string',
					displayOptions: { show: { '/respondWith': ['allIncomingItems', 'firstIncomingItem'] } },
					default: '',
					description: 'The name of the response field to put all items in',
					placeholder: 'e.g. data',
				},
			],
		},
	],
	codex: {
		categories: ['Core Nodes', 'Utility'],
		subcategories: { 'Core Nodes': ['Helpers'] },
		resources: {
			primaryDocumentation: [
				{
					url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.respondtowebhook/',
				},
			],
		},
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/RespondToWebhook/webhook.svg',
} satisfies INodeTypeDescription;

export const nodeTypeWebhookV1 = {
	displayName: 'Webhook',
	name: 'n8n-nodes-base.webhook',
	group: ['trigger'],
	version: [1, 1.1],
	description: 'Starts the workflow when a webhook is called',
	eventTriggerDescription: 'Waiting for you to call the Test URL',
	activationMessage: 'You can now make calls to your production webhook URL.',
	defaults: { name: 'Webhook' },
	supportsCORS: true,
	triggerPanel: {
		header: '',
		executionsHelp: {
			inactive:
				'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. <a data-key="activate">Activate</a> the workflow, then make requests to the production URL. These executions will show up in the executions list, but not in the editor.',
			active:
				'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. Since the workflow is activated, you can make requests to the production URL. These executions will show up in the <a data-key="executions">executions list</a>, but not in the editor.',
		},
		activationHint:
			'Once you’ve finished building your workflow, run it without having to click this button by using the production webhook URL.',
	},
	inputs: [],
	outputs: ['main'],
	credentials: [
		{
			name: 'httpBasicAuth',
			required: true,
			displayOptions: { show: { authentication: ['basicAuth'] } },
		},
		{
			name: 'httpHeaderAuth',
			required: true,
			displayOptions: { show: { authentication: ['headerAuth'] } },
		},
	],
	webhooks: [
		{
			name: 'default',
			httpMethod: '={{$parameter["httpMethod"] || "GET"}}',
			isFullPath: true,
			responseCode: '={{$parameter["responseCode"]}}',
			responseMode: '={{$parameter["responseMode"]}}',
			responseData:
				'={{$parameter["responseData"] || ($parameter.options.noResponseBody ? "noData" : undefined) }}',
			responseBinaryPropertyName: '={{$parameter["responseBinaryPropertyName"]}}',
			responseContentType: '={{$parameter["options"]["responseContentType"]}}',
			responsePropertyName: '={{$parameter["options"]["responsePropertyName"]}}',
			responseHeaders: '={{$parameter["options"]["responseHeaders"]}}',
			path: '={{$parameter["path"]}}',
		},
	],
	properties: [
		{
			displayName: 'Authentication',
			name: 'authentication',
			type: 'options',
			options: [
				{ name: 'Basic Auth', value: 'basicAuth' },
				{ name: 'Header Auth', value: 'headerAuth' },
				{ name: 'None', value: 'none' },
			],
			default: 'none',
			description: 'The way to authenticate',
		},
		{
			displayName: 'HTTP Method',
			name: 'httpMethod',
			type: 'options',
			options: [
				{ name: 'DELETE', value: 'DELETE' },
				{ name: 'GET', value: 'GET' },
				{ name: 'HEAD', value: 'HEAD' },
				{ name: 'PATCH', value: 'PATCH' },
				{ name: 'POST', value: 'POST' },
				{ name: 'PUT', value: 'PUT' },
			],
			default: 'GET',
			description: 'The HTTP method to listen to',
		},
		{
			displayName: 'Path',
			name: 'path',
			type: 'string',
			default: '',
			placeholder: 'webhook',
			required: true,
			description: 'The path to listen to',
		},
		{
			displayName: 'Respond',
			name: 'responseMode',
			type: 'options',
			options: [
				{
					name: 'Immediately',
					value: 'onReceived',
					description: 'As soon as this node executes',
				},
				{
					name: 'When Last Node Finishes',
					value: 'lastNode',
					description: 'Returns data of the last-executed node',
				},
				{
					name: "Using 'Respond to Webhook' Node",
					value: 'responseNode',
					description: 'Response defined in that node',
				},
			],
			default: 'onReceived',
			description: 'When and how to respond to the webhook',
		},
		{
			displayName:
				'Insert a \'Respond to Webhook\' node to control when and how you respond. <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.respondtowebhook/" target="_blank">More details</a>',
			name: 'webhookNotice',
			type: 'notice',
			displayOptions: { show: { responseMode: ['responseNode'] } },
			default: '',
		},
		{
			displayName: 'Response Code',
			name: 'responseCode',
			type: 'number',
			displayOptions: { hide: { responseMode: ['responseNode'] } },
			typeOptions: { minValue: 100, maxValue: 599 },
			default: 200,
			description: 'The HTTP Response code to return',
		},
		{
			displayName: 'Response Data',
			name: 'responseData',
			type: 'options',
			displayOptions: { show: { responseMode: ['lastNode'] } },
			options: [
				{
					name: 'All Entries',
					value: 'allEntries',
					description: 'Returns all the entries of the last node. Always returns an array.',
				},
				{
					name: 'First Entry JSON',
					value: 'firstEntryJson',
					description:
						'Returns the JSON data of the first entry of the last node. Always returns a JSON object.',
				},
				{
					name: 'First Entry Binary',
					value: 'firstEntryBinary',
					description:
						'Returns the binary data of the first entry of the last node. Always returns a binary file.',
				},
				{ name: 'No Response Body', value: 'noData', description: 'Returns without a body' },
			],
			default: 'firstEntryJson',
			description:
				'What data should be returned. If it should return all items as an array or only the first item as object.',
		},
		{
			displayName: 'Property Name',
			name: 'responseBinaryPropertyName',
			type: 'string',
			required: true,
			default: 'data',
			displayOptions: { show: { responseData: ['firstEntryBinary'] } },
			description: 'Name of the binary property to return',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			options: [
				{
					displayName: 'Binary Data',
					name: 'binaryData',
					type: 'boolean',
					displayOptions: { show: { '/httpMethod': ['PATCH', 'PUT', 'POST'], '@version': [1] } },
					default: false,
					description: 'Whether the webhook will receive binary data',
				},
				{
					displayName: 'Binary Property',
					name: 'binaryPropertyName',
					type: 'string',
					default: 'data',
					displayOptions: { show: { binaryData: [true], '@version': [1] } },
					description:
						'Name of the binary property to write the data of the received file to. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.',
				},
				{
					displayName: 'Binary Property',
					name: 'binaryPropertyName',
					type: 'string',
					default: 'data',
					displayOptions: { hide: { '@version': [1] } },
					description:
						'Name of the binary property to write the data of the received file to, only relevant if binary data is received',
				},
				{
					displayName: 'Ignore Bots',
					name: 'ignoreBots',
					type: 'boolean',
					default: false,
					description: 'Whether to ignore requests from bots like link previewers and web crawlers',
				},
				{
					displayName: 'No Response Body',
					name: 'noResponseBody',
					type: 'boolean',
					default: false,
					description: 'Whether to send any body in the response',
					displayOptions: {
						hide: { rawBody: [true] },
						show: { '/responseMode': ['onReceived'] },
					},
				},
				{
					displayName: 'Raw Body',
					name: 'rawBody',
					type: 'boolean',
					displayOptions: {
						show: { '@version': [1] },
						hide: { binaryData: [true], noResponseBody: [true] },
					},
					default: false,
					description: 'Raw body (binary)',
				},
				{
					displayName: 'Raw Body',
					name: 'rawBody',
					type: 'boolean',
					displayOptions: { hide: { noResponseBody: [true], '@version': [1] } },
					default: false,
					description: 'Whether to return the raw body',
				},
				{
					displayName: 'Response Data',
					name: 'responseData',
					type: 'string',
					displayOptions: {
						show: { '/responseMode': ['onReceived'] },
						hide: { noResponseBody: [true] },
					},
					default: '',
					placeholder: 'success',
					description: 'Custom response data to send',
				},
				{
					displayName: 'Response Content-Type',
					name: 'responseContentType',
					type: 'string',
					displayOptions: {
						show: { '/responseData': ['firstEntryJson'], '/responseMode': ['lastNode'] },
					},
					default: '',
					placeholder: 'application/xml',
					description:
						'Set a custom content-type to return if another one as the "application/json" should be returned',
				},
				{
					displayName: 'Response Headers',
					name: 'responseHeaders',
					placeholder: 'Add Response Header',
					description: 'Add headers to the webhook response',
					type: 'fixedCollection',
					typeOptions: { multipleValues: true },
					default: {},
					options: [
						{
							name: 'entries',
							displayName: 'Entries',
							values: [
								{
									displayName: 'Name',
									name: 'name',
									type: 'string',
									default: '',
									description: 'Name of the header',
								},
								{
									displayName: 'Value',
									name: 'value',
									type: 'string',
									default: '',
									description: 'Value of the header',
								},
							],
						},
					],
				},
				{
					displayName: 'Property Name',
					name: 'responsePropertyName',
					type: 'string',
					displayOptions: {
						show: { '/responseData': ['firstEntryJson'], '/responseMode': ['lastNode'] },
					},
					default: 'data',
					description: 'Name of the property to return the data of instead of the whole JSON',
				},
				{
					displayName: 'Allowed Origins (CORS)',
					name: 'allowedOrigins',
					type: 'string',
					default: '*',
					description:
						'The origin(s) to allow cross-origin non-preflight requests from in a browser',
				},
			],
		},
	],
	codex: {
		categories: ['Development', 'Core Nodes'],
		subcategories: { 'Core Nodes': ['Helpers'] },
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook/' },
			],
		},
		alias: ['HTTP', 'API', 'Build', 'WH'],
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Webhook/webhook.svg',
} satisfies INodeTypeDescription;

export const nodeTypeWebhookV1_1 = {
	displayName: 'Webhook',
	name: 'n8n-nodes-base.webhook',
	group: ['trigger'],
	version: [1, 1.1],
	description: 'Starts the workflow when a webhook is called',
	eventTriggerDescription: 'Waiting for you to call the Test URL',
	activationMessage: 'You can now make calls to your production webhook URL.',
	defaults: { name: 'Webhook' },
	supportsCORS: true,
	triggerPanel: {
		header: '',
		executionsHelp: {
			inactive:
				'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. <a data-key="activate">Activate</a> the workflow, then make requests to the production URL. These executions will show up in the executions list, but not in the editor.',
			active:
				'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. Since the workflow is activated, you can make requests to the production URL. These executions will show up in the <a data-key="executions">executions list</a>, but not in the editor.',
		},
		activationHint:
			'Once you’ve finished building your workflow, run it without having to click this button by using the production webhook URL.',
	},
	inputs: [],
	outputs: ['main'],
	credentials: [
		{
			name: 'httpBasicAuth',
			required: true,
			displayOptions: { show: { authentication: ['basicAuth'] } },
		},
		{
			name: 'httpHeaderAuth',
			required: true,
			displayOptions: { show: { authentication: ['headerAuth'] } },
		},
	],
	webhooks: [
		{
			name: 'default',
			httpMethod: '={{$parameter["httpMethod"] || "GET"}}',
			isFullPath: true,
			responseCode: '={{$parameter["responseCode"]}}',
			responseMode: '={{$parameter["responseMode"]}}',
			responseData:
				'={{$parameter["responseData"] || ($parameter.options.noResponseBody ? "noData" : undefined) }}',
			responseBinaryPropertyName: '={{$parameter["responseBinaryPropertyName"]}}',
			responseContentType: '={{$parameter["options"]["responseContentType"]}}',
			responsePropertyName: '={{$parameter["options"]["responsePropertyName"]}}',
			responseHeaders: '={{$parameter["options"]["responseHeaders"]}}',
			path: '={{$parameter["path"]}}',
		},
	],
	properties: [
		{
			displayName: 'Authentication',
			name: 'authentication',
			type: 'options',
			options: [
				{ name: 'Basic Auth', value: 'basicAuth' },
				{ name: 'Header Auth', value: 'headerAuth' },
				{ name: 'None', value: 'none' },
			],
			default: 'none',
			description: 'The way to authenticate',
		},
		{
			displayName: 'HTTP Method',
			name: 'httpMethod',
			type: 'options',
			options: [
				{ name: 'DELETE', value: 'DELETE' },
				{ name: 'GET', value: 'GET' },
				{ name: 'HEAD', value: 'HEAD' },
				{ name: 'PATCH', value: 'PATCH' },
				{ name: 'POST', value: 'POST' },
				{ name: 'PUT', value: 'PUT' },
			],
			default: 'GET',
			description: 'The HTTP method to listen to',
		},
		{
			displayName: 'Path',
			name: 'path',
			type: 'string',
			default: '',
			placeholder: 'webhook',
			required: true,
			description: 'The path to listen to',
		},
		{
			displayName: 'Respond',
			name: 'responseMode',
			type: 'options',
			options: [
				{
					name: 'Immediately',
					value: 'onReceived',
					description: 'As soon as this node executes',
				},
				{
					name: 'When Last Node Finishes',
					value: 'lastNode',
					description: 'Returns data of the last-executed node',
				},
				{
					name: "Using 'Respond to Webhook' Node",
					value: 'responseNode',
					description: 'Response defined in that node',
				},
			],
			default: 'onReceived',
			description: 'When and how to respond to the webhook',
		},
		{
			displayName:
				'Insert a \'Respond to Webhook\' node to control when and how you respond. <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.respondtowebhook/" target="_blank">More details</a>',
			name: 'webhookNotice',
			type: 'notice',
			displayOptions: { show: { responseMode: ['responseNode'] } },
			default: '',
		},
		{
			displayName: 'Response Code',
			name: 'responseCode',
			type: 'number',
			displayOptions: { hide: { responseMode: ['responseNode'] } },
			typeOptions: { minValue: 100, maxValue: 599 },
			default: 200,
			description: 'The HTTP Response code to return',
		},
		{
			displayName: 'Response Data',
			name: 'responseData',
			type: 'options',
			displayOptions: { show: { responseMode: ['lastNode'] } },
			options: [
				{
					name: 'All Entries',
					value: 'allEntries',
					description: 'Returns all the entries of the last node. Always returns an array.',
				},
				{
					name: 'First Entry JSON',
					value: 'firstEntryJson',
					description:
						'Returns the JSON data of the first entry of the last node. Always returns a JSON object.',
				},
				{
					name: 'First Entry Binary',
					value: 'firstEntryBinary',
					description:
						'Returns the binary data of the first entry of the last node. Always returns a binary file.',
				},
				{ name: 'No Response Body', value: 'noData', description: 'Returns without a body' },
			],
			default: 'firstEntryJson',
			description:
				'What data should be returned. If it should return all items as an array or only the first item as object.',
		},
		{
			displayName: 'Property Name',
			name: 'responseBinaryPropertyName',
			type: 'string',
			required: true,
			default: 'data',
			displayOptions: { show: { responseData: ['firstEntryBinary'] } },
			description: 'Name of the binary property to return',
		},
		{
			displayName: 'Options',
			name: 'options',
			type: 'collection',
			placeholder: 'Add Option',
			default: {},
			options: [
				{
					displayName: 'Binary Data',
					name: 'binaryData',
					type: 'boolean',
					displayOptions: { show: { '/httpMethod': ['PATCH', 'PUT', 'POST'], '@version': [1] } },
					default: false,
					description: 'Whether the webhook will receive binary data',
				},
				{
					displayName: 'Binary Property',
					name: 'binaryPropertyName',
					type: 'string',
					default: 'data',
					displayOptions: { show: { binaryData: [true], '@version': [1] } },
					description:
						'Name of the binary property to write the data of the received file to. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.',
				},
				{
					displayName: 'Binary Property',
					name: 'binaryPropertyName',
					type: 'string',
					default: 'data',
					displayOptions: { hide: { '@version': [1] } },
					description:
						'Name of the binary property to write the data of the received file to, only relevant if binary data is received',
				},
				{
					displayName: 'Ignore Bots',
					name: 'ignoreBots',
					type: 'boolean',
					default: false,
					description: 'Whether to ignore requests from bots like link previewers and web crawlers',
				},
				{
					displayName: 'No Response Body',
					name: 'noResponseBody',
					type: 'boolean',
					default: false,
					description: 'Whether to send any body in the response',
					displayOptions: {
						hide: { rawBody: [true] },
						show: { '/responseMode': ['onReceived'] },
					},
				},
				{
					displayName: 'Raw Body',
					name: 'rawBody',
					type: 'boolean',
					displayOptions: {
						show: { '@version': [1] },
						hide: { binaryData: [true], noResponseBody: [true] },
					},
					default: false,
					description: 'Raw body (binary)',
				},
				{
					displayName: 'Raw Body',
					name: 'rawBody',
					type: 'boolean',
					displayOptions: { hide: { noResponseBody: [true], '@version': [1] } },
					default: false,
					description: 'Whether to return the raw body',
				},
				{
					displayName: 'Response Data',
					name: 'responseData',
					type: 'string',
					displayOptions: {
						show: { '/responseMode': ['onReceived'] },
						hide: { noResponseBody: [true] },
					},
					default: '',
					placeholder: 'success',
					description: 'Custom response data to send',
				},
				{
					displayName: 'Response Content-Type',
					name: 'responseContentType',
					type: 'string',
					displayOptions: {
						show: { '/responseData': ['firstEntryJson'], '/responseMode': ['lastNode'] },
					},
					default: '',
					placeholder: 'application/xml',
					description:
						'Set a custom content-type to return if another one as the "application/json" should be returned',
				},
				{
					displayName: 'Response Headers',
					name: 'responseHeaders',
					placeholder: 'Add Response Header',
					description: 'Add headers to the webhook response',
					type: 'fixedCollection',
					typeOptions: { multipleValues: true },
					default: {},
					options: [
						{
							name: 'entries',
							displayName: 'Entries',
							values: [
								{
									displayName: 'Name',
									name: 'name',
									type: 'string',
									default: '',
									description: 'Name of the header',
								},
								{
									displayName: 'Value',
									name: 'value',
									type: 'string',
									default: '',
									description: 'Value of the header',
								},
							],
						},
					],
				},
				{
					displayName: 'Property Name',
					name: 'responsePropertyName',
					type: 'string',
					displayOptions: {
						show: { '/responseData': ['firstEntryJson'], '/responseMode': ['lastNode'] },
					},
					default: 'data',
					description: 'Name of the property to return the data of instead of the whole JSON',
				},
				{
					displayName: 'Allowed Origins (CORS)',
					name: 'allowedOrigins',
					type: 'string',
					default: '*',
					description:
						'The origin(s) to allow cross-origin non-preflight requests from in a browser',
				},
			],
		},
	],
	codex: {
		categories: ['Development', 'Core Nodes'],
		subcategories: { 'Core Nodes': ['Helpers'] },
		resources: {
			primaryDocumentation: [
				{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook/' },
			],
		},
		alias: ['HTTP', 'API', 'Build', 'WH'],
	},
	iconUrl: 'icons/n8n-nodes-base/dist/nodes/Webhook/webhook.svg',
} satisfies INodeTypeDescription;

export const nodeTypesSet = {
	'1': {
		displayName: 'Set',
		name: 'n8n-nodes-base.set',
		icon: 'fa:pen',
		group: ['input'],
		description: 'Sets values on items and optionally remove other values',
		defaultVersion: 3.2,
		version: [1, 2],
		defaults: { name: 'Set', color: '#0000FF' },
		inputs: ['main'],
		outputs: ['main'],
		properties: [
			{
				displayName: 'Keep Only Set',
				name: 'keepOnlySet',
				type: 'boolean',
				default: false,
				description:
					'Whether only the values set on this node should be kept and all others removed',
			},
			{
				displayName: 'Values to Set',
				name: 'values',
				placeholder: 'Add Value',
				type: 'fixedCollection',
				typeOptions: { multipleValues: true, sortable: true },
				description: 'The value to set',
				default: {},
				options: [
					{
						name: 'boolean',
						displayName: 'Boolean',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								requiresDataPath: 'single',
								default: 'propertyName',
								description:
									'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
							},
							{
								displayName: 'Value',
								name: 'value',
								type: 'boolean',
								default: false,
								description: 'The boolean value to write in the property',
							},
						],
					},
					{
						name: 'number',
						displayName: 'Number',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: 'propertyName',
								requiresDataPath: 'single',
								description:
									'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
							},
							{
								displayName: 'Value',
								name: 'value',
								type: 'number',
								default: 0,
								description: 'The number value to write in the property',
							},
						],
					},
					{
						name: 'string',
						displayName: 'String',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: 'propertyName',
								requiresDataPath: 'single',
								description:
									'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
							},
							{
								displayName: 'Value',
								name: 'value',
								type: 'string',
								default: '',
								description: 'The string value to write in the property',
							},
						],
					},
				],
			},
			{
				displayName: 'Options',
				name: 'options',
				type: 'collection',
				placeholder: 'Add Option',
				default: {},
				options: [
					{
						displayName: 'Dot Notation',
						name: 'dotNotation',
						type: 'boolean',
						default: true,
						description:
							'<p>By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.<p></p>If that is not intended this can be deactivated, it will then set { "a.b": value } instead.</p>.',
					},
				],
			},
		],
		codex: {
			categories: ['Core Nodes'],
			subcategories: { 'Core Nodes': ['Data Transformation'] },
			resources: {
				primaryDocumentation: [
					{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/' },
				],
			},
			alias: ['Set', 'JSON', 'Filter', 'Transform', 'Map'],
		},
	},
	'2': {
		displayName: 'Set',
		name: 'n8n-nodes-base.set',
		icon: 'fa:pen',
		group: ['input'],
		description: 'Sets values on items and optionally remove other values',
		defaultVersion: 3.2,
		version: [1, 2],
		defaults: { name: 'Set', color: '#0000FF' },
		inputs: ['main'],
		outputs: ['main'],
		properties: [
			{
				displayName: 'Keep Only Set',
				name: 'keepOnlySet',
				type: 'boolean',
				default: false,
				description:
					'Whether only the values set on this node should be kept and all others removed',
			},
			{
				displayName: 'Values to Set',
				name: 'values',
				placeholder: 'Add Value',
				type: 'fixedCollection',
				typeOptions: { multipleValues: true, sortable: true },
				description: 'The value to set',
				default: {},
				options: [
					{
						name: 'boolean',
						displayName: 'Boolean',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								requiresDataPath: 'single',
								default: 'propertyName',
								description:
									'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
							},
							{
								displayName: 'Value',
								name: 'value',
								type: 'boolean',
								default: false,
								description: 'The boolean value to write in the property',
							},
						],
					},
					{
						name: 'number',
						displayName: 'Number',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: 'propertyName',
								requiresDataPath: 'single',
								description:
									'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
							},
							{
								displayName: 'Value',
								name: 'value',
								type: 'number',
								default: 0,
								description: 'The number value to write in the property',
							},
						],
					},
					{
						name: 'string',
						displayName: 'String',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: 'propertyName',
								requiresDataPath: 'single',
								description:
									'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
							},
							{
								displayName: 'Value',
								name: 'value',
								type: 'string',
								default: '',
								description: 'The string value to write in the property',
							},
						],
					},
				],
			},
			{
				displayName: 'Options',
				name: 'options',
				type: 'collection',
				placeholder: 'Add Option',
				default: {},
				options: [
					{
						displayName: 'Dot Notation',
						name: 'dotNotation',
						type: 'boolean',
						default: true,
						description:
							'<p>By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.<p></p>If that is not intended this can be deactivated, it will then set { "a.b": value } instead.</p>.',
					},
				],
			},
		],
		codex: {
			categories: ['Core Nodes'],
			subcategories: { 'Core Nodes': ['Data Transformation'] },
			resources: {
				primaryDocumentation: [
					{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/' },
				],
			},
			alias: ['Set', 'JSON', 'Filter', 'Transform', 'Map'],
		},
	},
	'3': {
		displayName: 'Edit Fields (Set)',
		name: 'n8n-nodes-base.set',
		icon: 'fa:pen',
		group: ['input'],
		description: 'Modify, add, or remove item fields',
		defaultVersion: 3.2,
		version: [3, 3.1, 3.2],
		subtitle: '={{$parameter["mode"]}}',
		defaults: { name: 'Edit Fields', color: '#0000FF' },
		inputs: ['main'],
		outputs: ['main'],
		properties: [
			{
				displayName: 'Mode',
				name: 'mode',
				type: 'options',
				noDataExpression: true,
				options: [
					{
						name: 'Manual Mapping',
						value: 'manual',
						description: 'Edit item fields one by one',
						action: 'Edit item fields one by one',
					},
					{
						name: 'JSON Output',
						value: 'raw',
						description: 'Customize item output with JSON',
						action: 'Customize item output with JSON',
					},
				],
				default: 'manual',
			},
			{
				displayName: 'Duplicate Item',
				name: 'duplicateItem',
				type: 'boolean',
				default: false,
				isNodeSetting: true,
			},
			{
				displayName: 'Duplicate Item Count',
				name: 'duplicateCount',
				type: 'number',
				default: 0,
				typeOptions: { minValue: 0 },
				description:
					'How many times the item should be duplicated, mainly used for testing and debugging',
				isNodeSetting: true,
				displayOptions: { show: { duplicateItem: [true] } },
			},
			{
				displayName:
					'Item duplication is set in the node settings. This option will be ignored when the workflow runs automatically.',
				name: 'duplicateWarning',
				type: 'notice',
				default: '',
				displayOptions: { show: { duplicateItem: [true] } },
			},
			{
				displayName: 'JSON Output',
				name: 'jsonOutput',
				type: 'json',
				typeOptions: { rows: 5 },
				default: '{\n  "my_field_1": "value",\n  "my_field_2": 1\n}',
				validateType: 'object',
				ignoreValidationDuringExecution: true,
				displayOptions: { show: { mode: ['raw'] } },
			},
			{
				displayName: 'Fields to Set',
				name: 'fields',
				placeholder: 'Add Field',
				type: 'fixedCollection',
				description: 'Edit existing fields or add new ones to modify the output data',
				typeOptions: { multipleValues: true, sortable: true },
				default: {},
				options: [
					{
						name: 'values',
						displayName: 'Values',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: '',
								placeholder: 'e.g. fieldName',
								description:
									'Name of the field to set the value of. Supports dot-notation. Example: data.person[0].name.',
								requiresDataPath: 'single',
							},
							{
								displayName: 'Type',
								name: 'type',
								type: 'options',
								description: 'The field value type',
								options: [
									{ name: 'String', value: 'stringValue' },
									{ name: 'Number', value: 'numberValue' },
									{ name: 'Boolean', value: 'booleanValue' },
									{ name: 'Array', value: 'arrayValue' },
									{ name: 'Object', value: 'objectValue' },
								],
								default: 'stringValue',
							},
							{
								displayName: 'Value',
								name: 'stringValue',
								type: 'string',
								default: '',
								displayOptions: { show: { type: ['stringValue'] } },
								validateType: 'string',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'numberValue',
								type: 'string',
								default: '',
								displayOptions: { show: { type: ['numberValue'] } },
								validateType: 'number',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'booleanValue',
								type: 'options',
								default: 'true',
								options: [
									{ name: 'True', value: 'true' },
									{ name: 'False', value: 'false' },
								],
								displayOptions: { show: { type: ['booleanValue'] } },
								validateType: 'boolean',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'arrayValue',
								type: 'string',
								default: '',
								placeholder: 'e.g. [ arrayItem1, arrayItem2, arrayItem3 ]',
								displayOptions: { show: { type: ['arrayValue'] } },
								validateType: 'array',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'objectValue',
								type: 'json',
								default: '={}',
								typeOptions: { rows: 2 },
								displayOptions: { show: { type: ['objectValue'] } },
								validateType: 'object',
								ignoreValidationDuringExecution: true,
							},
						],
					},
				],
				displayOptions: { show: { mode: ['manual'] } },
			},
			{
				displayName: 'Include in Output',
				name: 'include',
				type: 'options',
				description: 'How to select the fields you want to include in your output items',
				default: 'all',
				options: [
					{
						name: 'All Input Fields',
						value: 'all',
						description: 'Also include all unchanged fields from the input',
					},
					{
						name: 'No Input Fields',
						value: 'none',
						description: 'Include only the fields specified above',
					},
					{
						name: 'Selected Input Fields',
						value: 'selected',
						description: 'Also include the fields listed in the parameter “Fields to Include”',
					},
					{
						name: 'All Input Fields Except',
						value: 'except',
						description: 'Exclude the fields listed in the parameter “Fields to Exclude”',
					},
				],
			},
			{
				displayName: 'Fields to Include',
				name: 'includeFields',
				type: 'string',
				default: '',
				placeholder: 'e.g. fieldToInclude1,fieldToInclude2',
				description:
					'Comma-separated list of the field names you want to include in the output. You can drag the selected fields from the input panel.',
				requiresDataPath: 'multiple',
				displayOptions: { show: { include: ['selected'] } },
			},
			{
				displayName: 'Fields to Exclude',
				name: 'excludeFields',
				type: 'string',
				default: '',
				placeholder: 'e.g. fieldToExclude1,fieldToExclude2',
				description:
					'Comma-separated list of the field names you want to exclude from the output. You can drag the selected fields from the input panel.',
				requiresDataPath: 'multiple',
				displayOptions: { show: { include: ['except'] } },
			},
			{
				displayName: 'Options',
				name: 'options',
				type: 'collection',
				placeholder: 'Add Option',
				default: {},
				options: [
					{
						displayName: 'Include Binary Data',
						name: 'includeBinary',
						type: 'boolean',
						default: true,
						description: 'Whether binary data should be included if present in the input item',
					},
					{
						displayName: 'Ignore Type Conversion Errors',
						name: 'ignoreConversionErrors',
						type: 'boolean',
						default: false,
						description:
							'Whether to ignore field type errors and apply a less strict type conversion',
						displayOptions: { show: { '/mode': ['manual'] } },
					},
					{
						displayName: 'Support Dot Notation',
						name: 'dotNotation',
						type: 'boolean',
						default: true,
						description:
							'By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }. If that is not intended this can be deactivated, it will then set { "a.b": value } instead.',
					},
				],
			},
		],
		codex: {
			categories: ['Core Nodes'],
			subcategories: { 'Core Nodes': ['Data Transformation'] },
			resources: {
				primaryDocumentation: [
					{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/' },
				],
			},
			alias: ['Set', 'JSON', 'Filter', 'Transform', 'Map'],
		},
	},
	'3.1': {
		displayName: 'Edit Fields (Set)',
		name: 'n8n-nodes-base.set',
		icon: 'fa:pen',
		group: ['input'],
		description: 'Modify, add, or remove item fields',
		defaultVersion: 3.2,
		version: [3, 3.1, 3.2],
		subtitle: '={{$parameter["mode"]}}',
		defaults: { name: 'Edit Fields', color: '#0000FF' },
		inputs: ['main'],
		outputs: ['main'],
		properties: [
			{
				displayName: 'Mode',
				name: 'mode',
				type: 'options',
				noDataExpression: true,
				options: [
					{
						name: 'Manual Mapping',
						value: 'manual',
						description: 'Edit item fields one by one',
						action: 'Edit item fields one by one',
					},
					{
						name: 'JSON Output',
						value: 'raw',
						description: 'Customize item output with JSON',
						action: 'Customize item output with JSON',
					},
				],
				default: 'manual',
			},
			{
				displayName: 'Duplicate Item',
				name: 'duplicateItem',
				type: 'boolean',
				default: false,
				isNodeSetting: true,
			},
			{
				displayName: 'Duplicate Item Count',
				name: 'duplicateCount',
				type: 'number',
				default: 0,
				typeOptions: { minValue: 0 },
				description:
					'How many times the item should be duplicated, mainly used for testing and debugging',
				isNodeSetting: true,
				displayOptions: { show: { duplicateItem: [true] } },
			},
			{
				displayName:
					'Item duplication is set in the node settings. This option will be ignored when the workflow runs automatically.',
				name: 'duplicateWarning',
				type: 'notice',
				default: '',
				displayOptions: { show: { duplicateItem: [true] } },
			},
			{
				displayName: 'JSON Output',
				name: 'jsonOutput',
				type: 'json',
				typeOptions: { rows: 5 },
				default: '{\n  "my_field_1": "value",\n  "my_field_2": 1\n}',
				validateType: 'object',
				ignoreValidationDuringExecution: true,
				displayOptions: { show: { mode: ['raw'] } },
			},
			{
				displayName: 'Fields to Set',
				name: 'fields',
				placeholder: 'Add Field',
				type: 'fixedCollection',
				description: 'Edit existing fields or add new ones to modify the output data',
				typeOptions: { multipleValues: true, sortable: true },
				default: {},
				options: [
					{
						name: 'values',
						displayName: 'Values',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: '',
								placeholder: 'e.g. fieldName',
								description:
									'Name of the field to set the value of. Supports dot-notation. Example: data.person[0].name.',
								requiresDataPath: 'single',
							},
							{
								displayName: 'Type',
								name: 'type',
								type: 'options',
								description: 'The field value type',
								options: [
									{ name: 'String', value: 'stringValue' },
									{ name: 'Number', value: 'numberValue' },
									{ name: 'Boolean', value: 'booleanValue' },
									{ name: 'Array', value: 'arrayValue' },
									{ name: 'Object', value: 'objectValue' },
								],
								default: 'stringValue',
							},
							{
								displayName: 'Value',
								name: 'stringValue',
								type: 'string',
								default: '',
								displayOptions: { show: { type: ['stringValue'] } },
								validateType: 'string',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'numberValue',
								type: 'string',
								default: '',
								displayOptions: { show: { type: ['numberValue'] } },
								validateType: 'number',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'booleanValue',
								type: 'options',
								default: 'true',
								options: [
									{ name: 'True', value: 'true' },
									{ name: 'False', value: 'false' },
								],
								displayOptions: { show: { type: ['booleanValue'] } },
								validateType: 'boolean',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'arrayValue',
								type: 'string',
								default: '',
								placeholder: 'e.g. [ arrayItem1, arrayItem2, arrayItem3 ]',
								displayOptions: { show: { type: ['arrayValue'] } },
								validateType: 'array',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'objectValue',
								type: 'json',
								default: '={}',
								typeOptions: { rows: 2 },
								displayOptions: { show: { type: ['objectValue'] } },
								validateType: 'object',
								ignoreValidationDuringExecution: true,
							},
						],
					},
				],
				displayOptions: { show: { mode: ['manual'] } },
			},
			{
				displayName: 'Include in Output',
				name: 'include',
				type: 'options',
				description: 'How to select the fields you want to include in your output items',
				default: 'all',
				options: [
					{
						name: 'All Input Fields',
						value: 'all',
						description: 'Also include all unchanged fields from the input',
					},
					{
						name: 'No Input Fields',
						value: 'none',
						description: 'Include only the fields specified above',
					},
					{
						name: 'Selected Input Fields',
						value: 'selected',
						description: 'Also include the fields listed in the parameter “Fields to Include”',
					},
					{
						name: 'All Input Fields Except',
						value: 'except',
						description: 'Exclude the fields listed in the parameter “Fields to Exclude”',
					},
				],
			},
			{
				displayName: 'Fields to Include',
				name: 'includeFields',
				type: 'string',
				default: '',
				placeholder: 'e.g. fieldToInclude1,fieldToInclude2',
				description:
					'Comma-separated list of the field names you want to include in the output. You can drag the selected fields from the input panel.',
				requiresDataPath: 'multiple',
				displayOptions: { show: { include: ['selected'] } },
			},
			{
				displayName: 'Fields to Exclude',
				name: 'excludeFields',
				type: 'string',
				default: '',
				placeholder: 'e.g. fieldToExclude1,fieldToExclude2',
				description:
					'Comma-separated list of the field names you want to exclude from the output. You can drag the selected fields from the input panel.',
				requiresDataPath: 'multiple',
				displayOptions: { show: { include: ['except'] } },
			},
			{
				displayName: 'Options',
				name: 'options',
				type: 'collection',
				placeholder: 'Add Option',
				default: {},
				options: [
					{
						displayName: 'Include Binary Data',
						name: 'includeBinary',
						type: 'boolean',
						default: true,
						description: 'Whether binary data should be included if present in the input item',
					},
					{
						displayName: 'Ignore Type Conversion Errors',
						name: 'ignoreConversionErrors',
						type: 'boolean',
						default: false,
						description:
							'Whether to ignore field type errors and apply a less strict type conversion',
						displayOptions: { show: { '/mode': ['manual'] } },
					},
					{
						displayName: 'Support Dot Notation',
						name: 'dotNotation',
						type: 'boolean',
						default: true,
						description:
							'By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }. If that is not intended this can be deactivated, it will then set { "a.b": value } instead.',
					},
				],
			},
		],
		codex: {
			categories: ['Core Nodes'],
			subcategories: { 'Core Nodes': ['Data Transformation'] },
			resources: {
				primaryDocumentation: [
					{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/' },
				],
			},
			alias: ['Set', 'JSON', 'Filter', 'Transform', 'Map'],
		},
	},
	'3.2': {
		displayName: 'Edit Fields (Set)',
		name: 'n8n-nodes-base.set',
		icon: 'fa:pen',
		group: ['input'],
		description: 'Modify, add, or remove item fields',
		defaultVersion: 3.2,
		version: [3, 3.1, 3.2],
		subtitle: '={{$parameter["mode"]}}',
		defaults: { name: 'Edit Fields', color: '#0000FF' },
		inputs: ['main'],
		outputs: ['main'],
		properties: [
			{
				displayName: 'Mode',
				name: 'mode',
				type: 'options',
				noDataExpression: true,
				options: [
					{
						name: 'Manual Mapping',
						value: 'manual',
						description: 'Edit item fields one by one',
						action: 'Edit item fields one by one',
					},
					{
						name: 'JSON Output',
						value: 'raw',
						description: 'Customize item output with JSON',
						action: 'Customize item output with JSON',
					},
				],
				default: 'manual',
			},
			{
				displayName: 'Duplicate Item',
				name: 'duplicateItem',
				type: 'boolean',
				default: false,
				isNodeSetting: true,
			},
			{
				displayName: 'Duplicate Item Count',
				name: 'duplicateCount',
				type: 'number',
				default: 0,
				typeOptions: { minValue: 0 },
				description:
					'How many times the item should be duplicated, mainly used for testing and debugging',
				isNodeSetting: true,
				displayOptions: { show: { duplicateItem: [true] } },
			},
			{
				displayName:
					'Item duplication is set in the node settings. This option will be ignored when the workflow runs automatically.',
				name: 'duplicateWarning',
				type: 'notice',
				default: '',
				displayOptions: { show: { duplicateItem: [true] } },
			},
			{
				displayName: 'JSON Output',
				name: 'jsonOutput',
				type: 'json',
				typeOptions: { rows: 5 },
				default: '{\n  "my_field_1": "value",\n  "my_field_2": 1\n}',
				validateType: 'object',
				ignoreValidationDuringExecution: true,
				displayOptions: { show: { mode: ['raw'] } },
			},
			{
				displayName: 'Fields to Set',
				name: 'fields',
				placeholder: 'Add Field',
				type: 'fixedCollection',
				description: 'Edit existing fields or add new ones to modify the output data',
				typeOptions: { multipleValues: true, sortable: true },
				default: {},
				options: [
					{
						name: 'values',
						displayName: 'Values',
						values: [
							{
								displayName: 'Name',
								name: 'name',
								type: 'string',
								default: '',
								placeholder: 'e.g. fieldName',
								description:
									'Name of the field to set the value of. Supports dot-notation. Example: data.person[0].name.',
								requiresDataPath: 'single',
							},
							{
								displayName: 'Type',
								name: 'type',
								type: 'options',
								description: 'The field value type',
								options: [
									{ name: 'String', value: 'stringValue' },
									{ name: 'Number', value: 'numberValue' },
									{ name: 'Boolean', value: 'booleanValue' },
									{ name: 'Array', value: 'arrayValue' },
									{ name: 'Object', value: 'objectValue' },
								],
								default: 'stringValue',
							},
							{
								displayName: 'Value',
								name: 'stringValue',
								type: 'string',
								default: '',
								displayOptions: { show: { type: ['stringValue'] } },
								validateType: 'string',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'numberValue',
								type: 'string',
								default: '',
								displayOptions: { show: { type: ['numberValue'] } },
								validateType: 'number',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'booleanValue',
								type: 'options',
								default: 'true',
								options: [
									{ name: 'True', value: 'true' },
									{ name: 'False', value: 'false' },
								],
								displayOptions: { show: { type: ['booleanValue'] } },
								validateType: 'boolean',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'arrayValue',
								type: 'string',
								default: '',
								placeholder: 'e.g. [ arrayItem1, arrayItem2, arrayItem3 ]',
								displayOptions: { show: { type: ['arrayValue'] } },
								validateType: 'array',
								ignoreValidationDuringExecution: true,
							},
							{
								displayName: 'Value',
								name: 'objectValue',
								type: 'json',
								default: '={}',
								typeOptions: { rows: 2 },
								displayOptions: { show: { type: ['objectValue'] } },
								validateType: 'object',
								ignoreValidationDuringExecution: true,
							},
						],
					},
				],
				displayOptions: { show: { mode: ['manual'] } },
			},
			{
				displayName: 'Include in Output',
				name: 'include',
				type: 'options',
				description: 'How to select the fields you want to include in your output items',
				default: 'all',
				options: [
					{
						name: 'All Input Fields',
						value: 'all',
						description: 'Also include all unchanged fields from the input',
					},
					{
						name: 'No Input Fields',
						value: 'none',
						description: 'Include only the fields specified above',
					},
					{
						name: 'Selected Input Fields',
						value: 'selected',
						description: 'Also include the fields listed in the parameter “Fields to Include”',
					},
					{
						name: 'All Input Fields Except',
						value: 'except',
						description: 'Exclude the fields listed in the parameter “Fields to Exclude”',
					},
				],
			},
			{
				displayName: 'Fields to Include',
				name: 'includeFields',
				type: 'string',
				default: '',
				placeholder: 'e.g. fieldToInclude1,fieldToInclude2',
				description:
					'Comma-separated list of the field names you want to include in the output. You can drag the selected fields from the input panel.',
				requiresDataPath: 'multiple',
				displayOptions: { show: { include: ['selected'] } },
			},
			{
				displayName: 'Fields to Exclude',
				name: 'excludeFields',
				type: 'string',
				default: '',
				placeholder: 'e.g. fieldToExclude1,fieldToExclude2',
				description:
					'Comma-separated list of the field names you want to exclude from the output. You can drag the selected fields from the input panel.',
				requiresDataPath: 'multiple',
				displayOptions: { show: { include: ['except'] } },
			},
			{
				displayName: 'Options',
				name: 'options',
				type: 'collection',
				placeholder: 'Add Option',
				default: {},
				options: [
					{
						displayName: 'Include Binary Data',
						name: 'includeBinary',
						type: 'boolean',
						default: true,
						description: 'Whether binary data should be included if present in the input item',
					},
					{
						displayName: 'Ignore Type Conversion Errors',
						name: 'ignoreConversionErrors',
						type: 'boolean',
						default: false,
						description:
							'Whether to ignore field type errors and apply a less strict type conversion',
						displayOptions: { show: { '/mode': ['manual'] } },
					},
					{
						displayName: 'Support Dot Notation',
						name: 'dotNotation',
						type: 'boolean',
						default: true,
						description:
							'By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }. If that is not intended this can be deactivated, it will then set { "a.b": value } instead.',
					},
				],
			},
		],
		codex: {
			categories: ['Core Nodes'],
			subcategories: { 'Core Nodes': ['Data Transformation'] },
			resources: {
				primaryDocumentation: [
					{ url: 'https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/' },
				],
			},
			alias: ['Set', 'JSON', 'Filter', 'Transform', 'Map'],
		},
	},
} satisfies { [version: string]: INodeTypeDescription };
