🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@headless-primitives/utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@headless-primitives/utils - npm Package Compare versions

Comparing version
1.0.0
to
1.1.0
+18
dist/overlay-position.d.ts
/**
* Utilities shared by overlay components (popover, dropdown-menu, context-menu, select).
* Centralizes scroll-parent detection and a rAF-driven position recompute loop.
*/
/**
* Walks up the DOM ancestors of `el` and returns every scrollable parent
* plus `window`. Useful for attaching `scroll` listeners that should
* reposition an overlay anchored to a trigger.
*/
export declare function getScrollParents(el: HTMLElement): EventTarget[];
/**
* Repeatedly invokes `compute` on every animation frame until `signal`
* is aborted. Returns no handle: cancellation is driven entirely by the
* AbortSignal so callers can plug it into HeadlessElement's per-open
* AbortController and have positioning stop automatically when the
* overlay closes or the host disconnects.
*/
export declare function startPositionLoop(compute: () => void, signal: AbortSignal): void;
+8
-0

@@ -7,2 +7,10 @@ import { LitElement } from "lit";

get hpId(): string;
private _abortController;
/**
* AbortSignal que se cancela automáticamente cuando el elemento se desconecta del DOM.
* Pásalo como `{ signal: this.signal }` a `addEventListener` para cleanup automático.
*/
get signal(): AbortSignal;
connectedCallback(): void;
disconnectedCallback(): void;
}
+1
-0
export * from "./headless-element";
export * from "./uid";
export * from "./custom-element";
export * from "./overlay-position";
/**

@@ -5,0 +6,0 @@ * Handles roving tabindex for a group of elements.

+113
-86

@@ -28,3 +28,3 @@ //#region ../../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.js

return a(t);
})(e) : e, { is: c, defineProperty: l, getOwnPropertyDescriptor: u, getOwnPropertyNames: d, getOwnPropertySymbols: ee, getPrototypeOf: te } = Object, f = globalThis, p = f.trustedTypes, ne = p ? p.emptyScript : "", m = f.reactiveElementPolyfillSupport, h = (e, t) => e, g = {
})(e) : e, { is: c, defineProperty: l, getOwnPropertyDescriptor: u, getOwnPropertyNames: d, getOwnPropertySymbols: ee, getPrototypeOf: te } = Object, f = globalThis, p = f.trustedTypes, ne = p ? p.emptyScript : "", re = f.reactiveElementPolyfillSupport, m = (e, t) => e, h = {
toAttribute(e, t) {

@@ -58,12 +58,12 @@ switch (t) {

}
}, _ = (e, t) => !c(e, t), v = {
}, g = (e, t) => !c(e, t), _ = {
attribute: !0,
type: String,
converter: g,
converter: h,
reflect: !1,
useDefault: !1,
hasChanged: _
hasChanged: g
};
Symbol.metadata ??= Symbol("metadata"), f.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
var y = class extends HTMLElement {
var v = class extends HTMLElement {
static addInitializer(e) {

@@ -75,3 +75,3 @@ this._$Ei(), (this.l ??= []).push(e);

}
static createProperty(e, t = v) {
static createProperty(e, t = _) {
if (t.state && (t.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(e) && ((t = Object.create(t)).wrapped = !0), this.elementProperties.set(e, t), !t.noAccessor) {

@@ -102,6 +102,6 @@ let n = Symbol(), r = this.getPropertyDescriptor(e, n, t);

static getPropertyOptions(e) {
return this.elementProperties.get(e) ?? v;
return this.elementProperties.get(e) ?? _;
}
static _$Ei() {
if (this.hasOwnProperty(h("elementProperties"))) return;
if (this.hasOwnProperty(m("elementProperties"))) return;
let e = te(this);

@@ -111,4 +111,4 @@ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);

static finalize() {
if (this.hasOwnProperty(h("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(h("properties"))) {
if (this.hasOwnProperty(m("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(m("properties"))) {
let e = this.properties, t = [...d(e), ...ee(e)];

@@ -175,3 +175,3 @@ for (let n of t) this.createProperty(n, e[n]);

if (r !== void 0 && !0 === n.reflect) {
let i = (n.converter?.toAttribute === void 0 ? g : n.converter).toAttribute(t, n.type);
let i = (n.converter?.toAttribute === void 0 ? h : n.converter).toAttribute(t, n.type);
this._$Em = e, i == null ? this.removeAttribute(r) : this.setAttribute(r, i), this._$Em = null;

@@ -183,3 +183,3 @@ }

if (r !== void 0 && this._$Em !== r) {
let e = n.getPropertyOptions(r), i = typeof e.converter == "function" ? { fromAttribute: e.converter } : e.converter?.fromAttribute === void 0 ? g : e.converter;
let e = n.getPropertyOptions(r), i = typeof e.converter == "function" ? { fromAttribute: e.converter } : e.converter?.fromAttribute === void 0 ? h : e.converter;
this._$Em = r;

@@ -193,3 +193,3 @@ let a = i.fromAttribute(t, e.type);

let a = this.constructor;
if (!1 === r && (i = this[e]), n ??= a.getPropertyOptions(e), !((n.hasChanged ?? _)(i, t) || n.useDefault && n.reflect && i === this._$Ej?.get(e) && !this.hasAttribute(a._$Eu(e, n)))) return;
if (!1 === r && (i = this[e]), n ??= a.getPropertyOptions(e), !((n.hasChanged ?? g)(i, t) || n.useDefault && n.reflect && i === this._$Ej?.get(e) && !this.hasAttribute(a._$Eu(e, n)))) return;
this.C(e, t, n);

@@ -258,32 +258,32 @@ }

};
y.elementStyles = [], y.shadowRootOptions = { mode: "open" }, y[h("elementProperties")] = /* @__PURE__ */ new Map(), y[h("finalized")] = /* @__PURE__ */ new Map(), m?.({ ReactiveElement: y }), (f.reactiveElementVersions ??= []).push("2.1.2");
v.elementStyles = [], v.shadowRootOptions = { mode: "open" }, v[m("elementProperties")] = /* @__PURE__ */ new Map(), v[m("finalized")] = /* @__PURE__ */ new Map(), re?.({ ReactiveElement: v }), (f.reactiveElementVersions ??= []).push("2.1.2");
//#endregion
//#region ../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.js
var b = globalThis, x = (e) => e, S = b.trustedTypes, C = S ? S.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, w = "$lit$", T = `lit$${Math.random().toFixed(9).slice(2)}$`, E = "?" + T, re = `<${E}>`, D = document, O = () => D.createComment(""), k = (e) => e === null || typeof e != "object" && typeof e != "function", A = Array.isArray, ie = (e) => A(e) || typeof e?.[Symbol.iterator] == "function", j = "[ \n\f\r]", M = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, N = /-->/g, P = />/g, F = RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), I = /'/g, L = /"/g, R = /^(?:script|style|textarea|title)$/i, z = Symbol.for("lit-noChange"), B = Symbol.for("lit-nothing"), V = /* @__PURE__ */ new WeakMap(), H = D.createTreeWalker(D, 129);
function U(e, t) {
if (!A(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
return C === void 0 ? t : C.createHTML(t);
var y = globalThis, b = (e) => e, x = y.trustedTypes, S = x ? x.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, C = "$lit$", w = `lit$${Math.random().toFixed(9).slice(2)}$`, T = "?" + w, ie = `<${T}>`, E = document, D = () => E.createComment(""), O = (e) => e === null || typeof e != "object" && typeof e != "function", k = Array.isArray, ae = (e) => k(e) || typeof e?.[Symbol.iterator] == "function", A = "[ \n\f\r]", j = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, M = /-->/g, N = />/g, P = RegExp(`>|${A}(?:([^\\s"'>=/]+)(${A}*=${A}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), F = /'/g, I = /"/g, L = /^(?:script|style|textarea|title)$/i, R = Symbol.for("lit-noChange"), z = Symbol.for("lit-nothing"), B = /* @__PURE__ */ new WeakMap(), V = E.createTreeWalker(E, 129);
function H(e, t) {
if (!k(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
return S === void 0 ? t : S.createHTML(t);
}
var ae = (e, t) => {
let n = e.length - 1, r = [], i, a = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = M;
var oe = (e, t) => {
let n = e.length - 1, r = [], i, a = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = j;
for (let t = 0; t < n; t++) {
let n = e[t], s, c, l = -1, u = 0;
for (; u < n.length && (o.lastIndex = u, c = o.exec(n), c !== null);) u = o.lastIndex, o === M ? c[1] === "!--" ? o = N : c[1] === void 0 ? c[2] === void 0 ? c[3] !== void 0 && (o = F) : (R.test(c[2]) && (i = RegExp("</" + c[2], "g")), o = F) : o = P : o === F ? c[0] === ">" ? (o = i ?? M, l = -1) : c[1] === void 0 ? l = -2 : (l = o.lastIndex - c[2].length, s = c[1], o = c[3] === void 0 ? F : c[3] === "\"" ? L : I) : o === L || o === I ? o = F : o === N || o === P ? o = M : (o = F, i = void 0);
let d = o === F && e[t + 1].startsWith("/>") ? " " : "";
a += o === M ? n + re : l >= 0 ? (r.push(s), n.slice(0, l) + w + n.slice(l) + T + d) : n + T + (l === -2 ? t : d);
for (; u < n.length && (o.lastIndex = u, c = o.exec(n), c !== null);) u = o.lastIndex, o === j ? c[1] === "!--" ? o = M : c[1] === void 0 ? c[2] === void 0 ? c[3] !== void 0 && (o = P) : (L.test(c[2]) && (i = RegExp("</" + c[2], "g")), o = P) : o = N : o === P ? c[0] === ">" ? (o = i ?? j, l = -1) : c[1] === void 0 ? l = -2 : (l = o.lastIndex - c[2].length, s = c[1], o = c[3] === void 0 ? P : c[3] === "\"" ? I : F) : o === I || o === F ? o = P : o === M || o === N ? o = j : (o = P, i = void 0);
let d = o === P && e[t + 1].startsWith("/>") ? " " : "";
a += o === j ? n + ie : l >= 0 ? (r.push(s), n.slice(0, l) + C + n.slice(l) + w + d) : n + w + (l === -2 ? t : d);
}
return [U(e, a + (e[n] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
}, W = class e {
return [H(e, a + (e[n] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
}, U = class e {
constructor({ strings: t, _$litType$: n }, r) {
let i;
this.parts = [];
let a = 0, o = 0, s = t.length - 1, c = this.parts, [l, u] = ae(t, n);
if (this.el = e.createElement(l, r), H.currentNode = this.el.content, n === 2 || n === 3) {
let a = 0, o = 0, s = t.length - 1, c = this.parts, [l, u] = oe(t, n);
if (this.el = e.createElement(l, r), V.currentNode = this.el.content, n === 2 || n === 3) {
let e = this.el.content.firstChild;
e.replaceWith(...e.childNodes);
}
for (; (i = H.nextNode()) !== null && c.length < s;) {
for (; (i = V.nextNode()) !== null && c.length < s;) {
if (i.nodeType === 1) {
if (i.hasAttributes()) for (let e of i.getAttributeNames()) if (e.endsWith(w)) {
let t = u[o++], n = i.getAttribute(e).split(T), r = /([.?@])?(.*)/.exec(t);
if (i.hasAttributes()) for (let e of i.getAttributeNames()) if (e.endsWith(C)) {
let t = u[o++], n = i.getAttribute(e).split(w), r = /([.?@])?(.*)/.exec(t);
c.push({

@@ -294,20 +294,20 @@ type: 1,

strings: n,
ctor: r[1] === "." ? se : r[1] === "?" ? ce : r[1] === "@" ? le : q
ctor: r[1] === "." ? ce : r[1] === "?" ? le : r[1] === "@" ? ue : K
}), i.removeAttribute(e);
} else e.startsWith(T) && (c.push({
} else e.startsWith(w) && (c.push({
type: 6,
index: a
}), i.removeAttribute(e));
if (R.test(i.tagName)) {
let e = i.textContent.split(T), t = e.length - 1;
if (L.test(i.tagName)) {
let e = i.textContent.split(w), t = e.length - 1;
if (t > 0) {
i.textContent = S ? S.emptyScript : "";
for (let n = 0; n < t; n++) i.append(e[n], O()), H.nextNode(), c.push({
i.textContent = x ? x.emptyScript : "";
for (let n = 0; n < t; n++) i.append(e[n], D()), V.nextNode(), c.push({
type: 2,
index: ++a
});
i.append(e[t], O());
i.append(e[t], D());
}
}
} else if (i.nodeType === 8) if (i.data === E) c.push({
} else if (i.nodeType === 8) if (i.data === T) c.push({
type: 2,

@@ -318,6 +318,6 @@ index: a

let e = -1;
for (; (e = i.data.indexOf(T, e + 1)) !== -1;) c.push({
for (; (e = i.data.indexOf(w, e + 1)) !== -1;) c.push({
type: 7,
index: a
}), e += T.length - 1;
}), e += w.length - 1;
}

@@ -328,12 +328,12 @@ a++;

static createElement(e, t) {
let n = D.createElement("template");
let n = E.createElement("template");
return n.innerHTML = e, n;
}
};
function G(e, t, n = e, r) {
if (t === z) return t;
let i = r === void 0 ? n._$Cl : n._$Co?.[r], a = k(t) ? void 0 : t._$litDirective$;
return i?.constructor !== a && (i?._$AO?.(!1), a === void 0 ? i = void 0 : (i = new a(e), i._$AT(e, n, r)), r === void 0 ? n._$Cl = i : (n._$Co ??= [])[r] = i), i !== void 0 && (t = G(e, i._$AS(e, t.values), i, r)), t;
function W(e, t, n = e, r) {
if (t === R) return t;
let i = r === void 0 ? n._$Cl : n._$Co?.[r], a = O(t) ? void 0 : t._$litDirective$;
return i?.constructor !== a && (i?._$AO?.(!1), a === void 0 ? i = void 0 : (i = new a(e), i._$AT(e, n, r)), r === void 0 ? n._$Cl = i : (n._$Co ??= [])[r] = i), i !== void 0 && (t = W(e, i._$AS(e, t.values), i, r)), t;
}
var oe = class {
var se = class {
constructor(e, t) {

@@ -349,13 +349,13 @@ this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;

u(e) {
let { el: { content: t }, parts: n } = this._$AD, r = (e?.creationScope ?? D).importNode(t, !0);
H.currentNode = r;
let i = H.nextNode(), a = 0, o = 0, s = n[0];
let { el: { content: t }, parts: n } = this._$AD, r = (e?.creationScope ?? E).importNode(t, !0);
V.currentNode = r;
let i = V.nextNode(), a = 0, o = 0, s = n[0];
for (; s !== void 0;) {
if (a === s.index) {
let t;
s.type === 2 ? t = new K(i, i.nextSibling, this, e) : s.type === 1 ? t = new s.ctor(i, s.name, s.strings, this, e) : s.type === 6 && (t = new ue(i, this, e)), this._$AV.push(t), s = n[++o];
s.type === 2 ? t = new G(i, i.nextSibling, this, e) : s.type === 1 ? t = new s.ctor(i, s.name, s.strings, this, e) : s.type === 6 && (t = new q(i, this, e)), this._$AV.push(t), s = n[++o];
}
a !== s?.index && (i = H.nextNode(), a++);
a !== s?.index && (i = V.nextNode(), a++);
}
return H.currentNode = D, r;
return V.currentNode = E, r;
}

@@ -366,3 +366,3 @@ p(e) {

}
}, K = class e {
}, G = class e {
get _$AU() {

@@ -372,3 +372,3 @@ return this._$AM?._$AU ?? this._$Cv;

constructor(e, t, n, r) {
this.type = 2, this._$AH = B, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = n, this.options = r, this._$Cv = r?.isConnected ?? !0;
this.type = 2, this._$AH = z, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = n, this.options = r, this._$Cv = r?.isConnected ?? !0;
}

@@ -386,3 +386,3 @@ get parentNode() {

_$AI(e, t = this) {
e = G(this, e, t), k(e) ? e === B || e == null || e === "" ? (this._$AH !== B && this._$AR(), this._$AH = B) : e !== this._$AH && e !== z && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? ie(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e);
e = W(this, e, t), O(e) ? e === z || e == null || e === "" ? (this._$AH !== z && this._$AR(), this._$AH = z) : e !== this._$AH && e !== R && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? ae(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e);
}

@@ -396,9 +396,9 @@ O(e) {

_(e) {
this._$AH !== B && k(this._$AH) ? this._$AA.nextSibling.data = e : this.T(D.createTextNode(e)), this._$AH = e;
this._$AH !== z && O(this._$AH) ? this._$AA.nextSibling.data = e : this.T(E.createTextNode(e)), this._$AH = e;
}
$(e) {
let { values: t, _$litType$: n } = e, r = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = W.createElement(U(n.h, n.h[0]), this.options)), n);
let { values: t, _$litType$: n } = e, r = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = U.createElement(H(n.h, n.h[0]), this.options)), n);
if (this._$AH?._$AD === r) this._$AH.p(t);
else {
let e = new oe(r, this), n = e.u(this.options);
let e = new se(r, this), n = e.u(this.options);
e.p(t), this.T(n), this._$AH = e;

@@ -408,9 +408,9 @@ }

_$AC(e) {
let t = V.get(e.strings);
return t === void 0 && V.set(e.strings, t = new W(e)), t;
let t = B.get(e.strings);
return t === void 0 && B.set(e.strings, t = new U(e)), t;
}
k(t) {
A(this._$AH) || (this._$AH = [], this._$AR());
k(this._$AH) || (this._$AH = [], this._$AR());
let n = this._$AH, r, i = 0;
for (let a of t) i === n.length ? n.push(r = new e(this.O(O()), this.O(O()), this, this.options)) : r = n[i], r._$AI(a), i++;
for (let a of t) i === n.length ? n.push(r = new e(this.O(D()), this.O(D()), this, this.options)) : r = n[i], r._$AI(a), i++;
i < n.length && (this._$AR(r && r._$AB.nextSibling, i), n.length = i);

@@ -420,4 +420,4 @@ }

for (this._$AP?.(!1, !0, t); e !== this._$AB;) {
let t = x(e).nextSibling;
x(e).remove(), e = t;
let t = b(e).nextSibling;
b(e).remove(), e = t;
}

@@ -428,3 +428,3 @@ }

}
}, q = class {
}, K = class {
get tagName() {

@@ -437,10 +437,10 @@ return this.element.tagName;

constructor(e, t, n, r, i) {
this.type = 1, this._$AH = B, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = B;
this.type = 1, this._$AH = z, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = z;
}
_$AI(e, t = this, n, r) {
let i = this.strings, a = !1;
if (i === void 0) e = G(this, e, t, 0), a = !k(e) || e !== this._$AH && e !== z, a && (this._$AH = e);
if (i === void 0) e = W(this, e, t, 0), a = !O(e) || e !== this._$AH && e !== R, a && (this._$AH = e);
else {
let r = e, o, s;
for (e = i[0], o = 0; o < i.length - 1; o++) s = G(this, r[n + o], t, o), s === z && (s = this._$AH[o]), a ||= !k(s) || s !== this._$AH[o], s === B ? e = B : e !== B && (e += (s ?? "") + i[o + 1]), this._$AH[o] = s;
for (e = i[0], o = 0; o < i.length - 1; o++) s = W(this, r[n + o], t, o), s === R && (s = this._$AH[o]), a ||= !O(s) || s !== this._$AH[o], s === z ? e = z : e !== z && (e += (s ?? "") + i[o + 1]), this._$AH[o] = s;
}

@@ -450,5 +450,5 @@ a && !r && this.j(e);

j(e) {
e === B ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
e === z ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
}
}, se = class extends q {
}, ce = class extends K {
constructor() {

@@ -458,5 +458,5 @@ super(...arguments), this.type = 3;

j(e) {
this.element[this.name] = e === B ? void 0 : e;
this.element[this.name] = e === z ? void 0 : e;
}
}, ce = class extends q {
}, le = class extends K {
constructor() {

@@ -466,5 +466,5 @@ super(...arguments), this.type = 4;

j(e) {
this.element.toggleAttribute(this.name, !!e && e !== B);
this.element.toggleAttribute(this.name, !!e && e !== z);
}
}, le = class extends q {
}, ue = class extends K {
constructor(e, t, n, r, i) {

@@ -474,4 +474,4 @@ super(e, t, n, r, i), this.type = 5;

_$AI(e, t = this) {
if ((e = G(this, e, t, 0) ?? B) === z) return;
let n = this._$AH, r = e === B && n !== B || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, i = e !== B && (n === B || r);
if ((e = W(this, e, t, 0) ?? z) === R) return;
let n = this._$AH, r = e === z && n !== z || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, i = e !== z && (n === z || r);
r && this.element.removeEventListener(this.name, this, n), i && this.element.addEventListener(this.name, this, e), this._$AH = e;

@@ -482,3 +482,3 @@ }

}
}, ue = class {
}, q = class {
constructor(e, t, n) {

@@ -491,6 +491,6 @@ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = n;

_$AI(e) {
G(this, e);
W(this, e);
}
}, de = b.litHtmlPolyfillSupport;
de?.(W, K), (b.litHtmlVersions ??= []).push("3.3.2");
}, de = y.litHtmlPolyfillSupport;
de?.(U, G), (y.litHtmlVersions ??= []).push("3.3.2");
var fe = (e, t, n) => {

@@ -500,6 +500,6 @@ let r = n?.renderBefore ?? t, i = r._$litPart$;

let e = n?.renderBefore ?? null;
r._$litPart$ = i = new K(t.insertBefore(O(), e), e, void 0, n ?? {});
r._$litPart$ = i = new G(t.insertBefore(D(), e), e, void 0, n ?? {});
}
return i._$AI(e), i;
}, J = globalThis, Y = class extends y {
}, J = globalThis, Y = class extends v {
constructor() {

@@ -523,3 +523,3 @@ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;

render() {
return z;
return R;
}

@@ -588,2 +588,12 @@ };

}
_abortController = null;
get signal() {
return (!this._abortController || this._abortController.signal.aborted) && (this._abortController = new AbortController()), this._abortController.signal;
}
connectedCallback() {
super.connectedCallback(), (!this._abortController || this._abortController.signal.aborted) && (this._abortController = new AbortController());
}
disconnectedCallback() {
super.disconnectedCallback(), this._abortController?.abort(), this._abortController = null;
}
};

@@ -598,4 +608,21 @@ //#endregion

//#endregion
//#region src/overlay-position.ts
function xe(e) {
let t = [], n = e.parentElement;
for (; n;) {
let { overflow: e, overflowY: r, overflowX: i } = getComputedStyle(n);
/auto|scroll|overlay/.test(e + r + i) && t.push(n), n = n.parentElement;
}
return t.push(window), t;
}
function Se(e, t) {
if (t.aborted) return;
let n = 0, r = () => {
t.aborted || (e(), n = requestAnimationFrame(r));
};
n = requestAnimationFrame(r), t.addEventListener("abort", () => cancelAnimationFrame(n), { once: !0 });
}
//#endregion
//#region src/index.ts
var xe = class {
var Ce = class {
_elements = [];

@@ -637,3 +664,3 @@ _onSelect;

}
}, Se = class {
}, we = class {
_container;

@@ -676,2 +703,2 @@ _active = !1;

//#endregion
export { Se as FocusTrap, ye as HeadlessElement, xe as RovingTabindex, be as customElement, $ as uid };
export { we as FocusTrap, ye as HeadlessElement, Ce as RovingTabindex, be as customElement, xe as getScrollParents, Se as startPositionLoop, $ as uid };
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.HeadlessPrimitivesUtils={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=globalThis,n=t.ShadowRoot&&(t.ShadyCSS===void 0||t.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,r=Symbol(),i=new WeakMap,a=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(n&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=i.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&i.set(t,e))}return e}toString(){return this.cssText}},o=e=>new a(typeof e==`string`?e:e+``,void 0,r),s=(e,r)=>{if(n)e.adoptedStyleSheets=r.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of r){let r=document.createElement(`style`),i=t.litNonce;i!==void 0&&r.setAttribute(`nonce`,i),r.textContent=n.cssText,e.appendChild(r)}},c=n?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return o(t)})(e):e,{is:l,defineProperty:u,getOwnPropertyDescriptor:d,getOwnPropertyNames:ee,getOwnPropertySymbols:te,getPrototypeOf:ne}=Object,f=globalThis,p=f.trustedTypes,re=p?p.emptyScript:``,ie=f.reactiveElementPolyfillSupport,m=(e,t)=>e,h={toAttribute(e,t){switch(t){case Boolean:e=e?re:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},g=(e,t)=>!l(e,t),_={attribute:!0,type:String,converter:h,reflect:!1,useDefault:!1,hasChanged:g};Symbol.metadata??=Symbol(`metadata`),f.litPropertyMetadata??=new WeakMap;var v=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=_){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&u(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=d(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??_}static _$Ei(){if(this.hasOwnProperty(m(`elementProperties`)))return;let e=ne(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(m(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(m(`properties`))){let e=this.properties,t=[...ee(e),...te(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(c(e))}else e!==void 0&&t.push(c(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?h:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?h:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??g)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};v.elementStyles=[],v.shadowRootOptions={mode:`open`},v[m(`elementProperties`)]=new Map,v[m(`finalized`)]=new Map,ie?.({ReactiveElement:v}),(f.reactiveElementVersions??=[]).push(`2.1.2`);var y=globalThis,b=e=>e,x=y.trustedTypes,S=x?x.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,C=`$lit$`,w=`lit$${Math.random().toFixed(9).slice(2)}$`,T=`?`+w,ae=`<${T}>`,E=document,D=()=>E.createComment(``),O=e=>e===null||typeof e!=`object`&&typeof e!=`function`,k=Array.isArray,oe=e=>k(e)||typeof e?.[Symbol.iterator]==`function`,A=`[
\f\r]`,j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,N=/>/g,P=RegExp(`>|${A}(?:([^\\s"'>=/]+)(${A}*=${A}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),F=/'/g,I=/"/g,L=/^(?:script|style|textarea|title)$/i,R=Symbol.for(`lit-noChange`),z=Symbol.for(`lit-nothing`),B=new WeakMap,V=E.createTreeWalker(E,129);function H(e,t){if(!k(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return S===void 0?t:S.createHTML(t)}var se=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=j;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===j?c[1]===`!--`?o=M:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=P):(L.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=P):o=N:o===P?c[0]===`>`?(o=i??j,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?P:c[3]===`"`?I:F):o===I||o===F?o=P:o===M||o===N?o=j:(o=P,i=void 0);let d=o===P&&e[t+1].startsWith(`/>`)?` `:``;a+=o===j?n+ae:l>=0?(r.push(s),n.slice(0,l)+C+n.slice(l)+w+d):n+w+(l===-2?t:d)}return[H(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},U=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=se(t,n);if(this.el=e.createElement(l,r),V.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=V.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(C)){let t=u[o++],n=i.getAttribute(e).split(w),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?le:r[1]===`?`?ue:r[1]===`@`?de:K}),i.removeAttribute(e)}else e.startsWith(w)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(L.test(i.tagName)){let e=i.textContent.split(w),t=e.length-1;if(t>0){i.textContent=x?x.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],D()),V.nextNode(),c.push({type:2,index:++a});i.append(e[t],D())}}}else if(i.nodeType===8)if(i.data===T)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(w,e+1))!==-1;)c.push({type:7,index:a}),e+=w.length-1}a++}}static createElement(e,t){let n=E.createElement(`template`);return n.innerHTML=e,n}};function W(e,t,n=e,r){if(t===R)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=O(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=W(e,i._$AS(e,t.values),i,r)),t}var ce=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??E).importNode(t,!0);V.currentNode=r;let i=V.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new G(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new fe(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=V.nextNode(),a++)}return V.currentNode=E,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},G=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=z,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=W(this,e,t),O(e)?e===z||e==null||e===``?(this._$AH!==z&&this._$AR(),this._$AH=z):e!==this._$AH&&e!==R&&this._(e):e._$litType$===void 0?e.nodeType===void 0?oe(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==z&&O(this._$AH)?this._$AA.nextSibling.data=e:this.T(E.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=U.createElement(H(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new ce(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return t===void 0&&B.set(e.strings,t=new U(e)),t}k(t){k(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(D()),this.O(D()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=b(e).nextSibling;b(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},K=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=z,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=z}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=W(this,e,t,0),a=!O(e)||e!==this._$AH&&e!==R,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=W(this,r[n+o],t,o),s===R&&(s=this._$AH[o]),a||=!O(s)||s!==this._$AH[o],s===z?e=z:e!==z&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},le=class extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===z?void 0:e}},ue=class extends K{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==z)}},de=class extends K{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=W(this,e,t,0)??z)===R)return;let n=this._$AH,r=e===z&&n!==z||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==z&&(n===z||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},fe=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){W(this,e)}},pe=y.litHtmlPolyfillSupport;pe?.(U,G),(y.litHtmlVersions??=[]).push(`3.3.2`);var me=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new G(t.insertBefore(D(),e),e,void 0,n??{})}return i._$AI(e),i},q=globalThis,J=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=me(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return R}};J._$litElement$=!0,J.finalized=!0,q.litElementHydrateSupport?.({LitElement:J});var he=q.litElementPolyfillSupport;he?.({LitElement:J}),(q.litElementVersions??=[]).push(`4.2.2`);var Y=[];for(let e=0;e<256;++e)Y.push((e+256).toString(16).slice(1));function ge(e,t=0){return(Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+`-`+Y[e[t+4]]+Y[e[t+5]]+`-`+Y[e[t+6]]+Y[e[t+7]]+`-`+Y[e[t+8]]+Y[e[t+9]]+`-`+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]).toLowerCase()}var X,_e=new Uint8Array(16);function ve(){if(!X){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);X=crypto.getRandomValues.bind(crypto)}return X(_e)}var Z={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Q(e,t,n){e||={};let r=e.random??e.rng?.()??ve();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return ge(r)}function ye(e,t,n){return Z.randomUUID&&!t&&!e?Z.randomUUID():Q(e,t,n)}function $(e=`hp`){return`${e}-${ye()}`}var be=class extends J{createRenderRoot(){return this}emit(e,t){let n=new CustomEvent(`hp-${e}`,{detail:t,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(n),n}_hpId=$();get hpId(){return this._hpId}};function xe(e){return function(t){typeof window<`u`&&(customElements.get(e)||customElements.define(e,t))}}var Se=class{_elements=[];_onSelect;constructor(e,t){this._elements=e,this._onSelect=t}updateElements(e){this._elements=e}handleKeyDown(e,t){let n=this._elements.indexOf(t),r=-1;switch(e.key){case`ArrowDown`:case`ArrowRight`:e.preventDefault(),r=(n+1)%this._elements.length;break;case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),r=(n-1+this._elements.length)%this._elements.length;break;case`Home`:e.preventDefault(),r=0;break;case`End`:e.preventDefault(),r=this._elements.length-1;break}if(r!==-1){let e=this._elements[r];this._focusElement(e),this._onSelect(e)}}_focusElement(e){this._elements.forEach(e=>{e.setAttribute(`tabindex`,`-1`)}),e.setAttribute(`tabindex`,`0`),e.focus()}};e.FocusTrap=class{_container;_active=!1;_previouslyFocusedElement=null;_focusableElements=[];constructor(e){this._container=e}activate(){this._active||(this._active=!0,this._previouslyFocusedElement=document.activeElement,this._updateFocusableElements(),this._focusableElements.length>0&&this._focusableElements[0].focus(),document.addEventListener(`focusin`,this._handleFocusIn),document.addEventListener(`keydown`,this._handleKeyDown))}deactivate(){this._active&&(this._active=!1,document.removeEventListener(`focusin`,this._handleFocusIn),document.removeEventListener(`keydown`,this._handleKeyDown),this._previouslyFocusedElement&&this._previouslyFocusedElement.focus())}_updateFocusableElements(){this._focusableElements=Array.from(this._container.querySelectorAll([`a[href]`,`button:not([disabled])`,`textarea:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable='true']`].join(`, `)))}_handleFocusIn=e=>{if(!this._active)return;let t=e.target;this._container.contains(t)||this._focusableElements.length>0&&this._focusableElements[0].focus()};_handleKeyDown=e=>{if(!this._active||e.key!==`Tab`)return;e.preventDefault();let t=this._focusableElements.indexOf(document.activeElement),n;n=e.shiftKey?t>0?t-1:this._focusableElements.length-1:t<this._focusableElements.length-1?t+1:0,this._focusableElements[n].focus()}},e.HeadlessElement=be,e.RovingTabindex=Se,e.customElement=xe,e.uid=$});
\f\r]`,j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,N=/>/g,P=RegExp(`>|${A}(?:([^\\s"'>=/]+)(${A}*=${A}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),F=/'/g,I=/"/g,L=/^(?:script|style|textarea|title)$/i,R=Symbol.for(`lit-noChange`),z=Symbol.for(`lit-nothing`),B=new WeakMap,V=E.createTreeWalker(E,129);function H(e,t){if(!k(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return S===void 0?t:S.createHTML(t)}var se=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=j;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===j?c[1]===`!--`?o=M:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=P):(L.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=P):o=N:o===P?c[0]===`>`?(o=i??j,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?P:c[3]===`"`?I:F):o===I||o===F?o=P:o===M||o===N?o=j:(o=P,i=void 0);let d=o===P&&e[t+1].startsWith(`/>`)?` `:``;a+=o===j?n+ae:l>=0?(r.push(s),n.slice(0,l)+C+n.slice(l)+w+d):n+w+(l===-2?t:d)}return[H(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},U=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=se(t,n);if(this.el=e.createElement(l,r),V.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=V.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(C)){let t=u[o++],n=i.getAttribute(e).split(w),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?le:r[1]===`?`?ue:r[1]===`@`?de:K}),i.removeAttribute(e)}else e.startsWith(w)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(L.test(i.tagName)){let e=i.textContent.split(w),t=e.length-1;if(t>0){i.textContent=x?x.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],D()),V.nextNode(),c.push({type:2,index:++a});i.append(e[t],D())}}}else if(i.nodeType===8)if(i.data===T)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(w,e+1))!==-1;)c.push({type:7,index:a}),e+=w.length-1}a++}}static createElement(e,t){let n=E.createElement(`template`);return n.innerHTML=e,n}};function W(e,t,n=e,r){if(t===R)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=O(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=W(e,i._$AS(e,t.values),i,r)),t}var ce=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??E).importNode(t,!0);V.currentNode=r;let i=V.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new G(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new fe(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=V.nextNode(),a++)}return V.currentNode=E,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},G=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=z,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=W(this,e,t),O(e)?e===z||e==null||e===``?(this._$AH!==z&&this._$AR(),this._$AH=z):e!==this._$AH&&e!==R&&this._(e):e._$litType$===void 0?e.nodeType===void 0?oe(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==z&&O(this._$AH)?this._$AA.nextSibling.data=e:this.T(E.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=U.createElement(H(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new ce(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return t===void 0&&B.set(e.strings,t=new U(e)),t}k(t){k(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(D()),this.O(D()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=b(e).nextSibling;b(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},K=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=z,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=z}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=W(this,e,t,0),a=!O(e)||e!==this._$AH&&e!==R,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=W(this,r[n+o],t,o),s===R&&(s=this._$AH[o]),a||=!O(s)||s!==this._$AH[o],s===z?e=z:e!==z&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},le=class extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===z?void 0:e}},ue=class extends K{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==z)}},de=class extends K{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=W(this,e,t,0)??z)===R)return;let n=this._$AH,r=e===z&&n!==z||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==z&&(n===z||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},fe=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){W(this,e)}},pe=y.litHtmlPolyfillSupport;pe?.(U,G),(y.litHtmlVersions??=[]).push(`3.3.2`);var me=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new G(t.insertBefore(D(),e),e,void 0,n??{})}return i._$AI(e),i},q=globalThis,J=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=me(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return R}};J._$litElement$=!0,J.finalized=!0,q.litElementHydrateSupport?.({LitElement:J});var he=q.litElementPolyfillSupport;he?.({LitElement:J}),(q.litElementVersions??=[]).push(`4.2.2`);var Y=[];for(let e=0;e<256;++e)Y.push((e+256).toString(16).slice(1));function ge(e,t=0){return(Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+`-`+Y[e[t+4]]+Y[e[t+5]]+`-`+Y[e[t+6]]+Y[e[t+7]]+`-`+Y[e[t+8]]+Y[e[t+9]]+`-`+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]).toLowerCase()}var X,_e=new Uint8Array(16);function ve(){if(!X){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);X=crypto.getRandomValues.bind(crypto)}return X(_e)}var Z={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Q(e,t,n){e||={};let r=e.random??e.rng?.()??ve();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return ge(r)}function ye(e,t,n){return Z.randomUUID&&!t&&!e?Z.randomUUID():Q(e,t,n)}function $(e=`hp`){return`${e}-${ye()}`}var be=class extends J{createRenderRoot(){return this}emit(e,t){let n=new CustomEvent(`hp-${e}`,{detail:t,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(n),n}_hpId=$();get hpId(){return this._hpId}_abortController=null;get signal(){return(!this._abortController||this._abortController.signal.aborted)&&(this._abortController=new AbortController),this._abortController.signal}connectedCallback(){super.connectedCallback(),(!this._abortController||this._abortController.signal.aborted)&&(this._abortController=new AbortController)}disconnectedCallback(){super.disconnectedCallback(),this._abortController?.abort(),this._abortController=null}};function xe(e){return function(t){typeof window<`u`&&(customElements.get(e)||customElements.define(e,t))}}function Se(e){let t=[],n=e.parentElement;for(;n;){let{overflow:e,overflowY:r,overflowX:i}=getComputedStyle(n);/auto|scroll|overlay/.test(e+r+i)&&t.push(n),n=n.parentElement}return t.push(window),t}function Ce(e,t){if(t.aborted)return;let n=0,r=()=>{t.aborted||(e(),n=requestAnimationFrame(r))};n=requestAnimationFrame(r),t.addEventListener(`abort`,()=>cancelAnimationFrame(n),{once:!0})}var we=class{_elements=[];_onSelect;constructor(e,t){this._elements=e,this._onSelect=t}updateElements(e){this._elements=e}handleKeyDown(e,t){let n=this._elements.indexOf(t),r=-1;switch(e.key){case`ArrowDown`:case`ArrowRight`:e.preventDefault(),r=(n+1)%this._elements.length;break;case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),r=(n-1+this._elements.length)%this._elements.length;break;case`Home`:e.preventDefault(),r=0;break;case`End`:e.preventDefault(),r=this._elements.length-1;break}if(r!==-1){let e=this._elements[r];this._focusElement(e),this._onSelect(e)}}_focusElement(e){this._elements.forEach(e=>{e.setAttribute(`tabindex`,`-1`)}),e.setAttribute(`tabindex`,`0`),e.focus()}};e.FocusTrap=class{_container;_active=!1;_previouslyFocusedElement=null;_focusableElements=[];constructor(e){this._container=e}activate(){this._active||(this._active=!0,this._previouslyFocusedElement=document.activeElement,this._updateFocusableElements(),this._focusableElements.length>0&&this._focusableElements[0].focus(),document.addEventListener(`focusin`,this._handleFocusIn),document.addEventListener(`keydown`,this._handleKeyDown))}deactivate(){this._active&&(this._active=!1,document.removeEventListener(`focusin`,this._handleFocusIn),document.removeEventListener(`keydown`,this._handleKeyDown),this._previouslyFocusedElement&&this._previouslyFocusedElement.focus())}_updateFocusableElements(){this._focusableElements=Array.from(this._container.querySelectorAll([`a[href]`,`button:not([disabled])`,`textarea:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable='true']`].join(`, `)))}_handleFocusIn=e=>{if(!this._active)return;let t=e.target;this._container.contains(t)||this._focusableElements.length>0&&this._focusableElements[0].focus()};_handleKeyDown=e=>{if(!this._active||e.key!==`Tab`)return;e.preventDefault();let t=this._focusableElements.indexOf(document.activeElement),n;n=e.shiftKey?t>0?t-1:this._focusableElements.length-1:t<this._focusableElements.length-1?t+1:0,this._focusableElements[n].focus()}},e.HeadlessElement=be,e.RovingTabindex=we,e.customElement=xe,e.getScrollParents=Se,e.startPositionLoop=Ce,e.uid=$});
{
"name": "@headless-primitives/utils",
"version": "1.0.0",
"version": "1.1.0",
"description": "Shared utilities for Headless Primitives",

@@ -5,0 +5,0 @@ "files": [