import { endOfScrollBox as e } from "../utils/dom.js";
import { attachInternals as t } from "../utils/a11y.js";
//#region src/internal/controllers/state-scroll.controller.ts
function n() {
	return (e) => e.addInitializer((e) => new r(e));
}
var r = class {
	get #e() {
		return this.host.stateScrollConfig?.target || this.host;
	}
	get #t() {
		return this.host.stateScrollConfig?.scrollOffset ?? 0;
	}
	constructor(e) {
		this.host = e, this.host.addController(this);
	}
	async hostConnected() {
		await this.host.updateComplete, t(this.host), this.#r(), this.#e.addEventListener("scrollend", this.#n);
	}
	hostDisconnected() {
		this.#e.removeEventListener("scrollend", this.#n);
	}
	#n = () => {
		this.host._internals.states.delete("scrolling"), e(this.#e, this.#t) && this.host.dispatchEvent(new CustomEvent("scrollboxend")), this.#r();
	};
	#r() {
		this.#e.addEventListener("scroll", () => this.host._internals.states.add("scrolling"), { once: !0 });
	}
};
//#endregion
export { r as StateScrollController, n as stateScroll };

//# sourceMappingURL=state-scroll.controller.js.map