import { formatStandardNumber as e } from "../internal/utils/objects.js";
import { I18nController as t } from "../internal/controllers/i18n.controller.js";
import { keyNavigationList as n } from "../internal/controllers/keynav-list.controller.js";
import { attachInternals as r } from "../internal/utils/a11y.js";
import { typeSSR as i } from "../internal/controllers/type-ssr.controller.js";
import { scopedRegistry as a } from "../internal/decorators/scoped-registry.js";
import { useStyles as o } from "../internal/styles/index.js";
import { __decorate as s } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/decorate.js";
import { IconButton as c } from "../icon-button/icon-button2.js";
import { Select as l } from "../select/select2.js";
import u from "./pagination.js";
import { LitElement as d, html as f, nothing as p } from "lit";
import { property as m } from "lit/decorators/property.js";
import { FormControlMixin as h } from "@nvidia-elements/forms/mixins";
//#region src/pagination/pagination.ts
var g = class extends h(d) {
	#e;
	static {
		this.styles = o([u]);
	}
	static {
		this.metadata = {
			tag: "nve-pagination",
			version: "0.2.3",
			valueSchema: { type: "number" }
		};
	}
	static {
		this.elementDefinitions = {
			[c.metadata.tag]: c,
			[l.metadata.tag]: l
		};
	}
	get keynavListConfig() {
		return {
			items: this.shadowRoot.querySelectorAll(`${c.metadata.tag}, input, select`),
			layout: "horizontal"
		};
	}
	get #t() {
		return (this.value - 1) * this.step + this.step;
	}
	get #n() {
		return this.items / this.value === this.step;
	}
	get #r() {
		return this.value === 1;
	}
	get #i() {
		let t = (this.value - 1) * this.step + 1, n = Math.min(this.value * this.step, this.items || Infinity);
		return `${e(t)}-${e(n)}`;
	}
	get #a() {
		return this.items ? f`<label><slot name="suffix-label">${this.i18n.of} ${e(this.items)}</slot></label>` : p;
	}
	get #o() {
		return f`<nve-icon-button part="icon-button previous-icon-button" @click="${() => this.#m(this.value - 1)}" .disabled="${this.disabled || this.#t <= this.step}" .ariaLabel="${this.i18n.previous}" container="inline" icon-name="chevron" direction="left"></nve-icon-button>`;
	}
	get #s() {
		return f`<nve-icon-button part="icon-button next-icon-button" @click="${() => this.#m(this.value + 1)}" .disabled="${this.disabled || this.#t >= this.items}" .ariaLabel="${this.i18n.next}" container="inline" icon-name="chevron" direction="right"></nve-icon-button>`;
	}
	get #c() {
		return f`<nve-icon-button part="icon-button start-icon-button" @click="${() => this.#m(1)}" .disabled="${this.disabled || this.#t <= this.step}" .ariaLabel="${this.i18n.start}" container="inline" icon-name="arrow-stop" direction="left"></nve-icon-button>`;
	}
	get #l() {
		return f`<nve-icon-button part="icon-button end-icon-button" @click="${() => this.#m(this.items / this.step)}" .disabled="${this.disabled || (this.value - 1) * this.step + this.step >= this.items}" .ariaLabel="${this.i18n.end}" container="inline" icon-name="arrow-stop" direction="right"></nve-icon-button>`;
	}
	#u;
	get #d() {
		return this.disableStep ? f`<label>${this.#i} </label>` : f`<nve-select part="select" .container="${this.container}"><select .ariaLabel="${this.i18n.currentPage}" @change="${(e) => this.#p(parseInt(e.target.value, 10))}" value="${this.step}" .disabled="${this.disabled || this.disableStep}">${this.stepSizes.map((e) => f`<option ?selected="${this.step === e}" value="${e}">${e}</option>`)}</select><div class="select-label">${this.#i}</div></nve-select>`;
	}
	render() {
		return f`<div internal-host role="presentation">${this.skippable && this.items ? f`${this.#c} ${this.#o} ${this.#d} ${this.#a} ${this.#s} ${this.#l}` : f`${this.#d} ${this.#a} ${this.#o} ${this.#s}`}</div>`;
	}
	constructor() {
		super(), this.step = 10, this.stepSizes = [
			10,
			20,
			50,
			100
		], this.#e = new t(this), this.i18n = this.#e.i18n, this.value = 1;
	}
	async connectedCallback() {
		super.connectedCallback(), r(this), this._internals.role = "toolbar", await this.updateComplete, this.#f();
	}
	disconnectedCallback() {
		super.disconnectedCallback(), this.#u?.unobserve(this);
	}
	#f() {
		let e = this.shadowRoot.querySelector(".select-label"), t = this.shadowRoot.querySelector("select");
		e && t && (this.#u = new ResizeObserver((e) => t.style.minWidth = `${e[0].contentRect.width + 36}px`), this.#u.observe(e));
	}
	#p(e) {
		this.step = e, this.dispatchEvent(new CustomEvent("step-change", {
			detail: this.step,
			bubbles: !0,
			composed: !0
		})), this.#m(this.value);
	}
	#m(e) {
		this.value !== e && (this.value = e, this.dispatchInputEvent(), this.dispatchChangeEvent()), this.#n && this.dispatchEvent(new CustomEvent("last-page", {
			bubbles: !0,
			composed: !0
		})), this.#r && this.dispatchEvent(new CustomEvent("first-page", {
			bubbles: !0,
			composed: !0
		}));
	}
};
s([m({ type: Number })], g.prototype, "step", void 0), s([m({ type: Array })], g.prototype, "stepSizes", void 0), s([m({ type: Number })], g.prototype, "items", void 0), s([m({ type: Boolean })], g.prototype, "skippable", void 0), s([m({
	type: Boolean,
	attribute: "disable-step"
})], g.prototype, "disableStep", void 0), s([m({
	type: String,
	reflect: !0
})], g.prototype, "container", void 0), s([m({ type: Object })], g.prototype, "i18n", void 0), g = s([
	i(),
	n(),
	a()
], g);
//#endregion
export { g as Pagination };

//# sourceMappingURL=pagination2.js.map