var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
import { r as registerInstance, h } from './index-dd1fc9a4.js';
import { c as createCommonjsModule, a as commonjsGlobal, u as unwrapExports } from './_commonjsHelpers-1d681858.js';
import { P as Prismic } from './prismic-javascript.min-ccec9a89.js';
var prismicDom_min = createCommonjsModule(function (module, exports) {
    !function (e, t) { module.exports = t(); }("undefined" != typeof self ? self : commonjsGlobal, (function () {
        return function (e) { var t = {}; function n(r) { if (t[r])
            return t[r].exports; var o = t[r] = { i: r, l: !1, exports: {} }; return e[r].call(o.exports, o, o.exports, n), o.l = !0, o.exports; } return n.m = e, n.c = t, n.d = function (e, t, r) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }); }, n.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }); }, n.t = function (e, t) { if (1 & t && (e = n(e)), 8 & t)
            return e; if (4 & t && "object" == typeof e && e && e.__esModule)
            return e; var r = Object.create(null); if (n.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e)
            for (var o in e)
                n.d(r, o, function (t) { return e[t]; }.bind(null, o)); return r; }, n.n = function (e) { var t = e && e.__esModule ? function () { return e.default; } : function () { return e; }; return n.d(t, "a", t), t; }, n.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t); }, n.p = "", n(n.s = 1); }([function (e, t, n) { e.exports = function (e) { var t = {}; function n(r) { if (t[r])
                return t[r].exports; var o = t[r] = { i: r, l: !1, exports: {} }; return e[r].call(o.exports, o, o.exports, n), o.l = !0, o.exports; } return n.m = e, n.c = t, n.d = function (e, t, r) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }); }, n.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }); }, n.t = function (e, t) { if (1 & t && (e = n(e)), 8 & t)
                return e; if (4 & t && "object" == typeof e && e && e.__esModule)
                return e; var r = Object.create(null); if (n.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e)
                for (var o in e)
                    n.d(r, o, function (t) { return e[t]; }.bind(null, o)); return r; }, n.n = function (e) { var t = e && e.__esModule ? function () { return e.default; } : function () { return e; }; return n.d(t, "a", t), t; }, n.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t); }, n.p = "", n(n.s = 0); }([function (e, t, n) { e.exports = n(1); }, function (e, t, n) { var r = n(2), o = n(3); e.exports = { Link: r, Date: o }; }, function (e, t, n) { e.exports = { url: function (e, t) { if (e && [e.link_type, e._linkType, e.linkType].some((function (e) { return e && ["Document", "Link.Document", "Link.document"].includes(e); })) && t && "function" == typeof t) {
                        var n = t(e);
                        if (n)
                            return n;
                    } return e && e.url ? e.url : ""; } }; }, function (e, t) { e.exports = function (e) { if (!e)
                    return null; var t = 24 == e.length ? "".concat(e.substring(0, 22), ":").concat(e.substring(22, 24)) : e; return new Date(t); }; }]); }, function (e, t, n) { e.exports = n(2); }, function (e, t, n) { var r = n(0), o = n(3), i = r.Date, u = r.Link; e.exports = { Date: i, Link: u, RichText: o }; }, function (e, t, n) { var r = n(4), o = n(0).Link, i = n(5), u = r.Elements; function c(e, t, n, r, c) { switch (t) {
                case u.heading1: return l("h1", n, c);
                case u.heading2: return l("h2", n, c);
                case u.heading3: return l("h3", n, c);
                case u.heading4: return l("h4", n, c);
                case u.heading5: return l("h5", n, c);
                case u.heading6: return l("h6", n, c);
                case u.paragraph: return l("p", n, c);
                case u.preformatted: return function (e) { return "<pre".concat(a(e), ">").concat(i(e.text), "</pre>"); }(n);
                case u.strong: return l("strong", n, c);
                case u.em: return l("em", n, c);
                case u.listItem:
                case u.oListItem: return l("li", n, c);
                case u.list: return l("ul", n, c);
                case u.oList: return l("ol", n, c);
                case u.image: return function (e, t) { var n = t.linkTo ? o.url(t.linkTo, e) : null, r = t.linkTo && t.linkTo.target ? 'target="'.concat(t.linkTo.target, '" rel="noopener"') : "", i = [t.label || "", "block-img"], u = '<img src="'.concat(t.url, '" alt="').concat(t.alt || "", '" copyright="').concat(t.copyright || "", '">'); return '\n    <p class="'.concat(i.join(" "), '">\n      ').concat(n ? "<a ".concat(r, ' href="').concat(n, '">').concat(u, "</a>") : u, "\n    </p>\n  "); }(e, n);
                case u.embed: return function (e) { return '\n    <div data-oembed="'.concat(e.oembed.embed_url, '"\n      data-oembed-type="').concat(e.oembed.type, '"\n      data-oembed-provider="').concat(e.oembed.provider_name, '"\n      ').concat(a(e), ">\n          \n      ").concat(e.oembed.html, "\n    </div>\n  "); }(n);
                case u.hyperlink: return function (e, t, n) { var r = t.data.target ? 'target="'.concat(t.data.target, '" rel="noopener"') : ""; return "<a ".concat(r, ' href="').concat(o.url(t.data, e), '">').concat(n.join(""), "</a>"); }(e, n, c);
                case u.label: return function (e, t) { return "<span ".concat(a(e.data), ">").concat(t.join(""), "</span>"); }(n, c);
                case u.span: return function (e) { return e ? i(e).replace(/\n/g, "<br />") : ""; }(r);
                default: return "";
            } } function a(e) { return e.label ? ' class="'.concat(e.label, '"') : ""; } function l(e, t, n) { return "<".concat(e).concat(a(t), ">").concat(n.join(""), "</").concat(e, ">"); } e.exports = { asText: function (e, t) { return r.asText(e, t); }, asHtml: function (e, t, n) { return r.serialize(e, c.bind(null, t), n).join(""); }, Elements: u }; }, function (e, t, n) { e.exports = function (e) { var t = {}; function n(r) { if (t[r])
                return t[r].exports; var o = t[r] = { i: r, l: !1, exports: {} }; return e[r].call(o.exports, o, o.exports, n), o.l = !0, o.exports; } return n.m = e, n.c = t, n.d = function (e, t, r) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }); }, n.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }); }, n.t = function (e, t) { if (1 & t && (e = n(e)), 8 & t)
                return e; if (4 & t && "object" == typeof e && e && e.__esModule)
                return e; var r = Object.create(null); if (n.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e)
                for (var o in e)
                    n.d(r, o, function (t) { return e[t]; }.bind(null, o)); return r; }, n.n = function (e) { var t = e && e.__esModule ? function () { return e.default; } : function () { return e; }; return n.d(t, "a", t), t; }, n.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t); }, n.p = "", n(n.s = 9); }([function (e, t, n) { var r = n(3); e.exports = function (e) { return function t(n) { return 0 === arguments.length || r(n) ? t : e.apply(this, arguments); }; }; }, function (e, t, n) { var r = n(0), o = n(3); e.exports = function (e) { return function t(n, i) { switch (arguments.length) {
                    case 0: return t;
                    case 1: return o(n) ? t : r((function (t) { return e(n, t); }));
                    default: return o(n) && o(i) ? t : o(n) ? r((function (t) { return e(t, i); })) : o(i) ? r((function (t) { return e(n, t); })) : e(n, i);
                } }; }; }, function (e, t, n) { var r; function o(e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e; } Object.defineProperty(t, "__esModule", { value: !0 }), t.PRIORITIES = t.NODE_TYPES = void 0; var i = { heading1: "heading1", heading2: "heading2", heading3: "heading3", heading4: "heading4", heading5: "heading5", heading6: "heading6", paragraph: "paragraph", preformatted: "preformatted", strong: "strong", em: "em", listItem: "list-item", oListItem: "o-list-item", list: "group-list-item", oList: "group-o-list-item", image: "image", embed: "embed", hyperlink: "hyperlink", label: "label", span: "span" }; t.NODE_TYPES = i; var u = (o(r = {}, i.heading1, 4), o(r, i.heading2, 4), o(r, i.heading3, 4), o(r, i.heading4, 4), o(r, i.heading5, 4), o(r, i.heading6, 4), o(r, i.paragraph, 3), o(r, i.preformatted, 5), o(r, i.strong, 6), o(r, i.em, 6), o(r, i.oList, 1), o(r, i.list, 1), o(r, i.listItem, 1), o(r, i.oListItem, 1), o(r, i.image, 1), o(r, i.embed, 1), o(r, i.hyperlink, 3), o(r, i.label, 4), o(r, i.span, 7), r); t.PRIORITIES = u; }, function (e, t) { e.exports = function (e) { return null != e && "object" == typeof e && !0 === e["@@functional/placeholder"]; }; }, function (e, t, n) { Object.defineProperty(t, "__esModule", { value: !0 }), t.default = void 0; var r = d(n(12)), o = d(n(15)), i = d(n(16)), u = d(n(17)), c = d(n(21)), a = d(n(7)), l = n(23), f = n(2), s = n(8); function d(e) { return e && e.__esModule ? e : { default: e }; } function p(e, t) { for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
                } } function h(e) { return function (e, t) { return t.reduce((function (e, t) { var n = (0, c.default)(e); if (n) {
                    if (n.some((function (e) { return e.isParentOf(t); })))
                        return (0, u.default)(e).concat([n.concat(t)]);
                    var r = (0, c.default)(n);
                    return r && function (e, t) { return e.end >= t.start; }(r, t) ? (0, u.default)(e).concat([n.concat(t)]) : e.concat([[t]]);
                } return [[t]]; }), []); }(0, (0, i.default)([function (e, t) { return e.start - t.start; }, function (e, t) { return e.end - t.end; }], e)); } function y(e) { if (0 === e.length)
                    throw new Error("Unable to elect node on empty list"); var t = function (e) { return function (e) { if (Array.isArray(e))
                    return e; }(e) || function (e) { if (Symbol.iterator in Object(e) || "[object Arguments]" === Object.prototype.toString.call(e))
                    return Array.from(e); }(e) || function () { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }(); }(e.sort((function (e, t) { if (e.isParentOf(t))
                    return -1; if (t.isParentOf(e))
                    return 1; var n = f.PRIORITIES[e.type] - f.PRIORITIES[t.type]; return 0 === n ? e.text.length - t.text.length : n; }))); return { elected: t[0], others: t.slice(1) }; } function v(e, t, n) { if (t.length > 0)
                    return function (e, t, n) { return t.reduce((function (r, o, i) { var u = [], c = 0 === i && o.start > n.lower, a = i === t.length - 1 && n.upper > o.end; if (c) {
                        var l = new s.TextNode(n.lower, o.start, e.slice(n.lower, o.start));
                        u = u.concat(l);
                    }
                    else {
                        var f = t[i - 1];
                        if (f && o.start > f.end) {
                            var d = e.slice(f.end, o.start), p = new s.TextNode(f.end, o.start, d);
                            u = u.concat(p);
                        }
                    } if (u = u.concat(o), a) {
                        var h = new s.TextNode(o.end, n.upper, e.slice(o.end, n.upper));
                        u = u.concat(h);
                    } return r.concat(u); }), []); }(e, m(e, t), n); var r = e.slice(n.lower, n.upper); return [new s.TextNode(n.lower, n.upper, r)]; } function m(e, t) { var n = h((0, o.default)((function (e) { return e.start; }), t)).map(y), i = (0, r.default)(n.map((function (t) { return function (e, t) { var n = t.others.reduce((function (n, r) { var o = n.inner, i = n.outer, u = function (e, t, n) { return n.start < t.start ? { inner: s.SpanNode.slice(n, t.start, n.end, e), outer: s.SpanNode.slice(n, n.start, t.start, e) } : n.end > t.end ? { inner: s.SpanNode.slice(n, n.start, t.end, e), outer: s.SpanNode.slice(n, t.end, n.end, e) } : { inner: n }; }(e, t.elected, r); return { inner: o.concat(u.inner), outer: u.outer ? i.concat(u.outer) : i }; }), { inner: [], outer: [] }), r = n.inner, o = n.outer; return [t.elected.setChildren(v(e, r, t.elected.boundaries()))].concat(m(e, o)); }(e, t); }))); return (0, o.default)((function (e) { return e.start; }), i); } var b = function () { function e() { !function (e, t) { if (!(e instanceof t))
                    throw new TypeError("Cannot call a class as a function"); }(this, e); } var t, n; return t = e, (n = [{ key: "fromRichText", value: function (e) { return { key: (0, a.default)(), children: e.reduce((function (e, t, n) { if (l.RichTextBlock.isEmbedBlock(t.type) || l.RichTextBlock.isImageBlock(t.type))
                                return e.concat(new s.BlockNode(t.type, t)); var r = function (e) { var t = e.spans.map((function (t) { var n = e.text.slice(t.start, t.end); return new s.SpanNode(t.start, t.end, t.type, n, [], t); })), n = { lower: 0, upper: e.text.length }; return v(e.text, t, n); }(t), o = e[e.length - 1]; if (l.RichTextBlock.isListItem(t.type) && o && o instanceof s.ListBlockNode) {
                                var i = new s.ListItemBlockNode(t, r), c = o.addChild(i);
                                return (0, u.default)(e).concat(c);
                            } if (l.RichTextBlock.isOrderedListItem(t.type) && o && o instanceof s.OrderedListBlockNode) {
                                var a = new s.OrderedListItemBlockNode(t, r), f = o.addChild(a);
                                return (0, u.default)(e).concat(f);
                            } if (l.RichTextBlock.isListItem(t.type)) {
                                var d = new s.ListItemBlockNode(t, r), p = new s.ListBlockNode(l.RichTextBlock.emptyList(), [d]);
                                return e.concat(p);
                            } if (l.RichTextBlock.isOrderedListItem(t.type)) {
                                var h = new s.OrderedListItemBlockNode(t, r), y = new s.OrderedListBlockNode(l.RichTextBlock.emptyOrderedList(), [h]);
                                return e.concat(y);
                            } return e.concat(new s.BlockNode(t.type, t, r)); }), []) }; } }]) && p(t, n), e; }(); t.default = b; }, function (e, t) { e.exports = Array.isArray || function (e) { return null != e && e.length >= 0 && "[object Array]" === Object.prototype.toString.call(e); }; }, function (e, t) { e.exports = function (e) { return "[object String]" === Object.prototype.toString.call(e); }; }, function (e, t, n) { Object.defineProperty(t, "__esModule", { value: !0 }), t.default = function () { var e = (new Date).getTime(); return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (function (t) { var n = (e + 16 * Math.random()) % 16 | 0; return e = Math.floor(e / 16), ("x" == t ? n : 3 & n | 8).toString(16); })); }; }, function (e, t, n) { Object.defineProperty(t, "__esModule", { value: !0 }), t.ListBlockNode = t.OrderedListBlockNode = t.OrderedListItemBlockNode = t.ListItemBlockNode = t.BlockNode = t.TextNode = t.SpanNode = t.Node = void 0; var r, o = (r = n(7)) && r.__esModule ? r : { default: r }, i = n(2); function u(e) { return (u = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) { return typeof e; } : function (e) { return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; })(e); } function c(e, t) { for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
                } } function a(e, t, n) { return t && c(e.prototype, t), n && c(e, n), e; } function l(e, t) { return !t || "object" !== u(t) && "function" != typeof t ? function (e) { if (void 0 === e)
                    throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }(e) : t; } function f(e) { return (f = Object.setPrototypeOf ? Object.getPrototypeOf : function (e) { return e.__proto__ || Object.getPrototypeOf(e); })(e); } function s(e, t) { if ("function" != typeof t && null !== t)
                    throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && function (e, t) { (Object.setPrototypeOf || function (e, t) { return e.__proto__ = t, e; })(e, t); }(e, t); } function d(e, t) { if (!(e instanceof t))
                    throw new TypeError("Cannot call a class as a function"); } var p = function e(t, n, r) { d(this, e), this.key = (0, o.default)(), this.type = t, this.element = n, this.children = r; }; t.Node = p; var h = function (e) { function t(e, n, r, o, i, u) { var c; return d(this, t), (c = l(this, f(t).call(this, r, u, i))).start = e, c.end = n, c.text = o, c.children = i, c; } return s(t, p), a(t, [{ key: "boundaries", value: function () { return { lower: this.start, upper: this.end }; } }, { key: "isParentOf", value: function (e) { return this.start <= e.start && this.end >= e.end; } }, { key: "setChildren", value: function (e) { return new t(this.start, this.end, this.type, this.text, e, this.element); } }], [{ key: "slice", value: function (e, n, r, o) { return new t(n, r, e.type, o.slice(n, r), e.children, e.element); } }]), t; }(); t.SpanNode = h; var y = function (e) { function t(e, n, r) { d(this, t); var o = { type: i.NODE_TYPES.span, start: e, end: n, text: r }; return l(this, f(t).call(this, e, n, i.NODE_TYPES.span, r, [], o)); } return s(t, h), t; }(); t.TextNode = y; var v = function (e) { function t(e, n) { var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : []; return d(this, t), l(this, f(t).call(this, e, n, r)); } return s(t, p), t; }(); t.BlockNode = v; var m = function (e) { function t(e, n) { return d(this, t), l(this, f(t).call(this, i.NODE_TYPES.listItem, e, n)); } return s(t, v), t; }(); t.ListItemBlockNode = m; var b = function (e) { function t(e, n) { return d(this, t), l(this, f(t).call(this, i.NODE_TYPES.oListItem, e, n)); } return s(t, v), t; }(); t.OrderedListItemBlockNode = b; var g = function (e) { function t(e, n) { return d(this, t), l(this, f(t).call(this, i.NODE_TYPES.oList, e, n)); } return s(t, v), a(t, [{ key: "addChild", value: function (e) { var n = this.children.concat(e); return new t(this.element, n); } }]), t; }(); t.OrderedListBlockNode = g; var x = function (e) { function t(e, n) { return d(this, t), l(this, f(t).call(this, i.NODE_TYPES.list, e, n)); } return s(t, v), a(t, [{ key: "addChild", value: function (e) { var n = this.children.concat(e); return new t(this.element, n); } }]), t; }(); t.ListBlockNode = x; }, function (e, t, n) { e.exports = n(10); }, function (e, t, n) { var r = c(n(11)), o = c(n(4)), i = c(n(24)), u = n(2); function c(e) { return e && e.__esModule ? e : { default: e }; } e.exports = { asText: r.default, asTree: o.default.fromRichText, serialize: i.default, Elements: u.NODE_TYPES }; }, function (e, t, n) { Object.defineProperty(t, "__esModule", { value: !0 }), t.default = void 0, t.default = function (e, t) { var n = "string" == typeof t ? t : " "; return e.map((function (e) { return e.text; })).join(n); }; }, function (e, t, n) { var r = n(0)(n(13)(!0)); e.exports = r; }, function (e, t, n) { var r = n(14); e.exports = function (e) { return function t(n) { for (var o, i, u, c = [], a = 0, l = n.length; a < l;) {
                    if (r(n[a]))
                        for (u = 0, i = (o = e ? t(n[a]) : n[a]).length; u < i;)
                            c[c.length] = o[u], u += 1;
                    else
                        c[c.length] = n[a];
                    a += 1;
                } return c; }; }; }, function (e, t, n) { var r = n(0), o = n(5), i = n(6), u = r((function (e) { return !!o(e) || !!e && "object" == typeof e && !i(e) && (1 === e.nodeType ? !!e.length : 0 === e.length || e.length > 0 && e.hasOwnProperty(0) && e.hasOwnProperty(e.length - 1)); })); e.exports = u; }, function (e, t, n) { var r = n(1)((function (e, t) { return Array.prototype.slice.call(t, 0).sort((function (t, n) { var r = e(t), o = e(n); return r < o ? -1 : r > o ? 1 : 0; })); })); e.exports = r; }, function (e, t, n) { var r = n(1)((function (e, t) { return Array.prototype.slice.call(t, 0).sort((function (t, n) { for (var r = 0, o = 0; 0 === r && o < e.length;)
                    r = e[o](t, n), o += 1; return r; })); })); e.exports = r; }, function (e, t, n) { var r = n(18)(0, -1); e.exports = r; }, function (e, t, n) { var r = n(19), o = n(20)(r("slice", (function (e, t, n) { return Array.prototype.slice.call(n, e, t); }))); e.exports = o; }, function (e, t, n) { var r = n(5); e.exports = function (e, t) { return function () { var n = arguments.length; if (0 === n)
                    return t(); var o = arguments[n - 1]; return r(o) || "function" != typeof o[e] ? t.apply(this, arguments) : o[e].apply(o, Array.prototype.slice.call(arguments, 0, n - 1)); }; }; }, function (e, t, n) { var r = n(0), o = n(1), i = n(3); e.exports = function (e) { return function t(n, u, c) { switch (arguments.length) {
                    case 0: return t;
                    case 1: return i(n) ? t : o((function (t, r) { return e(n, t, r); }));
                    case 2: return i(n) && i(u) ? t : i(n) ? o((function (t, n) { return e(t, u, n); })) : i(u) ? o((function (t, r) { return e(n, t, r); })) : r((function (t) { return e(n, u, t); }));
                    default: return i(n) && i(u) && i(c) ? t : i(n) && i(u) ? o((function (t, n) { return e(t, n, c); })) : i(n) && i(c) ? o((function (t, n) { return e(t, u, n); })) : i(u) && i(c) ? o((function (t, r) { return e(n, t, r); })) : i(n) ? r((function (t) { return e(t, u, c); })) : i(u) ? r((function (t) { return e(n, t, c); })) : i(c) ? r((function (t) { return e(n, u, t); })) : e(n, u, c);
                } }; }; }, function (e, t, n) { var r = n(22)(-1); e.exports = r; }, function (e, t, n) { var r = n(1), o = n(6), i = r((function (e, t) { var n = e < 0 ? t.length + e : e; return o(t) ? t.charAt(n) : t[n]; })); e.exports = i; }, function (e, t, n) { Object.defineProperty(t, "__esModule", { value: !0 }), t.RichTextBlock = void 0; var r = n(2); function o(e, t) { for (var n = 0; n < t.length; n++) {
                    var r = t[n];
                    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
                } } var i = function () { function e(t, n, r) { !function (e, t) { if (!(e instanceof t))
                    throw new TypeError("Cannot call a class as a function"); }(this, e), this.type = t, this.text = n, this.spans = r; } var t, n; return t = e, (n = [{ key: "isEmbedBlock", value: function (e) { return e === r.NODE_TYPES.embed; } }, { key: "isImageBlock", value: function (e) { return e === r.NODE_TYPES.image; } }, { key: "isList", value: function (e) { return e === r.NODE_TYPES.list; } }, { key: "isOrderedList", value: function (e) { return e === r.NODE_TYPES.oList; } }, { key: "isListItem", value: function (e) { return e === r.NODE_TYPES.listItem; } }, { key: "isOrderedListItem", value: function (e) { return e === r.NODE_TYPES.oListItem; } }, { key: "emptyList", value: function () { return { type: r.NODE_TYPES.list, spans: [], text: "" }; } }, { key: "emptyOrderedList", value: function () { return { type: r.NODE_TYPES.oList, spans: [], text: "" }; } }]) && o(t, n), e; }(); t.RichTextBlock = i; }, function (e, t, n) { Object.defineProperty(t, "__esModule", { value: !0 }), t.default = void 0; var r, o = (r = n(4)) && r.__esModule ? r : { default: r }, i = n(8); t.default = function (e, t, n) { return o.default.fromRichText(e).children.map((function (e, r) { return function (e, t, n, r) { return function e(n, o) { var u = n instanceof i.SpanNode ? n.text : null, c = n.children.reduce((function (t, n, r) { return t.concat([e(n, r)]); }), []); return r && r(n.type, n.element, u, c, o) || t(n.type, n.element, u, c, o); }(e, n); }(e, t, r, n); })); }; }]); }, function (e, t, n) {
                var r = /["'&<>]/;
                e.exports = function (e) { var t, n = "" + e, o = r.exec(n); if (!o)
                    return n; var i = "", u = 0, c = 0; for (u = o.index; u < n.length; u++) {
                    switch (n.charCodeAt(u)) {
                        case 34:
                            t = "&quot;";
                            break;
                        case 38:
                            t = "&amp;";
                            break;
                        case 39:
                            t = "&#39;";
                            break;
                        case 60:
                            t = "&lt;";
                            break;
                        case 62:
                            t = "&gt;";
                            break;
                        default: continue;
                    }
                    c !== u && (i += n.substring(c, u)), c = u + 1, i += t;
                } return c !== u ? i + n.substring(c, u) : i; };
            }]);
    }));
});
var PrismicDOM = unwrapExports(prismicDom_min);
var apiURL = 'https://ionicframeworkcom.prismic.io/api/v2';
var cacheLife = 20 * 60 * 1000; // 20 mins
var ads;
var lastFetch = null;
var getLatest = function () { return __awaiter(void 0, void 0, void 0, function () {
    var api, response;
    return __generator(this, function (_b) {
        switch (_b.label) {
            case 0: return [4 /*yield*/, Prismic.getApi(apiURL)];
            case 1:
                api = _b.sent();
                return [4 /*yield*/, api.query(Prismic.Predicates.at('document.type', 'docs_ad'), {})];
            case 2:
                response = _b.sent();
                ads = response.results;
                lastFetch = Date.now();
                return [2 /*return*/];
        }
    });
}); };
var getAd = function () { return __awaiter(void 0, void 0, void 0, function () {
    return __generator(this, function (_b) {
        switch (_b.label) {
            case 0:
                if (!(lastFetch === null || (Date.now() - lastFetch) > cacheLife)) return [3 /*break*/, 2];
                return [4 /*yield*/, getLatest()];
            case 1:
                _b.sent();
                _b.label = 2;
            case 2: return [2 /*return*/, chooseAdByWeight()];
        }
    });
}); };
var chooseAdByWeight = function () {
    var _a;
    var weightList = []; // Just Checking...
    for (var _i = 0, ads_1 = ads; _i < ads_1.length; _i++) {
        var ad = ads_1[_i];
        if (ad['data']) { // Safety
            if (!ad['data'].ad_weight) {
                ad['data'].ad_weight = 1;
            }
            for (var i = 0; i < ad['data'].ad_weight; i++) {
                weightList.push(ad);
            }
        }
    }
    // Probability Fun
    return ((_a = weightList[Math.floor(Math.random() * weightList.length)]) === null || _a === void 0 ? void 0 : _a.data) || null;
};
var trackView = function (adId) {
    hubspotTrack('View', adId);
    googleAnalyticsTrack('View', adId);
};
var trackClick = function (adId, event) {
    var timeForTrackingRequests = 150; // ms
    if (event) {
        event.preventDefault();
    }
    hubspotTrack('Click', adId);
    googleAnalyticsTrack('Click', adId);
    // give tracking request time to complete
    setTimeout(function () {
        var link = hrefClimber(event === null || event === void 0 ? void 0 : event.target);
        if (link.target && link.target.toLowerCase() === '_blank') {
            window.open(link.href);
        }
        else if (link.href) {
            document.location = link.href;
        }
    }, timeForTrackingRequests);
};
var hubspotTrack = function (type, adId) {
    if (!window['_hsq']) {
        console.warn('Unable to track Hubspot event, _hsq not found', type, adId);
        return;
    }
    window['_hsq'].push(['trackEvent', {
            id: "Docs ad - " + type + " - " + adId
        }]);
};
var googleAnalyticsTrack = function (type, adId) {
    if (!window['gtag']) {
        console.warn('Unable to track Google Analytics event, gtag not found', type, adId);
        return;
    }
    window['gtag']('event', "Docs ad - " + type + " - " + adId, {
        'event_category': "Docs ad - " + type,
        'event_label': adId
    });
};
// recursive function to climb the DOM looking for href tags
var hrefClimber = function (el) {
    if (el['href']) {
        return el;
    }
    else if (el.parentNode) {
        return hrefClimber(el.parentNode);
    }
};
var internalAdCss = "internal-ad{max-width:148px;display:block;margin:48px 0 0}internal-ad p{font-size:13px;line-height:19px;font-weight:400;letter-spacing:0.02em;color:var(--c-indigo-100);-webkit-transition:.2s color;transition:.2s color}internal-ad a:hover p{color:var(--c-indigo-90)}@media (max-width: 1233px){internal-ad{display:none}}";
var InternalAd = /** @class */ (function () {
    function class_1(hostRef) {
        registerInstance(this, hostRef);
        this.update();
    }
    class_1.prototype.update = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _b;
            var _this = this;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        _b = this;
                        return [4 /*yield*/, getAd()];
                    case 1:
                        _b.ad = _c.sent();
                        if (!this.ad) {
                            return [2 /*return*/];
                        }
                        // give the page a chance to reflow
                        this.timeout = setTimeout(function () {
                            trackView(_this.ad.ad_id);
                        }, 50);
                        return [2 /*return*/];
                }
            });
        });
    };
    class_1.prototype.disconnectedCallback = function () {
        // if the reflowed page doesn't have an ad, don't fire view events
        clearTimeout(this.timeout);
    };
    class_1.prototype.render = function () {
        var _this = this;
        if (!this.ad || Object.keys(this.ad).length === 0) {
            return;
        }
        return (h("a", { href: this.ad.ad_url.url, target: this.ad.ad_url.target, onClick: function (e) { return trackClick(_this.ad.ad_id, e); } }, h("picture", null, h("source", { media: "(min-width: 37.5em)", src: this.ad.ad_image.url }), h("source", { src: this.ad.ad_image['1x'].url }), h("img", { src: this.ad.ad_image.url, alt: this.ad.ad_image.alt, height: this.ad.ad_image['1x'].dimensions.height, width: this.ad.ad_image['1x'].dimensions.width }), h("p", null, this.ad.ad_image.alt)), h("div", { innerHTML: PrismicDOM.RichText.asHtml(this.ad.ad_copy) })));
    };
    return class_1;
}());
InternalAd.style = internalAdCss;
export { InternalAd as internal_ad };
