/*
foo.bar(baz) becomes:

(fun => {
	return function() {
		if (fun == eval) logJS(arguments[0]);
		return fun.apply(foo, arguments)
	}
})(foo.bar)(baz)
*/
module.exports = (foo, foobar) => ({
	"type": "CallExpression",
	"callee": {
		"autogenerated": true,
		"type": "ArrowFunctionExpression",
		"id": null,
		"params": [
			{
				"type": "Identifier",
				"name": "fun",
			},
		],
		"defaults": [],
		"body": {
			"type": "BlockStatement",
			"body": [
				{
					"type": "ReturnStatement",
					"argument": {
						"type": "FunctionExpression",
						"id": null,
						"params": [],
						"defaults": [],
						"body": {
							"type": "BlockStatement",
							"body": [
								{
									"type": "IfStatement",
									"test": {
										"type": "BinaryExpression",
										"operator": "==",
										"left": {
											"type": "Identifier",
											"name": "fun",
										},
										"right": {
											"type": "Identifier",
											"name": "eval",
										},
									},
									"consequent": {
										"type": "ExpressionStatement",
										"expression": {
											"type": "CallExpression",
											"callee": {
												"type": "Identifier",
												"name": "logJS",
											},
											"arguments": [
												{
													"type": "MemberExpression",
													"computed": true,
													"object": {
														"type": "Identifier",
														"name": "arguments",
													},
													"property": {
														"type": "Literal",
														"value": 0,
														"raw": "0",
													},
												},
											],
										},
									},
									"alternate": null,
								},
								{
									"type": "ReturnStatement",
									"argument": {
										"type": "CallExpression",
										"callee": {
											"type": "MemberExpression",
											"computed": false,
											"object": {
												"type": "Identifier",
												"name": "fun",
											},
											"property": {
												"type": "Identifier",
												"name": "apply",
											},
										},
										"arguments": [
											foo,
											{
												"type": "Identifier",
												"name": "arguments",
											},
										],
									},
								},
							],
						},
						"generator": false,
						"expression": false,
					},
				},
			],
		},
		"generator": false,
		"expression": false,
	},
	"arguments": [
		foobar,
	],
});