UNPKG

@skhemata/skhemata-blog

Version:

Skhemata Blog Web Component. This web component provides several sub components in addition to main component, allowing featured blogs, blog listing and blog post display.

1,855 lines (1,561 loc) 732 kB
/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const t = window.ShadowRoot && (void 0 === window.ShadyCSS || window.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, e = Symbol(); class s { constructor(t, s) { if (s !== e) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t; } get styleSheet() { return t && void 0 === this.t && (this.t = new CSSStyleSheet(), this.t.replaceSync(this.cssText)), this.t; } toString() { return this.cssText; } } const n = new Map(), o = t => { let o = n.get(t); return void 0 === o && n.set(t, o = new s(t, e)), o; }, r = t => o("string" == typeof t ? t : t + ""), i = (t, ...e) => { const n = 1 === t.length ? t[0] : e.reduce((e, n, o) => e + (t => { if (t instanceof s) return t.cssText; if ("number" == typeof t) return t; throw Error("Value passed to 'css' function must be a 'css' function result: " + t + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); })(n) + t[o + 1], t[0]); return o(n); }, S = (e, s) => { t ? e.adoptedStyleSheets = s.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet) : s.forEach(t => { const s = document.createElement("style"); s.textContent = t.cssText, e.appendChild(s); }); }, u = t ? t => t : t => t instanceof CSSStyleSheet ? (t => { let e = ""; for (const s of t.cssRules) e += s.cssText; return r(e); })(t) : t; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var s$1, e$1, h, r$1; const o$1 = { toAttribute(t, i) { switch (i) { case Boolean: t = t ? "" : null; break; case Object: case Array: t = null == t ? t : JSON.stringify(t); } return t; }, fromAttribute(t, i) { let s = t; switch (i) { case Boolean: s = null !== t; break; case Number: s = null === t ? null : Number(t); break; case Object: case Array: try { s = JSON.parse(t); } catch (t) { s = null; } } return s; } }, n$1 = (t, i) => i !== t && (i == i || t == t), l = { attribute: !0, type: String, converter: o$1, reflect: !1, hasChanged: n$1 }; class a extends HTMLElement { constructor() { super(), this.Πi = new Map(), this.Πo = void 0, this.Πl = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this.Πh = null, this.u(); } static addInitializer(t) { var i; null !== (i = this.v) && void 0 !== i || (this.v = []), this.v.push(t); } static get observedAttributes() { this.finalize(); const t = []; return this.elementProperties.forEach((i, s) => { const e = this.Πp(s, i); void 0 !== e && (this.Πm.set(e, s), t.push(e)); }), t; } static createProperty(t, i = l) { if (i.state && (i.attribute = !1), this.finalize(), this.elementProperties.set(t, i), !i.noAccessor && !this.prototype.hasOwnProperty(t)) { const s = "symbol" == typeof t ? Symbol() : "__" + t, e = this.getPropertyDescriptor(t, s, i); void 0 !== e && Object.defineProperty(this.prototype, t, e); } } static getPropertyDescriptor(t, i, s) { return { get() { return this[i]; }, set(e) { const h = this[t]; this[i] = e, this.requestUpdate(t, h, s); }, configurable: !0, enumerable: !0 }; } static getPropertyOptions(t) { return this.elementProperties.get(t) || l; } static finalize() { if (this.hasOwnProperty("finalized")) return !1; this.finalized = !0; const t = Object.getPrototypeOf(this); if (t.finalize(), this.elementProperties = new Map(t.elementProperties), this.Πm = new Map(), this.hasOwnProperty("properties")) { const t = this.properties, i = [...Object.getOwnPropertyNames(t), ...Object.getOwnPropertySymbols(t)]; for (const s of i) this.createProperty(s, t[s]); } return this.elementStyles = this.finalizeStyles(this.styles), !0; } static finalizeStyles(i) { const s = []; if (Array.isArray(i)) { const e = new Set(i.flat(1 / 0).reverse()); for (const i of e) s.unshift(u(i)); } else void 0 !== i && s.push(u(i)); return s; } static Πp(t, i) { const s = i.attribute; return !1 === s ? void 0 : "string" == typeof s ? s : "string" == typeof t ? t.toLowerCase() : void 0; } u() { var t; this.Πg = new Promise(t => this.enableUpdating = t), this.L = new Map(), this.Π_(), this.requestUpdate(), null === (t = this.constructor.v) || void 0 === t || t.forEach(t => t(this)); } addController(t) { var i, s; (null !== (i = this.ΠU) && void 0 !== i ? i : this.ΠU = []).push(t), void 0 !== this.renderRoot && this.isConnected && (null === (s = t.hostConnected) || void 0 === s || s.call(t)); } removeController(t) { var i; null === (i = this.ΠU) || void 0 === i || i.splice(this.ΠU.indexOf(t) >>> 0, 1); } Π_() { this.constructor.elementProperties.forEach((t, i) => { this.hasOwnProperty(i) && (this.Πi.set(i, this[i]), delete this[i]); }); } createRenderRoot() { var t; const s = null !== (t = this.shadowRoot) && void 0 !== t ? t : this.attachShadow(this.constructor.shadowRootOptions); return S(s, this.constructor.elementStyles), s; } connectedCallback() { var t; void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), null === (t = this.ΠU) || void 0 === t || t.forEach(t => { var i; return null === (i = t.hostConnected) || void 0 === i ? void 0 : i.call(t); }), this.Πl && (this.Πl(), this.Πo = this.Πl = void 0); } enableUpdating(t) {} disconnectedCallback() { var t; null === (t = this.ΠU) || void 0 === t || t.forEach(t => { var i; return null === (i = t.hostDisconnected) || void 0 === i ? void 0 : i.call(t); }), this.Πo = new Promise(t => this.Πl = t); } attributeChangedCallback(t, i, s) { this.K(t, s); } Πj(t, i, s = l) { var e, h; const r = this.constructor.Πp(t, s); if (void 0 !== r && !0 === s.reflect) { const n = (null !== (h = null === (e = s.converter) || void 0 === e ? void 0 : e.toAttribute) && void 0 !== h ? h : o$1.toAttribute)(i, s.type); this.Πh = t, null == n ? this.removeAttribute(r) : this.setAttribute(r, n), this.Πh = null; } } K(t, i) { var s, e, h; const r = this.constructor, n = r.Πm.get(t); if (void 0 !== n && this.Πh !== n) { const t = r.getPropertyOptions(n), l = t.converter, a = null !== (h = null !== (e = null === (s = l) || void 0 === s ? void 0 : s.fromAttribute) && void 0 !== e ? e : "function" == typeof l ? l : null) && void 0 !== h ? h : o$1.fromAttribute; this.Πh = n, this[n] = a(i, t.type), this.Πh = null; } } requestUpdate(t, i, s) { let e = !0; void 0 !== t && (((s = s || this.constructor.getPropertyOptions(t)).hasChanged || n$1)(this[t], i) ? (this.L.has(t) || this.L.set(t, i), !0 === s.reflect && this.Πh !== t && (void 0 === this.Πk && (this.Πk = new Map()), this.Πk.set(t, s))) : e = !1), !this.isUpdatePending && e && (this.Πg = this.Πq()); } async Πq() { this.isUpdatePending = !0; try { for (await this.Πg; this.Πo;) await this.Πo; } catch (t) { Promise.reject(t); } const t = this.performUpdate(); return null != t && (await t), !this.isUpdatePending; } performUpdate() { var t; if (!this.isUpdatePending) return; this.hasUpdated, this.Πi && (this.Πi.forEach((t, i) => this[i] = t), this.Πi = void 0); let i = !1; const s = this.L; try { i = this.shouldUpdate(s), i ? (this.willUpdate(s), null === (t = this.ΠU) || void 0 === t || t.forEach(t => { var i; return null === (i = t.hostUpdate) || void 0 === i ? void 0 : i.call(t); }), this.update(s)) : this.Π$(); } catch (t) { throw i = !1, this.Π$(), t; } i && this.E(s); } willUpdate(t) {} E(t) { var i; null === (i = this.ΠU) || void 0 === i || i.forEach(t => { var i; return null === (i = t.hostUpdated) || void 0 === i ? void 0 : i.call(t); }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); } Π$() { this.L = new Map(), this.isUpdatePending = !1; } get updateComplete() { return this.getUpdateComplete(); } getUpdateComplete() { return this.Πg; } shouldUpdate(t) { return !0; } update(t) { void 0 !== this.Πk && (this.Πk.forEach((t, i) => this.Πj(i, this[i], t)), this.Πk = void 0), this.Π$(); } updated(t) {} firstUpdated(t) {} } a.finalized = !0, a.elementProperties = new Map(), a.elementStyles = [], a.shadowRootOptions = { mode: "open" }, null === (e$1 = (s$1 = globalThis).reactiveElementPlatformSupport) || void 0 === e$1 || e$1.call(s$1, { ReactiveElement: a }), (null !== (h = (r$1 = globalThis).reactiveElementVersions) && void 0 !== h ? h : r$1.reactiveElementVersions = []).push("1.0.0-rc.2"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$1, i$1, s$2, e$2; const o$2 = globalThis.trustedTypes, l$1 = o$2 ? o$2.createPolicy("lit-html", { createHTML: t => t }) : void 0, n$2 = `lit$${(Math.random() + "").slice(9)}$`, h$1 = "?" + n$2, r$2 = `<${h$1}>`, u$1 = document, c = (t = "") => u$1.createComment(t), d = t => null === t || "object" != typeof t && "function" != typeof t, v = Array.isArray, a$1 = t => { var i; return v(t) || "function" == typeof (null === (i = t) || void 0 === i ? void 0 : i[Symbol.iterator]); }, f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _ = /-->/g, m = />/g, p = />|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g, $ = /'/g, g = /"/g, y = /^(?:script|style|textarea)$/i, b = t => (i, ...s) => ({ _$litType$: t, strings: i, values: s }), T = b(1), w = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), P = new WeakMap(), V = (t, i, s) => { var e, o; const l = null !== (e = null == s ? void 0 : s.renderBefore) && void 0 !== e ? e : i; let n = l._$litPart$; if (void 0 === n) { const t = null !== (o = null == s ? void 0 : s.renderBefore) && void 0 !== o ? o : null; l._$litPart$ = n = new C(i.insertBefore(c(), t), t, void 0, s); } return n.I(t), n; }, E = u$1.createTreeWalker(u$1, 129, null, !1), M = (t, i) => { const s = t.length - 1, e = []; let o, h = 2 === i ? "<svg>" : "", u = f; for (let i = 0; i < s; i++) { const s = t[i]; let l, c, d = -1, v = 0; for (; v < s.length && (u.lastIndex = v, c = u.exec(s), null !== c);) v = u.lastIndex, u === f ? "!--" === c[1] ? u = _ : void 0 !== c[1] ? u = m : void 0 !== c[2] ? (y.test(c[2]) && (o = RegExp("</" + c[2], "g")), u = p) : void 0 !== c[3] && (u = p) : u === p ? ">" === c[0] ? (u = null != o ? o : f, d = -1) : void 0 === c[1] ? d = -2 : (d = u.lastIndex - c[2].length, l = c[1], u = void 0 === c[3] ? p : '"' === c[3] ? g : $) : u === g || u === $ ? u = p : u === _ || u === m ? u = f : (u = p, o = void 0); const a = u === p && t[i + 1].startsWith("/>") ? " " : ""; h += u === f ? s + r$2 : d >= 0 ? (e.push(l), s.slice(0, d) + "$lit$" + s.slice(d) + n$2 + a) : s + n$2 + (-2 === d ? (e.push(void 0), i) : a); } const c = h + (t[s] || "<?>") + (2 === i ? "</svg>" : ""); return [void 0 !== l$1 ? l$1.createHTML(c) : c, e]; }; class N { constructor({ strings: t, _$litType$: i }, s) { let e; this.parts = []; let l = 0, r = 0; const u = t.length - 1, d = this.parts, [v, a] = M(t, i); if (this.el = N.createElement(v, s), E.currentNode = this.el.content, 2 === i) { const t = this.el.content, i = t.firstChild; i.remove(), t.append(...i.childNodes); } for (; null !== (e = E.nextNode()) && d.length < u;) { if (1 === e.nodeType) { if (e.hasAttributes()) { const t = []; for (const i of e.getAttributeNames()) if (i.endsWith("$lit$") || i.startsWith(n$2)) { const s = a[r++]; if (t.push(i), void 0 !== s) { const t = e.getAttribute(s.toLowerCase() + "$lit$").split(n$2), i = /([.?@])?(.*)/.exec(s); d.push({ type: 1, index: l, name: i[2], strings: t, ctor: "." === i[1] ? I : "?" === i[1] ? L : "@" === i[1] ? R : H }); } else d.push({ type: 6, index: l }); } for (const i of t) e.removeAttribute(i); } if (y.test(e.tagName)) { const t = e.textContent.split(n$2), i = t.length - 1; if (i > 0) { e.textContent = o$2 ? o$2.emptyScript : ""; for (let s = 0; s < i; s++) e.append(t[s], c()), E.nextNode(), d.push({ type: 2, index: ++l }); e.append(t[i], c()); } } } else if (8 === e.nodeType) if (e.data === h$1) d.push({ type: 2, index: l });else { let t = -1; for (; -1 !== (t = e.data.indexOf(n$2, t + 1));) d.push({ type: 7, index: l }), t += n$2.length - 1; } l++; } } static createElement(t, i) { const s = u$1.createElement("template"); return s.innerHTML = t, s; } } function S$1(t, i, s = t, e) { var o, l, n, h; if (i === w) return i; let r = void 0 !== e ? null === (o = s.Σi) || void 0 === o ? void 0 : o[e] : s.Σo; const u = d(i) ? void 0 : i._$litDirective$; return (null == r ? void 0 : r.constructor) !== u && (null === (l = null == r ? void 0 : r.O) || void 0 === l || l.call(r, !1), void 0 === u ? r = void 0 : (r = new u(t), r.T(t, s, e)), void 0 !== e ? (null !== (n = (h = s).Σi) && void 0 !== n ? n : h.Σi = [])[e] = r : s.Σo = r), void 0 !== r && (i = S$1(t, r.S(t, i.values), r, e)), i; } class k { constructor(t, i) { this.l = [], this.N = void 0, this.D = t, this.M = i; } u(t) { var i; const { el: { content: s }, parts: e } = this.D, o = (null !== (i = null == t ? void 0 : t.creationScope) && void 0 !== i ? i : u$1).importNode(s, !0); E.currentNode = o; let l = E.nextNode(), n = 0, h = 0, r = e[0]; for (; void 0 !== r;) { if (n === r.index) { let i; 2 === r.type ? i = new C(l, l.nextSibling, this, t) : 1 === r.type ? i = new r.ctor(l, r.name, r.strings, this, t) : 6 === r.type && (i = new z(l, this, t)), this.l.push(i), r = e[++h]; } n !== (null == r ? void 0 : r.index) && (l = E.nextNode(), n++); } return o; } v(t) { let i = 0; for (const s of this.l) void 0 !== s && (void 0 !== s.strings ? (s.I(t, s, i), i += s.strings.length - 2) : s.I(t[i])), i++; } } class C { constructor(t, i, s, e) { this.type = 2, this.N = void 0, this.A = t, this.B = i, this.M = s, this.options = e; } setConnected(t) { var i; null === (i = this.P) || void 0 === i || i.call(this, t); } get parentNode() { return this.A.parentNode; } get startNode() { return this.A; } get endNode() { return this.B; } I(t, i = this) { t = S$1(this, t, i), d(t) ? t === A || null == t || "" === t ? (this.H !== A && this.R(), this.H = A) : t !== this.H && t !== w && this.m(t) : void 0 !== t._$litType$ ? this._(t) : void 0 !== t.nodeType ? this.$(t) : a$1(t) ? this.g(t) : this.m(t); } k(t, i = this.B) { return this.A.parentNode.insertBefore(t, i); } $(t) { this.H !== t && (this.R(), this.H = this.k(t)); } m(t) { const i = this.A.nextSibling; null !== i && 3 === i.nodeType && (null === this.B ? null === i.nextSibling : i === this.B.previousSibling) ? i.data = t : this.$(u$1.createTextNode(t)), this.H = t; } _(t) { var i; const { values: s, _$litType$: e } = t, o = "number" == typeof e ? this.C(t) : (void 0 === e.el && (e.el = N.createElement(e.h, this.options)), e); if ((null === (i = this.H) || void 0 === i ? void 0 : i.D) === o) this.H.v(s);else { const t = new k(o, this), i = t.u(this.options); t.v(s), this.$(i), this.H = t; } } C(t) { let i = P.get(t.strings); return void 0 === i && P.set(t.strings, i = new N(t)), i; } g(t) { v(this.H) || (this.H = [], this.R()); const i = this.H; let s, e = 0; for (const o of t) e === i.length ? i.push(s = new C(this.k(c()), this.k(c()), this, this.options)) : s = i[e], s.I(o), e++; e < i.length && (this.R(s && s.B.nextSibling, e), i.length = e); } R(t = this.A.nextSibling, i) { var s; for (null === (s = this.P) || void 0 === s || s.call(this, !1, !0, i); t && t !== this.B;) { const i = t.nextSibling; t.remove(), t = i; } } } class H { constructor(t, i, s, e, o) { this.type = 1, this.H = A, this.N = void 0, this.V = void 0, this.element = t, this.name = i, this.M = e, this.options = o, s.length > 2 || "" !== s[0] || "" !== s[1] ? (this.H = Array(s.length - 1).fill(A), this.strings = s) : this.H = A; } get tagName() { return this.element.tagName; } I(t, i = this, s, e) { const o = this.strings; let l = !1; if (void 0 === o) t = S$1(this, t, i, 0), l = !d(t) || t !== this.H && t !== w, l && (this.H = t);else { const e = t; let n, h; for (t = o[0], n = 0; n < o.length - 1; n++) h = S$1(this, e[s + n], i, n), h === w && (h = this.H[n]), l || (l = !d(h) || h !== this.H[n]), h === A ? t = A : t !== A && (t += (null != h ? h : "") + o[n + 1]), this.H[n] = h; } l && !e && this.W(t); } W(t) { t === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t ? t : ""); } } class I extends H { constructor() { super(...arguments), this.type = 3; } W(t) { this.element[this.name] = t === A ? void 0 : t; } } class L extends H { constructor() { super(...arguments), this.type = 4; } W(t) { t && t !== A ? this.element.setAttribute(this.name, "") : this.element.removeAttribute(this.name); } } class R extends H { constructor() { super(...arguments), this.type = 5; } I(t, i = this) { var s; if ((t = null !== (s = S$1(this, t, i, 0)) && void 0 !== s ? s : A) === w) return; const e = this.H, o = t === A && e !== A || t.capture !== e.capture || t.once !== e.once || t.passive !== e.passive, l = t !== A && (e === A || o); o && this.element.removeEventListener(this.name, this, e), l && this.element.addEventListener(this.name, this, t), this.H = t; } handleEvent(t) { var i, s; "function" == typeof this.H ? this.H.call(null !== (s = null === (i = this.options) || void 0 === i ? void 0 : i.host) && void 0 !== s ? s : this.element, t) : this.H.handleEvent(t); } } class z { constructor(t, i, s) { this.element = t, this.type = 6, this.N = void 0, this.V = void 0, this.M = i, this.options = s; } I(t) { S$1(this, t); } } null === (i$1 = (t$1 = globalThis).litHtmlPlatformSupport) || void 0 === i$1 || i$1.call(t$1, N, C), (null !== (s$2 = (e$2 = globalThis).litHtmlVersions) && void 0 !== s$2 ? s$2 : e$2.litHtmlVersions = []).push("2.0.0-rc.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var i$2, l$2, o$3, s$3, n$3, a$2; (null !== (i$2 = (a$2 = globalThis).litElementVersions) && void 0 !== i$2 ? i$2 : a$2.litElementVersions = []).push("3.0.0-rc.2"); class h$2 extends a { constructor() { super(...arguments), this.renderOptions = { host: this }, this.Φt = void 0; } createRenderRoot() { var t, e; const r = super.createRenderRoot(); return null !== (t = (e = this.renderOptions).renderBefore) && void 0 !== t || (e.renderBefore = r.firstChild), r; } update(t) { const r = this.render(); super.update(t), this.Φt = V(r, this.renderRoot, this.renderOptions); } connectedCallback() { var t; super.connectedCallback(), null === (t = this.Φt) || void 0 === t || t.setConnected(!0); } disconnectedCallback() { var t; super.disconnectedCallback(), null === (t = this.Φt) || void 0 === t || t.setConnected(!1); } render() { return w; } } h$2.finalized = !0, h$2._$litElement$ = !0, null === (o$3 = (l$2 = globalThis).litElementHydrateSupport) || void 0 === o$3 || o$3.call(l$2, { LitElement: h$2 }), null === (n$3 = (s$3 = globalThis).litElementPlatformSupport) || void 0 === n$3 || n$3.call(s$3, { LitElement: h$2 }); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const i$3 = (i, e) => "method" === e.kind && e.descriptor && !("value" in e.descriptor) ? { ...e, finisher(n) { n.createProperty(e.key, i); } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e.key, initializer() { "function" == typeof e.initializer && (this[e.key] = e.initializer.call(this)); }, finisher(n) { n.createProperty(e.key, i); } }; function e$3(e) { return (n, t) => void 0 !== t ? ((i, e, n) => { e.constructor.createProperty(n, i); })(e, n, t) : i$3(e, n); } (function () { function g(a) { var b = 0; return function () { return b < a.length ? { done: !1, value: a[b++] } : { done: !0 }; }; } if (!ShadowRoot.prototype.createElement) { var h = window.HTMLElement, l = window.customElements.define, m = window.customElements.get, n = window.customElements, p = new WeakMap(), q = new WeakMap(), r = new WeakMap(), t = new WeakMap(); window.CustomElementRegistry = function () { this.l = new Map(); this.o = new Map(); this.i = new Map(); this.h = new Map(); }; window.CustomElementRegistry.prototype.define = function (a, b) { a = a.toLowerCase(); if (void 0 !== this.j(a)) throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"" + a + '" has already been used with this registry'); if (void 0 !== this.o.get(b)) throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry"); var c = b.prototype.attributeChangedCallback, d = new Set(b.observedAttributes || []); u(b, d, c); c = { g: b, connectedCallback: b.prototype.connectedCallback, disconnectedCallback: b.prototype.disconnectedCallback, adoptedCallback: b.prototype.adoptedCallback, attributeChangedCallback: c, observedAttributes: d }; this.l.set(a, c); this.o.set(b, c); d = m.call(n, a); d || (d = v(a), l.call(n, a, d)); this === window.customElements && (r.set(b, c), c.s = d); if (d = this.h.get(a)) { this.h.delete(a); var e = "undefined" != typeof Symbol && Symbol.iterator && d[Symbol.iterator]; d = e ? e.call(d) : { next: g(d) }; for (e = d.next(); !e.done; e = d.next()) e = e.value, q.delete(e), w(e, c, !0); } c = this.i.get(a); void 0 !== c && (c.resolve(b), this.i.delete(a)); return b; }; window.CustomElementRegistry.prototype.upgrade = function () { x.push(this); n.upgrade.apply(n, arguments); x.pop(); }; window.CustomElementRegistry.prototype.get = function (a) { var b; return null == (b = this.l.get(a)) ? void 0 : b.g; }; window.CustomElementRegistry.prototype.j = function (a) { return this.l.get(a); }; window.CustomElementRegistry.prototype.whenDefined = function (a) { var b = this.j(a); if (void 0 !== b) return Promise.resolve(b.g); var c = this.i.get(a); void 0 === c && (c = {}, c.promise = new Promise(function (d) { return c.resolve = d; }), this.i.set(a, c)); return c.promise; }; window.CustomElementRegistry.prototype.m = function (a, b, c) { var d = this.h.get(b); d || this.h.set(b, d = new Set()); c ? d.add(a) : d.delete(a); }; var y; window.HTMLElement = function () { var a = y; if (a) return y = void 0, a; var b = r.get(this.constructor); if (!b) throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)"); a = Reflect.construct(h, [], b.s); Object.setPrototypeOf(a, this.constructor.prototype); p.set(a, b); return a; }; window.HTMLElement.prototype = h.prototype; var v = function (a) { function b() { var c = Reflect.construct(h, [], this.constructor); Object.setPrototypeOf(c, HTMLElement.prototype); a: { var d = c.getRootNode(); if (!(d === document || d instanceof ShadowRoot)) { d = x[x.length - 1]; if (d instanceof CustomElementRegistry) { var e = d; break a; } d = d.getRootNode(); d === document || d instanceof ShadowRoot || (d = (null == (e = t.get(d)) ? void 0 : e.getRootNode()) || document); } e = d.customElements; } e = e || window.customElements; (d = e.j(a)) ? w(c, d) : q.set(c, e); return c; } b.prototype.connectedCallback = function () { var c = p.get(this); c ? c.connectedCallback && c.connectedCallback.apply(this, arguments) : q.get(this).m(this, a, !0); }; b.prototype.disconnectedCallback = function () { var c = p.get(this); c ? c.disconnectedCallback && c.disconnectedCallback.apply(this, arguments) : q.get(this).m(this, a, !1); }; b.prototype.adoptedCallback = function () { var c, d; null == (c = p.get(this)) || null == (d = c.adoptedCallback) || d.apply(this, arguments); }; return b; }, u = function (a, b, c) { if (0 !== b.size && void 0 !== c) { var d = a.prototype.setAttribute; d && (a.prototype.setAttribute = function (f, k) { if (b.has(f)) { var C = this.getAttribute(f); d.call(this, f, k); c.call(this, f, C, k); } else d.call(this, f, k); }); var e = a.prototype.removeAttribute; e && (a.prototype.removeAttribute = function (f) { if (b.has(f)) { var k = this.getAttribute(f); e.call(this, f); c.call(this, f, k, null); } else e.call(this, f); }); } }, z = function (a) { var b = Object.getPrototypeOf(a); if (b !== window.HTMLElement) return b === h ? Object.setPrototypeOf(a, window.HTMLElement) : z(b); }, w = function (a, b, c) { c = void 0 === c ? !1 : c; Object.setPrototypeOf(a, b.g.prototype); p.set(a, b); y = a; try { new b.g(); } catch (d) { z(b.g), new b.g(); } b.observedAttributes.forEach(function (d) { a.hasAttribute(d) && b.attributeChangedCallback.call(a, d, null, a.getAttribute(d)); }); c && b.connectedCallback && a.isConnected && b.connectedCallback.call(a); }, A = Element.prototype.attachShadow; Element.prototype.attachShadow = function (a) { var b = A.apply(this, arguments); a.customElements && (b.customElements = a.customElements); return b; }; var x = [document], B = function (a, b, c) { var d = (c ? Object.getPrototypeOf(c) : a.prototype)[b]; a.prototype[b] = function () { x.push(this); var e = d.apply(c || this, arguments); void 0 !== e && t.set(e, this); x.pop(); return e; }; }; B(ShadowRoot, "createElement", document); B(ShadowRoot, "importNode", document); B(Element, "insertAdjacentHTML"); var D = function (a) { var b = Object.getOwnPropertyDescriptor(a.prototype, "innerHTML"); Object.defineProperty(a.prototype, "innerHTML", Object.assign({}, b, { set: function (c) { x.push(this); b.set.call(this, c); x.pop(); } })); }; D(Element); D(ShadowRoot); Object.defineProperty(window, "customElements", { value: new CustomElementRegistry(), configurable: !0, writable: !0 }); } }).call(self); const appliedClassMixins = new WeakMap(); /** Vefify if the Mixin was previously applyed * @private * @param {function} mixin Mixin being applyed * @param {object} superClass Class receiving the new mixin * @returns {boolean} */ function wasMixinPreviouslyApplied(mixin, superClass) { let klass = superClass; while (klass) { if (appliedClassMixins.get(klass) === mixin) { return true; } klass = Object.getPrototypeOf(klass); } return false; } /** Apply each mixin in the chain to make sure they are not applied more than once to the final class. * @export * @param {function} mixin Mixin to be applyed * @returns {object} Mixed class with mixin applied */ function dedupeMixin(mixin) { return superClass => { if (wasMixinPreviouslyApplied(mixin, superClass)) { return superClass; } const mixedClass = mixin(superClass); appliedClassMixins.set(mixedClass, mixin); return mixedClass; }; } /** * @typedef {import('./types').RenderOptions} RenderOptions * @typedef {import('./types').ScopedElementsMixin} ScopedElementsMixin * @typedef {import('./types').ScopedElementsHost} ScopedElementsHost * @typedef {import('./types').ScopedElementsMap} ScopedElementsMap * @typedef {import('@lit/reactive-element').CSSResultFlatArray} CSSResultFlatArray */ /** * @template {import('./types').Constructor<HTMLElement>} T * @param {T} superclass * @return {T & import('./types').Constructor<ScopedElementsHost>} */ const ScopedElementsMixinImplementation = superclass => /** @type {ScopedElementsHost} */ class ScopedElementsHost extends superclass { /** * Obtains the scoped elements definitions map if specified. * * @returns {ScopedElementsMap} */ static get scopedElements() { return {}; } /** * Obtains the ShadowRoot options. * * @type {ShadowRootInit} */ static get shadowRootOptions() { return this.__shadowRootOptions; } /** * Set the shadowRoot options. * * @param {ShadowRootInit} value */ static set shadowRootOptions(value) { this.__shadowRootOptions = value; } /** * Obtains the element styles. * * @returns {CSSResultFlatArray} */ static get elementStyles() { return this.__elementStyles; } static set elementStyles(styles) { this.__elementStyles = styles; } // either TS or ESLint will complain here // eslint-disable-next-line no-unused-vars constructor(..._args) { super(); /** @type {RenderOptions} */ this.renderOptions = this.renderOptions || undefined; } /** * Obtains the CustomElementRegistry associated to the ShadowRoot. * * @returns {CustomElementRegistry} */ get registry() { // @ts-ignore return this.constructor.__registry; } /** * Set the CustomElementRegistry associated to the ShadowRoot * * @param {CustomElementRegistry} registry */ set registry(registry) { // @ts-ignore this.constructor.__registry = registry; } /** @override */ createRenderRoot() { const { scopedElements, shadowRootOptions, elementStyles } = /** @type {typeof ScopedElementsHost} */ this.constructor; if (!this.registry) { this.registry = new CustomElementRegistry(); Object.entries(scopedElements).forEach(([tagName, klass]) => this.registry.define(tagName, klass)); } /** @type {ShadowRootInit} */ const options = { mode: 'open', ...shadowRootOptions, customElements: this.registry }; this.renderOptions.creationScope = this.attachShadow(options); if (this.renderOptions.creationScope instanceof ShadowRoot) S(this.renderOptions.creationScope, elementStyles); return this.renderOptions.creationScope; } /** * Defines a scoped element. * * @param {string} tagName * @param {typeof HTMLElement} klass */ defineScopedElement(tagName, klass) { return this.registry.get(tagName) || this.registry.define(tagName, klass); } /** * @deprecated use the native el.tagName instead * * @param {string} tagName * @returns {string} the tag name */ // eslint-disable-next-line class-methods-use-this getScopedTagName(tagName) { return tagName; } /** * @deprecated use the native el.tagName instead * * @param {string} tagName * @returns {string} the tag name */ // eslint-disable-next-line class-methods-use-this static getScopedTagName(tagName) { return tagName; } }; const ScopedElementsMixin = dedupeMixin(ScopedElementsMixinImplementation); var RequestMethod; (function (RequestMethod) { RequestMethod["POST"] = "post"; RequestMethod["GET"] = "get"; RequestMethod["PUT"] = "put"; RequestMethod["DELETE"] = "delete"; })(RequestMethod || (RequestMethod = {})); class APICall { /** * * @param apiUrl api url * @param authToken x-auth-token token */ constructor(apiUrl, authToken) { this.apiUrl = ''; this.authToken = ''; this.apiUrl = apiUrl; this.authToken = authToken; } /** * * @param request APIRequest */ send(request) { return new Promise((resolve, reject) => { const { requestMethod, endpoint, data, searchParams } = request; const options = { method: requestMethod, headers: {} }; if (this.authToken) { options.headers['x-auth-token'] = this.authToken; } if (data) { options.headers['Content-Type'] = 'application/json'; try { options.body = JSON.stringify(data); } catch (error) { reject(error); } } const url = new URL(`${this.apiUrl}/${endpoint}`); if (searchParams) { url.search = searchParams.toString(); } fetch(url.toString(), options).then(res => res.json()).then(resData => { resolve(resData); }).catch(resolve); }); } } class Campaign { constructor(data = {}, api) { this.data = {}; this.images = []; this.data = data; this.id = data.id; this.api = api; } save(data) { return new Promise((resolve, reject) => { const request = { requestMethod: this.id ? RequestMethod.PUT : RequestMethod.POST, endpoint: this.id ? `campaign/${this.id}` : 'campaign', data }; this.api.send(request).then(res => { this.data = res; resolve(res); }).catch(reject); }); } } class Subscription { constructor(data = {}, api) { this.data = {}; this.data = data; this.id = data.id; this.api = api; } /** * * @param stripe the stripe object to create the subscription with * @param cardToken token ID of tokenized card * @returns */ async payWithStripe(stripe, cardToken) { const subscriptionData = { token: cardToken, email: this.data.email, first_name: this.data.first_name, last_name: this.data.last_name, street1: this.data.street1, mail_code: this.data.mail_code, city_id: this.data.city_id, subscription_plan_id: this.data.subscription_plan_id, portal_name: this.data.portal_name.trim().replace(/ /g, '_'), terms: this.data.terms, use_sca: 1, source: this.data.source, create_sample_data: this.data.create_sample_data, secure_site: 0, custom_domain: 'custom' }; /* if (this.data.plan.addon) { subscriptionData.addon_domain = 1; } */ const request = { requestMethod: RequestMethod.POST, endpoint: 'subscription', data: subscriptionData }; return new Promise((resolve, reject) => { this.api.send(request).then(success => { if (success.sca_status === 'requies_action' || success.sca_status === 'requires_source_action') { stripe.confirmCardPayment(success.client_secret).then(pi => { if (pi.error) { reject(pi.error); } else { resolve(success); } }).catch(error => { reject(error); }); } else { console.log('no auth, resolving'); resolve(success); } }).catch(error => { reject(error); }); }); } } /** * constants */ const AUTH_TOKEN = 'skhemataToken'; var CampaignFileRegion; (function (CampaignFileRegion) { CampaignFileRegion[CampaignFileRegion["header"] = 1] = "header"; CampaignFileRegion[CampaignFileRegion["body"] = 2] = "body"; CampaignFileRegion[CampaignFileRegion["thumbnail"] = 3] = "thumbnail"; CampaignFileRegion[CampaignFileRegion["top_header"] = 5] = "top_header"; CampaignFileRegion[CampaignFileRegion["thumbnail_video"] = 6] = "thumbnail_video"; })(CampaignFileRegion || (CampaignFileRegion = {})); class Skhemata { /** * * @param apiUrl string * @param authToken string */ constructor(apiUrl, authToken) { this.api = new APICall(apiUrl, authToken); window.addEventListener('skhemata-login', e => { this.api.authToken = e.detail.authToken; }); } /** * initialize skhemata api object * @returns boolean of auth status */ init() { const authToken = localStorage.getItem(AUTH_TOKEN) || undefined; return new Promise(resolve => { if (!authToken) { resolve(false); } this.authenticate({ authToken }).then(() => resolve(true)).catch(() => resolve(false)); }); } /** * authenticate * @param auth auth info * @returns Promise with api response */ authenticate(auth) { const { authToken, email, password } = auth; let data; if (email && password) { data = { email, password }; } if (authToken) { this.api.authToken = authToken; } const request = { requestMethod: data ? RequestMethod.POST : RequestMethod.GET, endpoint: 'authenticate', data }; return this.api.send(request).then(res => { this.api.authToken = res.authToken; localStorage.set(AUTH_TOKEN, this.api.authToken); window.dispatchEvent(new CustomEvent('skhemata-login', { detail: { authToken: this.api.authToken } })); return res; }); } logout() { this.api.authToken = undefined; localStorage.removeItem(AUTH_TOKEN); window.dispatchEvent(new CustomEvent('skhemata-logout')); } /*************** * Campaign * ***************/ /** * * @param id ID of the campaign * @returns Promise<Campaign> */ getCampaign(id) { const campaignRequest = { requestMethod: RequestMethod.GET, endpoint: `campaign/${id}` }; const imageRequest = { requestMethod: RequestMethod.GET, endpoint: `campaign/${id}/resource/file` }; let newCampaign; return this.api.send(campaignRequest).then(campaign => { newCampaign = new Campaign(campaign, this.api); }).then(() => this.api.send(imageRequest)).then(images => { newCampaign.images = images.filter(image => image.region_id === CampaignFileRegion.thumbnail); return newCampaign; }); } /** * * @param data campaign data * @returns Promise<Campaign> */ createCampaign(data) { const request = { requestMethod: RequestMethod.POST, endpoint: 'campaign', data }; return this.api.send(request).then(campaign => new Campaign(campaign, this.api)); } /** * getCampaigns * @param params CampaignSearch object * @returns Promise with Array of Campaign objects or Error */ getCampaigns(params) { const { sort, filter, page } = params; const searchParams = new URLSearchParams(); if (sort) { searchParams.set('sort', JSON.stringify(sort)); } if (sort) { searchParams.set('filter', JSON.stringify(filter)); } if (page) { if (typeof page.page !== undefined) { searchParams.set('page', `${page.page}`); } if (typeof page.page_entries !== undefined) { searchParams.set('page_entries', `${page.page_entries}`); } } const request = { requestMethod: RequestMethod.GET, endpoint: 'campaign', searchParams }; return this.api.send(request).then(res => res.map(campaign => new Campaign(campaign, this.api))).catch(() => new Error('Error')); } /*************** * SUBSCRIPTION * ***************/ /** * * @param data data to create the subscription * @returns Subscription object */ createSubscription(data) { return new Subscription(data, this.api); } } /** * * This element is needed for bulma styling * Refer to documentation: https://bulma.io/documentation * **/ const Bulma = i` /*! bulma.io v0.9.2 | MIT License | github.com/jgthms/bulma */ /* Bulma Utilities */ .button, .input, .textarea, .select select, .file-cta, .file-name, .pagination-previous, .pagination-next, .pagination-link, .pagination-ellipsis { -moz-appearance: none; -webkit-appearance: none; align-items: center; border: 1px solid transparent; border-radius: 4px; box-shadow: none; display: inline-flex; font-size: 1rem; height: 2.5em; justify-content: flex-start; line-height: 1.5; padding-bottom: calc(0.5em - 1px); padding-left: calc(0.75em - 1px); padding-right: calc(0.75em - 1px); padding-top: calc(0.5em - 1px); position: relative; vertical-align: top; } .button:focus, .input:focus, .textarea:focus, .select select:focus, .file-cta:focus, .file-name:focus, .pagination-previous:focus, .pagination-next:focus, .pagination-link:focus, .pagination-ellipsis:focus, .is-focused.button, .is-focused.input, .is-focused.textarea, .select select.is-focused, .is-focused.file-cta, .is-focused.file-name, .is-focused.pagination-previous, .is-focused.pagination-next, .is-focused.pagination-link, .is-focused.pagination-ellipsis, .button:active, .input:active, .textarea:active, .select select:active, .file-cta:active, .file-name:active, .pagination-previous:active, .pagination-next:active, .pagination-link:active, .pagination-ellipsis:active, .is-active.button, .is-active.input, .is-active.textarea, .select select.is-active, .is-active.file-cta, .is-active.file-name, .is-active.pagination-previous, .is-active.pagination-next, .is-active.pagination-link, .is-active.pagination-ellipsis { outline: none; } .button[disabled], .input[disabled], .textarea[disabled], .select select[disabled], .file-cta[disabled], .file-name[disabled], .pagination-previous[disabled], .pagination-next[disabled], .pagination-link[disabled], .pagination-ellipsis[disabled], fieldset[disabled] .button, fieldset[disabled] .input, fieldset[disabled] .textarea, fieldset[disabled] .select select, .select fieldset[disabled] select, fieldset[disabled] .file-cta, fieldset[disabled] .file-name, fieldset[disabled] .pagination-previous, fieldset[disabled] .pagination-next, fieldset[disabled] .pagination-link, fieldset[disabled] .pagination-ellipsis { cursor: not-allowed; } .button, .file, .breadcrumb, .pagination-previous, .pagination-next, .pagination-link, .pagination-ellipsis, .tabs, .is-unselectable { -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .select:not(.is-multiple):not(.is-loading)::after, .navbar-link:not(.is-arrowless)::after { border: 3px solid transparent; border-radius: 2px; border-right: 0; border-top: 0; content: " "; display: block; height: 0.625em; margin-top: -0.4375em; pointer-events: none; position: absolute; top: 50%; transform: rotate(-45deg); transform-origin: center; width: 0.625em; } .box:not(:last-child), .content:not(:last-child), .notification:not(:last-child), .progress:not(:last-child), .table:not(:last-child), .table-container:not(:last-child), .title:not(:last-child), .subtitle:not(:last-child), .block:not(:last-child), .highlight:not(:last-child), .breadcrumb:not(:last-child), .level:not(:last-child), .message:not(:last-child), .pagination:not(:last-child), .tabs:not(:last-child) { margin-bottom: 1.5rem; } .delete, .modal-close { -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -moz-appearance: none; -webkit-appearance: none; background-color: rgba(10, 10, 10, 0.2); border: none; border-radius: 290486px; cursor: pointer; pointer-events: auto; display: inline-block; flex-grow: 0; flex-shrink: 0; font-size: 0; height: 20px; max-height: 20px; max-width: 20px; min-height: 20px; min-width: 20px; outline: none; position: relative; vertical-align: top; width: 20px; } .delete::before, .modal-close::before, .delete::after, .modal-close::after { background-color: white; content: ""; display: block; left: 50%; position: absolute; top: 50%; transform: translateX(-50%) translateY(-50%) rotate(45deg); transform-origin: center center; } .delete::before, .modal-close::before { height: 2px; width: 50%; } .delete::after, .modal-close::after { height: 50%; width: 2px; } .delete:hover, .modal-close:hover, .delete:focus, .modal-close:focus { background-color: rgba(10, 10, 10, 0.3); } .delete:active, .modal-close:active { background-color: rgba(10, 10, 10, 0.4); } .is-small.delete, .is-small.modal-close { height: 16px; max-height: 16px; max-width: 16px; min-height: 16px; min-width: 16px; width: 16px; } .is-medium.delete, .is-medium.modal-close { height: 24px; max-height: 24px; max-width: 24px; min-height: 24px; min-width: 24px; width: 24px; } .is-large.delete, .is-large.modal-close { height: 32px; max-height: 32px; max-width: 32px; min-height: 32px; min-width: 32px; width: 32px; } .button.is-loading::after, .loader, .select.is-loading::after, .control.is-loading::after { -webkit-animation: spinAround 500ms infinite linear; animation: spinAround 500ms infinite linear; border: 2px solid #dbdbdb; border-radius: 290486px; border-right-color: transparent; border-top-color: transparent; content: ""; display: block; height: 1em; position: relative; width: 1em; } .image.is-square img, .image.is-square .has-ratio, .image.is-1by1 img, .image.is-1by1 .has-ratio, .image.is-5by4 img, .image.is-5by4 .has-ratio, .image.is-4by3 img, .image.is-4by3 .has-ratio, .image.is-3by2 img, .image.is-3by2 .has-ratio, .image.is-5by3 img, .image.is-5by3 .has-ratio, .image.is-16by9 img, .image.is-16by9 .has-ratio, .image.is-2by1 img, .image.is-2by1 .has-ratio, .image.is-3by1 img, .image.is-3by1 .has-ratio, .image.is-4by5 img, .image.is-4by5 .has-ratio, .image.is-3by4 img, .image.is-3by4 .has-ratio, .image.is-2by3 img, .image.is-2by3 .has-ratio, .image.is-3by5 img, .image.is-3by5 .has-ratio, .image.is-9by16 img, .image.is-9by16 .has-ratio, .image.is-1by2 img, .image.is-1by2 .has-ratio, .image.is-1by3 img, .image.is-1by3 .has-ratio, .modal, .modal-background, .is-overlay, .hero-video { bottom: 0; left: 0; position: absolute; right: 0; top: 0; } /* Bulma Base */ /*! minireset.css v0.0.6 | MIT License | github.com/jgthms/minireset.css */ html, body, p, ol, ul, li, dl, dt, dd, blockquote, figure, fieldset, legend, textarea, pre, ifr