UNPKG

@adyen/adyen-document-viewer

Version:
1,002 lines (1,001 loc) 34.2 kB
//#region \0rolldown/runtime.js var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, i, o, s) => { if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, { get: ((e) => i[e]).bind(null, d), enumerable: !(s = n(i, d)) || s.enumerable }); return e; }, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", { value: n, enumerable: !0 }) : a, n)), l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w = {}, T = [], E = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, D = Array.isArray; function O(e, t) { for (var n in t) e[n] = t[n]; return e; } function ee(e) { e && e.parentNode && e.parentNode.removeChild(e); } function k(e, t, n) { var r, i, a, o = {}; for (a in t) a == "key" ? r = t[a] : a == "ref" ? i = t[a] : o[a] = t[a]; if (arguments.length > 2 && (o.children = arguments.length > 3 ? l.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (a in e.defaultProps) o[a] === void 0 && (o[a] = e.defaultProps[a]); return A(e, o, r, i, null); } function A(e, t, n, r, i) { var a = { type: e, props: t, key: n, ref: r, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++d, __i: -1, __u: 0 }; return i == null && u.vnode != null && u.vnode(a), a; } function j(e) { return e.children; } function M(e, t) { this.props = e, this.context = t; } function N(e, t) { if (t == null) return e.__ ? N(e.__, e.__i + 1) : null; for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e; return typeof e.type == "function" ? N(e) : null; } function te(e) { if (e.__P && e.__d) { var t = e.__v, n = t.__e, r = [], i = [], a = O({}, t); a.__v = t.__v + 1, u.vnode && u.vnode(a), L(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? N(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, le(r, a, i), t.__e = t.__ = null, a.__e != n && ne(a); } } function ne(e) { if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) { if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e; }), ne(e); } function P(e) { (!e.__d && (e.__d = !0) && f.push(e) && !F.__r++ || p != u.debounceRendering) && ((p = u.debounceRendering) || m)(F); } function F() { try { for (var e, t = 1; f.length;) f.length > t && f.sort(h), e = f.shift(), t = f.length, te(e); } finally { f.length = F.__r = 0; } } function re(e, t, n, r, i, a, o, s, c, l, u) { var d, f, p, m, h, g, _, v = r && r.__k || T, y = t.length; for (c = ie(n, t, v, c, y), d = 0; d < y; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && v[p.__i] || w, p.__i = d, g = L(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && fe(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), (_ = !!(4 & p.__u)) || f.__k === p.__k ? (c = ae(p, c, e, _), _ && f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7); return n.__e = h, c; } function ie(e, t, n, r, i) { var a, o, s, c, l, u = n.length, d = u, f = 0; for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = A(null, o, null, null, null) : D(o) ? o = e.__k[a] = A(j, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = A(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = oe(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null; if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = N(s)), pe(s, s)); return r; } function ae(e, t, n, r) { var i, a; if (typeof e.type == "function") { for (i = e.__k, a = 0; i && a < i.length; a++) i[a] && (i[a].__ = e, t = ae(i[a], t, n, r)); return t; } e.__e != t && (r && (t && e.type && !t.parentNode && (t = N(e)), n.insertBefore(e.__e, t || null)), t = e.__e); do t &&= t.nextSibling; while (t != null && t.nodeType == 8); return t; } function oe(e, t, n, r) { var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && (2 & l.__u) == 0; if (l === null && s == null || u && s == l.key && c == l.type) return n; if (r > +!!u) { for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) != null && !(2 & l.__u) && s == l.key && c == l.type) return o; } return -1; } function se(e, t, n) { t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || E.test(t) ? n : n + "px"; } function I(e, t, n, r, i) { var a, o; n: if (t == "style") if (typeof n == "string") e.style.cssText = n; else { if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || se(e.style, t, ""); if (n) for (t in n) r && n[t] == r[t] || se(e.style, t, n[t]); } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(y, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[v] = r[v] : (n[v] = b, e.addEventListener(t, a ? S : x, a)) : e.removeEventListener(t, a ? S : x, a); else { if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s"); else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try { e[t] = n ?? ""; break n; } catch {} typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n)); } } function ce(e) { return function(t) { if (this.l) { var n = this.l[t.type + e]; if (t[_] == null) t[_] = b++; else if (t[_] < n[v]) return; return n(u.event ? u.event(t) : t); } }; } function L(e, t, n, r, i, a, o, s, c, l) { var d, f, p, m, h, g, _, v, y, b, x, S, C, w, E, k = t.type; if (t.constructor !== void 0) return null; 128 & n.__u && (c = !!(32 & n.__u), a = [s = t.__e = n.__e]), (d = u.__b) && d(t); n: if (typeof k == "function") try { if (v = t.props, y = k.prototype && k.prototype.render, b = (d = k.contextType) && r[d.__c], x = d ? b ? b.props.value : d.__ : r, n.__c ? _ = (f = t.__c = n.__c).__ = f.__E : (y ? t.__c = f = new k(v, x) : (t.__c = f = new M(v, x), f.constructor = k, f.render = me), b && b.sub(f), f.state ||= {}, f.__n = r, p = f.__d = !0, f.__h = [], f._sb = []), y && f.__s == null && (f.__s = f.state), y && k.getDerivedStateFromProps != null && (f.__s == f.state && (f.__s = O({}, f.__s)), O(f.__s, k.getDerivedStateFromProps(v, f.__s))), m = f.props, h = f.state, f.__v = t, p) y && k.getDerivedStateFromProps == null && f.componentWillMount != null && f.componentWillMount(), y && f.componentDidMount != null && f.__h.push(f.componentDidMount); else { if (y && k.getDerivedStateFromProps == null && v !== m && f.componentWillReceiveProps != null && f.componentWillReceiveProps(v, x), t.__v == n.__v || !f.__e && f.shouldComponentUpdate != null && !1 === f.shouldComponentUpdate(v, f.__s, x)) { t.__v != n.__v && (f.props = v, f.state = f.__s, f.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) { e && (e.__ = t); }), T.push.apply(f.__h, f._sb), f._sb = [], f.__h.length && o.push(f); break n; } f.componentWillUpdate != null && f.componentWillUpdate(v, f.__s, x), y && f.componentDidUpdate != null && f.__h.push(function() { f.componentDidUpdate(m, h, g); }); } if (f.context = x, f.props = v, f.__P = e, f.__e = !1, S = u.__r, C = 0, y) f.state = f.__s, f.__d = !1, S && S(t), d = f.render(f.props, f.state, f.context), T.push.apply(f.__h, f._sb), f._sb = []; else do f.__d = !1, S && S(t), d = f.render(f.props, f.state, f.context), f.state = f.__s; while (f.__d && ++C < 25); f.state = f.__s, f.getChildContext != null && (r = O(O({}, r), f.getChildContext())), y && !p && f.getSnapshotBeforeUpdate != null && (g = f.getSnapshotBeforeUpdate(m, h)), w = d != null && d.type === j && d.key == null ? ue(d.props.children) : d, s = re(e, D(w) ? w : [w], t, n, r, i, a, o, s, c, l), f.base = t.__e, t.__u &= -161, f.__h.length && o.push(f), _ && (f.__E = f.__ = null); } catch (e) { if (t.__v = null, c || a != null) if (e.then) { for (t.__u |= c ? 160 : 128; s && s.nodeType == 8 && s.nextSibling;) s = s.nextSibling; a[a.indexOf(s)] = null, t.__e = s; } else { for (E = a.length; E--;) ee(a[E]); R(t); } else t.__e = n.__e, t.__k = n.__k, e.then || R(t); u.__e(e, t, n); } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : s = t.__e = de(n.__e, t, n, r, i, a, o, c, l); return (d = u.diffed) && d(t), 128 & t.__u ? void 0 : s; } function R(e) { e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(R)); } function le(e, t, n) { for (var r = 0; r < n.length; r++) fe(n[r], n[++r], n[++r]); u.__c && u.__c(t, e), e.some(function(t) { try { e = t.__h, t.__h = [], e.some(function(e) { e.call(t); }); } catch (e) { u.__e(e, t.__v); } }); } function ue(e) { return typeof e != "object" || !e || e.__b > 0 ? e : D(e) ? e.map(ue) : O({}, e); } function de(e, t, n, r, i, a, o, s, c) { var d, f, p, m, h, g, _, v = n.props || w, y = t.props, b = t.type; if (b == "svg" ? i = "http://www.w3.org/2000/svg" : b == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", a != null) { for (d = 0; d < a.length; d++) if ((h = a[d]) && "setAttribute" in h == !!b && (b ? h.localName == b : h.nodeType == 3)) { e = h, a[d] = null; break; } } if (e == null) { if (b == null) return document.createTextNode(y); e = document.createElementNS(i, b, y.is && y), s &&= (u.__m && u.__m(t, a), !1), a = null; } if (b == null) v === y || s && e.data == y || (e.data = y); else { if (a &&= l.call(e.childNodes), !s && a != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value; for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in y || d == "value" && "defaultValue" in y || d == "checked" && "defaultChecked" in y || I(e, d, null, h, i); for (d in y) h = y[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : s && typeof h != "function" || v[d] === h || I(e, d, h, v[d], i); if (f) s || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = []; else if (p && (e.innerHTML = ""), re(t.type == "template" ? e.content : e, D(m) ? m : [m], t, n, r, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, a, o, a ? a[0] : n.__k && N(n, 0), s, c), a != null) for (d = a.length; d--;) ee(a[d]); s || (d = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || b == "progress" && !g || b == "option" && g != v[d]) && I(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && I(e, d, _, v[d], i)); } return e; } function fe(e, t, n) { try { if (typeof e == "function") { var r = typeof e.__u == "function"; r && e.__u(), r && t == null || (e.__u = e(t)); } else e.current = t; } catch (e) { u.__e(e, n); } } function pe(e, t, n) { var r, i; if (u.unmount && u.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || fe(r, null, t)), (r = e.__c) != null) { if (r.componentWillUnmount) try { r.componentWillUnmount(); } catch (e) { u.__e(e, t); } r.base = r.__P = null; } if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && pe(r[i], t, n || typeof e.type != "function"); n || ee(e.__e), e.__c = e.__ = e.__e = void 0; } function me(e, t, n) { return this.constructor(e, n); } function he(e, t, n) { var r, i, a, o; t == document && (t = document.documentElement), u.__ && u.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, a = [], o = [], L(t, e = (!r && n || t).__k = k(j, null, [e]), i || w, w, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? l.call(t.childNodes) : null, a, !r && n ? n : i ? i.__e : t.firstChild, r, o), le(a, e, o); } function ge(e) { function t(e) { var n, r; return this.getChildContext || (n = /* @__PURE__ */ new Set(), (r = {})[t.__c] = this, this.getChildContext = function() { return r; }, this.componentWillUnmount = function() { n = null; }, this.shouldComponentUpdate = function(e) { this.props.value != e.value && n.forEach(function(e) { e.__e = !0, P(e); }); }, this.sub = function(e) { n.add(e); var t = e.componentWillUnmount; e.componentWillUnmount = function() { n && n.delete(e), t && t.call(e); }; }), e.children; } return t.__c = "__cC" + C++, t.__ = e, t.Provider = t.__l = (t.Consumer = function(e, t) { return e.children(t); }).contextType = t, t; } l = T.slice, u = { __e: function(e, t, n, r) { for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try { if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i; } catch (t) { e = t; } throw e; } }, d = 0, M.prototype.setState = function(e, t) { var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = O({}, this.state); typeof e == "function" && (e = e(O({}, n), this.props)), e && O(n, e), e != null && this.__v && (t && this._sb.push(t), P(this)); }, M.prototype.forceUpdate = function(e) { this.__v && (this.__e = !0, e && this.__h.push(e), P(this)); }, M.prototype.render = j, f = [], m = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, h = function(e, t) { return e.__v.__b - t.__v.__b; }, F.__r = 0, g = Math.random().toString(8), _ = "__d" + g, v = "__a" + g, y = /(PointerCapture)$|Capture$/i, b = 0, x = ce(!1), S = ce(!0), C = 0; //#endregion //#region src/types/index.ts var z = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => { (function() { var e = {}.hasOwnProperty; function n() { for (var e = "", t = 0; t < arguments.length; t++) { var n = arguments[t]; n && (e = i(e, r(n))); } return e; } function r(t) { if (typeof t == "string" || typeof t == "number") return t; if (typeof t != "object") return ""; if (Array.isArray(t)) return n.apply(null, t); if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) return t.toString(); var r = ""; for (var a in t) e.call(t, a) && t[a] && (r = i(r, a)); return r; } function i(e, t) { return t ? e ? e + " " + t : e + t : e; } t !== void 0 && t.exports ? (n.default = n, t.exports = n) : typeof define == "function" && typeof define.amd == "object" && define.amd ? define("classnames", [], function() { return n; }) : window.classNames = n; })(); })))(), 1), B = /* @__PURE__ */ function(e) { return e.Chapter = "chapter", e.Section = "section", e.Paragraph = "paragraph", e.Text = "text", e.Weblink = "weblink", e.List = "list", e.Table = "table", e.InternalReference = "internalReference", e.Bigskip = "bigskip", e; }({}), _e = /* @__PURE__ */ function(e) { return e.Bold = "BOLD", e.Italic = "ITALIC", e; }({}), ve = Date.now(), ye = (e = "id") => (ve += 1, `${e}-${ve}`), V, H, be, xe, U = 0, Se = [], W = u, Ce = W.__b, we = W.__r, Te = W.diffed, Ee = W.__c, De = W.unmount, Oe = W.__; function G(e, t) { W.__h && W.__h(H, e, U || t), U = 0; var n = H.__H ||= { __: [], __h: [] }; return e >= n.__.length && n.__.push({}), n.__[e]; } function K(e) { return U = 1, ke(Re, e); } function ke(e, t, n) { var r = G(V++, 2); if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Re(void 0, t), function(e) { var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e); t !== n && (r.__N = [n, r.__[1]], r.__c.setState({})); }], r.__c = H, !H.__f)) { var i = function(e, t, n) { if (!r.__c.__H) return !0; var i = r.__c.__H.__.filter(function(e) { return e.__c; }); if (i.every(function(e) { return !e.__N; })) return !a || a.call(this, e, t, n); var o = r.__c.props !== e; return i.some(function(e) { if (e.__N) { var t = e.__[0]; e.__ = e.__N, e.__N = void 0, t !== e.__[0] && (o = !0); } }), a && a.call(this, e, t, n) || o; }; H.__f = !0; var a = H.shouldComponentUpdate, o = H.componentWillUpdate; H.componentWillUpdate = function(e, t, n) { if (this.__e) { var r = a; a = void 0, i(e, t, n), a = r; } o && o.call(this, e, t, n); }, H.shouldComponentUpdate = i; } return r.__N || r.__; } function q(e, t) { var n = G(V++, 3); !W.__s && Le(n.__H, t) && (n.__ = e, n.u = t, H.__H.__h.push(n)); } function Ae(e) { return U = 5, je(function() { return { current: e }; }, []); } function je(e, t) { var n = G(V++, 7); return Le(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__; } function Me(e) { var t = H.context[e.__c], n = G(V++, 9); return n.c = e, t ? (n.__ ?? (n.__ = !0, t.sub(H)), t.props.value) : e.__; } function Ne() { for (var e; e = Se.shift();) { var t = e.__H; if (e.__P && t) try { t.__h.some(J), t.__h.some(Ie), t.__h = []; } catch (n) { t.__h = [], W.__e(n, e.__v); } } } W.__b = function(e) { H = null, Ce && Ce(e); }, W.__ = function(e, t) { e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Oe && Oe(e, t); }, W.__r = function(e) { we && we(e), V = 0; var t = (H = e.__c).__H; t && (be === H ? (t.__h = [], H.__h = [], t.__.some(function(e) { e.__N && (e.__ = e.__N), e.u = e.__N = void 0; })) : (t.__h.some(J), t.__h.some(Ie), t.__h = [], V = 0)), be = H; }, W.diffed = function(e) { Te && Te(e); var t = e.__c; t && t.__H && (t.__H.__h.length && (Se.push(t) !== 1 && xe === W.requestAnimationFrame || ((xe = W.requestAnimationFrame) || Fe)(Ne)), t.__H.__.some(function(e) { e.u && (e.__H = e.u), e.u = void 0; })), be = H = null; }, W.__c = function(e, t) { t.some(function(e) { try { e.__h.some(J), e.__h = e.__h.filter(function(e) { return !e.__ || Ie(e); }); } catch (n) { t.some(function(e) { e.__h &&= []; }), t = [], W.__e(n, e.__v); } }), Ee && Ee(e, t); }, W.unmount = function(e) { De && De(e); var t, n = e.__c; n && n.__H && (n.__H.__.some(function(e) { try { J(e); } catch (e) { t = e; } }), n.__H = void 0, t && W.__e(t, n.__v)); }; var Pe = typeof requestAnimationFrame == "function"; function Fe(e) { var t, n = function() { clearTimeout(r), Pe && cancelAnimationFrame(t), setTimeout(e); }, r = setTimeout(n, 35); Pe && (t = requestAnimationFrame(n)); } function J(e) { var t = H, n = e.__c; typeof n == "function" && (e.__c = void 0, n()), H = t; } function Ie(e) { var t = H; e.__c = e.__(), H = t; } function Le(e, t) { return !e || e.length !== t.length || t.some(function(t, n) { return t !== e[n]; }); } function Re(e, t) { return typeof t == "function" ? t(e) : t; } //#endregion //#region src/components/Accordion/AccordionContext.ts var ze = ge(null), Be = 0; Array.isArray; function Y(e, t, n, r, i, a) { t ||= {}; var o, s, c = t; if ("ref" in c) for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s]; var l = { type: e, props: c, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Be, __i: -1, __u: 0, __source: i, __self: a }; if (typeof e == "function" && (o = e.defaultProps)) for (s in o) c[s] === void 0 && (c[s] = o[s]); return u.vnode && u.vnode(l), l; } //#endregion //#region src/components/Accordion/Accordion.tsx function Ve({ children: e, className: t, expand: n = !1, type: r, onExpandSection: i }) { let [a, o] = K([]), s = (0, z.default)("adv-accordion", t, { "adv-accordion--container": r === "container" }); return /* @__PURE__ */ Y(ze.Provider, { value: { expand: n, items: a, setItems: o, onExpandSection: i }, children: /* @__PURE__ */ Y("div", { className: s, children: e }) }); } //#endregion //#region src/components/Bigskip/Bigskip.tsx function He() { return /* @__PURE__ */ Y("div", { className: "adv-bigskip" }); } //#endregion //#region src/components/Heading/Heading.tsx var Ue = { 1: "h1", 2: "h2" }; function We({ className: e, level: t, children: n }) { return k(Ue[t] || Ue[1], { className: (0, z.default)("adv-heading", `adv-heading--${t}`, e) }, n); } //#endregion //#region src/components/Text/Text.tsx function X({ content: e, styles: t }) { return /* @__PURE__ */ Y("span", { className: (0, z.default)({ "adv-u-font-weight-semi-bold": t?.includes(_e.Bold), "adv-u-font-italic": t?.includes(_e.Italic) }), children: e }); } //#endregion //#region src/components/Chapter/Chapter.tsx function Ge({ title: e, contentElements: t }) { return /* @__PURE__ */ Y("section", { className: "adv-u-margin-bottom-48", children: [/* @__PURE__ */ Y(We, { level: 2, className: "adv-u-margin-top-24 adv-u-margin-bottom-16", children: /* @__PURE__ */ Y(X, { content: e.content, styles: e.styles }) }), /* @__PURE__ */ Y(Q, { contentElements: t, isTopLevel: !0 })] }); } //#endregion //#region src/ReferenceContext/ReferenceContext.tsx var Ke = ge({ references: {}, addReference: () => {} }); //#endregion //#region src/ReferenceContext/useReferenceContext.ts function qe() { let e = Me(Ke); if (e === void 0) throw Error("useReferenceContext must be used within a ReferenceProvider"); return e; } //#endregion //#region src/utils/delay.ts var Je = (e) => new Promise((t) => { setTimeout(t, e); }), Z = (e) => { if (e) return `adyen-document-viewer-${e.replace(/[^\w-]/g, "").slice(0, 32)}`; }, Ye = (e) => { if (!e) return null; let t = e instanceof HTMLElement, n = t && window.getComputedStyle(e).overflowY; return t && n !== "visible" && n !== "hidden" ? e : Ye(e.parentNode) ?? document.body; }, Xe = ({ onClick: e, label: t }) => /* @__PURE__ */ Y("button", { className: "adv-link", type: "button", onClick: e, title: t, children: t }); //#endregion //#region src/components/InternalReference/InternalReference.tsx function Ze({ referencedLabel: e, displayText: t }) { let n = t ? t.content : e, r = Z(e) ?? "", { references: i } = qe(); return /* @__PURE__ */ Y(Xe, { onClick: async () => { i && r && i[r] && (i[r].openSection(), await Je(150)), (Ye(document.getElementById(r))?.querySelector(`#${r}`))?.scrollIntoView({ behavior: "smooth" }); }, label: n }); } //#endregion //#region src/components/List/List.tsx function Qe({ className: e, nested: t, ordered: n, noMarkers: r, children: i }) { return /* @__PURE__ */ Y("ul", { className: (0, z.default)([ "adv-list", t && "adv-list--nested", n && "adv-list--ordered", r && "adv-list--no-markers", e ]), children: i }); } //#endregion //#region src/components/List/ListItem.tsx function $e({ className: e, children: t, noMarkers: n }) { return /* @__PURE__ */ Y("li", { className: (0, z.default)([ "adv-list__item", n && "adv-list__item--no-markers", e ]), children: t }); } //#endregion //#region src/components/ListElemennt/List.tsx function et({ items: e, style: t }) { return /* @__PURE__ */ Y(Qe, { ordered: t.ordered, children: e.map((e, t) => /* @__PURE__ */ Y($e, { children: [/* @__PURE__ */ Y(Q, { contentElements: e.content }), e.subList && /* @__PURE__ */ Y(et, { style: e.subList.style, items: e.subList.items })] }, t)) }); } //#endregion //#region src/components/Paragraph/Paragraph.tsx function tt({ isTopLevel: e, contentElements: t }) { return /* @__PURE__ */ Y("p", { className: (0, z.default)("adv-paragraph", { "adv-u-margin-bottom-16": e }), children: /* @__PURE__ */ Y(Q, { contentElements: t }) }); } //#endregion //#region src/components/CollapsibleContainer/CollapsibleContainer.tsx function nt({ children: e, collapsed: t = !1 }) { let n = Ae(null), [r, i] = K(t ? 0 : void 0); return q(() => { i(t ? 0 : n.current?.scrollHeight); }, [t]), /* @__PURE__ */ Y("div", { className: "adv-collapsible-container", "aria-hidden": t, ref: n, style: { height: r }, children: e }); } //#endregion //#region src/components/Icon/Icon.tsx var rt = ({ className: e = "", name: t }) => { let n = { "chevron-up": /* @__PURE__ */ Y("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 15 15", width: "15", height: "15", children: /* @__PURE__ */ Y("path", { fillRule: "evenodd", d: "M13 10a1 1 0 0 1-1.743.669L7.5 6.495 3.743 10.67a1 1 0 0 1-1.486-1.338l4.5-5a1 1 0 0 1 1.486 0l4.5 5a.998.998 0 0 1 .257.67z" }) }), "chevron-down": /* @__PURE__ */ Y("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 15 15", width: "15", height: "15", children: /* @__PURE__ */ Y("path", { fillRule: "evenodd", d: "M2 5a1 1 0 0 1 1.743-.669L7.5 8.505l3.757-4.174a1 1 0 0 1 1.486 1.338l-4.5 5a1 1 0 0 1-1.486 0l-4.5-5A.998.998 0 0 1 2 4.999z" }) }) }; return /* @__PURE__ */ Y("i", { className: (0, z.default)("adv-icon", e), role: "img", "aria-hidden": !0, children: n[t] }); }; //#endregion //#region src/components/AccordionItem/useAccordionContext.ts function it() { return Me(ze); } //#endregion //#region src/components/AccordionItem/AccordionItem.tsx function at({ children: e, open: t = !1, title: n = "", onOpen: r = () => {}, onClose: i = () => {} }) { let { expand: a, items: o, setItems: s, onExpandSection: c } = it(), [l, u] = K(t), [d] = K(ye); return q(() => { s((e) => [...e, { id: d, isOpen: l }]); }, []), q(() => { u(t); }, [t]), q(() => { u(o.find((e) => e.id === d)?.isOpen ?? !1); }, [o]), q(() => { l ? (c?.(n), r()) : i(); }, [l]), /* @__PURE__ */ Y("div", { className: "adv-accordion__item", children: [/* @__PURE__ */ Y("div", { role: "button", className: "adv-accordion__header", tabIndex: 0, onClick: () => { let e = !l, t = [...o]; a ? (t.find((e) => e.id === d).isOpen = e, s(t)) : s(t.map((t) => ({ ...t, isOpen: t.id === d ? e : !1 }))); }, children: [/* @__PURE__ */ Y(rt, { name: l ? "chevron-up" : "chevron-down", className: "adv-accordion__toggle" }), /* @__PURE__ */ Y("div", { className: "adv-accordion__title-wrapper", children: /* @__PURE__ */ Y("div", { className: "adv-accordion__title", children: n }) })] }), /* @__PURE__ */ Y(nt, { collapsed: !l, children: /* @__PURE__ */ Y("div", { className: "adv-accordion__content", children: e }) })] }); } //#endregion //#region src/components/Section/Section.tsx var ot = (e) => { if (typeof e != "object" || !e) return []; let t = []; "label" in e && typeof e.label == "string" && e.label !== "" && t.push(e.label); for (let n in e) { let r = e[n]; (Array.isArray(r) || typeof r == "object" && r) && t.push(...ot(r)); } return t; }; function st({ title: e, label: t, isTopLevel: n, contentElements: r }) { let [i, a] = K(!1), { addReference: o } = qe(), s = Z(t); return q(() => { if (n) { let e = ot(r).map(Z); s && e.push(s), e.length && e.forEach((e) => { o({ [e]: { openSection: () => a(!0) } }); }); } }, []), n ? /* @__PURE__ */ Y(at, { title: e.content, open: i, onOpen: () => { a(!0); }, onClose: () => { a(!1); }, children: /* @__PURE__ */ Y("section", { className: "adv-section-box", id: s, children: /* @__PURE__ */ Y(Q, { contentElements: r }) }) }) : /* @__PURE__ */ Y("section", { id: s, children: [/* @__PURE__ */ Y(We, { level: 2, className: "adv-u-margin-top-24 adv-u-margin-bottom-16", children: /* @__PURE__ */ Y(X, { content: e.content, styles: e.styles }) }), /* @__PURE__ */ Y(Q, { contentElements: r })] }); } //#endregion //#region src/components/Table/Table.tsx function ct({ rows: e, label: t, captions: n, titlePrefix: r, title: i }) { return /* @__PURE__ */ Y("div", { id: Z(t), children: [/* @__PURE__ */ Y("div", { className: "adv-u-margin-y-8 adv-u-text-align-center", children: [ r && /* @__PURE__ */ Y(X, { ...r }), r && i && " ", i && /* @__PURE__ */ Y(X, { ...i }) ] }), /* @__PURE__ */ Y("table", { className: "adv-table adv-table--condensed", children: [n && /* @__PURE__ */ Y("caption", { children: /* @__PURE__ */ Y(Q, { contentElements: n }) }), /* @__PURE__ */ Y("tbody", { className: "adv-table__body", children: e.map((e, t) => /* @__PURE__ */ Y("tr", { className: "adv-table__row", children: e.map((e, t) => /* @__PURE__ */ Y("td", { className: "adv-table__cell", children: /* @__PURE__ */ Y(Q, { contentElements: e.elements }) }, t)) }, t)) })] })] }); } //#endregion //#region src/components/Link/Link.tsx var lt = ({ className: e, children: t, href: n, underline: r, inheritStyles: i, onClick: a }) => /* @__PURE__ */ Y("a", { href: n, className: (0, z.default)("adv-link", e, { "adv-link--underline": r, "adv-link--inherit": i }), target: "_blank", rel: "noopener noreferrer", onClick: a, children: /* @__PURE__ */ Y("span", { className: "adv-link__text", children: t }) }), ut = { chapter: Ge, section: st, paragraph: tt, text: X, weblink: ({ url: e, displayText: t }) => /* @__PURE__ */ Y(lt, { href: e, children: t ? /* @__PURE__ */ Y(X, { ...t }) : e }), list: et, table: ct, internalReference: Ze, breakline: "br", bigskip: He }, dt = (e) => `key-${e}-${ye()}`, ft = (e, t) => { if (!("type" in e)) return null; switch (e.type) { case B.Chapter: return { title: e.title, contentElements: e.contentElements }; case B.Section: return { isTopLevel: t, title: e.title, label: e.label, contentElements: e.contentElements }; case B.Paragraph: return { isTopLevel: t, contentElements: e.contentElements }; case B.Text: return { content: e.content, styles: e.styles }; case B.Weblink: return { url: e.url, displayText: e.displayText }; case B.List: return { items: e.items, style: e.style }; case B.Table: return { rows: e.rows, label: e.label, captions: e.captions, titlePrefix: e.titlePrefix, title: e.title }; case B.InternalReference: return { referencedLabel: e.referencedLabel, displayText: e.displayText }; case B.Bigskip: return {}; default: return null; } }; function Q({ contentElements: e, isTopLevel: t = !1, onExpandSection: n, multiple: r }) { let i = e.map((e) => { if (!("type" in e)) return null; let n = ut[e.type]; return /* @__PURE__ */ Y(n, { ...ft(e, t) }, dt(e.type)); }); return t ? /* @__PURE__ */ Y(Ve, { onExpandSection: n, expand: r, children: i }) : /* @__PURE__ */ Y("span", { children: i }); } //#endregion //#region src/ReferenceContext/ReferenceContextProvider.tsx function pt({ children: e }) { let [t, n] = K({}), r = je(() => ({ addReference: (e) => { n((t) => ({ ...t, ...e })); }, references: t }), [t, n]); return /* @__PURE__ */ Y(Ke.Provider, { value: r, children: e }); } //#endregion //#region src/DocumentViewer.tsx function mt({ document: e, className: t, onExpandSection: n, multiple: r }) { return /* @__PURE__ */ Y(pt, { children: /* @__PURE__ */ Y("div", { className: (0, z.default)("adyen-document-viewer", t), children: [/* @__PURE__ */ Y(We, { level: 1, className: "adv-u-margin-top-24 adv-u-margin-bottom-16", children: /* @__PURE__ */ Y(X, { content: e.title.content, styles: e.title.styles }) }), /* @__PURE__ */ Y(Q, { contentElements: e.contentElements, onExpandSection: n, multiple: r, isTopLevel: !0 })] }) }); } //#endregion //#region src/utils/preprocessDocument.ts function ht(e) { return "type" in e && e.type === B.Chapter; } function gt(e) { return "type" in e && e.type === B.Section; } function _t(e) { return "contentElements" in e && Array.isArray(e.contentElements); } function vt(e) { return e.isTopLevel ? `${e.counter}` : `${e.prefix}${e.counter}`; } function yt(e, t) { return `${e} ${t}`; } function $(e, t) { if (ht(e)) { let t = { prefix: "", counter: 1, isTopLevel: !0 }; return { ...e, contentElements: e.contentElements.map((e) => $(e, t)) }; } else if (gt(e)) { let n = vt(t), r = { ...e, title: { ...e.title, content: yt(n, e.title.content) } }; t.counter += 1; let i = { prefix: `${n}.`, counter: 1, isTopLevel: !1 }; return r.contentElements = e.contentElements.map((e) => $(e, i)), r; } else if (_t(e)) return { ...e, contentElements: e.contentElements.map((e) => $(e, t)) }; return e; } function bt(e) { let t = { prefix: "", counter: 1, isTopLevel: !0 }; return { ...e, contentElements: e.contentElements.map((e) => $(e, t)) }; } //#endregion //#region src/index.tsx var xt = class { constructor(e, t = {}) { if (typeof e == "object" && "nodeType" in e) this.target = e; else { let t = window.document.querySelector(e); if (t instanceof HTMLElement) this.target = t; else throw Error("Target element was not found"); } this.options = { onExpandSection: t.onExpandSection ?? void 0, multiple: t.multiple ?? !1, showSectionNumbering: t.showSectionNumbering ?? !1 }; } render(e) { he(/* @__PURE__ */ Y(mt, { document: this.options.showSectionNumbering ? bt(e) : e, onExpandSection: this.options.onExpandSection, multiple: this.options.multiple }), this.target); } }; //#endregion export { xt as default };