pollcatch
Version:
A collection of lightweight, customizable feedback Web Components built with Lit and TypeScript.
1,434 lines (1,389 loc) • 154 kB
JavaScript
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const dt = globalThis, Et = dt.ShadowRoot && (dt.ShadyCSS === void 0 || dt.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Ct = Symbol(), It = /* @__PURE__ */ new WeakMap();
let ae = class {
constructor(t, s, i) {
if (this._$cssResult$ = !0, i !== Ct) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
this.cssText = t, this.t = s;
}
get styleSheet() {
let t = this.o;
const s = this.t;
if (Et && t === void 0) {
const i = s !== void 0 && s.length === 1;
i && (t = It.get(s)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && It.set(s, t));
}
return t;
}
toString() {
return this.cssText;
}
};
const _e = (e) => new ae(typeof e == "string" ? e : e + "", void 0, Ct), H = (e, ...t) => {
const s = e.length === 1 ? e[0] : t.reduce((i, o, r) => i + ((n) => {
if (n._$cssResult$ === !0) return n.cssText;
if (typeof n == "number") return n;
throw Error("Value passed to 'css' function must be a 'css' function result: " + n + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
})(o) + e[r + 1], e[0]);
return new ae(s, e, Ct);
}, Te = (e, t) => {
if (Et) e.adoptedStyleSheets = t.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet);
else for (const s of t) {
const i = document.createElement("style"), o = dt.litNonce;
o !== void 0 && i.setAttribute("nonce", o), i.textContent = s.cssText, e.appendChild(i);
}
}, Ut = Et ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => {
let s = "";
for (const i of t.cssRules) s += i.cssText;
return _e(s);
})(e) : e;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const { is: Pe, defineProperty: Oe, getOwnPropertyDescriptor: Me, getOwnPropertyNames: Ne, getOwnPropertySymbols: ze, getPrototypeOf: Re } = Object, j = globalThis, jt = j.trustedTypes, Ie = jt ? jt.emptyScript : "", bt = j.reactiveElementPolyfillSupport, et = (e, t) => e, pt = { toAttribute(e, t) {
switch (t) {
case Boolean:
e = e ? Ie : null;
break;
case Object:
case Array:
e = e == null ? e : JSON.stringify(e);
}
return e;
}, fromAttribute(e, t) {
let s = e;
switch (t) {
case Boolean:
s = e !== null;
break;
case Number:
s = e === null ? null : Number(e);
break;
case Object:
case Array:
try {
s = JSON.parse(e);
} catch {
s = null;
}
}
return s;
} }, At = (e, t) => !Pe(e, t), Lt = { attribute: !0, type: String, converter: pt, reflect: !1, hasChanged: At };
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), j.litPropertyMetadata ?? (j.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
let Z = class extends HTMLElement {
static addInitializer(t) {
this._$Ei(), (this.l ?? (this.l = [])).push(t);
}
static get observedAttributes() {
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
}
static createProperty(t, s = Lt) {
if (s.state && (s.attribute = !1), this._$Ei(), this.elementProperties.set(t, s), !s.noAccessor) {
const i = Symbol(), o = this.getPropertyDescriptor(t, i, s);
o !== void 0 && Oe(this.prototype, t, o);
}
}
static getPropertyDescriptor(t, s, i) {
const { get: o, set: r } = Me(this.prototype, t) ?? { get() {
return this[s];
}, set(n) {
this[s] = n;
} };
return { get() {
return o == null ? void 0 : o.call(this);
}, set(n) {
const a = o == null ? void 0 : o.call(this);
r.call(this, n), this.requestUpdate(t, a, i);
}, configurable: !0, enumerable: !0 };
}
static getPropertyOptions(t) {
return this.elementProperties.get(t) ?? Lt;
}
static _$Ei() {
if (this.hasOwnProperty(et("elementProperties"))) return;
const t = Re(this);
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
}
static finalize() {
if (this.hasOwnProperty(et("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(et("properties"))) {
const s = this.properties, i = [...Ne(s), ...ze(s)];
for (const o of i) this.createProperty(o, s[o]);
}
const t = this[Symbol.metadata];
if (t !== null) {
const s = litPropertyMetadata.get(t);
if (s !== void 0) for (const [i, o] of s) this.elementProperties.set(i, o);
}
this._$Eh = /* @__PURE__ */ new Map();
for (const [s, i] of this.elementProperties) {
const o = this._$Eu(s, i);
o !== void 0 && this._$Eh.set(o, s);
}
this.elementStyles = this.finalizeStyles(this.styles);
}
static finalizeStyles(t) {
const s = [];
if (Array.isArray(t)) {
const i = new Set(t.flat(1 / 0).reverse());
for (const o of i) s.unshift(Ut(o));
} else t !== void 0 && s.push(Ut(t));
return s;
}
static _$Eu(t, s) {
const i = s.attribute;
return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
}
constructor() {
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
}
_$Ev() {
var t;
this._$ES = new Promise((s) => this.enableUpdating = s), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((s) => s(this));
}
addController(t) {
var s;
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((s = t.hostConnected) == null || s.call(t));
}
removeController(t) {
var s;
(s = this._$EO) == null || s.delete(t);
}
_$E_() {
const t = /* @__PURE__ */ new Map(), s = this.constructor.elementProperties;
for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
t.size > 0 && (this._$Ep = t);
}
createRenderRoot() {
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
return Te(t, this.constructor.elementStyles), t;
}
connectedCallback() {
var t;
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((s) => {
var i;
return (i = s.hostConnected) == null ? void 0 : i.call(s);
});
}
enableUpdating(t) {
}
disconnectedCallback() {
var t;
(t = this._$EO) == null || t.forEach((s) => {
var i;
return (i = s.hostDisconnected) == null ? void 0 : i.call(s);
});
}
attributeChangedCallback(t, s, i) {
this._$AK(t, i);
}
_$EC(t, s) {
var r;
const i = this.constructor.elementProperties.get(t), o = this.constructor._$Eu(t, i);
if (o !== void 0 && i.reflect === !0) {
const n = (((r = i.converter) == null ? void 0 : r.toAttribute) !== void 0 ? i.converter : pt).toAttribute(s, i.type);
this._$Em = t, n == null ? this.removeAttribute(o) : this.setAttribute(o, n), this._$Em = null;
}
}
_$AK(t, s) {
var r;
const i = this.constructor, o = i._$Eh.get(t);
if (o !== void 0 && this._$Em !== o) {
const n = i.getPropertyOptions(o), a = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((r = n.converter) == null ? void 0 : r.fromAttribute) !== void 0 ? n.converter : pt;
this._$Em = o, this[o] = a.fromAttribute(s, n.type), this._$Em = null;
}
}
requestUpdate(t, s, i) {
if (t !== void 0) {
if (i ?? (i = this.constructor.getPropertyOptions(t)), !(i.hasChanged ?? At)(this[t], s)) return;
this.P(t, s, i);
}
this.isUpdatePending === !1 && (this._$ES = this._$ET());
}
P(t, s, i) {
this._$AL.has(t) || this._$AL.set(t, s), i.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
}
async _$ET() {
this.isUpdatePending = !0;
try {
await this._$ES;
} catch (s) {
Promise.reject(s);
}
const t = this.scheduleUpdate();
return t != null && await t, !this.isUpdatePending;
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
var i;
if (!this.isUpdatePending) return;
if (!this.hasUpdated) {
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
for (const [r, n] of this._$Ep) this[r] = n;
this._$Ep = void 0;
}
const o = this.constructor.elementProperties;
if (o.size > 0) for (const [r, n] of o) n.wrapped !== !0 || this._$AL.has(r) || this[r] === void 0 || this.P(r, this[r], n);
}
let t = !1;
const s = this._$AL;
try {
t = this.shouldUpdate(s), t ? (this.willUpdate(s), (i = this._$EO) == null || i.forEach((o) => {
var r;
return (r = o.hostUpdate) == null ? void 0 : r.call(o);
}), this.update(s)) : this._$EU();
} catch (o) {
throw t = !1, this._$EU(), o;
}
t && this._$AE(s);
}
willUpdate(t) {
}
_$AE(t) {
var s;
(s = this._$EO) == null || s.forEach((i) => {
var o;
return (o = i.hostUpdated) == null ? void 0 : o.call(i);
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
}
_$EU() {
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
}
get updateComplete() {
return this.getUpdateComplete();
}
getUpdateComplete() {
return this._$ES;
}
shouldUpdate(t) {
return !0;
}
update(t) {
this._$Ej && (this._$Ej = this._$Ej.forEach((s) => this._$EC(s, this[s]))), this._$EU();
}
updated(t) {
}
firstUpdated(t) {
}
};
Z.elementStyles = [], Z.shadowRootOptions = { mode: "open" }, Z[et("elementProperties")] = /* @__PURE__ */ new Map(), Z[et("finalized")] = /* @__PURE__ */ new Map(), bt == null || bt({ ReactiveElement: Z }), (j.reactiveElementVersions ?? (j.reactiveElementVersions = [])).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const st = globalThis, ht = st.trustedTypes, Dt = ht ? ht.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, le = "$lit$", U = `lit$${Math.random().toFixed(9).slice(2)}$`, ce = "?" + U, Ue = `<${ce}>`, K = document, ot = () => K.createComment(""), rt = (e) => e === null || typeof e != "object" && typeof e != "function", _t = Array.isArray, je = (e) => _t(e) || typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", ft = `[
\f\r]`, tt = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Vt = /-->/g, Ht = />/g, q = RegExp(`>|${ft}(?:([^\\s"'>=/]+)(${ft}*=${ft}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g"), Bt = /'/g, qt = /"/g, de = /^(?:script|style|textarea|title)$/i, Le = (e) => (t, ...s) => ({ _$litType$: e, strings: t, values: s }), c = Le(1), D = Symbol.for("lit-noChange"), h = Symbol.for("lit-nothing"), Ft = /* @__PURE__ */ new WeakMap(), F = K.createTreeWalker(K, 129);
function pe(e, t) {
if (!_t(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
return Dt !== void 0 ? Dt.createHTML(t) : t;
}
const De = (e, t) => {
const s = e.length - 1, i = [];
let o, r = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", n = tt;
for (let a = 0; a < s; a++) {
const l = e[a];
let p, u, b = -1, w = 0;
for (; w < l.length && (n.lastIndex = w, u = n.exec(l), u !== null); ) w = n.lastIndex, n === tt ? u[1] === "!--" ? n = Vt : u[1] !== void 0 ? n = Ht : u[2] !== void 0 ? (de.test(u[2]) && (o = RegExp("</" + u[2], "g")), n = q) : u[3] !== void 0 && (n = q) : n === q ? u[0] === ">" ? (n = o ?? tt, b = -1) : u[1] === void 0 ? b = -2 : (b = n.lastIndex - u[2].length, p = u[1], n = u[3] === void 0 ? q : u[3] === '"' ? qt : Bt) : n === qt || n === Bt ? n = q : n === Vt || n === Ht ? n = tt : (n = q, o = void 0);
const I = n === q && e[a + 1].startsWith("/>") ? " " : "";
r += n === tt ? l + Ue : b >= 0 ? (i.push(p), l.slice(0, b) + le + l.slice(b) + U + I) : l + U + (b === -2 ? a : I);
}
return [pe(e, r + (e[s] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), i];
};
let St = class he {
constructor({ strings: t, _$litType$: s }, i) {
let o;
this.parts = [];
let r = 0, n = 0;
const a = t.length - 1, l = this.parts, [p, u] = De(t, s);
if (this.el = he.createElement(p, i), F.currentNode = this.el.content, s === 2 || s === 3) {
const b = this.el.content.firstChild;
b.replaceWith(...b.childNodes);
}
for (; (o = F.nextNode()) !== null && l.length < a; ) {
if (o.nodeType === 1) {
if (o.hasAttributes()) for (const b of o.getAttributeNames()) if (b.endsWith(le)) {
const w = u[n++], I = o.getAttribute(b).split(U), lt = /([.?@])?(.*)/.exec(w);
l.push({ type: 1, index: r, name: lt[2], strings: I, ctor: lt[1] === "." ? He : lt[1] === "?" ? Be : lt[1] === "@" ? qe : ut }), o.removeAttribute(b);
} else b.startsWith(U) && (l.push({ type: 6, index: r }), o.removeAttribute(b));
if (de.test(o.tagName)) {
const b = o.textContent.split(U), w = b.length - 1;
if (w > 0) {
o.textContent = ht ? ht.emptyScript : "";
for (let I = 0; I < w; I++) o.append(b[I], ot()), F.nextNode(), l.push({ type: 2, index: ++r });
o.append(b[w], ot());
}
}
} else if (o.nodeType === 8) if (o.data === ce) l.push({ type: 2, index: r });
else {
let b = -1;
for (; (b = o.data.indexOf(U, b + 1)) !== -1; ) l.push({ type: 7, index: r }), b += U.length - 1;
}
r++;
}
}
static createElement(t, s) {
const i = K.createElement("template");
return i.innerHTML = t, i;
}
};
function W(e, t, s = e, i) {
var n, a;
if (t === D) return t;
let o = i !== void 0 ? (n = s._$Co) == null ? void 0 : n[i] : s._$Cl;
const r = rt(t) ? void 0 : t._$litDirective$;
return (o == null ? void 0 : o.constructor) !== r && ((a = o == null ? void 0 : o._$AO) == null || a.call(o, !1), r === void 0 ? o = void 0 : (o = new r(e), o._$AT(e, s, i)), i !== void 0 ? (s._$Co ?? (s._$Co = []))[i] = o : s._$Cl = o), o !== void 0 && (t = W(e, o._$AS(e, t.values), o, i)), t;
}
let Ve = class {
constructor(t, s) {
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = s;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
u(t) {
const { el: { content: s }, parts: i } = this._$AD, o = ((t == null ? void 0 : t.creationScope) ?? K).importNode(s, !0);
F.currentNode = o;
let r = F.nextNode(), n = 0, a = 0, l = i[0];
for (; l !== void 0; ) {
if (n === l.index) {
let p;
l.type === 2 ? p = new nt(r, r.nextSibling, this, t) : l.type === 1 ? p = new l.ctor(r, l.name, l.strings, this, t) : l.type === 6 && (p = new Fe(r, this, t)), this._$AV.push(p), l = i[++a];
}
n !== (l == null ? void 0 : l.index) && (r = F.nextNode(), n++);
}
return F.currentNode = K, o;
}
p(t) {
let s = 0;
for (const i of this._$AV) i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, s), s += i.strings.length - 2) : i._$AI(t[s])), s++;
}
};
class nt {
get _$AU() {
var t;
return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
}
constructor(t, s, i, o) {
this.type = 2, this._$AH = h, this._$AN = void 0, this._$AA = t, this._$AB = s, this._$AM = i, this.options = o, this._$Cv = (o == null ? void 0 : o.isConnected) ?? !0;
}
get parentNode() {
let t = this._$AA.parentNode;
const s = this._$AM;
return s !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = s.parentNode), t;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t, s = this) {
t = W(this, t, s), rt(t) ? t === h || t == null || t === "" ? (this._$AH !== h && this._$AR(), this._$AH = h) : t !== this._$AH && t !== D && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : je(t) ? this.k(t) : this._(t);
}
O(t) {
return this._$AA.parentNode.insertBefore(t, this._$AB);
}
T(t) {
this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
}
_(t) {
this._$AH !== h && rt(this._$AH) ? this._$AA.nextSibling.data = t : this.T(K.createTextNode(t)), this._$AH = t;
}
$(t) {
var r;
const { values: s, _$litType$: i } = t, o = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el = St.createElement(pe(i.h, i.h[0]), this.options)), i);
if (((r = this._$AH) == null ? void 0 : r._$AD) === o) this._$AH.p(s);
else {
const n = new Ve(o, this), a = n.u(this.options);
n.p(s), this.T(a), this._$AH = n;
}
}
_$AC(t) {
let s = Ft.get(t.strings);
return s === void 0 && Ft.set(t.strings, s = new St(t)), s;
}
k(t) {
_t(this._$AH) || (this._$AH = [], this._$AR());
const s = this._$AH;
let i, o = 0;
for (const r of t) o === s.length ? s.push(i = new nt(this.O(ot()), this.O(ot()), this, this.options)) : i = s[o], i._$AI(r), o++;
o < s.length && (this._$AR(i && i._$AB.nextSibling, o), s.length = o);
}
_$AR(t = this._$AA.nextSibling, s) {
var i;
for ((i = this._$AP) == null ? void 0 : i.call(this, !1, !0, s); t && t !== this._$AB; ) {
const o = t.nextSibling;
t.remove(), t = o;
}
}
setConnected(t) {
var s;
this._$AM === void 0 && (this._$Cv = t, (s = this._$AP) == null || s.call(this, t));
}
}
class ut {
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
constructor(t, s, i, o, r) {
this.type = 1, this._$AH = h, this._$AN = void 0, this.element = t, this.name = s, this._$AM = o, this.options = r, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = h;
}
_$AI(t, s = this, i, o) {
const r = this.strings;
let n = !1;
if (r === void 0) t = W(this, t, s, 0), n = !rt(t) || t !== this._$AH && t !== D, n && (this._$AH = t);
else {
const a = t;
let l, p;
for (t = r[0], l = 0; l < r.length - 1; l++) p = W(this, a[i + l], s, l), p === D && (p = this._$AH[l]), n || (n = !rt(p) || p !== this._$AH[l]), p === h ? t = h : t !== h && (t += (p ?? "") + r[l + 1]), this._$AH[l] = p;
}
n && !o && this.j(t);
}
j(t) {
t === h ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
}
}
let He = class extends ut {
constructor() {
super(...arguments), this.type = 3;
}
j(t) {
this.element[this.name] = t === h ? void 0 : t;
}
};
class Be extends ut {
constructor() {
super(...arguments), this.type = 4;
}
j(t) {
this.element.toggleAttribute(this.name, !!t && t !== h);
}
}
class qe extends ut {
constructor(t, s, i, o, r) {
super(t, s, i, o, r), this.type = 5;
}
_$AI(t, s = this) {
if ((t = W(this, t, s, 0) ?? h) === D) return;
const i = this._$AH, o = t === h && i !== h || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, r = t !== h && (i === h || o);
o && this.element.removeEventListener(this.name, this, i), r && this.element.addEventListener(this.name, this, t), this._$AH = t;
}
handleEvent(t) {
var s;
typeof this._$AH == "function" ? this._$AH.call(((s = this.options) == null ? void 0 : s.host) ?? this.element, t) : this._$AH.handleEvent(t);
}
}
class Fe {
constructor(t, s, i) {
this.element = t, this.type = 6, this._$AN = void 0, this._$AM = s, this.options = i;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t) {
W(this, t);
}
}
const gt = st.litHtmlPolyfillSupport;
gt == null || gt(St, nt), (st.litHtmlVersions ?? (st.litHtmlVersions = [])).push("3.2.1");
const Ye = (e, t, s) => {
const i = (s == null ? void 0 : s.renderBefore) ?? t;
let o = i._$litPart$;
if (o === void 0) {
const r = (s == null ? void 0 : s.renderBefore) ?? null;
i._$litPart$ = o = new nt(t.insertBefore(ot(), r), r, void 0, s ?? {});
}
return o._$AI(e), o;
};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let L = class extends Z {
constructor() {
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
}
createRenderRoot() {
var s;
const t = super.createRenderRoot();
return (s = this.renderOptions).renderBefore ?? (s.renderBefore = t.firstChild), t;
}
update(t) {
const s = this.render();
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ye(s, this.renderRoot, this.renderOptions);
}
connectedCallback() {
var t;
super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0);
}
disconnectedCallback() {
var t;
super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
}
render() {
return D;
}
};
var ne;
L._$litElement$ = !0, L.finalized = !0, (ne = globalThis.litElementHydrateSupport) == null || ne.call(globalThis, { LitElement: L });
const yt = globalThis.litElementPolyfillSupport;
yt == null || yt({ LitElement: L });
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const B = (e) => (t, s) => {
s !== void 0 ? s.addInitializer(() => {
customElements.define(e, t);
}) : customElements.define(e, t);
};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Ke = { attribute: !0, type: String, converter: pt, reflect: !1, hasChanged: At }, Ge = (e = Ke, t, s) => {
const { kind: i, metadata: o } = s;
let r = globalThis.litPropertyMetadata.get(o);
if (r === void 0 && globalThis.litPropertyMetadata.set(o, r = /* @__PURE__ */ new Map()), r.set(s.name, e), i === "accessor") {
const { name: n } = s;
return { set(a) {
const l = t.get.call(this);
t.set.call(this, a), this.requestUpdate(n, l, e);
}, init(a) {
return a !== void 0 && this.P(n, void 0, e), a;
} };
}
if (i === "setter") {
const { name: n } = s;
return function(a) {
const l = this[n];
t.call(this, a), this.requestUpdate(n, l, e);
};
}
throw Error("Unsupported decorator location: " + i);
};
function d(e) {
return (t, s) => typeof s == "object" ? Ge(e, t, s) : ((i, o, r) => {
const n = o.hasOwnProperty(r);
return o.constructor.createProperty(r, n ? { ...i, wrapped: !0 } : i), n ? Object.getOwnPropertyDescriptor(o, r) : void 0;
})(e, t, s);
}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function x(e) {
return d({ ...e, state: !0, attribute: !1 });
}
const ue = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='20'%20height='5'%20viewBox='0%200%2020%205'%20fill='currentColor'%3e%3ccircle%20cx='3'%20cy='2.5'%20r='1.5'%20opacity='0.3'%3e%3canimate%20attributeName='opacity'%20begin='0s'%20dur='1s'%20values='0.3;0.8;0.3'%20repeatCount='indefinite'/%3e%3c/circle%3e%3ccircle%20cx='10'%20cy='2.5'%20r='1.5'%20opacity='0.3'%3e%3canimate%20attributeName='opacity'%20begin='0.2s'%20dur='1s'%20values='0.3;0.8;0.3'%20repeatCount='indefinite'/%3e%3c/circle%3e%3ccircle%20cx='17'%20cy='2.5'%20r='1.5'%20opacity='0.3'%3e%3canimate%20attributeName='opacity'%20begin='0.4s'%20dur='1s'%20values='0.3;0.8;0.3'%20repeatCount='indefinite'/%3e%3c/circle%3e%3c/svg%3e", Ze = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M640-160v-280h160v280H640Zm-240%200v-640h160v640H400Zm-240%200v-440h160v440H160Z'/%3e%3c/svg%3e", We = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M160-160v-440h160v440H160Zm240%200v-400l160%20160v240H400Zm160-354L400-674v-126h160v286Zm240%20240L640-434v-6h160v166Zm-9%20219L55-791l57-57%20736%20736-57%2057Z'/%3e%3c/svg%3e", Je = H`
:host {
/* Base CSS variables */
--pc-primary-color: #2196f3;
--pc-text-color: #333333;
--pc-mute-color: #cccccc;
--pc-accent-color: #f2b200; /* Added accent color for stars, icons, etc. - made lighter */
--pc-accent-hover-color: #ffc61a; /* Hover state for accent elements */
/* Common icon and control sizing */
--pc-icon-size: clamp(1.1em, calc(1em + 0.4vw), 1.6em);
--pc-control-spacing: clamp(0.4em, 0.6em, 0.8em);
/* Button radius - defaults to medium size if not specified */
--pc-button-radius: var(--pc-border-radius-md);
/* Standardized border radius values */
--pc-border-radius-sm: 2px;
--pc-border-radius-md: 4px;
--pc-border-radius-lg: 8px;
/* Responsive sizing */
--pc-loading-width: clamp(1.4em, 1.8em, 2.2em);
--pc-loading-height: clamp(0.6em, 0.7em, 0.8em);
--pc-chart-max-width: clamp(200px, 100%, 300px);
--pc-chart-min-width: clamp(150px, 12px, 200px);
--pc-bar-height: clamp(0.5em, 0.6em, 0.8em);
--pc-font-size-small: clamp(0.6em, 0.7em, 0.8em);
--pc-font-size-medium: clamp(0.8em, 0.9em, 1em);
--pc-font-size-large: clamp(1em, 1.1em, 1.2em);
}
.pc-container {
display: flex;
gap: var(--pc-control-spacing, 0.4rem);
}
.pc-container:has(.label-left) {
flex-direction: row;
align-items: center;
}
.pc-container:has(.label-right) {
flex-direction: row-reverse;
align-items: center;
}
.pc-container:has(.label-top) {
flex-direction: column;
}
.pc-container:has(.label-bottom) {
flex-direction: column-reverse;
}
.pc-label {
font-size: 0.8em;
color: currentColor;
}
.pc-body {
display: flex;
flex-wrap: nowrap;
gap: var(--pc-control-spacing, 0.4rem);
}
.pc-section {
position: relative;
}
.pc-flex-pos-left {
display: flex;
flex-direction: row;
align-items: center;
}
.pc-flex-pos-right {
display: flex;
flex-direction: row-reverse;
align-items: center;
}
.pc-flex-pos-top {
display: flex;
flex-direction: column;
align-items: center;
}
.pc-flex-pos-bottom {
display: flex;
flex-direction: column-reverse;
align-items: center;
}
.pc-flex-align-start {
align-items: flex-start;
}
.pc-flex-align-center {
align-items: center;
}
.pc-flex-align-end {
align-items: flex-end;
}
.pc-stats-text {
font-size: var(--pc-font-size-small, 0.6em);
/* line-height: 0.6em; */
color: var(--pc-text-color, #666);
}
.pc-stats-text--clickable {
cursor: pointer;
text-decoration: underline;
text-decoration-style: dotted;
text-underline-offset: 2px;
}
.pc-loading-icon {
width: var(--pc-loading-width);
height: var(--pc-loading-height);
vertical-align: middle;
color: var(--pc-mute-color, #999);
display: inline-block;
}
/* Inline chart toggle icon - shared between components */
.chart-toggle-icon,
.edit-toggle-icon {
width: 1.2em;
height: 1.2em;
margin-left: 0.4em;
opacity: 0.6;
cursor: pointer;
transition: opacity 0.2s ease;
vertical-align: middle;
}
.chart-toggle-icon:hover,
.edit-toggle-icon:hover {
opacity: 1;
}
.chart-toggle-icon:focus-visible,
.edit-toggle-icon:focus-visible {
outline: 2px solid var(--pc-primary-color);
outline-offset: 2px;
border-radius: 2px;
}
/* Chart styles - shared between pc-stars and pc-nps */
.pc-stats-chart {
margin: 0.5em, 0;
display: none;
}
.pc-stats-chart.visible {
display: block;
}
/* Inline chart styles */
.pc-stats-chart-inline {
width: 100%;
max-width: var(--pc-chart-max-width);
min-width: var(--pc-chart-min-width);
padding: 0.5em 0;
margin: 0.3em 0;
border-top: 1px solid var(--pc-mute-color);
border-bottom: 1px solid var(--pc-mute-color);
}
.pc-chart-container {
height: auto;
width: 100%;
max-width: var(--pc-chart-max-width);
}
/* Bar chart styles */
.pc-bar-chart {
display: flex;
flex-direction: column;
gap: 0.25em;
color: var(--pc-text-color);
}
.pc-bar-row {
display: flex;
align-items: center;
gap: 0.2em;
}
.pc-bar-label {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.1em;
font-size: 0.8em;
width: clamp(1.5em, 2em, 2.5em);
}
.pc-bar-label-text {
display: inline-block;
white-space: nowrap;
}
.pc-bar-label-icon {
display: inline-block;
white-space: nowrap;
line-height: 0.9; /* don't know why need this for vertical alignment */
}
.pc-bar-container {
display: flex;
align-items: center;
flex-grow: 1;
gap: 0.4em;
}
.pc-bar {
height: var(--pc-bar-height);
background-color: var(--pc-primary-color);
min-width: 1px;
border-radius: var(--pc-border-radius-sm);
}
.pc-bar-value {
font-size: 0.7em;
color: var(--pc-text-color);
}
.pc-action-link-button {
background: none;
border: none;
color: var(--pc-primary-color);
cursor: pointer;
padding: 0;
font: inherit;
font-size: var(--pc-font-size-small);
text-decoration: underline;
transition: color 0.2s;
margin-left: 0.3em;
}
.pc-action-link-button:hover {
color: color-mix(in srgb, var(--pc-primary-color) 80%, white);
}
/* Focus styles for better accessibility */
button:focus-visible,
a:focus-visible {
outline: 2px solid var(--pc-primary-color);
outline-offset: 2px;
}
/* Add utility class for screen reader only content */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
/* Common animation keyframes */
@keyframes pc-click-animation {
0% {
transform: scale(1);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
.pc-animate-click {
animation: pc-click-animation 0.5s ease-in-out;
}
/* Responsive adjustments for smaller screens */
@media screen and (max-width: 480px) {
:host {
--pc-loading-width: 1.4em;
--pc-loading-height: 0.6em;
--pc-chart-max-width: 100%;
--pc-bar-height: 0.5em;
--pc-icon-size: 1.3em;
--pc-control-spacing: 0.4em;
--pc-font-size-small: 0.55em;
--pc-font-size-medium: 0.8em;
}
.pc-stats-text {
font-size: var(--pc-font-size-medium);
}
.pc-bar-label {
width: 1.5em;
}
/* Improve touch target sizes for better mobile experience */
.pc-action-link-button {
font-size: var(--pc-font-size-medium);
padding: 0.2em 0;
}
}
.thank-you-msg {
font-size: 0.8em;
color: var(--pc-text-color, #333);
background: white;
padding: 1em 1.5em;
border-radius: var(--pc-border-radius, 0.375em);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
border: 1px solid var(--pc-mute-color, #ddd);
max-width: 300px;
font-style: normal;
white-space: normal;
word-wrap: break-word;
overflow-wrap: break-word;
}
/* Unified thank you overlay section and overlay */
.pc-thank-you-section-with-overlay {
position: relative;
}
.pc-thank-you-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(2px);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
animation: fadeInOverlay 0.3s ease-out;
}
@keyframes fadeInOverlay {
from {
opacity: 0;
backdrop-filter: blur(0px);
}
to {
opacity: 1;
backdrop-filter: blur(2px);
}
}
.pc-thank-you-overlay .thank-you-msg {
animation: slideInUp 0.4s ease-out;
}
@keyframes slideInUp {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
`, me = "https://jpxwfjorwcsrqraorpbj.supabase.co/functions/v1/data", Xe = "pc_session_id", Qe = 24 * 60 * 60 * 1e3;
function ts(e) {
return {
debug: (t, ...s) => {
},
info: (t, ...s) => {
},
warn: (t, ...s) => {
},
error: (t, ...s) => {
console.error(`[${e}]`, t, ...s);
}
};
}
const f = ts("Pollcatch");
function Yt() {
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : (f.warn("crypto.randomUUID not available, using fallback UUID generator"), "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
const t = Math.random() * 16 | 0;
return (e === "x" ? t : t & 3 | 8).toString(16);
}));
}
function Tt() {
const e = "test-local-storage";
try {
return localStorage.setItem(e, e), localStorage.removeItem(e), !0;
} catch {
return f.warn("localStorage not available, session ID will not persist"), !1;
}
}
function be(e) {
try {
const t = localStorage.getItem(e);
return t ? JSON.parse(t) : void 0;
} catch (t) {
f.warn(`Failed to get item from localStorage: ${e}`, t);
return;
}
}
function fe(e, t) {
try {
return localStorage.setItem(e, JSON.stringify(t)), !0;
} catch (s) {
return f.warn(`Failed to set item in localStorage: ${e}`, s), !1;
}
}
async function es() {
if (typeof window < "u") {
if (window.pcProject !== void 0)
return f.debug("Found project key in global variable"), window.pcProject;
const e = document.querySelectorAll("script[pc-project]");
if (e.length > 0) {
const t = e[e.length - 1], s = t == null ? void 0 : t.getAttribute("pc-project");
if (s)
return f.debug("Found project key in script tag attribute"), s;
}
}
f.warn("No project key found in global variable or script tags");
}
async function Kt() {
const e = Xe, t = Qe;
if (Tt()) {
const s = be(e);
if (s && s.id && s.timestamp && Date.now() - s.timestamp < t)
return f.debug("Using existing session ID from localStorage"), s.id;
f.debug(
s ? "Session ID expired" : "No session ID found",
"generating new one"
);
const i = Yt();
return fe(e, {
id: i,
timestamp: Date.now()
}) ? f.debug("Generated and stored new session ID") : f.warn("Generated session ID but failed to store it"), i;
} else {
const s = Yt();
return f.debug("Generated non-persistent session ID"), s;
}
}
async function ss(e, t) {
try {
if (!e)
throw new Error("Name parameter is required");
const s = `${me}/${encodeURIComponent(t)}/${encodeURIComponent(e)}`;
f.debug(`Fetching stats for: ${e}`, { projectKey: t });
const i = await fetch(s);
if (!i.ok)
throw new Error(`API request failed with status: ${i.status}`);
const o = await i.json();
if (!o.success)
throw f.error("Backend returned unsuccessful response", o), new Error("Backend returned unsuccessful response");
const r = o.data || {}, n = r.count > 0 ? Math.round(r.sum / r.count) : 0, a = Math.round(r.sum / r.count * 100);
return {
count: r.count ?? 0,
sum: r.sum,
avg: n,
pct: a,
breakdown: r.breakdown ?? {},
updated: r.updated_at || (/* @__PURE__ */ new Date()).toISOString()
};
} catch (s) {
throw f.error("Error loading stats:", s), s;
}
}
async function is(e) {
const t = JSON.stringify(e), s = `${me}`;
try {
if (f.debug("Sending stats", e), typeof navigator < "u" && navigator.sendBeacon)
if (navigator.sendBeacon(s, t)) {
f.debug("Successfully sent stats via sendBeacon");
return;
} else
f.debug("sendBeacon failed, falling back to fetch");
const i = await fetch(s, {
body: t,
method: "POST",
keepalive: !0,
headers: {
"Content-Type": "application/json"
}
});
if (!i.ok)
throw new Error(`API request failed with status: ${i.status}`);
f.debug("Successfully sent stats via fetch");
} catch (i) {
throw f.error("Failed to send analytics:", i), i;
}
}
function ge(e) {
return !e || typeof e != "string" ? !1 : /^[\p{Emoji}]$/u.test(e) ? !0 : new RegExp("^\\p{Emoji}(\\p{Emoji_Modifier}|\\u200D\\p{Emoji})*$", "u").test(e);
}
function Pt(e) {
if (!e || typeof e != "string")
return !1;
const t = e.trim();
if (t.length === 0)
return !1;
try {
return t.startsWith("//") ? (new URL(`http:${t}`), !0) : (new URL(t), !0);
} catch {
return !1;
}
}
function os(e) {
if (!e || typeof e != "string")
return [];
const t = e.trim();
if (!t)
return [];
if (t.startsWith("[") && t.endsWith("]"))
try {
const s = JSON.parse(t);
if (Array.isArray(s))
return s.map((i) => String(i)).filter((i) => i.trim() !== "");
} catch {
}
return t.split(",").map((s) => s.trim()).filter((s) => s !== "");
}
function rs(e, t) {
const s = /{([^{}]+)}/g;
return e.replace(s, (i, o) => {
const r = o.trim(), n = t[r];
return n !== void 0 ? String(n) : i;
});
}
function ns(e, t) {
let s = 2166136261;
const i = e + ":" + t;
for (let o = 0; o < i.length; o++)
s ^= i.charCodeAt(o), s += (s << 1) + (s << 4) + (s << 7) + (s << 8) + (s << 24);
return (s >>> 0).toString(16).padStart(8, "0");
}
var as = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, M = function(e) {
return typeof e == "string" ? e.length > 0 : typeof e == "number";
}, v = function(e, t, s) {
return t === void 0 && (t = 0), s === void 0 && (s = Math.pow(10, t)), Math.round(s * e) / s + 0;
}, S = function(e, t, s) {
return t === void 0 && (t = 0), s === void 0 && (s = 1), e > s ? s : e > t ? e : t;
}, ye = function(e) {
return (e = isFinite(e) ? e % 360 : 0) > 0 ? e : e + 360;
}, Gt = function(e) {
return { r: S(e.r, 0, 255), g: S(e.g, 0, 255), b: S(e.b, 0, 255), a: S(e.a) };
}, vt = function(e) {
return { r: v(e.r), g: v(e.g), b: v(e.b), a: v(e.a, 3) };
}, ls = /^#([0-9a-f]{3,8})$/i, ct = function(e) {
var t = e.toString(16);
return t.length < 2 ? "0" + t : t;
}, ve = function(e) {
var t = e.r, s = e.g, i = e.b, o = e.a, r = Math.max(t, s, i), n = r - Math.min(t, s, i), a = n ? r === t ? (s - i) / n : r === s ? 2 + (i - t) / n : 4 + (t - s) / n : 0;
return { h: 60 * (a < 0 ? a + 6 : a), s: r ? n / r * 100 : 0, v: r / 255 * 100, a: o };
}, xe = function(e) {
var t = e.h, s = e.s, i = e.v, o = e.a;
t = t / 360 * 6, s /= 100, i /= 100;
var r = Math.floor(t), n = i * (1 - s), a = i * (1 - (t - r) * s), l = i * (1 - (1 - t + r) * s), p = r % 6;
return { r: 255 * [i, a, n, n, l, i][p], g: 255 * [l, i, i, a, n, n][p], b: 255 * [n, n, l, i, i, a][p], a: o };
}, Zt = function(e) {
return { h: ye(e.h), s: S(e.s, 0, 100), l: S(e.l, 0, 100), a: S(e.a) };
}, Wt = function(e) {
return { h: v(e.h), s: v(e.s), l: v(e.l), a: v(e.a, 3) };
}, Jt = function(e) {
return xe((s = (t = e).s, { h: t.h, s: (s *= ((i = t.l) < 50 ? i : 100 - i) / 100) > 0 ? 2 * s / (i + s) * 100 : 0, v: i + s, a: t.a }));
var t, s, i;
}, it = function(e) {
return { h: (t = ve(e)).h, s: (o = (200 - (s = t.s)) * (i = t.v) / 100) > 0 && o < 200 ? s * i / 100 / (o <= 100 ? o : 200 - o) * 100 : 0, l: o / 2, a: t.a };
var t, s, i, o;
}, cs = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ds = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ps = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, hs = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Xt = { string: [[function(e) {
var t = ls.exec(e);
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? v(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? v(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
}, "hex"], [function(e) {
var t = ps.exec(e) || hs.exec(e);
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Gt({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
}, "rgb"], [function(e) {
var t = cs.exec(e) || ds.exec(e);
if (!t) return null;
var s, i, o = Zt({ h: (s = t[1], i = t[2], i === void 0 && (i = "deg"), Number(s) * (as[i] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
return Jt(o);
}, "hsl"]], object: [[function(e) {
var t = e.r, s = e.g, i = e.b, o = e.a, r = o === void 0 ? 1 : o;
return M(t) && M(s) && M(i) ? Gt({ r: Number(t), g: Number(s), b: Number(i), a: Number(r) }) : null;
}, "rgb"], [function(e) {
var t = e.h, s = e.s, i = e.l, o = e.a, r = o === void 0 ? 1 : o;
if (!M(t) || !M(s) || !M(i)) return null;
var n = Zt({ h: Number(t), s: Number(s), l: Number(i), a: Number(r) });
return Jt(n);
}, "hsl"], [function(e) {
var t = e.h, s = e.s, i = e.v, o = e.a, r = o === void 0 ? 1 : o;
if (!M(t) || !M(s) || !M(i)) return null;
var n = function(a) {
return { h: ye(a.h), s: S(a.s, 0, 100), v: S(a.v, 0, 100), a: S(a.a) };
}({ h: Number(t), s: Number(s), v: Number(i), a: Number(r) });
return xe(n);
}, "hsv"]] }, Qt = function(e, t) {
for (var s = 0; s < t.length; s++) {
var i = t[s][0](e);
if (i) return [i, t[s][1]];
}
return [null, void 0];
}, us = function(e) {
return typeof e == "string" ? Qt(e.trim(), Xt.string) : typeof e == "object" && e !== null ? Qt(e, Xt.object) : [null, void 0];
}, xt = function(e, t) {
var s = it(e);
return { h: s.h, s: S(s.s + 100 * t, 0, 100), l: s.l, a: s.a };
}, $t = function(e) {
return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
}, te = function(e, t) {
var s = it(e);
return { h: s.h, s: s.s, l: S(s.l + 100 * t, 0, 100), a: s.a };
}, ee = function() {
function e(t) {
this.parsed = us(t)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
}
return e.prototype.isValid = function() {
return this.parsed !== null;
}, e.prototype.brightness = function() {
return v($t(this.rgba), 2);
}, e.prototype.isDark = function() {
return $t(this.rgba) < 0.5;
}, e.prototype.isLight = function() {
return $t(this.rgba) >= 0.5;
}, e.prototype.toHex = function() {
return t = vt(this.rgba), s = t.r, i = t.g, o = t.b, n = (r = t.a) < 1 ? ct(v(255 * r)) : "", "#" + ct(s) + ct(i) + ct(o) + n;
var t, s, i, o, r, n;
}, e.prototype.toRgb = function() {
return vt(this.rgba);
}, e.prototype.toRgbString = function() {
return t = vt(this.rgba), s = t.r, i = t.g, o = t.b, (r = t.a) < 1 ? "rgba(" + s + ", " + i + ", " + o + ", " + r + ")" : "rgb(" + s + ", " + i + ", " + o + ")";
var t, s, i, o, r;
}, e.prototype.toHsl = function() {
return Wt(it(this.rgba));
}, e.prototype.toHslString = function() {
return t = Wt(it(this.rgba)), s = t.h, i = t.s, o = t.l, (r = t.a) < 1 ? "hsla(" + s + ", " + i + "%, " + o + "%, " + r + ")" : "hsl(" + s + ", " + i + "%, " + o + "%)";
var t, s, i, o, r;
}, e.prototype.toHsv = function() {
return t = ve(this.rgba), { h: v(t.h), s: v(t.s), v: v(t.v), a: v(t.a, 3) };
var t;
}, e.prototype.invert = function() {
return E({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
var t;
}, e.prototype.saturate = function(t) {
return t === void 0 && (t = 0.1), E(xt(this.rgba, t));
}, e.prototype.desaturate = function(t) {
return t === void 0 && (t = 0.1), E(xt(this.rgba, -t));
}, e.prototype.grayscale = function() {
return E(xt(this.rgba, -1));
}, e.prototype.lighten = function(t) {
return t === void 0 && (t = 0.1), E(te(this.rgba, t));
}, e.prototype.darken = function(t) {
return t === void 0 && (t = 0.1), E(te(this.rgba, -t));
}, e.prototype.rotate = function(t) {
return t === void 0 && (t = 15), this.hue(this.hue() + t);
}, e.prototype.alpha = function(t) {
return typeof t == "number" ? E({ r: (s = this.rgba).r, g: s.g, b: s.b, a: t }) : v(this.rgba.a, 3);
var s;
}, e.prototype.hue = function(t) {
var s = it(this.rgba);
return typeof t == "number" ? E({ h: t, s: s.s, l: s.l, a: s.a }) : v(s.h);
}, e.prototype.isEqual = function(t) {
return this.toHex() === E(t).toHex();
}, e;
}(), E = function(e) {
return e instanceof ee ? e : new ee(e);
}, $e = /* @__PURE__ */ ((e) => (e[e.AA_NORMAL = 4.5] = "AA_NORMAL", e[e.AA_LARGE = 3] = "AA_LARGE", e[e.AAA_NORMAL = 7] = "AAA_NORMAL", e[e.AAA_LARGE = 4.5] = "AAA_LARGE", e))($e || {});
const ms = {
black: "#000000",
white: "#ffffff",
red: "#ff0000",
green: "#00ff00",
blue: "#0000ff",
yellow: "#ffff00",
cyan: "#00ffff",
magenta: "#ff00ff",
silver: "#c0c0c0",
gray: "#808080",
maroon: "#800000",
olive: "#808000",
purple: "#800080",
teal: "#008080",
navy: "#000080"
};
function bs(e) {
const t = e.toLowerCase().trim();
return ms[t] || null;
}
function wt(e, t) {
const s = se(e), i = se(t), o = Math.max(s, i), r = Math.min(s, i);
return (o + 0.05) / (r + 0.05);
}
function se(e) {
const t = fs(e), s = t.r / 255, i = t.g / 255, o = t.b / 255, r = s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4), n = i <= 0.03928 ? i / 12.92 : Math.pow((i + 0.055) / 1.055, 2.4), a = o <= 0.03928 ? o / 12.92 : Math.pow((o + 0.055) / 1.055, 2.4);
return 0.2126 * r + 0.7152 * n + 0.0722 * a;
}
function ie(e, t = {}) {
if (!E(e).isValid())
return console.warn(`Invalid color provided: ${e}`), "black";
const {
minContrast: i = 4.5,
colorOptions: o = ["black", "white", "light", "dark"],
customShades: r = {
light: "#f8f9fa",
dark: "#343a40"
},
fallback: n = "white"
} = t, a = o.map((u) => u === "black" ? "#000000" : u === "white" ? "#ffffff" : u === "light" ? r.light || "#f8f9fa" : u === "dark" ? r.dark || "#343a40" : u);
let l = n, p = 0;
for (const u of a) {
const b = wt(e, u);
b >= i && b > p && (p = b, l = u);
}
if (p === 0) {
const u = wt(e, n);
l = n, p = u;
for (const b of a) {
if (b === n) continue;
const w = wt(e, b);
w > p && (p = w, l = b);
}
console.warn(
`No color option met the minimum contrast ratio of ${i}:1 against ${e}. Using ${l} with contrast ratio ${p.toFixed(2)}:1 instead.`
);
}
return l;
}
function fs(e) {
const s = bs(e) || e, i = E(s);
if (!i.isValid())
return console.warn(`Invalid color provided: ${e}`), { r: 0, g: 0, b: 0 };
const { r: o, g: r, b: n } = i.toRgb();
return { r: o, g: r, b: n };
}
function N(e, t) {
return e === "left" || e === "right" ? t || "center" : e === "top" || e === "bottom" ? t || "start" : t || "center";
}
function gs(e, t = "1rem") {
if (!e) return t;
const s = {
xs: "0.75rem",
sm: "0.875rem",
md: "1rem",
lg: "1.25rem",
xl: "1.5rem"
}, i = e.toLowerCase().trim();
if (s[i])
return s[i];
const o = e.trim().replace(/\s+/g, " ");
if (/\d+(\.\d+)?\s*(px|em|rem|%|vh|vw|pt|pc|in|cm|mm|ex|ch|vmin|vmax)$/i.test(
o
))
return o.replace(/\s+/g, "");
const n = parseFloat(o);
return isNaN(n) ? t : `${n}rem`;
}
function ys(e, t = "4px") {
if (!e) return t;
const s = {
xs: "2px",
sm: "4px",
md: "6px",
lg: "8px",
xl: "12px",
pill: "9999px"
}, i = e.toLowerCase().trim();
if (s[i])
return s[i];
const o = e.trim().replace(/\s+/g, " ");
if (/\d+(\.\d+)?\s*(px|em|rem|%|vh|vw|pt|pc|in|cm|mm|ex|ch|vmin|vmax)$/i.test(
o
))
return o.replace(/\s+/g, "");
const n = parseFloat(o);
return isNaN(n) ? t : `${n}px`;
}
function Y() {
return {
count: 0,
sum: 0,
avg: 0,
pct: 0,
breakdown: {},
updated: (/* @__PURE__ */ new Date()).toISOString()
};
}
function vs(e) {
if (!Tt())
return Y();
try {
const t = be(e);
return t ? { ...Y(), ...t } : Y();
} catch (t) {
return f.warn("Failed to load localStats from localStorage", t), Y();
}
}
function xs(e, t) {
if (!Tt())
return !1;
try {
return fe(e, t) ? (f.debug("Saved localStats to localStorage", t), !0) : !1;
} catch (s) {
return f.warn("Failed to save localStats to localStorage", s), !1;
}
}
function $s(e, t) {
const s = {
count: Math.max(0, e.count - t.count),
sum: (e.sum || 0) - (t.sum || 0),
avg: 0,
// Will be recalculated below
pct: e.pct || 0,
breakdown: { ...e.breakdown },
updated: e.updated
};
if (s.count > 0 && s.sum !== void 0 ? s.avg = Math.round(s.sum / s.count * 100) / 100 : s.avg = 0, t.breakdown && s.breakdown)
for (const [i, o] of Object.entries(t.breakdown))
s.breakdown[i] && (s.breakdown[i] = Math.max(0, s.breakdown[i] - o), s.breakdown[i] === 0 && delete s.breakdown[i]);
return s;
}
function ws(e, t) {
if (!e.count && !t.count)
return Y();
if (!e.count)
return { ...t };
const s = {
count: e.count + t.count,
sum: (e.sum || 0) + (t.sum || 0),
avg: 0,
// Will be recalculated below
pct: e.pct || 0,
breakdown: { ...e.breakdown },
updated: (/* @__PURE__ */ new Date()).toISOString()
};
if (s.count > 0 && s.sum !== void 0 ? s.avg = Math.round(s.sum / s.count * 100) / 100 : s.avg = 0, t.breakdown) {
s.breakdown || (s.breakdown = {});
for (const [i, o] of Object.entries(t.breakdown))
s.breakdown[i] = (s.breakdown[i] || 0) + o;