@cal.macconnachie/web-components 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,859 +0,0 @@
1
- const z = globalThis, I = z.ShadowRoot && (z.ShadyCSS === void 0 || z.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, j = Symbol(), G = /* @__PURE__ */ new WeakMap();
2
- let it = class {
3
- constructor(t, e, s) {
4
- if (this._$cssResult$ = !0, s !== j) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
5
- this.cssText = t, this.t = e;
6
- }
7
- get styleSheet() {
8
- let t = this.o;
9
- const e = this.t;
10
- if (I && t === void 0) {
11
- const s = e !== void 0 && e.length === 1;
12
- s && (t = G.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && G.set(e, t));
13
- }
14
- return t;
15
- }
16
- toString() {
17
- return this.cssText;
18
- }
19
- };
20
- const lt = (n) => new it(typeof n == "string" ? n : n + "", void 0, j), ct = (n, ...t) => {
21
- const e = n.length === 1 ? n[0] : t.reduce(((s, i, r) => s + ((o) => {
22
- if (o._$cssResult$ === !0) return o.cssText;
23
- if (typeof o == "number") return o;
24
- throw Error("Value passed to 'css' function must be a 'css' function result: " + o + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
25
- })(i) + n[r + 1]), n[0]);
26
- return new it(e, n, j);
27
- }, dt = (n, t) => {
28
- if (I) n.adoptedStyleSheets = t.map(((e) => e instanceof CSSStyleSheet ? e : e.styleSheet));
29
- else for (const e of t) {
30
- const s = document.createElement("style"), i = z.litNonce;
31
- i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, n.appendChild(s);
32
- }
33
- }, J = I ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((t) => {
34
- let e = "";
35
- for (const s of t.cssRules) e += s.cssText;
36
- return lt(e);
37
- })(n) : n;
38
- const { is: ut, defineProperty: pt, getOwnPropertyDescriptor: $t, getOwnPropertyNames: mt, getOwnPropertySymbols: ft, getPrototypeOf: yt } = Object, N = globalThis, Q = N.trustedTypes, _t = Q ? Q.emptyScript : "", gt = N.reactiveElementPolyfillSupport, x = (n, t) => n, H = { toAttribute(n, t) {
39
- switch (t) {
40
- case Boolean:
41
- n = n ? _t : null;
42
- break;
43
- case Object:
44
- case Array:
45
- n = n == null ? n : JSON.stringify(n);
46
- }
47
- return n;
48
- }, fromAttribute(n, t) {
49
- let e = n;
50
- switch (t) {
51
- case Boolean:
52
- e = n !== null;
53
- break;
54
- case Number:
55
- e = n === null ? null : Number(n);
56
- break;
57
- case Object:
58
- case Array:
59
- try {
60
- e = JSON.parse(n);
61
- } catch {
62
- e = null;
63
- }
64
- }
65
- return e;
66
- } }, L = (n, t) => !ut(n, t), Z = { attribute: !0, type: String, converter: H, reflect: !1, useDefault: !1, hasChanged: L };
67
- Symbol.metadata ??= Symbol("metadata"), N.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
68
- let A = class extends HTMLElement {
69
- static addInitializer(t) {
70
- this._$Ei(), (this.l ??= []).push(t);
71
- }
72
- static get observedAttributes() {
73
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
74
- }
75
- static createProperty(t, e = Z) {
76
- if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
77
- const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
78
- i !== void 0 && pt(this.prototype, t, i);
79
- }
80
- }
81
- static getPropertyDescriptor(t, e, s) {
82
- const { get: i, set: r } = $t(this.prototype, t) ?? { get() {
83
- return this[e];
84
- }, set(o) {
85
- this[e] = o;
86
- } };
87
- return { get: i, set(o) {
88
- const h = i?.call(this);
89
- r?.call(this, o), this.requestUpdate(t, h, s);
90
- }, configurable: !0, enumerable: !0 };
91
- }
92
- static getPropertyOptions(t) {
93
- return this.elementProperties.get(t) ?? Z;
94
- }
95
- static _$Ei() {
96
- if (this.hasOwnProperty(x("elementProperties"))) return;
97
- const t = yt(this);
98
- t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
99
- }
100
- static finalize() {
101
- if (this.hasOwnProperty(x("finalized"))) return;
102
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(x("properties"))) {
103
- const e = this.properties, s = [...mt(e), ...ft(e)];
104
- for (const i of s) this.createProperty(i, e[i]);
105
- }
106
- const t = this[Symbol.metadata];
107
- if (t !== null) {
108
- const e = litPropertyMetadata.get(t);
109
- if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
110
- }
111
- this._$Eh = /* @__PURE__ */ new Map();
112
- for (const [e, s] of this.elementProperties) {
113
- const i = this._$Eu(e, s);
114
- i !== void 0 && this._$Eh.set(i, e);
115
- }
116
- this.elementStyles = this.finalizeStyles(this.styles);
117
- }
118
- static finalizeStyles(t) {
119
- const e = [];
120
- if (Array.isArray(t)) {
121
- const s = new Set(t.flat(1 / 0).reverse());
122
- for (const i of s) e.unshift(J(i));
123
- } else t !== void 0 && e.push(J(t));
124
- return e;
125
- }
126
- static _$Eu(t, e) {
127
- const s = e.attribute;
128
- return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
129
- }
130
- constructor() {
131
- super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
132
- }
133
- _$Ev() {
134
- this._$ES = new Promise(((t) => this.enableUpdating = t)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t) => t(this)));
135
- }
136
- addController(t) {
137
- (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
138
- }
139
- removeController(t) {
140
- this._$EO?.delete(t);
141
- }
142
- _$E_() {
143
- const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
144
- for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
145
- t.size > 0 && (this._$Ep = t);
146
- }
147
- createRenderRoot() {
148
- const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
149
- return dt(t, this.constructor.elementStyles), t;
150
- }
151
- connectedCallback() {
152
- this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
153
- }
154
- enableUpdating(t) {
155
- }
156
- disconnectedCallback() {
157
- this._$EO?.forEach(((t) => t.hostDisconnected?.()));
158
- }
159
- attributeChangedCallback(t, e, s) {
160
- this._$AK(t, s);
161
- }
162
- _$ET(t, e) {
163
- const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
164
- if (i !== void 0 && s.reflect === !0) {
165
- const r = (s.converter?.toAttribute !== void 0 ? s.converter : H).toAttribute(e, s.type);
166
- this._$Em = t, r == null ? this.removeAttribute(i) : this.setAttribute(i, r), this._$Em = null;
167
- }
168
- }
169
- _$AK(t, e) {
170
- const s = this.constructor, i = s._$Eh.get(t);
171
- if (i !== void 0 && this._$Em !== i) {
172
- const r = s.getPropertyOptions(i), o = typeof r.converter == "function" ? { fromAttribute: r.converter } : r.converter?.fromAttribute !== void 0 ? r.converter : H;
173
- this._$Em = i;
174
- const h = o.fromAttribute(e, r.type);
175
- this[i] = h ?? this._$Ej?.get(i) ?? h, this._$Em = null;
176
- }
177
- }
178
- requestUpdate(t, e, s) {
179
- if (t !== void 0) {
180
- const i = this.constructor, r = this[t];
181
- if (s ??= i.getPropertyOptions(t), !((s.hasChanged ?? L)(r, e) || s.useDefault && s.reflect && r === this._$Ej?.get(t) && !this.hasAttribute(i._$Eu(t, s)))) return;
182
- this.C(t, e, s);
183
- }
184
- this.isUpdatePending === !1 && (this._$ES = this._$EP());
185
- }
186
- C(t, e, { useDefault: s, reflect: i, wrapped: r }, o) {
187
- s && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, o ?? e ?? this[t]), r !== !0 || o !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
188
- }
189
- async _$EP() {
190
- this.isUpdatePending = !0;
191
- try {
192
- await this._$ES;
193
- } catch (e) {
194
- Promise.reject(e);
195
- }
196
- const t = this.scheduleUpdate();
197
- return t != null && await t, !this.isUpdatePending;
198
- }
199
- scheduleUpdate() {
200
- return this.performUpdate();
201
- }
202
- performUpdate() {
203
- if (!this.isUpdatePending) return;
204
- if (!this.hasUpdated) {
205
- if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
206
- for (const [i, r] of this._$Ep) this[i] = r;
207
- this._$Ep = void 0;
208
- }
209
- const s = this.constructor.elementProperties;
210
- if (s.size > 0) for (const [i, r] of s) {
211
- const { wrapped: o } = r, h = this[i];
212
- o !== !0 || this._$AL.has(i) || h === void 0 || this.C(i, void 0, r, h);
213
- }
214
- }
215
- let t = !1;
216
- const e = this._$AL;
217
- try {
218
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), this._$EO?.forEach(((s) => s.hostUpdate?.())), this.update(e)) : this._$EM();
219
- } catch (s) {
220
- throw t = !1, this._$EM(), s;
221
- }
222
- t && this._$AE(e);
223
- }
224
- willUpdate(t) {
225
- }
226
- _$AE(t) {
227
- this._$EO?.forEach(((e) => e.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
228
- }
229
- _$EM() {
230
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
231
- }
232
- get updateComplete() {
233
- return this.getUpdateComplete();
234
- }
235
- getUpdateComplete() {
236
- return this._$ES;
237
- }
238
- shouldUpdate(t) {
239
- return !0;
240
- }
241
- update(t) {
242
- this._$Eq &&= this._$Eq.forEach(((e) => this._$ET(e, this[e]))), this._$EM();
243
- }
244
- updated(t) {
245
- }
246
- firstUpdated(t) {
247
- }
248
- };
249
- A.elementStyles = [], A.shadowRootOptions = { mode: "open" }, A[x("elementProperties")] = /* @__PURE__ */ new Map(), A[x("finalized")] = /* @__PURE__ */ new Map(), gt?.({ ReactiveElement: A }), (N.reactiveElementVersions ??= []).push("2.1.1");
250
- const B = globalThis, k = B.trustedTypes, F = k ? k.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, nt = "$lit$", m = `lit$${Math.random().toFixed(9).slice(2)}$`, rt = "?" + m, bt = `<${rt}>`, g = document, P = () => g.createComment(""), T = (n) => n === null || typeof n != "object" && typeof n != "function", V = Array.isArray, vt = (n) => V(n) || typeof n?.[Symbol.iterator] == "function", D = `[
251
- \f\r]`, S = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, X = /-->/g, Y = />/g, y = RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^
252
- \f\r"'\`<>=]|("|')|))|$)`, "g"), tt = /'/g, et = /"/g, ot = /^(?:script|style|textarea|title)$/i, At = (n) => (t, ...e) => ({ _$litType$: n, strings: t, values: e }), wt = At(1), b = Symbol.for("lit-noChange"), d = Symbol.for("lit-nothing"), st = /* @__PURE__ */ new WeakMap(), _ = g.createTreeWalker(g, 129);
253
- function at(n, t) {
254
- if (!V(n) || !n.hasOwnProperty("raw")) throw Error("invalid template strings array");
255
- return F !== void 0 ? F.createHTML(t) : t;
256
- }
257
- const Et = (n, t) => {
258
- const e = n.length - 1, s = [];
259
- let i, r = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = S;
260
- for (let h = 0; h < e; h++) {
261
- const a = n[h];
262
- let c, u, l = -1, p = 0;
263
- for (; p < a.length && (o.lastIndex = p, u = o.exec(a), u !== null); ) p = o.lastIndex, o === S ? u[1] === "!--" ? o = X : u[1] !== void 0 ? o = Y : u[2] !== void 0 ? (ot.test(u[2]) && (i = RegExp("</" + u[2], "g")), o = y) : u[3] !== void 0 && (o = y) : o === y ? u[0] === ">" ? (o = i ?? S, l = -1) : u[1] === void 0 ? l = -2 : (l = o.lastIndex - u[2].length, c = u[1], o = u[3] === void 0 ? y : u[3] === '"' ? et : tt) : o === et || o === tt ? o = y : o === X || o === Y ? o = S : (o = y, i = void 0);
264
- const $ = o === y && n[h + 1].startsWith("/>") ? " " : "";
265
- r += o === S ? a + bt : l >= 0 ? (s.push(c), a.slice(0, l) + nt + a.slice(l) + m + $) : a + m + (l === -2 ? h : $);
266
- }
267
- return [at(n, r + (n[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
268
- };
269
- class U {
270
- constructor({ strings: t, _$litType$: e }, s) {
271
- let i;
272
- this.parts = [];
273
- let r = 0, o = 0;
274
- const h = t.length - 1, a = this.parts, [c, u] = Et(t, e);
275
- if (this.el = U.createElement(c, s), _.currentNode = this.el.content, e === 2 || e === 3) {
276
- const l = this.el.content.firstChild;
277
- l.replaceWith(...l.childNodes);
278
- }
279
- for (; (i = _.nextNode()) !== null && a.length < h; ) {
280
- if (i.nodeType === 1) {
281
- if (i.hasAttributes()) for (const l of i.getAttributeNames()) if (l.endsWith(nt)) {
282
- const p = u[o++], $ = i.getAttribute(l).split(m), M = /([.?@])?(.*)/.exec(p);
283
- a.push({ type: 1, index: r, name: M[2], strings: $, ctor: M[1] === "." ? xt : M[1] === "?" ? Ct : M[1] === "@" ? Pt : R }), i.removeAttribute(l);
284
- } else l.startsWith(m) && (a.push({ type: 6, index: r }), i.removeAttribute(l));
285
- if (ot.test(i.tagName)) {
286
- const l = i.textContent.split(m), p = l.length - 1;
287
- if (p > 0) {
288
- i.textContent = k ? k.emptyScript : "";
289
- for (let $ = 0; $ < p; $++) i.append(l[$], P()), _.nextNode(), a.push({ type: 2, index: ++r });
290
- i.append(l[p], P());
291
- }
292
- }
293
- } else if (i.nodeType === 8) if (i.data === rt) a.push({ type: 2, index: r });
294
- else {
295
- let l = -1;
296
- for (; (l = i.data.indexOf(m, l + 1)) !== -1; ) a.push({ type: 7, index: r }), l += m.length - 1;
297
- }
298
- r++;
299
- }
300
- }
301
- static createElement(t, e) {
302
- const s = g.createElement("template");
303
- return s.innerHTML = t, s;
304
- }
305
- }
306
- function w(n, t, e = n, s) {
307
- if (t === b) return t;
308
- let i = s !== void 0 ? e._$Co?.[s] : e._$Cl;
309
- const r = T(t) ? void 0 : t._$litDirective$;
310
- return i?.constructor !== r && (i?._$AO?.(!1), r === void 0 ? i = void 0 : (i = new r(n), i._$AT(n, e, s)), s !== void 0 ? (e._$Co ??= [])[s] = i : e._$Cl = i), i !== void 0 && (t = w(n, i._$AS(n, t.values), i, s)), t;
311
- }
312
- class St {
313
- constructor(t, e) {
314
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
315
- }
316
- get parentNode() {
317
- return this._$AM.parentNode;
318
- }
319
- get _$AU() {
320
- return this._$AM._$AU;
321
- }
322
- u(t) {
323
- const { el: { content: e }, parts: s } = this._$AD, i = (t?.creationScope ?? g).importNode(e, !0);
324
- _.currentNode = i;
325
- let r = _.nextNode(), o = 0, h = 0, a = s[0];
326
- for (; a !== void 0; ) {
327
- if (o === a.index) {
328
- let c;
329
- a.type === 2 ? c = new O(r, r.nextSibling, this, t) : a.type === 1 ? c = new a.ctor(r, a.name, a.strings, this, t) : a.type === 6 && (c = new Tt(r, this, t)), this._$AV.push(c), a = s[++h];
330
- }
331
- o !== a?.index && (r = _.nextNode(), o++);
332
- }
333
- return _.currentNode = g, i;
334
- }
335
- p(t) {
336
- let e = 0;
337
- for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
338
- }
339
- }
340
- class O {
341
- get _$AU() {
342
- return this._$AM?._$AU ?? this._$Cv;
343
- }
344
- constructor(t, e, s, i) {
345
- this.type = 2, this._$AH = d, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = i?.isConnected ?? !0;
346
- }
347
- get parentNode() {
348
- let t = this._$AA.parentNode;
349
- const e = this._$AM;
350
- return e !== void 0 && t?.nodeType === 11 && (t = e.parentNode), t;
351
- }
352
- get startNode() {
353
- return this._$AA;
354
- }
355
- get endNode() {
356
- return this._$AB;
357
- }
358
- _$AI(t, e = this) {
359
- t = w(this, t, e), T(t) ? t === d || t == null || t === "" ? (this._$AH !== d && this._$AR(), this._$AH = d) : t !== this._$AH && t !== b && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : vt(t) ? this.k(t) : this._(t);
360
- }
361
- O(t) {
362
- return this._$AA.parentNode.insertBefore(t, this._$AB);
363
- }
364
- T(t) {
365
- this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
366
- }
367
- _(t) {
368
- this._$AH !== d && T(this._$AH) ? this._$AA.nextSibling.data = t : this.T(g.createTextNode(t)), this._$AH = t;
369
- }
370
- $(t) {
371
- const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = U.createElement(at(s.h, s.h[0]), this.options)), s);
372
- if (this._$AH?._$AD === i) this._$AH.p(e);
373
- else {
374
- const r = new St(i, this), o = r.u(this.options);
375
- r.p(e), this.T(o), this._$AH = r;
376
- }
377
- }
378
- _$AC(t) {
379
- let e = st.get(t.strings);
380
- return e === void 0 && st.set(t.strings, e = new U(t)), e;
381
- }
382
- k(t) {
383
- V(this._$AH) || (this._$AH = [], this._$AR());
384
- const e = this._$AH;
385
- let s, i = 0;
386
- for (const r of t) i === e.length ? e.push(s = new O(this.O(P()), this.O(P()), this, this.options)) : s = e[i], s._$AI(r), i++;
387
- i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
388
- }
389
- _$AR(t = this._$AA.nextSibling, e) {
390
- for (this._$AP?.(!1, !0, e); t !== this._$AB; ) {
391
- const s = t.nextSibling;
392
- t.remove(), t = s;
393
- }
394
- }
395
- setConnected(t) {
396
- this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
397
- }
398
- }
399
- class R {
400
- get tagName() {
401
- return this.element.tagName;
402
- }
403
- get _$AU() {
404
- return this._$AM._$AU;
405
- }
406
- constructor(t, e, s, i, r) {
407
- this.type = 1, this._$AH = d, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = r, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = d;
408
- }
409
- _$AI(t, e = this, s, i) {
410
- const r = this.strings;
411
- let o = !1;
412
- if (r === void 0) t = w(this, t, e, 0), o = !T(t) || t !== this._$AH && t !== b, o && (this._$AH = t);
413
- else {
414
- const h = t;
415
- let a, c;
416
- for (t = r[0], a = 0; a < r.length - 1; a++) c = w(this, h[s + a], e, a), c === b && (c = this._$AH[a]), o ||= !T(c) || c !== this._$AH[a], c === d ? t = d : t !== d && (t += (c ?? "") + r[a + 1]), this._$AH[a] = c;
417
- }
418
- o && !i && this.j(t);
419
- }
420
- j(t) {
421
- t === d ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
422
- }
423
- }
424
- class xt extends R {
425
- constructor() {
426
- super(...arguments), this.type = 3;
427
- }
428
- j(t) {
429
- this.element[this.name] = t === d ? void 0 : t;
430
- }
431
- }
432
- class Ct extends R {
433
- constructor() {
434
- super(...arguments), this.type = 4;
435
- }
436
- j(t) {
437
- this.element.toggleAttribute(this.name, !!t && t !== d);
438
- }
439
- }
440
- class Pt extends R {
441
- constructor(t, e, s, i, r) {
442
- super(t, e, s, i, r), this.type = 5;
443
- }
444
- _$AI(t, e = this) {
445
- if ((t = w(this, t, e, 0) ?? d) === b) return;
446
- const s = this._$AH, i = t === d && s !== d || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, r = t !== d && (s === d || i);
447
- i && this.element.removeEventListener(this.name, this, s), r && this.element.addEventListener(this.name, this, t), this._$AH = t;
448
- }
449
- handleEvent(t) {
450
- typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
451
- }
452
- }
453
- class Tt {
454
- constructor(t, e, s) {
455
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
456
- }
457
- get _$AU() {
458
- return this._$AM._$AU;
459
- }
460
- _$AI(t) {
461
- w(this, t);
462
- }
463
- }
464
- const Ut = B.litHtmlPolyfillSupport;
465
- Ut?.(U, O), (B.litHtmlVersions ??= []).push("3.3.1");
466
- const Ot = (n, t, e) => {
467
- const s = e?.renderBefore ?? t;
468
- let i = s._$litPart$;
469
- if (i === void 0) {
470
- const r = e?.renderBefore ?? null;
471
- s._$litPart$ = i = new O(t.insertBefore(P(), r), r, void 0, e ?? {});
472
- }
473
- return i._$AI(n), i;
474
- };
475
- const K = globalThis;
476
- let C = class extends A {
477
- constructor() {
478
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
479
- }
480
- createRenderRoot() {
481
- const t = super.createRenderRoot();
482
- return this.renderOptions.renderBefore ??= t.firstChild, t;
483
- }
484
- update(t) {
485
- const e = this.render();
486
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ot(e, this.renderRoot, this.renderOptions);
487
- }
488
- connectedCallback() {
489
- super.connectedCallback(), this._$Do?.setConnected(!0);
490
- }
491
- disconnectedCallback() {
492
- super.disconnectedCallback(), this._$Do?.setConnected(!1);
493
- }
494
- render() {
495
- return b;
496
- }
497
- };
498
- C._$litElement$ = !0, C.finalized = !0, K.litElementHydrateSupport?.({ LitElement: C });
499
- const Mt = K.litElementPolyfillSupport;
500
- Mt?.({ LitElement: C });
501
- (K.litElementVersions ??= []).push("4.2.1");
502
- const qt = (n) => (t, e) => {
503
- e !== void 0 ? e.addInitializer((() => {
504
- customElements.define(n, t);
505
- })) : customElements.define(n, t);
506
- };
507
- const zt = { attribute: !0, type: String, converter: H, reflect: !1, hasChanged: L }, Ht = (n = zt, t, e) => {
508
- const { kind: s, metadata: i } = e;
509
- let r = globalThis.litPropertyMetadata.get(i);
510
- if (r === void 0 && globalThis.litPropertyMetadata.set(i, r = /* @__PURE__ */ new Map()), s === "setter" && ((n = Object.create(n)).wrapped = !0), r.set(e.name, n), s === "accessor") {
511
- const { name: o } = e;
512
- return { set(h) {
513
- const a = t.get.call(this);
514
- t.set.call(this, h), this.requestUpdate(o, a, n);
515
- }, init(h) {
516
- return h !== void 0 && this.C(o, void 0, n, h), h;
517
- } };
518
- }
519
- if (s === "setter") {
520
- const { name: o } = e;
521
- return function(h) {
522
- const a = this[o];
523
- t.call(this, h), this.requestUpdate(o, a, n);
524
- };
525
- }
526
- throw Error("Unsupported decorator location: " + s);
527
- };
528
- function v(n) {
529
- return (t, e) => typeof e == "object" ? Ht(n, t, e) : ((s, i, r) => {
530
- const o = i.hasOwnProperty(r);
531
- return i.constructor.createProperty(r, s), o ? Object.getOwnPropertyDescriptor(i, r) : void 0;
532
- })(n, t, e);
533
- }
534
- const kt = { ATTRIBUTE: 1 }, Nt = (n) => (...t) => ({ _$litDirective$: n, values: t });
535
- class Rt {
536
- constructor(t) {
537
- }
538
- get _$AU() {
539
- return this._$AM._$AU;
540
- }
541
- _$AT(t, e, s) {
542
- this._$Ct = t, this._$AM = e, this._$Ci = s;
543
- }
544
- _$AS(t, e) {
545
- return this.update(t, e);
546
- }
547
- update(t, e) {
548
- return this.render(...e);
549
- }
550
- }
551
- const q = Nt(class extends Rt {
552
- constructor(n) {
553
- if (super(n), n.type !== kt.ATTRIBUTE || n.name !== "class" || n.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
554
- }
555
- render(n) {
556
- return " " + Object.keys(n).filter(((t) => n[t])).join(" ") + " ";
557
- }
558
- update(n, [t]) {
559
- if (this.st === void 0) {
560
- this.st = /* @__PURE__ */ new Set(), n.strings !== void 0 && (this.nt = new Set(n.strings.join(" ").split(/\s/).filter(((s) => s !== ""))));
561
- for (const s in t) t[s] && !this.nt?.has(s) && this.st.add(s);
562
- return this.render(t);
563
- }
564
- const e = n.element.classList;
565
- for (const s of this.st) s in t || (e.remove(s), this.st.delete(s));
566
- for (const s in t) {
567
- const i = !!t[s];
568
- i === this.st.has(s) || this.nt?.has(s) || (i ? (e.add(s), this.st.add(s)) : (e.remove(s), this.st.delete(s)));
569
- }
570
- return b;
571
- }
572
- });
573
- var Dt = Object.defineProperty, ht = (n, t, e, s) => {
574
- for (var i = void 0, r = n.length - 1, o; r >= 0; r--)
575
- (o = n[r]) && (i = o(t, e, i) || i);
576
- return i && Dt(t, e, i), i;
577
- };
578
- class W extends C {
579
- constructor() {
580
- super(...arguments), this.theme = "light", this.storageKey = "theme-preference", this.boundThemeChangeHandler = this.handleGlobalThemeChange.bind(this);
581
- }
582
- connectedCallback() {
583
- super.connectedCallback();
584
- const t = document.documentElement.getAttribute("data-theme"), e = localStorage.getItem(this.storageKey), s = window.matchMedia("(prefers-color-scheme: dark)").matches;
585
- t ? this.theme = t : e ? (this.theme = e, this.applyTheme()) : s ? (this.theme = "dark", this.applyTheme()) : this.applyTheme(), window.addEventListener("theme-changed", this.boundThemeChangeHandler);
586
- }
587
- disconnectedCallback() {
588
- window.removeEventListener("theme-changed", this.boundThemeChangeHandler), super.disconnectedCallback();
589
- }
590
- handleGlobalThemeChange(t) {
591
- const e = t;
592
- e.target !== this && e.detail.theme !== this.theme && (this.theme = e.detail.theme);
593
- }
594
- applyTheme() {
595
- document.documentElement.setAttribute("data-theme", this.theme), localStorage.setItem(this.storageKey, this.theme), this.dispatchEvent(
596
- new CustomEvent("theme-changed", {
597
- detail: { theme: this.theme },
598
- bubbles: !0,
599
- composed: !0
600
- })
601
- );
602
- }
603
- }
604
- ht([
605
- v({ type: String, attribute: "data-theme", reflect: !0 })
606
- ], W.prototype, "theme");
607
- ht([
608
- v({ type: String, attribute: "storage-key" })
609
- ], W.prototype, "storageKey");
610
- var It = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, E = (n, t, e, s) => {
611
- for (var i = s > 1 ? void 0 : s ? jt(t, e) : t, r = n.length - 1, o; r >= 0; r--)
612
- (o = n[r]) && (i = (s ? o(t, e, i) : o(i)) || i);
613
- return s && i && It(t, e, i), i;
614
- };
615
- let f = class extends W {
616
- constructor() {
617
- super(...arguments), this.value = 0, this.min = 0, this.max = 99, this.size = "md", this.allowInput = !0;
618
- }
619
- clampValue(n) {
620
- return Math.max(this.min, Math.min(this.max, n));
621
- }
622
- updateValue(n) {
623
- const t = this.clampValue(n), e = this.value;
624
- t !== e && (this.value = t, this.dispatchEvent(
625
- new CustomEvent("change", {
626
- detail: { value: this.value, oldValue: e },
627
- bubbles: !0,
628
- composed: !0
629
- })
630
- ));
631
- }
632
- handleDecrement() {
633
- this.updateValue(this.value - 1);
634
- }
635
- handleIncrement() {
636
- this.updateValue(this.value + 1);
637
- }
638
- handleInput(n) {
639
- const t = n.target, e = parseInt(t.value, 10);
640
- isNaN(e) ? t.value = String(this.value) : this.updateValue(e);
641
- }
642
- handleKeydown(n) {
643
- n.key === "ArrowUp" ? (n.preventDefault(), this.handleIncrement()) : n.key === "ArrowDown" && (n.preventDefault(), this.handleDecrement());
644
- }
645
- render() {
646
- const n = {
647
- "quantity-input-wrapper": !0,
648
- [`quantity-input-wrapper--${this.size}`]: !0
649
- }, t = (s) => ({
650
- "quantity-btn": !0,
651
- [`quantity-btn--${s}`]: !0,
652
- [`quantity-btn--${this.size}`]: !0
653
- }), e = {
654
- "quantity-input": !0,
655
- [`quantity-input--${this.size}`]: !0
656
- };
657
- return wt`
658
- <div class=${q(n)}>
659
- <button
660
- type="button"
661
- @click=${this.handleDecrement}
662
- ?disabled=${this.value <= this.min}
663
- class=${q(t("minus"))}
664
- aria-label="Decrease quantity"
665
- >
666
-
667
- </button>
668
- <input
669
- id="quantity"
670
- .value=${String(this.value)}
671
- ?readonly=${!this.allowInput}
672
- type="number"
673
- min=${this.min}
674
- max=${this.max}
675
- class=${q(e)}
676
- @input=${this.handleInput}
677
- @keydown=${this.handleKeydown}
678
- aria-label="Quantity"
679
- />
680
- <button
681
- type="button"
682
- @click=${this.handleIncrement}
683
- ?disabled=${this.value >= this.max}
684
- class=${q(t("plus"))}
685
- aria-label="Increase quantity"
686
- >
687
- +
688
- </button>
689
- </div>
690
- `;
691
- }
692
- };
693
- f.styles = ct`
694
- :host {
695
- display: inline-block;
696
- }
697
-
698
- .quantity-input-wrapper {
699
- display: flex;
700
- align-items: center;
701
- gap: 0;
702
- width: fit-content;
703
- opacity: 1;
704
- visibility: visible;
705
- transition:
706
- opacity 0.2s ease,
707
- visibility 0.2s ease;
708
- }
709
-
710
- .quantity-input-wrapper--hidden {
711
- opacity: 0;
712
- visibility: hidden;
713
- pointer-events: none;
714
- }
715
-
716
- .quantity-btn {
717
- border: 2px solid var(--color-border);
718
- background: var(--color-bg-primary);
719
- color: var(--color-text-primary);
720
- cursor: pointer;
721
- font-weight: var(--font-weight-bold);
722
- display: flex;
723
- align-items: center;
724
- justify-content: center;
725
- transition: all 0.2s ease;
726
- user-select: none;
727
- font-family: var(--font-family-sans);
728
- box-sizing: border-box;
729
- }
730
-
731
- .quantity-btn:hover:not(:disabled) {
732
- background: var(--color-bg-secondary);
733
- border-color: var(--color-border-hover);
734
- }
735
-
736
- .quantity-btn:disabled {
737
- cursor: not-allowed;
738
- opacity: 0.5;
739
- }
740
-
741
- .quantity-btn--minus {
742
- border-radius: var(--radius-md) 0 0 var(--radius-md);
743
- border-right: none;
744
- }
745
-
746
- .quantity-btn--plus {
747
- border-radius: 0 var(--radius-md) var(--radius-md) 0;
748
- border-left: none;
749
- }
750
-
751
- .quantity-input {
752
- border: 2px solid var(--color-border);
753
- border-left: none;
754
- border-right: none;
755
- background: var(--color-bg-primary);
756
- color: var(--color-text-primary);
757
- text-align: center;
758
- font-weight: var(--font-weight-medium);
759
- outline: none;
760
- font-family: var(--font-family-sans);
761
- transition: border-color 0.2s ease;
762
- box-sizing: border-box;
763
- }
764
-
765
- .quantity-input:focus {
766
- outline: none;
767
- }
768
-
769
- .quantity-input:disabled {
770
- cursor: not-allowed;
771
- opacity: 0.7;
772
- }
773
-
774
- .quantity-input:read-only {
775
- cursor: default;
776
- background: var(--color-bg-muted);
777
- }
778
-
779
- .quantity-input::-webkit-outer-spin-button,
780
- .quantity-input::-webkit-inner-spin-button {
781
- -webkit-appearance: none;
782
- margin: 0;
783
- }
784
-
785
- .quantity-input[type='number'] {
786
- -moz-appearance: textfield;
787
- appearance: textfield;
788
- }
789
-
790
- /* Size variants */
791
- .quantity-btn--xs {
792
- width: 24px;
793
- height: 24px;
794
- font-size: var(--font-size-sm);
795
- }
796
-
797
- .quantity-input--xs {
798
- width: 32px;
799
- height: 24px;
800
- font-size: calc(var(--font-size-sm) * 3 / 4);
801
- }
802
-
803
- .quantity-btn--sm {
804
- width: 32px;
805
- height: 32px;
806
- font-size: var(--font-size-base);
807
- }
808
-
809
- .quantity-input--sm {
810
- width: 48px;
811
- height: 32px;
812
- font-size: var(--font-size-sm);
813
- }
814
-
815
- .quantity-btn--md {
816
- width: 40px;
817
- height: 40px;
818
- font-size: var(--font-size-lg);
819
- }
820
-
821
- .quantity-input--md {
822
- width: 60px;
823
- height: 40px;
824
- font-size: var(--font-size-base);
825
- }
826
-
827
- .quantity-btn--lg {
828
- width: 48px;
829
- height: 48px;
830
- font-size: var(--font-size-xl);
831
- }
832
-
833
- .quantity-input--lg {
834
- width: 72px;
835
- height: 48px;
836
- font-size: var(--font-size-lg);
837
- }
838
- `;
839
- E([
840
- v({ type: Number })
841
- ], f.prototype, "value", 2);
842
- E([
843
- v({ type: Number })
844
- ], f.prototype, "min", 2);
845
- E([
846
- v({ type: Number })
847
- ], f.prototype, "max", 2);
848
- E([
849
- v({ type: String })
850
- ], f.prototype, "size", 2);
851
- E([
852
- v({ type: Boolean, attribute: "allow-input" })
853
- ], f.prototype, "allowInput", 2);
854
- f = E([
855
- qt("quantity-select")
856
- ], f);
857
- export {
858
- f as QuantitySelect
859
- };