mealz-components 0.2.1 → 0.3.0-alpha.1

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.
@@ -0,0 +1,7 @@
1
+ .mealz-like-button__icon img {
2
+ display: none;
3
+ }
4
+
5
+ .mealz-like-button__icon .active {
6
+ display: block;
7
+ }
@@ -0,0 +1,638 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const ot = (n) => (t, e) => {
7
+ e !== void 0 ? e.addInitializer(() => {
8
+ customElements.define(n, t);
9
+ }) : customElements.define(n, t);
10
+ };
11
+ /**
12
+ * @license
13
+ * Copyright 2019 Google LLC
14
+ * SPDX-License-Identifier: BSD-3-Clause
15
+ */
16
+ const N = globalThis, j = N.ShadowRoot && (N.ShadyCSS === void 0 || N.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Y = Symbol(), B = /* @__PURE__ */ new WeakMap();
17
+ let ht = class {
18
+ constructor(t, e, s) {
19
+ if (this._$cssResult$ = !0, s !== Y)
20
+ throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
21
+ this.cssText = t, this.t = e;
22
+ }
23
+ get styleSheet() {
24
+ let t = this.o;
25
+ const e = this.t;
26
+ if (j && t === void 0) {
27
+ const s = e !== void 0 && e.length === 1;
28
+ s && (t = B.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && B.set(e, t));
29
+ }
30
+ return t;
31
+ }
32
+ toString() {
33
+ return this.cssText;
34
+ }
35
+ };
36
+ const at = (n) => new ht(typeof n == "string" ? n : n + "", void 0, Y), lt = (n, t) => {
37
+ if (j)
38
+ n.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
39
+ else
40
+ for (const e of t) {
41
+ const s = document.createElement("style"), i = N.litNonce;
42
+ i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, n.appendChild(s);
43
+ }
44
+ }, q = j ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((t) => {
45
+ let e = "";
46
+ for (const s of t.cssRules)
47
+ e += s.cssText;
48
+ return at(e);
49
+ })(n) : n;
50
+ /**
51
+ * @license
52
+ * Copyright 2017 Google LLC
53
+ * SPDX-License-Identifier: BSD-3-Clause
54
+ */
55
+ const { is: ct, defineProperty: dt, getOwnPropertyDescriptor: pt, getOwnPropertyNames: ut, getOwnPropertySymbols: $t, getPrototypeOf: _t } = Object, f = globalThis, W = f.trustedTypes, ft = W ? W.emptyScript : "", M = f.reactiveElementPolyfillSupport, E = (n, t) => n, I = { toAttribute(n, t) {
56
+ switch (t) {
57
+ case Boolean:
58
+ n = n ? ft : null;
59
+ break;
60
+ case Object:
61
+ case Array:
62
+ n = n == null ? n : JSON.stringify(n);
63
+ }
64
+ return n;
65
+ }, fromAttribute(n, t) {
66
+ let e = n;
67
+ switch (t) {
68
+ case Boolean:
69
+ e = n !== null;
70
+ break;
71
+ case Number:
72
+ e = n === null ? null : Number(n);
73
+ break;
74
+ case Object:
75
+ case Array:
76
+ try {
77
+ e = JSON.parse(n);
78
+ } catch {
79
+ e = null;
80
+ }
81
+ }
82
+ return e;
83
+ } }, tt = (n, t) => !ct(n, t), V = { attribute: !0, type: String, converter: I, reflect: !1, hasChanged: tt };
84
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), f.litPropertyMetadata ?? (f.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
85
+ class y extends HTMLElement {
86
+ static addInitializer(t) {
87
+ this._$Ei(), (this.l ?? (this.l = [])).push(t);
88
+ }
89
+ static get observedAttributes() {
90
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
91
+ }
92
+ static createProperty(t, e = V) {
93
+ if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
94
+ const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
95
+ i !== void 0 && dt(this.prototype, t, i);
96
+ }
97
+ }
98
+ static getPropertyDescriptor(t, e, s) {
99
+ const { get: i, set: r } = pt(this.prototype, t) ?? { get() {
100
+ return this[e];
101
+ }, set(o) {
102
+ this[e] = o;
103
+ } };
104
+ return { get() {
105
+ return i == null ? void 0 : i.call(this);
106
+ }, set(o) {
107
+ const l = i == null ? void 0 : i.call(this);
108
+ r.call(this, o), this.requestUpdate(t, l, s);
109
+ }, configurable: !0, enumerable: !0 };
110
+ }
111
+ static getPropertyOptions(t) {
112
+ return this.elementProperties.get(t) ?? V;
113
+ }
114
+ static _$Ei() {
115
+ if (this.hasOwnProperty(E("elementProperties")))
116
+ return;
117
+ const t = _t(this);
118
+ t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
119
+ }
120
+ static finalize() {
121
+ if (this.hasOwnProperty(E("finalized")))
122
+ return;
123
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(E("properties"))) {
124
+ const e = this.properties, s = [...ut(e), ...$t(e)];
125
+ for (const i of s)
126
+ this.createProperty(i, e[i]);
127
+ }
128
+ const t = this[Symbol.metadata];
129
+ if (t !== null) {
130
+ const e = litPropertyMetadata.get(t);
131
+ if (e !== void 0)
132
+ for (const [s, i] of e)
133
+ this.elementProperties.set(s, i);
134
+ }
135
+ this._$Eh = /* @__PURE__ */ new Map();
136
+ for (const [e, s] of this.elementProperties) {
137
+ const i = this._$Eu(e, s);
138
+ i !== void 0 && this._$Eh.set(i, e);
139
+ }
140
+ this.elementStyles = this.finalizeStyles(this.styles);
141
+ }
142
+ static finalizeStyles(t) {
143
+ const e = [];
144
+ if (Array.isArray(t)) {
145
+ const s = new Set(t.flat(1 / 0).reverse());
146
+ for (const i of s)
147
+ e.unshift(q(i));
148
+ } else
149
+ t !== void 0 && e.push(q(t));
150
+ return e;
151
+ }
152
+ static _$Eu(t, e) {
153
+ const s = e.attribute;
154
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
155
+ }
156
+ constructor() {
157
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
158
+ }
159
+ _$Ev() {
160
+ var t;
161
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
162
+ }
163
+ addController(t) {
164
+ var e;
165
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
166
+ }
167
+ removeController(t) {
168
+ var e;
169
+ (e = this._$EO) == null || e.delete(t);
170
+ }
171
+ _$E_() {
172
+ const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
173
+ for (const s of e.keys())
174
+ this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
175
+ t.size > 0 && (this._$Ep = t);
176
+ }
177
+ createRenderRoot() {
178
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
179
+ return lt(t, this.constructor.elementStyles), t;
180
+ }
181
+ connectedCallback() {
182
+ var t;
183
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
184
+ var s;
185
+ return (s = e.hostConnected) == null ? void 0 : s.call(e);
186
+ });
187
+ }
188
+ enableUpdating(t) {
189
+ }
190
+ disconnectedCallback() {
191
+ var t;
192
+ (t = this._$EO) == null || t.forEach((e) => {
193
+ var s;
194
+ return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
195
+ });
196
+ }
197
+ attributeChangedCallback(t, e, s) {
198
+ this._$AK(t, s);
199
+ }
200
+ _$EC(t, e) {
201
+ var r;
202
+ const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
203
+ if (i !== void 0 && s.reflect === !0) {
204
+ const o = (((r = s.converter) == null ? void 0 : r.toAttribute) !== void 0 ? s.converter : I).toAttribute(e, s.type);
205
+ this._$Em = t, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null;
206
+ }
207
+ }
208
+ _$AK(t, e) {
209
+ var r;
210
+ const s = this.constructor, i = s._$Eh.get(t);
211
+ if (i !== void 0 && this._$Em !== i) {
212
+ const o = s.getPropertyOptions(i), l = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((r = o.converter) == null ? void 0 : r.fromAttribute) !== void 0 ? o.converter : I;
213
+ this._$Em = i, this[i] = l.fromAttribute(e, o.type), this._$Em = null;
214
+ }
215
+ }
216
+ requestUpdate(t, e, s) {
217
+ if (t !== void 0) {
218
+ if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? tt)(this[t], e))
219
+ return;
220
+ this.P(t, e, s);
221
+ }
222
+ this.isUpdatePending === !1 && (this._$ES = this._$ET());
223
+ }
224
+ P(t, e, s) {
225
+ this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
226
+ }
227
+ async _$ET() {
228
+ this.isUpdatePending = !0;
229
+ try {
230
+ await this._$ES;
231
+ } catch (e) {
232
+ Promise.reject(e);
233
+ }
234
+ const t = this.scheduleUpdate();
235
+ return t != null && await t, !this.isUpdatePending;
236
+ }
237
+ scheduleUpdate() {
238
+ return this.performUpdate();
239
+ }
240
+ performUpdate() {
241
+ var s;
242
+ if (!this.isUpdatePending)
243
+ return;
244
+ if (!this.hasUpdated) {
245
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
246
+ for (const [r, o] of this._$Ep)
247
+ this[r] = o;
248
+ this._$Ep = void 0;
249
+ }
250
+ const i = this.constructor.elementProperties;
251
+ if (i.size > 0)
252
+ for (const [r, o] of i)
253
+ o.wrapped !== !0 || this._$AL.has(r) || this[r] === void 0 || this.P(r, this[r], o);
254
+ }
255
+ let t = !1;
256
+ const e = this._$AL;
257
+ try {
258
+ t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => {
259
+ var r;
260
+ return (r = i.hostUpdate) == null ? void 0 : r.call(i);
261
+ }), this.update(e)) : this._$EU();
262
+ } catch (i) {
263
+ throw t = !1, this._$EU(), i;
264
+ }
265
+ t && this._$AE(e);
266
+ }
267
+ willUpdate(t) {
268
+ }
269
+ _$AE(t) {
270
+ var e;
271
+ (e = this._$EO) == null || e.forEach((s) => {
272
+ var i;
273
+ return (i = s.hostUpdated) == null ? void 0 : i.call(s);
274
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
275
+ }
276
+ _$EU() {
277
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
278
+ }
279
+ get updateComplete() {
280
+ return this.getUpdateComplete();
281
+ }
282
+ getUpdateComplete() {
283
+ return this._$ES;
284
+ }
285
+ shouldUpdate(t) {
286
+ return !0;
287
+ }
288
+ update(t) {
289
+ this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
290
+ }
291
+ updated(t) {
292
+ }
293
+ firstUpdated(t) {
294
+ }
295
+ }
296
+ y.elementStyles = [], y.shadowRootOptions = { mode: "open" }, y[E("elementProperties")] = /* @__PURE__ */ new Map(), y[E("finalized")] = /* @__PURE__ */ new Map(), M == null || M({ ReactiveElement: y }), (f.reactiveElementVersions ?? (f.reactiveElementVersions = [])).push("2.0.4");
297
+ /**
298
+ * @license
299
+ * Copyright 2017 Google LLC
300
+ * SPDX-License-Identifier: BSD-3-Clause
301
+ */
302
+ const w = globalThis, T = w.trustedTypes, J = T ? T.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, et = "$lit$", _ = `lit$${Math.random().toFixed(9).slice(2)}$`, st = "?" + _, At = `<${st}>`, g = document, P = () => g.createComment(""), k = (n) => n === null || typeof n != "object" && typeof n != "function", it = Array.isArray, mt = (n) => it(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", R = `[
303
+ \f\r]`, S = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, K = /-->/g, F = />/g, A = RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^
304
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Z = /'/g, G = /"/g, nt = /^(?:script|style|textarea|title)$/i, v = Symbol.for("lit-noChange"), d = Symbol.for("lit-nothing"), Q = /* @__PURE__ */ new WeakMap(), m = g.createTreeWalker(g, 129);
305
+ function rt(n, t) {
306
+ if (!Array.isArray(n) || !n.hasOwnProperty("raw"))
307
+ throw Error("invalid template strings array");
308
+ return J !== void 0 ? J.createHTML(t) : t;
309
+ }
310
+ const gt = (n, t) => {
311
+ const e = n.length - 1, s = [];
312
+ let i, r = t === 2 ? "<svg>" : "", o = S;
313
+ for (let l = 0; l < e; l++) {
314
+ const h = n[l];
315
+ let c, p, a = -1, u = 0;
316
+ for (; u < h.length && (o.lastIndex = u, p = o.exec(h), p !== null); )
317
+ u = o.lastIndex, o === S ? p[1] === "!--" ? o = K : p[1] !== void 0 ? o = F : p[2] !== void 0 ? (nt.test(p[2]) && (i = RegExp("</" + p[2], "g")), o = A) : p[3] !== void 0 && (o = A) : o === A ? p[0] === ">" ? (o = i ?? S, a = -1) : p[1] === void 0 ? a = -2 : (a = o.lastIndex - p[2].length, c = p[1], o = p[3] === void 0 ? A : p[3] === '"' ? G : Z) : o === G || o === Z ? o = A : o === K || o === F ? o = S : (o = A, i = void 0);
318
+ const $ = o === A && n[l + 1].startsWith("/>") ? " " : "";
319
+ r += o === S ? h + At : a >= 0 ? (s.push(c), h.slice(0, a) + et + h.slice(a) + _ + $) : h + _ + (a === -2 ? l : $);
320
+ }
321
+ return [rt(n, r + (n[e] || "<?>") + (t === 2 ? "</svg>" : "")), s];
322
+ };
323
+ class x {
324
+ constructor({ strings: t, _$litType$: e }, s) {
325
+ let i;
326
+ this.parts = [];
327
+ let r = 0, o = 0;
328
+ const l = t.length - 1, h = this.parts, [c, p] = gt(t, e);
329
+ if (this.el = x.createElement(c, s), m.currentNode = this.el.content, e === 2) {
330
+ const a = this.el.content.firstChild;
331
+ a.replaceWith(...a.childNodes);
332
+ }
333
+ for (; (i = m.nextNode()) !== null && h.length < l; ) {
334
+ if (i.nodeType === 1) {
335
+ if (i.hasAttributes())
336
+ for (const a of i.getAttributeNames())
337
+ if (a.endsWith(et)) {
338
+ const u = p[o++], $ = i.getAttribute(a).split(_), H = /([.?@])?(.*)/.exec(u);
339
+ h.push({ type: 1, index: r, name: H[2], strings: $, ctor: H[1] === "." ? vt : H[1] === "?" ? bt : H[1] === "@" ? St : O }), i.removeAttribute(a);
340
+ } else
341
+ a.startsWith(_) && (h.push({ type: 6, index: r }), i.removeAttribute(a));
342
+ if (nt.test(i.tagName)) {
343
+ const a = i.textContent.split(_), u = a.length - 1;
344
+ if (u > 0) {
345
+ i.textContent = T ? T.emptyScript : "";
346
+ for (let $ = 0; $ < u; $++)
347
+ i.append(a[$], P()), m.nextNode(), h.push({ type: 2, index: ++r });
348
+ i.append(a[u], P());
349
+ }
350
+ }
351
+ } else if (i.nodeType === 8)
352
+ if (i.data === st)
353
+ h.push({ type: 2, index: r });
354
+ else {
355
+ let a = -1;
356
+ for (; (a = i.data.indexOf(_, a + 1)) !== -1; )
357
+ h.push({ type: 7, index: r }), a += _.length - 1;
358
+ }
359
+ r++;
360
+ }
361
+ }
362
+ static createElement(t, e) {
363
+ const s = g.createElement("template");
364
+ return s.innerHTML = t, s;
365
+ }
366
+ }
367
+ function b(n, t, e = n, s) {
368
+ var o, l;
369
+ if (t === v)
370
+ return t;
371
+ let i = s !== void 0 ? (o = e._$Co) == null ? void 0 : o[s] : e._$Cl;
372
+ const r = k(t) ? void 0 : t._$litDirective$;
373
+ return (i == null ? void 0 : i.constructor) !== r && ((l = i == null ? void 0 : i._$AO) == null || l.call(i, !1), r === void 0 ? i = void 0 : (i = new r(n), i._$AT(n, e, s)), s !== void 0 ? (e._$Co ?? (e._$Co = []))[s] = i : e._$Cl = i), i !== void 0 && (t = b(n, i._$AS(n, t.values), i, s)), t;
374
+ }
375
+ class yt {
376
+ constructor(t, e) {
377
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
378
+ }
379
+ get parentNode() {
380
+ return this._$AM.parentNode;
381
+ }
382
+ get _$AU() {
383
+ return this._$AM._$AU;
384
+ }
385
+ u(t) {
386
+ const { el: { content: e }, parts: s } = this._$AD, i = ((t == null ? void 0 : t.creationScope) ?? g).importNode(e, !0);
387
+ m.currentNode = i;
388
+ let r = m.nextNode(), o = 0, l = 0, h = s[0];
389
+ for (; h !== void 0; ) {
390
+ if (o === h.index) {
391
+ let c;
392
+ h.type === 2 ? c = new U(r, r.nextSibling, this, t) : h.type === 1 ? c = new h.ctor(r, h.name, h.strings, this, t) : h.type === 6 && (c = new Et(r, this, t)), this._$AV.push(c), h = s[++l];
393
+ }
394
+ o !== (h == null ? void 0 : h.index) && (r = m.nextNode(), o++);
395
+ }
396
+ return m.currentNode = g, i;
397
+ }
398
+ p(t) {
399
+ let e = 0;
400
+ for (const s of this._$AV)
401
+ s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
402
+ }
403
+ }
404
+ class U {
405
+ get _$AU() {
406
+ var t;
407
+ return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
408
+ }
409
+ constructor(t, e, s, i) {
410
+ 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 == null ? void 0 : i.isConnected) ?? !0;
411
+ }
412
+ get parentNode() {
413
+ let t = this._$AA.parentNode;
414
+ const e = this._$AM;
415
+ return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
416
+ }
417
+ get startNode() {
418
+ return this._$AA;
419
+ }
420
+ get endNode() {
421
+ return this._$AB;
422
+ }
423
+ _$AI(t, e = this) {
424
+ t = b(this, t, e), k(t) ? t === d || t == null || t === "" ? (this._$AH !== d && this._$AR(), this._$AH = d) : t !== this._$AH && t !== v && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : mt(t) ? this.k(t) : this._(t);
425
+ }
426
+ S(t) {
427
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
428
+ }
429
+ T(t) {
430
+ this._$AH !== t && (this._$AR(), this._$AH = this.S(t));
431
+ }
432
+ _(t) {
433
+ this._$AH !== d && k(this._$AH) ? this._$AA.nextSibling.data = t : this.T(g.createTextNode(t)), this._$AH = t;
434
+ }
435
+ $(t) {
436
+ var r;
437
+ const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = x.createElement(rt(s.h, s.h[0]), this.options)), s);
438
+ if (((r = this._$AH) == null ? void 0 : r._$AD) === i)
439
+ this._$AH.p(e);
440
+ else {
441
+ const o = new yt(i, this), l = o.u(this.options);
442
+ o.p(e), this.T(l), this._$AH = o;
443
+ }
444
+ }
445
+ _$AC(t) {
446
+ let e = Q.get(t.strings);
447
+ return e === void 0 && Q.set(t.strings, e = new x(t)), e;
448
+ }
449
+ k(t) {
450
+ it(this._$AH) || (this._$AH = [], this._$AR());
451
+ const e = this._$AH;
452
+ let s, i = 0;
453
+ for (const r of t)
454
+ i === e.length ? e.push(s = new U(this.S(P()), this.S(P()), this, this.options)) : s = e[i], s._$AI(r), i++;
455
+ i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
456
+ }
457
+ _$AR(t = this._$AA.nextSibling, e) {
458
+ var s;
459
+ for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) {
460
+ const i = t.nextSibling;
461
+ t.remove(), t = i;
462
+ }
463
+ }
464
+ setConnected(t) {
465
+ var e;
466
+ this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
467
+ }
468
+ }
469
+ class O {
470
+ get tagName() {
471
+ return this.element.tagName;
472
+ }
473
+ get _$AU() {
474
+ return this._$AM._$AU;
475
+ }
476
+ constructor(t, e, s, i, r) {
477
+ 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;
478
+ }
479
+ _$AI(t, e = this, s, i) {
480
+ const r = this.strings;
481
+ let o = !1;
482
+ if (r === void 0)
483
+ t = b(this, t, e, 0), o = !k(t) || t !== this._$AH && t !== v, o && (this._$AH = t);
484
+ else {
485
+ const l = t;
486
+ let h, c;
487
+ for (t = r[0], h = 0; h < r.length - 1; h++)
488
+ c = b(this, l[s + h], e, h), c === v && (c = this._$AH[h]), o || (o = !k(c) || c !== this._$AH[h]), c === d ? t = d : t !== d && (t += (c ?? "") + r[h + 1]), this._$AH[h] = c;
489
+ }
490
+ o && !i && this.j(t);
491
+ }
492
+ j(t) {
493
+ t === d ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
494
+ }
495
+ }
496
+ class vt extends O {
497
+ constructor() {
498
+ super(...arguments), this.type = 3;
499
+ }
500
+ j(t) {
501
+ this.element[this.name] = t === d ? void 0 : t;
502
+ }
503
+ }
504
+ class bt extends O {
505
+ constructor() {
506
+ super(...arguments), this.type = 4;
507
+ }
508
+ j(t) {
509
+ this.element.toggleAttribute(this.name, !!t && t !== d);
510
+ }
511
+ }
512
+ class St extends O {
513
+ constructor(t, e, s, i, r) {
514
+ super(t, e, s, i, r), this.type = 5;
515
+ }
516
+ _$AI(t, e = this) {
517
+ if ((t = b(this, t, e, 0) ?? d) === v)
518
+ return;
519
+ 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);
520
+ i && this.element.removeEventListener(this.name, this, s), r && this.element.addEventListener(this.name, this, t), this._$AH = t;
521
+ }
522
+ handleEvent(t) {
523
+ var e;
524
+ typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
525
+ }
526
+ }
527
+ class Et {
528
+ constructor(t, e, s) {
529
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
530
+ }
531
+ get _$AU() {
532
+ return this._$AM._$AU;
533
+ }
534
+ _$AI(t) {
535
+ b(this, t);
536
+ }
537
+ }
538
+ const L = w.litHtmlPolyfillSupport;
539
+ L == null || L(x, U), (w.litHtmlVersions ?? (w.litHtmlVersions = [])).push("3.1.3");
540
+ const wt = (n, t, e) => {
541
+ const s = (e == null ? void 0 : e.renderBefore) ?? t;
542
+ let i = s._$litPart$;
543
+ if (i === void 0) {
544
+ const r = (e == null ? void 0 : e.renderBefore) ?? null;
545
+ s._$litPart$ = i = new U(t.insertBefore(P(), r), r, void 0, e ?? {});
546
+ }
547
+ return i._$AI(n), i;
548
+ };
549
+ /**
550
+ * @license
551
+ * Copyright 2017 Google LLC
552
+ * SPDX-License-Identifier: BSD-3-Clause
553
+ */
554
+ class C extends y {
555
+ constructor() {
556
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
557
+ }
558
+ createRenderRoot() {
559
+ var e;
560
+ const t = super.createRenderRoot();
561
+ return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
562
+ }
563
+ update(t) {
564
+ const e = this.render();
565
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = wt(e, this.renderRoot, this.renderOptions);
566
+ }
567
+ connectedCallback() {
568
+ var t;
569
+ super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0);
570
+ }
571
+ disconnectedCallback() {
572
+ var t;
573
+ super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
574
+ }
575
+ render() {
576
+ return v;
577
+ }
578
+ }
579
+ var X;
580
+ C._$litElement$ = !0, C.finalized = !0, (X = globalThis.litElementHydrateSupport) == null || X.call(globalThis, { LitElement: C });
581
+ const z = globalThis.litElementPolyfillSupport;
582
+ z == null || z({ LitElement: C });
583
+ (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.5");
584
+ class Ct extends C {
585
+ createRenderRoot() {
586
+ return this;
587
+ }
588
+ }
589
+ var Pt = (n, t, e, s) => {
590
+ for (var i = t, r = n.length - 1, o; r >= 0; r--)
591
+ (o = n[r]) && (i = o(i) || i);
592
+ return i;
593
+ };
594
+ let D = class extends Ct {
595
+ constructor() {
596
+ super(...arguments), this.liked = null, this.recipeLikeId = "", this.requestHeaders = new Headers();
597
+ }
598
+ connectedCallback() {
599
+ super.connectedCallback(), console.debug("[MealzComponents] loading like button"), this.requestHeaders.append("Authorization", "Bearer <your-token>"), this.requestHeaders.append("miam-origin", "partners"), this.requestHeaders.append("Content-Type", "application/vnd.api+json");
600
+ }
601
+ render() {
602
+ this.button = this.querySelector(".mealz-like-button"), this.button && (this.getInitialStatus(), this.recipeLikeId && this.button.addEventListener("click", () => this.toggle()), console.log(this.button));
603
+ }
604
+ getInitialStatus() {
605
+ var s;
606
+ const n = (s = this.attributes["starting-data"]) == null ? void 0 : s.value;
607
+ if (console.log(n), !n)
608
+ return;
609
+ const { id: t, liked: e } = JSON.parse(n);
610
+ this.recipeLikeId = t, this.liked = e, this.removeAttribute("starting-data");
611
+ }
612
+ async toggle() {
613
+ var e, s;
614
+ const n = JSON.stringify({
615
+ data: {
616
+ type: "recipe-likes",
617
+ id: 1,
618
+ attributes: {
619
+ "is-past": this.liked
620
+ }
621
+ }
622
+ }), t = await fetch(
623
+ `http://localhost:3000/api/v1/recipe-likes/${this.recipeLikeId}`,
624
+ { headers: this.requestHeaders, method: "PATCH", body: n }
625
+ ).then((i) => i.json());
626
+ this.liked = !((s = (e = t.data) == null ? void 0 : e.attributes) != null && s["is-past"]), this.updateDOM();
627
+ }
628
+ updateDOM() {
629
+ this.button.querySelector(".mealz-like-button__icon").classList.toggle("fill", this.liked), this.button.querySelectorAll(".mealz-like-button__icon img").forEach((n) => n.classList.toggle("active"));
630
+ }
631
+ };
632
+ D = Pt([
633
+ ot("mealz-like-button")
634
+ ], D);
635
+ window.customElements.get("mealz-like-button") || window.customElements.define("mealz-like-button", D);
636
+ export {
637
+ D as MealzLikeButton
638
+ };