'use strict';

const require_runtime = require('../_virtual/_rolldown/runtime.js');
const require_index = require('../utils/index.js');

//#region lib/rules/no-multiple-slot-args.js
/**
* @author Yosuke Ota
* See LICENSE file in root directory for full license.
*/
var require_no_multiple_slot_args = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
	const utils = require_index.default;
	const { findVariable } = require("@eslint-community/eslint-utils");
	module.exports = {
		meta: {
			type: "problem",
			docs: {
				description: "disallow passing multiple arguments to scoped slots",
				categories: ["vue3-recommended", "vue2-recommended"],
				url: "https://eslint.vuejs.org/rules/no-multiple-slot-args.html"
			},
			fixable: null,
			schema: [],
			messages: {
				unexpected: "Unexpected multiple arguments.",
				unexpectedSpread: "Unexpected spread argument."
			}
		},
		create(context) {
			/**
			* Verify the given node
			* @param {MemberExpression | Identifier} node The node to verify
			*/
			function verify(node) {
				const parent = node.parent;
				if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") {
					verifyReferences(parent.id);
					return;
				}
				if (parent.type === "AssignmentExpression" && parent.right === node && parent.left.type === "Identifier") {
					verifyReferences(parent.left);
					return;
				}
				if (parent.type !== "CallExpression" || parent.arguments.includes(node)) return;
				if (parent.arguments.length === 0) return;
				if (parent.arguments.length > 1) context.report({
					node: parent.arguments[1],
					messageId: "unexpected"
				});
				if (parent.arguments[0].type === "SpreadElement") context.report({
					node: parent.arguments[0],
					messageId: "unexpectedSpread"
				});
			}
			/**
			* Verify the references of the given node.
			* @param {Identifier} node The node to verify
			*/
			function verifyReferences(node) {
				const variable = findVariable(utils.getScope(context, node), node);
				if (!variable) return;
				for (const reference of variable.references) {
					if (!reference.isRead()) continue;
					/** @type {Identifier} */
					const id = reference.identifier;
					verify(id);
				}
			}
			return utils.defineVueVisitor(context, { MemberExpression(node) {
				const object = utils.skipChainExpression(node.object);
				if (object.type !== "MemberExpression") return;
				const name = utils.getStaticPropertyName(object);
				if (!name || name !== "$slots" && name !== "$scopedSlots") return;
				if (!utils.isThis(object.object, context)) return;
				verify(node);
			} });
		}
	};
}));

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_no_multiple_slot_args();
  }
});