"use client";
const require_use_force_update = require("../use-force-update/use-force-update.cjs");
let react = require("react");
//#region packages/@mantine/hooks/src/use-set/use-set.ts
function readonlySetLikeToSet(input) {
	if (input instanceof Set) return input;
	const result = /* @__PURE__ */ new Set();
	const iterator = input.keys();
	let next = iterator.next();
	while (!next.done) {
		result.add(next.value);
		next = iterator.next();
	}
	return result;
}
function useSet(values) {
	const setRef = (0, react.useRef)(new Set(values));
	const forceUpdate = require_use_force_update.useForceUpdate();
	setRef.current.add = (...args) => {
		const res = Set.prototype.add.apply(setRef.current, args);
		forceUpdate();
		return res;
	};
	setRef.current.clear = (...args) => {
		Set.prototype.clear.apply(setRef.current, args);
		forceUpdate();
	};
	setRef.current.delete = (...args) => {
		const res = Set.prototype.delete.apply(setRef.current, args);
		forceUpdate();
		return res;
	};
	setRef.current.union = (other) => {
		const result = new Set(setRef.current);
		readonlySetLikeToSet(other).forEach((item) => result.add(item));
		return result;
	};
	setRef.current.intersection = (other) => {
		const result = /* @__PURE__ */ new Set();
		const otherSet = readonlySetLikeToSet(other);
		setRef.current.forEach((item) => {
			if (otherSet.has(item)) result.add(item);
		});
		return result;
	};
	setRef.current.difference = (other) => {
		const result = /* @__PURE__ */ new Set();
		const otherSet = readonlySetLikeToSet(other);
		setRef.current.forEach((item) => {
			if (!otherSet.has(item)) result.add(item);
		});
		return result;
	};
	setRef.current.symmetricDifference = (other) => {
		const result = /* @__PURE__ */ new Set();
		const otherSet = readonlySetLikeToSet(other);
		setRef.current.forEach((item) => {
			if (!otherSet.has(item)) result.add(item);
		});
		otherSet.forEach((item) => {
			if (!setRef.current.has(item)) result.add(item);
		});
		return result;
	};
	return setRef.current;
}
//#endregion
exports.useSet = useSet;

//# sourceMappingURL=use-set.cjs.map