import { stream as e } from "../utils/stream.js";
import { MultiMap as t } from "../utils/collections.js";
//#region ../../node_modules/langium/lib/references/scope.js
var n = class {
	constructor(e, t, n) {
		this.elements = e, this.outerScope = t, this.caseInsensitive = n?.caseInsensitive ?? !1, this.concatOuterScope = n?.concatOuterScope ?? !0;
	}
	getAllElements() {
		return this.outerScope ? this.elements.concat(this.outerScope.getAllElements()) : this.elements;
	}
	getElement(e) {
		let t = this.caseInsensitive ? e.toLowerCase() : e, n = this.caseInsensitive ? this.elements.find((e) => e.name.toLowerCase() === t) : this.elements.find((t) => t.name === e);
		if (n) return n;
		if (this.outerScope) return this.outerScope.getElement(e);
	}
	getElements(e) {
		let t = this.caseInsensitive ? e.toLowerCase() : e, n = this.caseInsensitive ? this.elements.filter((e) => e.name.toLowerCase() === t) : this.elements.filter((t) => t.name === e);
		return (this.concatOuterScope || n.isEmpty()) && this.outerScope ? n.concat(this.outerScope.getElements(e)) : n;
	}
}, r = class {
	constructor(e, n, r) {
		this.elements = new t(), this.caseInsensitive = r?.caseInsensitive ?? !1, this.concatOuterScope = r?.concatOuterScope ?? !0;
		for (let t of e) {
			let e = this.caseInsensitive ? t.name.toLowerCase() : t.name;
			this.elements.add(e, t);
		}
		this.outerScope = n;
	}
	getElement(e) {
		let t = this.caseInsensitive ? e.toLowerCase() : e, n = this.elements.get(t)[0];
		if (n) return n;
		if (this.outerScope) return this.outerScope.getElement(e);
	}
	getElements(t) {
		let n = this.caseInsensitive ? t.toLowerCase() : t, r = this.elements.get(n);
		return (this.concatOuterScope || r.length === 0) && this.outerScope ? e(r).concat(this.outerScope.getElements(t)) : e(r);
	}
	getAllElements() {
		let t = e(this.elements.values());
		return this.outerScope && (t = t.concat(this.outerScope.getAllElements())), t;
	}
};
//#endregion
export { r as MultiMapScope, n as StreamScope };
