pollcatch
Version:
1,335 lines (1,334 loc) • 206 kB
JavaScript
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const $t = globalThis, Yt = $t.ShadowRoot && ($t.ShadyCSS === void 0 || $t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Kt = Symbol(), ee = /* @__PURE__ */ new WeakMap();
let Ee = class {
constructor(t, o, r) {
if (this._$cssResult$ = !0, r !== Kt) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
this.cssText = t, this.t = o;
}
get styleSheet() {
let t = this.o;
const o = this.t;
if (Yt && t === void 0) {
const r = o !== void 0 && o.length === 1;
r && (t = ee.get(o)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && ee.set(o, t));
}
return t;
}
toString() {
return this.cssText;
}
};
const We = (e) => new Ee(typeof e == "string" ? e : e + "", void 0, Kt), R = (e, ...t) => {
const o = e.length === 1 ? e[0] : t.reduce((r, s, i) => r + ((a) => {
if (a._$cssResult$ === !0) return a.cssText;
if (typeof a == "number") return a;
throw Error("Value passed to 'css' function must be a 'css' function result: " + a + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
})(s) + e[i + 1], e[0]);
return new Ee(o, e, Kt);
}, Ge = (e, t) => {
if (Yt) e.adoptedStyleSheets = t.map((o) => o instanceof CSSStyleSheet ? o : o.styleSheet);
else for (const o of t) {
const r = document.createElement("style"), s = $t.litNonce;
s !== void 0 && r.setAttribute("nonce", s), r.textContent = o.cssText, e.appendChild(r);
}
}, oe = Yt ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => {
let o = "";
for (const r of t.cssRules) o += r.cssText;
return We(o);
})(e) : e;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const { is: Ze, defineProperty: Xe, getOwnPropertyDescriptor: Je, getOwnPropertyNames: Qe, getOwnPropertySymbols: to, getPrototypeOf: eo } = Object, j = globalThis, re = j.trustedTypes, oo = re ? re.emptyScript : "", Mt = j.reactiveElementPolyfillSupport, ct = (e, t) => e, Ct = { toAttribute(e, t) {
switch (t) {
case Boolean:
e = e ? oo : null;
break;
case Object:
case Array:
e = e == null ? e : JSON.stringify(e);
}
return e;
}, fromAttribute(e, t) {
let o = e;
switch (t) {
case Boolean:
o = e !== null;
break;
case Number:
o = e === null ? null : Number(e);
break;
case Object:
case Array:
try {
o = JSON.parse(e);
} catch {
o = null;
}
}
return o;
} }, Wt = (e, t) => !Ze(e, t), se = { attribute: !0, type: String, converter: Ct, reflect: !1, hasChanged: Wt };
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), j.litPropertyMetadata ?? (j.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
let et = 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, o = se) {
if (o.state && (o.attribute = !1), this._$Ei(), this.elementProperties.set(t, o), !o.noAccessor) {
const r = Symbol(), s = this.getPropertyDescriptor(t, r, o);
s !== void 0 && Xe(this.prototype, t, s);
}
}
static getPropertyDescriptor(t, o, r) {
const { get: s, set: i } = Je(this.prototype, t) ?? { get() {
return this[o];
}, set(a) {
this[o] = a;
} };
return { get() {
return s == null ? void 0 : s.call(this);
}, set(a) {
const l = s == null ? void 0 : s.call(this);
i.call(this, a), this.requestUpdate(t, l, r);
}, configurable: !0, enumerable: !0 };
}
static getPropertyOptions(t) {
return this.elementProperties.get(t) ?? se;
}
static _$Ei() {
if (this.hasOwnProperty(ct("elementProperties"))) return;
const t = eo(this);
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
}
static finalize() {
if (this.hasOwnProperty(ct("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(ct("properties"))) {
const o = this.properties, r = [...Qe(o), ...to(o)];
for (const s of r) this.createProperty(s, o[s]);
}
const t = this[Symbol.metadata];
if (t !== null) {
const o = litPropertyMetadata.get(t);
if (o !== void 0) for (const [r, s] of o) this.elementProperties.set(r, s);
}
this._$Eh = /* @__PURE__ */ new Map();
for (const [o, r] of this.elementProperties) {
const s = this._$Eu(o, r);
s !== void 0 && this._$Eh.set(s, o);
}
this.elementStyles = this.finalizeStyles(this.styles);
}
static finalizeStyles(t) {
const o = [];
if (Array.isArray(t)) {
const r = new Set(t.flat(1 / 0).reverse());
for (const s of r) o.unshift(oe(s));
} else t !== void 0 && o.push(oe(t));
return o;
}
static _$Eu(t, o) {
const r = o.attribute;
return r === !1 ? void 0 : typeof r == "string" ? r : 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((o) => this.enableUpdating = o), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((o) => o(this));
}
addController(t) {
var o;
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((o = t.hostConnected) == null || o.call(t));
}
removeController(t) {
var o;
(o = this._$EO) == null || o.delete(t);
}
_$E_() {
const t = /* @__PURE__ */ new Map(), o = this.constructor.elementProperties;
for (const r of o.keys()) this.hasOwnProperty(r) && (t.set(r, this[r]), delete this[r]);
t.size > 0 && (this._$Ep = t);
}
createRenderRoot() {
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
return Ge(t, this.constructor.elementStyles), t;
}
connectedCallback() {
var t;
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((o) => {
var r;
return (r = o.hostConnected) == null ? void 0 : r.call(o);
});
}
enableUpdating(t) {
}
disconnectedCallback() {
var t;
(t = this._$EO) == null || t.forEach((o) => {
var r;
return (r = o.hostDisconnected) == null ? void 0 : r.call(o);
});
}
attributeChangedCallback(t, o, r) {
this._$AK(t, r);
}
_$EC(t, o) {
var i;
const r = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, r);
if (s !== void 0 && r.reflect === !0) {
const a = (((i = r.converter) == null ? void 0 : i.toAttribute) !== void 0 ? r.converter : Ct).toAttribute(o, r.type);
this._$Em = t, a == null ? this.removeAttribute(s) : this.setAttribute(s, a), this._$Em = null;
}
}
_$AK(t, o) {
var i;
const r = this.constructor, s = r._$Eh.get(t);
if (s !== void 0 && this._$Em !== s) {
const a = r.getPropertyOptions(s), l = typeof a.converter == "function" ? { fromAttribute: a.converter } : ((i = a.converter) == null ? void 0 : i.fromAttribute) !== void 0 ? a.converter : Ct;
this._$Em = s, this[s] = l.fromAttribute(o, a.type), this._$Em = null;
}
}
requestUpdate(t, o, r) {
if (t !== void 0) {
if (r ?? (r = this.constructor.getPropertyOptions(t)), !(r.hasChanged ?? Wt)(this[t], o)) return;
this.P(t, o, r);
}
this.isUpdatePending === !1 && (this._$ES = this._$ET());
}
P(t, o, r) {
this._$AL.has(t) || this._$AL.set(t, o), r.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
}
async _$ET() {
this.isUpdatePending = !0;
try {
await this._$ES;
} catch (o) {
Promise.reject(o);
}
const t = this.scheduleUpdate();
return t != null && await t, !this.isUpdatePending;
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
var r;
if (!this.isUpdatePending) return;
if (!this.hasUpdated) {
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
for (const [i, a] of this._$Ep) this[i] = a;
this._$Ep = void 0;
}
const s = this.constructor.elementProperties;
if (s.size > 0) for (const [i, a] of s) a.wrapped !== !0 || this._$AL.has(i) || this[i] === void 0 || this.P(i, this[i], a);
}
let t = !1;
const o = this._$AL;
try {
t = this.shouldUpdate(o), t ? (this.willUpdate(o), (r = this._$EO) == null || r.forEach((s) => {
var i;
return (i = s.hostUpdate) == null ? void 0 : i.call(s);
}), this.update(o)) : this._$EU();
} catch (s) {
throw t = !1, this._$EU(), s;
}
t && this._$AE(o);
}
willUpdate(t) {
}
_$AE(t) {
var o;
(o = this._$EO) == null || o.forEach((r) => {
var s;
return (s = r.hostUpdated) == null ? void 0 : s.call(r);
}), 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((o) => this._$EC(o, this[o]))), this._$EU();
}
updated(t) {
}
firstUpdated(t) {
}
};
et.elementStyles = [], et.shadowRootOptions = { mode: "open" }, et[ct("elementProperties")] = /* @__PURE__ */ new Map(), et[ct("finalized")] = /* @__PURE__ */ new Map(), Mt == null || Mt({ ReactiveElement: et }), (j.reactiveElementVersions ?? (j.reactiveElementVersions = [])).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const dt = globalThis, kt = dt.trustedTypes, ie = kt ? kt.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, Ae = "$lit$", V = `lit$${Math.random().toFixed(9).slice(2)}$`, Pe = "?" + V, ro = `<${Pe}>`, G = document, ut = () => G.createComment(""), ht = (e) => e === null || typeof e != "object" && typeof e != "function", Gt = Array.isArray, so = (e) => Gt(e) || typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", Lt = `[
\f\r]`, nt = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ae = /-->/g, ne = />/g, K = RegExp(`>|${Lt}(?:([^\\s"'>=/]+)(${Lt}*=${Lt}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g"), le = /'/g, ce = /"/g, Te = /^(?:script|style|textarea|title)$/i, io = (e) => (t, ...o) => ({ _$litType$: e, strings: t, values: o }), c = io(1), q = Symbol.for("lit-noChange"), u = Symbol.for("lit-nothing"), de = /* @__PURE__ */ new WeakMap(), W = G.createTreeWalker(G, 129);
function _e(e, t) {
if (!Gt(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
return ie !== void 0 ? ie.createHTML(t) : t;
}
const ao = (e, t) => {
const o = e.length - 1, r = [];
let s, i = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = nt;
for (let l = 0; l < o; l++) {
const n = e[l];
let d, p, h = -1, b = 0;
for (; b < n.length && (a.lastIndex = b, p = a.exec(n), p !== null); ) b = a.lastIndex, a === nt ? p[1] === "!--" ? a = ae : p[1] !== void 0 ? a = ne : p[2] !== void 0 ? (Te.test(p[2]) && (s = RegExp("</" + p[2], "g")), a = K) : p[3] !== void 0 && (a = K) : a === K ? p[0] === ">" ? (a = s ?? nt, h = -1) : p[1] === void 0 ? h = -2 : (h = a.lastIndex - p[2].length, d = p[1], a = p[3] === void 0 ? K : p[3] === '"' ? ce : le) : a === ce || a === le ? a = K : a === ae || a === ne ? a = nt : (a = K, s = void 0);
const x = a === K && e[l + 1].startsWith("/>") ? " " : "";
i += a === nt ? n + ro : h >= 0 ? (r.push(d), n.slice(0, h) + Ae + n.slice(h) + V + x) : n + V + (h === -2 ? l : x);
}
return [_e(e, i + (e[o] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
};
let Ft = class Oe {
constructor({ strings: t, _$litType$: o }, r) {
let s;
this.parts = [];
let i = 0, a = 0;
const l = t.length - 1, n = this.parts, [d, p] = ao(t, o);
if (this.el = Oe.createElement(d, r), W.currentNode = this.el.content, o === 2 || o === 3) {
const h = this.el.content.firstChild;
h.replaceWith(...h.childNodes);
}
for (; (s = W.nextNode()) !== null && n.length < l; ) {
if (s.nodeType === 1) {
if (s.hasAttributes()) for (const h of s.getAttributeNames()) if (h.endsWith(Ae)) {
const b = p[a++], x = s.getAttribute(h).split(V), E = /([.?@])?(.*)/.exec(b);
n.push({ type: 1, index: i, name: E[2], strings: x, ctor: E[1] === "." ? lo : E[1] === "?" ? co : E[1] === "@" ? po : Tt }), s.removeAttribute(h);
} else h.startsWith(V) && (n.push({ type: 6, index: i }), s.removeAttribute(h));
if (Te.test(s.tagName)) {
const h = s.textContent.split(V), b = h.length - 1;
if (b > 0) {
s.textContent = kt ? kt.emptyScript : "";
for (let x = 0; x < b; x++) s.append(h[x], ut()), W.nextNode(), n.push({ type: 2, index: ++i });
s.append(h[b], ut());
}
}
} else if (s.nodeType === 8) if (s.data === Pe) n.push({ type: 2, index: i });
else {
let h = -1;
for (; (h = s.data.indexOf(V, h + 1)) !== -1; ) n.push({ type: 7, index: i }), h += V.length - 1;
}
i++;
}
}
static createElement(t, o) {
const r = G.createElement("template");
return r.innerHTML = t, r;
}
};
function rt(e, t, o = e, r) {
var a, l;
if (t === q) return t;
let s = r !== void 0 ? (a = o._$Co) == null ? void 0 : a[r] : o._$Cl;
const i = ht(t) ? void 0 : t._$litDirective$;
return (s == null ? void 0 : s.constructor) !== i && ((l = s == null ? void 0 : s._$AO) == null || l.call(s, !1), i === void 0 ? s = void 0 : (s = new i(e), s._$AT(e, o, r)), r !== void 0 ? (o._$Co ?? (o._$Co = []))[r] = s : o._$Cl = s), s !== void 0 && (t = rt(e, s._$AS(e, t.values), s, r)), t;
}
let no = class {
constructor(t, o) {
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = o;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
u(t) {
const { el: { content: o }, parts: r } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ?? G).importNode(o, !0);
W.currentNode = s;
let i = W.nextNode(), a = 0, l = 0, n = r[0];
for (; n !== void 0; ) {
if (a === n.index) {
let d;
n.type === 2 ? d = new ft(i, i.nextSibling, this, t) : n.type === 1 ? d = new n.ctor(i, n.name, n.strings, this, t) : n.type === 6 && (d = new uo(i, this, t)), this._$AV.push(d), n = r[++l];
}
a !== (n == null ? void 0 : n.index) && (i = W.nextNode(), a++);
}
return W.currentNode = G, s;
}
p(t) {
let o = 0;
for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, o), o += r.strings.length - 2) : r._$AI(t[o])), o++;
}
};
class ft {
get _$AU() {
var t;
return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
}
constructor(t, o, r, s) {
this.type = 2, this._$AH = u, this._$AN = void 0, this._$AA = t, this._$AB = o, this._$AM = r, this.options = s, this._$Cv = (s == null ? void 0 : s.isConnected) ?? !0;
}
get parentNode() {
let t = this._$AA.parentNode;
const o = this._$AM;
return o !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = o.parentNode), t;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t, o = this) {
t = rt(this, t, o), ht(t) ? t === u || t == null || t === "" ? (this._$AH !== u && this._$AR(), this._$AH = u) : t !== this._$AH && t !== q && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : so(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 !== u && ht(this._$AH) ? this._$AA.nextSibling.data = t : this.T(G.createTextNode(t)), this._$AH = t;
}
$(t) {
var i;
const { values: o, _$litType$: r } = t, s = typeof r == "number" ? this._$AC(t) : (r.el === void 0 && (r.el = Ft.createElement(_e(r.h, r.h[0]), this.options)), r);
if (((i = this._$AH) == null ? void 0 : i._$AD) === s) this._$AH.p(o);
else {
const a = new no(s, this), l = a.u(this.options);
a.p(o), this.T(l), this._$AH = a;
}
}
_$AC(t) {
let o = de.get(t.strings);
return o === void 0 && de.set(t.strings, o = new Ft(t)), o;
}
k(t) {
Gt(this._$AH) || (this._$AH = [], this._$AR());
const o = this._$AH;
let r, s = 0;
for (const i of t) s === o.length ? o.push(r = new ft(this.O(ut()), this.O(ut()), this, this.options)) : r = o[s], r._$AI(i), s++;
s < o.length && (this._$AR(r && r._$AB.nextSibling, s), o.length = s);
}
_$AR(t = this._$AA.nextSibling, o) {
var r;
for ((r = this._$AP) == null ? void 0 : r.call(this, !1, !0, o); t && t !== this._$AB; ) {
const s = t.nextSibling;
t.remove(), t = s;
}
}
setConnected(t) {
var o;
this._$AM === void 0 && (this._$Cv = t, (o = this._$AP) == null || o.call(this, t));
}
}
class Tt {
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
constructor(t, o, r, s, i) {
this.type = 1, this._$AH = u, this._$AN = void 0, this.element = t, this.name = o, this._$AM = s, this.options = i, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = u;
}
_$AI(t, o = this, r, s) {
const i = this.strings;
let a = !1;
if (i === void 0) t = rt(this, t, o, 0), a = !ht(t) || t !== this._$AH && t !== q, a && (this._$AH = t);
else {
const l = t;
let n, d;
for (t = i[0], n = 0; n < i.length - 1; n++) d = rt(this, l[r + n], o, n), d === q && (d = this._$AH[n]), a || (a = !ht(d) || d !== this._$AH[n]), d === u ? t = u : t !== u && (t += (d ?? "") + i[n + 1]), this._$AH[n] = d;
}
a && !s && this.j(t);
}
j(t) {
t === u ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
}
}
let lo = class extends Tt {
constructor() {
super(...arguments), this.type = 3;
}
j(t) {
this.element[this.name] = t === u ? void 0 : t;
}
};
class co extends Tt {
constructor() {
super(...arguments), this.type = 4;
}
j(t) {
this.element.toggleAttribute(this.name, !!t && t !== u);
}
}
class po extends Tt {
constructor(t, o, r, s, i) {
super(t, o, r, s, i), this.type = 5;
}
_$AI(t, o = this) {
if ((t = rt(this, t, o, 0) ?? u) === q) return;
const r = this._$AH, s = t === u && r !== u || t.capture !== r.capture || t.once !== r.once || t.passive !== r.passive, i = t !== u && (r === u || s);
s && this.element.removeEventListener(this.name, this, r), i && this.element.addEventListener(this.name, this, t), this._$AH = t;
}
handleEvent(t) {
var o;
typeof this._$AH == "function" ? this._$AH.call(((o = this.options) == null ? void 0 : o.host) ?? this.element, t) : this._$AH.handleEvent(t);
}
}
class uo {
constructor(t, o, r) {
this.element = t, this.type = 6, this._$AN = void 0, this._$AM = o, this.options = r;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t) {
rt(this, t);
}
}
const Nt = dt.litHtmlPolyfillSupport;
Nt == null || Nt(Ft, ft), (dt.litHtmlVersions ?? (dt.litHtmlVersions = [])).push("3.2.1");
const ho = (e, t, o) => {
const r = (o == null ? void 0 : o.renderBefore) ?? t;
let s = r._$litPart$;
if (s === void 0) {
const i = (o == null ? void 0 : o.renderBefore) ?? null;
r._$litPart$ = s = new ft(t.insertBefore(ut(), i), i, void 0, o ?? {});
}
return s._$AI(e), s;
};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let N = class extends et {
constructor() {
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
}
createRenderRoot() {
var o;
const t = super.createRenderRoot();
return (o = this.renderOptions).renderBefore ?? (o.renderBefore = t.firstChild), t;
}
update(t) {
const o = this.render();
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = ho(o, 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 q;
}
};
var ke;
N._$litElement$ = !0, N.finalized = !0, (ke = globalThis.litElementHydrateSupport) == null || ke.call(globalThis, { LitElement: N });
const Dt = globalThis.litElementPolyfillSupport;
Dt == null || Dt({ LitElement: N });
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const F = (e) => (t, o) => {
o !== void 0 ? o.addInitializer(() => {
customElements.define(e, t);
}) : customElements.define(e, t);
};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const fo = { attribute: !0, type: String, converter: Ct, reflect: !1, hasChanged: Wt }, go = (e = fo, t, o) => {
const { kind: r, metadata: s } = o;
let i = globalThis.litPropertyMetadata.get(s);
if (i === void 0 && globalThis.litPropertyMetadata.set(s, i = /* @__PURE__ */ new Map()), i.set(o.name, e), r === "accessor") {
const { name: a } = o;
return { set(l) {
const n = t.get.call(this);
t.set.call(this, l), this.requestUpdate(a, n, e);
}, init(l) {
return l !== void 0 && this.P(a, void 0, e), l;
} };
}
if (r === "setter") {
const { name: a } = o;
return function(l) {
const n = this[a];
t.call(this, l), this.requestUpdate(a, n, e);
};
}
throw Error("Unsupported decorator location: " + r);
};
function f(e) {
return (t, o) => typeof o == "object" ? go(e, t, o) : ((r, s, i) => {
const a = s.hasOwnProperty(i);
return s.constructor.createProperty(i, a ? { ...r, wrapped: !0 } : r), a ? Object.getOwnPropertyDescriptor(s, i) : void 0;
})(e, t, o);
}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function k(e) {
return f({ ...e, state: !0, attribute: !1 });
}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const mo = (e, t, o) => (o.configurable = !0, o.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(e, t, o), o);
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function gt(e, t) {
return (o, r, s) => {
const i = (a) => {
var l;
return ((l = a.renderRoot) == null ? void 0 : l.querySelector(e)) ?? null;
};
return mo(o, r, { get() {
return i(this);
} });
};
}
var $ = /* @__PURE__ */ ((e) => (e.reaction = "reaction", e.stars = "stars", e.poll = "poll", e.text = "text", e.nps = "nps", e))($ || {});
const Zt = c`
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="currentColor"
>
<path d="M640-160v-280h160v280H640Zm-240 0v-640h160v640H400Zm-240 0v-440h160v440H160Z" />
</svg>
`, Xt = c`
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="currentColor"
>
<path
d="M160-160v-440h160v440H160Zm240 0v-400l160 160v240H400Zm160-354L400-674v-126h160v286Zm240 240L640-434v-6h160v166Zm-9 219L55-791l57-57 736 736-57 57Z"
/>
</svg>
`, Et = c`
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="currentColor"
>
<path
d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"
/>
</svg>
`, _t = c`
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
viewBox="0 0 16 16"
>
<path
d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"
/>
</svg>
`, Ie = c`
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="currentColor"
>
<path d="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z" />
</svg>
`;
var vo = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, M = function(e) {
return typeof e == "string" ? e.length > 0 : typeof e == "number";
}, S = function(e, t, o) {
return t === void 0 && (t = 0), o === void 0 && (o = Math.pow(10, t)), Math.round(o * e) / o + 0;
}, T = function(e, t, o) {
return t === void 0 && (t = 0), o === void 0 && (o = 1), e > o ? o : e > t ? e : t;
}, ze = function(e) {
return (e = isFinite(e) ? e % 360 : 0) > 0 ? e : e + 360;
}, pe = function(e) {
return { r: T(e.r, 0, 255), g: T(e.g, 0, 255), b: T(e.b, 0, 255), a: T(e.a) };
}, Rt = function(e) {
return { r: S(e.r), g: S(e.g), b: S(e.b), a: S(e.a, 3) };
}, bo = /^#([0-9a-f]{3,8})$/i, yt = function(e) {
var t = e.toString(16);
return t.length < 2 ? "0" + t : t;
}, Me = function(e) {
var t = e.r, o = e.g, r = e.b, s = e.a, i = Math.max(t, o, r), a = i - Math.min(t, o, r), l = a ? i === t ? (o - r) / a : i === o ? 2 + (r - t) / a : 4 + (t - o) / a : 0;
return { h: 60 * (l < 0 ? l + 6 : l), s: i ? a / i * 100 : 0, v: i / 255 * 100, a: s };
}, Le = function(e) {
var t = e.h, o = e.s, r = e.v, s = e.a;
t = t / 360 * 6, o /= 100, r /= 100;
var i = Math.floor(t), a = r * (1 - o), l = r * (1 - (t - i) * o), n = r * (1 - (1 - t + i) * o), d = i % 6;
return { r: 255 * [r, l, a, a, n, r][d], g: 255 * [n, r, r, l, a, a][d], b: 255 * [a, a, n, r, r, l][d], a: s };
}, ue = function(e) {
return { h: ze(e.h), s: T(e.s, 0, 100), l: T(e.l, 0, 100), a: T(e.a) };
}, he = function(e) {
return { h: S(e.h), s: S(e.s), l: S(e.l), a: S(e.a, 3) };
}, fe = function(e) {
return Le((o = (t = e).s, { h: t.h, s: (o *= ((r = t.l) < 50 ? r : 100 - r) / 100) > 0 ? 2 * o / (r + o) * 100 : 0, v: r + o, a: t.a }));
var t, o, r;
}, pt = function(e) {
return { h: (t = Me(e)).h, s: (s = (200 - (o = t.s)) * (r = t.v) / 100) > 0 && s < 200 ? o * r / 100 / (s <= 100 ? s : 200 - s) * 100 : 0, l: s / 2, a: t.a };
var t, o, r, s;
}, yo = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, xo = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, wo = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, $o = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = { string: [[function(e) {
var t = bo.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 ? S(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 ? S(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
}, "hex"], [function(e) {
var t = wo.exec(e) || $o.exec(e);
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : pe({ 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 = yo.exec(e) || xo.exec(e);
if (!t) return null;
var o, r, s = ue({ h: (o = t[1], r = t[2], r === void 0 && (r = "deg"), Number(o) * (vo[r] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
return fe(s);
}, "hsl"]], object: [[function(e) {
var t = e.r, o = e.g, r = e.b, s = e.a, i = s === void 0 ? 1 : s;
return M(t) && M(o) && M(r) ? pe({ r: Number(t), g: Number(o), b: Number(r), a: Number(i) }) : null;
}, "rgb"], [function(e) {
var t = e.h, o = e.s, r = e.l, s = e.a, i = s === void 0 ? 1 : s;
if (!M(t) || !M(o) || !M(r)) return null;
var a = ue({ h: Number(t), s: Number(o), l: Number(r), a: Number(i) });
return fe(a);
}, "hsl"], [function(e) {
var t = e.h, o = e.s, r = e.v, s = e.a, i = s === void 0 ? 1 : s;
if (!M(t) || !M(o) || !M(r)) return null;
var a = function(l) {
return { h: ze(l.h), s: T(l.s, 0, 100), v: T(l.v, 0, 100), a: T(l.a) };
}({ h: Number(t), s: Number(o), v: Number(r), a: Number(i) });
return Le(a);
}, "hsv"]] }, me = function(e, t) {
for (var o = 0; o < t.length; o++) {
var r = t[o][0](e);
if (r) return [r, t[o][1]];
}
return [null, void 0];
}, So = function(e) {
return typeof e == "string" ? me(e.trim(), ge.string) : typeof e == "object" && e !== null ? me(e, ge.object) : [null, void 0];
}, Bt = function(e, t) {
var o = pt(e);
return { h: o.h, s: T(o.s + 100 * t, 0, 100), l: o.l, a: o.a };
}, Vt = function(e) {
return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
}, ve = function(e, t) {
var o = pt(e);
return { h: o.h, s: o.s, l: T(o.l + 100 * t, 0, 100), a: o.a };
}, be = function() {
function e(t) {
this.parsed = So(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 S(Vt(this.rgba), 2);
}, e.prototype.isDark = function() {
return Vt(this.rgba) < 0.5;
}, e.prototype.isLight = function() {
return Vt(this.rgba) >= 0.5;
}, e.prototype.toHex = function() {
return t = Rt(this.rgba), o = t.r, r = t.g, s = t.b, a = (i = t.a) < 1 ? yt(S(255 * i)) : "", "#" + yt(o) + yt(r) + yt(s) + a;
var t, o, r, s, i, a;
}, e.prototype.toRgb = function() {
return Rt(this.rgba);
}, e.prototype.toRgbString = function() {
return t = Rt(this.rgba), o = t.r, r = t.g, s = t.b, (i = t.a) < 1 ? "rgba(" + o + ", " + r + ", " + s + ", " + i + ")" : "rgb(" + o + ", " + r + ", " + s + ")";
var t, o, r, s, i;
}, e.prototype.toHsl = function() {
return he(pt(this.rgba));
}, e.prototype.toHslString = function() {
return t = he(pt(this.rgba)), o = t.h, r = t.s, s = t.l, (i = t.a) < 1 ? "hsla(" + o + ", " + r + "%, " + s + "%, " + i + ")" : "hsl(" + o + ", " + r + "%, " + s + "%)";
var t, o, r, s, i;
}, e.prototype.toHsv = function() {
return t = Me(this.rgba), { h: S(t.h), s: S(t.s), v: S(t.v), a: S(t.a, 3) };
var t;
}, e.prototype.invert = function() {
return _({ 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), _(Bt(this.rgba, t));
}, e.prototype.desaturate = function(t) {
return t === void 0 && (t = 0.1), _(Bt(this.rgba, -t));
}, e.prototype.grayscale = function() {
return _(Bt(this.rgba, -1));
}, e.prototype.lighten = function(t) {
return t === void 0 && (t = 0.1), _(ve(this.rgba, t));
}, e.prototype.darken = function(t) {
return t === void 0 && (t = 0.1), _(ve(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" ? _({ r: (o = this.rgba).r, g: o.g, b: o.b, a: t }) : S(this.rgba.a, 3);
var o;
}, e.prototype.hue = function(t) {
var o = pt(this.rgba);
return typeof t == "number" ? _({ h: t, s: o.s, l: o.l, a: o.a }) : S(o.h);
}, e.prototype.isEqual = function(t) {
return this.toHex() === _(t).toHex();
}, e;
}(), _ = function(e) {
return e instanceof be ? e : new be(e);
};
const Co = typeof process < "u" && (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test");
function Ut() {
if (Co) return !0;
try {
return typeof localStorage < "u" && localStorage.getItem("pc-mode") === "development";
} catch {
return !1;
}
}
function ko(e) {
return {
debug: (t, ...o) => {
Ut() && console.debug(`[${e}]`, t, ...o);
},
info: (t, ...o) => {
Ut() && console.info(`[${e}]`, t, ...o);
},
warn: (t, ...o) => {
Ut() && console.warn(`[${e}]`, t, ...o);
},
error: (t, ...o) => {
console.error(`[${e}]`, t, ...o);
}
};
}
const g = ko("Pollcatch");
var Ne = /* @__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))(Ne || {});
const Eo = {
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 Ao(e) {
const t = e.toLowerCase().trim();
return Eo[t] || null;
}
function jt(e, t) {
const o = ye(e), r = ye(t), s = Math.max(o, r), i = Math.min(o, r);
return (s + 0.05) / (i + 0.05);
}
function ye(e) {
const t = To(e), o = t.r / 255, r = t.g / 255, s = t.b / 255, i = o <= 0.03928 ? o / 12.92 : Math.pow((o + 0.055) / 1.055, 2.4), a = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4), l = s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
return 0.2126 * i + 0.7152 * a + 0.0722 * l;
}
function Po(e, t = {}) {
if (!_(e).isValid())
return g.warn(`Invalid color provided: ${e}`), "black";
const {
minContrast: r = 4.5,
colorOptions: s = ["black", "white", "light", "dark"],
customShades: i = {
light: "#f8f9fa",
dark: "#343a40"
},
fallback: a = "white"
} = t, l = s.map((p) => p === "black" ? "#000000" : p === "white" ? "#ffffff" : p === "light" ? i.light || "#f8f9fa" : p === "dark" ? i.dark || "#343a40" : p);
let n = a, d = 0;
for (const p of l) {
const h = jt(e, p);
h >= r && h > d && (d = h, n = p);
}
if (d === 0) {
const p = jt(e, a);
n = a, d = p;
for (const h of l) {
if (h === a) continue;
const b = jt(e, h);
b > d && (d = b, n = h);
}
g.warn(
`No color option met the minimum contrast ratio of ${r}:1 against ${e}. Using ${n} with contrast ratio ${d.toFixed(2)}:1 instead.`
);
}
return n;
}
function To(e) {
const o = Ao(e) || e, r = _(o);
if (!r.isValid())
return g.warn(`Invalid color provided: ${e}`), { r: 0, g: 0, b: 0 };
const { r: s, g: i, b: a } = r.toRgb();
return { r: s, g: i, b: a };
}
function I(e, t) {
const r = t ? {
left: "start",
right: "end",
top: "start",
bottom: "end",
center: "center",
start: "start",
end: "end"
}[t] : void 0;
return e === "left" || e === "right" ? r || "center" : e === "top" || e === "bottom" ? r || "start" : r || "center";
}
function qt(e, t = "1rem", o = 1) {
if (!e) return t;
const r = {
xs: 0.7,
sm: 0.8,
md: 1,
lg: 1.2,
xl: 1.5
}, s = e.toLowerCase().trim();
if (r[s] !== void 0)
return `${r[s] * o}em`;
const i = 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(
i
))
return i.replace(/\s+/g, "");
const l = parseFloat(i);
return isNaN(l) ? t : `${l}rem`;
}
function _o(e, t = "4px") {
if (!e) return t;
const o = {
xs: "2px",
sm: "4px",
md: "6px",
lg: "8px",
xl: "12px",
pill: "9999px"
}, r = e.toLowerCase().trim();
if (o[r])
return o[r];
const s = 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(
s
))
return s.replace(/\s+/g, "");
const a = parseFloat(s);
return isNaN(a) ? t : `${a}px`;
}
var L = /* @__PURE__ */ ((e) => (e.BUTTON = "button", e.CHECKBOX = "checkbox", e.RADIO = "radio", e.RADIOGROUP = "radiogroup", e.SWITCH = "switch", e.TAB = "tab", e.TABLIST = "tablist", e.TABPANEL = "tabpanel", e.MENU = "menu", e.MENUITEM = "menuitem", e.MENUITEMCHECKBOX = "menuitemcheckbox", e.MENUITEMRADIO = "menuitemradio", e.SLIDER = "slider", e.TEXTBOX = "textbox", e.COMBOBOX = "combobox", e.LISTBOX = "listbox", e.OPTION = "option", e.PROGRESSBAR = "progressbar", e.STATUS = "status", e.ALERT = "alert", e.DIALOG = "dialog", e.GROUP = "group", e.REGION = "region", e.NONE = "none", e.PRESENTATION = "presentation", e))(L || {});
function ot(e) {
const t = {};
e.role !== void 0 && (t.role = e.role);
for (const [o, r] of Object.entries(e)) {
if (o === "role" || r === void 0) continue;
const s = `aria-${o.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^aria-aria-/, "aria-")}`;
typeof r == "boolean" ? t[s] = r ? "true" : "false" : t[s] = r;
}
return t;
}
function Oo(e, t, o) {
return ot({
role: "button",
ariaLabel: e,
ariaPressed: t,
ariaDisabled: o
});
}
function Io(e, t, o, r = !1) {
return ot({
role: r ? "radio" : "checkbox",
ariaLabel: e,
ariaChecked: t,
ariaDisabled: o
});
}
function Ht(e, t, o) {
typeof o == "boolean" ? e.setAttribute(t, o ? "true" : "false") : e.setAttribute(t, o);
}
function zo(e) {
if (typeof e != "string")
return !1;
const t = e.replace(/[<>"']/g, "").trim();
return /^(#[0-9a-fA-F]{3,8}|rgb\([^)]+\)|rgba\([^)]+\)|hsl\([^)]+\)|hsla\([^)]+\)|[a-zA-Z]+)$/.test(t);
}
function tt(e) {
return zo(e) ? e.replace(/[<>"']/g, "").trim() : (g.warn("Invalid color value:", e), "#000000");
}
function Mo(e) {
if (typeof e != "string")
return g.warn("Non-string value passed to sanitizeCSS:", typeof e), "";
let t = e;
return t = t.replace(/@import[^;]+;/gi, "").replace(/expression\s*\([^)]*\)/gi, "").replace(/javascript:\s*[^"'\s;]*/gi, "").replace(/url\s*\(\s*["']?data:(?!image\/[^;]+;base64,)[^"')]*["']?\s*\)/gi, "").replace(/-moz-binding\s*:[^;]+;/gi, "").replace(/behavior\s*:[^;]+;/gi, ""), t;
}
function Lo(e) {
return typeof e != "string" || !e.trim() ? "" : e.replace(
/([^{}:;]+):\s*([^;{}!]+)(\s*!important)?\s*(;|})/gi,
(t, o, r, s, i) => s ? t : `${o}: ${r.trim()} !important${i}`
);
}
const No = "https://jpxwfjorwcsrqraorpbj.supabase.co/functions/v1/data", Do = "pc_session_id", Ro = 24 * 60 * 60 * 1e3;
function xe() {
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : (g.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 Jt() {
const e = "test-local-storage";
try {
return localStorage.setItem(e, e), localStorage.removeItem(e), !0;
} catch {
return g.warn("localStorage not available, session ID will not persist"), !1;
}
}
function De(e) {
try {
const t = localStorage.getItem(e);
return t ? JSON.parse(t) : void 0;
} catch (t) {
g.warn(`Failed to get item from localStorage: ${e}`, t);
return;
}
}
function Re(e, t) {
try {
return localStorage.setItem(e, JSON.stringify(t)), !0;
} catch (o) {
return g.warn(`Failed to set item in localStorage: ${e}`, o), !1;
}
}
async function we() {
const e = Do, t = Ro;
if (Jt()) {
const o = De(e);
if (o && o.id && o.timestamp && Date.now() - o.timestamp < t)
return g.debug("Using existing session ID from localStorage"), o.id;
g.debug(
o ? "Session ID expired" : "No session ID found",
"generating new one"
);
const r = xe();
return Re(e, {
id: r,
timestamp: Date.now()
}) ? g.debug("Generated and stored new session ID") : g.warn("Generated session ID but failed to store it"), r;
} else {
const o = xe();
return g.debug("Generated non-persistent session ID"), o;
}
}
function At(e) {
if (!e || typeof e != "object")
return 0;
let t = 0, o = 0, r = 0;
for (let a = 0; a <= 10; a++) {
const l = a.toString(), n = Math.max(0, e[l] || 0);
r += n, a >= 9 ? t += n : a >= 7 || (o += n);
}
if (r === 0)
return 0;
const s = t / r * 100, i = o / r * 100;
return Math.round(s - i);
}
function Bo(e) {
if (!e || typeof e != "object")
return { promoters: 0, passives: 0, detractors: 0 };
let t = 0, o = 0, r = 0;
for (let s = 0; s <= 10; s++) {
const i = s.toString(), a = Math.max(0, e[i] || 0);
s >= 9 ? t += a : s >= 7 ? o += a : r += a;
}
return { promoters: t, passives: o, detractors: r };
}
function Vo(e, t) {
const o = {};
for (const r of t)
o[r] = e[r] || 0;
return o;
}
function Uo(e, t) {
const o = t ? Vo(e, t) : e;
let r = 0, s = 0;
for (const [a, l] of Object.entries(o)) {
s += l;
const n = parseInt(a, 10);
isNaN(n) || (r += n * l);
}
return { avg: s > 0 ? Math.round(r / s * 10) / 10 : 0, count: s, sum: r, breakdown: o };
}
function U() {
return {
count: 0,
sum: 0,
avg: 0,
pct: 0,
breakdown: {},
updated: (/* @__PURE__ */ new Date()).toISOString()
};
}
function jo(e) {
if (!Jt())
return U();
try {
const t = De(e);
return t ? { ...U(), ...t } : U();
} catch (t) {
return g.warn("Failed to load localStats from localStorage", t), U();
}
}
function qo(e, t) {
if (!Jt())
return !1;
try {
return Re(e, t) ? (g.debug("Saved localStats to localStorage", t), !0) : !1;
} catch (o) {
return g.warn("Failed to save localStats to localStorage", o), !1;
}
}
function Ho(e, t) {
const o = {
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 (o.count > 0 && o.sum !== void 0 ? o.avg = Math.round(o.sum / o.count * 100) / 100 : o.avg = 0, t.breakdown && o.breakdown)
for (const [r, s] of Object.entries(t.breakdown))
o.breakdown[r] && (o.breakdown[r] = Math.max(0, o.breakdown[r] - s), o.breakdown[r] === 0 && delete o.breakdown[r]);
return o.nps = At((o == null ? void 0 : o.breakdown) || {}), o;
}
function Fo(e, t) {
if (!e.count && !t.count)
return U();
if (!e.count)
return { ...t };
const o = {
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 (o.count > 0 && o.sum !== void 0 ? o.avg = Math.round(o.sum / o.count * 100) / 100 : o.avg = 0, t.breakdown) {
o.breakdown || (o.breakdown = {});
for (const [r, s] of Object.entries(t.breakdown))
o.breakdown[r] = (o.breakdown[r] || 0) + s;
}
return o.nps = At((o == null ? void 0 : o.breakdown) || {}), o;
}
function Be(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 Ot(e) {
if (!e || typeof e != "string")
return !1;
const t = e.trim();
if (t.length === 0)
return !1;
if (t.startsWith("/") || t.startsWith("./"))
return !0;
try {
return t.startsWith("//") ? (new URL(`http:${t}`), !0) : (new URL(t), !0);
} catch {
return !1;
}
}
function Ve(e) {
if (!e || typeof e != "string")
return [];
const t = e.trim();
if (!t)
return [];
if (t.startsWith("[") && t.endsWith("]"))
try {
const o = JSON.parse(t);
if (Array.isArray(o))
return o.map((r) => String(r)).filter((r) => r.trim() !== "");
} catch {
}
return t.split(",").map((o) => o.trim()).filter((o) => o !== "");
}
function Yo(e, t) {
const o = /{([^{}]+)}/g;
return e.replace(o, (r, s) => {
const i = s.trim(), a = t[i];
return a !== void 0 ? String(a) : r;
});
}
function Ko(e, t) {
let o = 2166136261;
const r = e + ":" + t;
for (let s = 0; s < r.length; s++)
o ^= r.charCodeAt(s), o += (o << 1) + (o << 4) + (o << 7) + (o << 8) + (o << 24);
return (o >>> 0).toString(16).padStart(8, "0");
}
function Wo(e, t = 50) {
return e.length <= t ? e : e.substring(0, t).trim() + "...";
}
function xt(e) {
if (!e) return;
const t = e.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
return t.length > 0 ? t : void 0;
}
const Go = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, $e = 5;
function Ue(e) {
return e || No;
}
function je(e, t, o) {
const r = Ue(t);
let s;
if (e.type === "registered" ? s = `${r}/widgets/${encodeURIComponent(e.widgetId)}` : s = `${r}/public-widgets/${encodeURIComponent(e.name)}`, o) {
const i = new URLSearchParams();
for (const [l, n] of Object.entries(o))
n && i.set(l, n);
const a = i.toString();
a && (s += `?${a}`);
}
return s;
}
async function Se(e, t, o) {
const r = je(e, t, o);
g.debug("API GET", { url: r });
const s = await fetch(r);
if (!s.ok)
throw new Error(`API request failed with status: ${s.status}`);
const i = await s.json();
if (!i.success)
throw new Error("Backend returned unsuccessful response");
return i;
}
async function Zo(e, t, o) {
const r = je(e, o);
if (g.debug("API POST", { url: r }), typeof navigator < "u" && navigator.sendBeacon) {
if (navigator.sendBeacon(r, t)) {
g.debug("Successfully sent stats via sendBeacon");
return;
}
g.debug("sendBeacon failed, falling back to fetch");
}
const s = await fetch(r, {
body: t,
method: "POST",
keepalive: !0,
headers: {
"Content-Type": "application/json"
}
});
if (!s.ok)
throw new Error(`API request failed with status: ${s.status}`);
g.debug("Successfully sent stats via fetch");
}
class Xo {
// Set when a fatal error occurs (e.g. type mismatch for registered widget)
constructor(t) {
this.stats = U(), this.localStats = U(), this.isLoading = !0, this.isLoadingConfig = !1, this.isSubmitting = !1, this.hasInteracted = !1, this.hasError = !1, (this.host = t).addController(this);
}
hostConnected() {
this.loadStats();
}
/**
* Validates and returns the widget identifier.
* Returns null (and logs the error) when validation fails.
*/
getWidgetIdentifier() {
const t = this.host;
return t.widgetId ? Go.test(t.widgetId) ? { type: "registered", widgetId: t.widgetId } : (g.error(`Invalid widget-id format: ${t.widgetId}`), null) : t.name ? t.name.length < $e ? (g.error(
`Widget name must be at least ${$e} characters long. Got: "${t.name}"`
), null) : { type: "public", name: t.name } : (g.error("Widget requires either widget-id or name attribute"), null);
}
async getLocalStatsKey() {
const t = this.host, o = await we(), r = t.widgetId || t.name || "unnamed", s = xt(t.metadata), i = s ? `-${s}` : "";
return `pc-local-stats-${o}-${r}${i}`;
}
/**
* while 'hostConnected' is not async, we need to use this wrapper function
* because we need to load the local stats first, and then the server stats.
*/
async loadStats() {
await this.loadLocalStats(), await this.loadServerStats();
}
/**
* Applies widget attributes from registered widget API response
* Sets attributes on the host element based on the attributes config
*/
applyWidgetAttributes(t) {
if (!t) return;
const o = typeof t.attributes == "object" && t.attributes !== null && !Array.isArray(t.attributes) ? t.attributes : t, r = this.host, s = r, i = /* @__PURE__ */ new Set(["type", "options", "initialized", "num-stars", "multiple"]), a = /* @__PURE__ */ new Set();
for (let l = 0; l < s.attributes.length; l++) {
const n = s.attributes[l];
n && !i.has(n.name) && a.add(n.name);
}
for (const [l, n] of Object.entries(o)) {
if (n == null) continue;
if (l === "options" && typeof n == "string") {
const p = Ve(n);
r.options = p.map((h) => ({
value: h,
label: h,
icon: r.type === $.reaction ? h : void 0
})), g.debug("Applied widget options as property:", p);
continue;
}
const d = l.replace(/([A-Z])/g, "-$1").toLowerCase();
if (a.has(d)) {
g.debug(`Skipping server attribute "${d}" — overridden by inline attribute`);
continue;
}
typeof n == "boolean" ? n ? s.setAttribute(d, "") : s.removeAttribute(d) : typeof n == "object" ? s.setAttribute(d, JSON.stringify(n)) : s.setAttribute(d, String(n)), g.debug(`Applied widget attribute: ${d}=${n}`);
}
}
/**
* Loads the stats for the widget.
*/
async loadServerStats() {
var r, s, i, a, l;
const t = this.host;
this.isLoading = !1, this.stats = this.localStats, this.host.requestUpdate();
const o = this.getWidgetIdentifier();
if (o)
try {
let n, d;
if (o.type === "registered") {
this.isLoadingConfig = !0, this.host.requestUpdate();
const C = xt(t.metadata), A = await Se(o, void 0, C ? { meta: C } : void 0), P = (s = (r = A.data) == null ? void 0 : r.config) == null ? void 0 : s.type;
if (P && P !== t.type) {