UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

496 lines 55.4 kB
import { a as $, u as e, h as O, c as R, b as j, e as X, f as Se, p as te, F as ce, _ as ee, T as oe, A as Ye, M as pe, g as he, i as ze, P as Ke, j as Xe, k as We, l as Je, m as et, D as fe, w as Ue, n as tt, t as rt } from "./view-CDrJuRMn.js"; import { v as nt, R as Z, B as W, M as J, Q as re, O as Te, a as ne, S as at, L as st, u as it, H as de, b as _e, g as ot, p as lt, c as ct, s as dt, d as ut } from "./videoPlayer-HNloD0SJ.js"; import { b as be, D as Ne, A as Ie, g as pt } from "./core-YTxB8B8q.js"; import { t as Ee } from "./metricsReporter-0HbKrvkx.js"; const mt = ({ properties: t, surveyVideoUrl: a, questionId: r }) => { const n = `ul-card-video__question_player-q${r}`, { apiURL: s, viewDocument: i } = $((l) => ({ apiURL: l.apiURL, viewDocument: l.viewDocument })); return e("div", { id: n, ref: (l) => { if (l && l.children.length === 0 && !t.properties.hideRecordedPrompt) { const u = nt(n, { src: a, type: "application/x-mpegURL" }, void 0, t.properties.mediaType === Z.MEDIA_TYPE_AUDIO, s, i); l.appendChild(u); } } }); }, ae = ({ isDisabled: t, onClick: a, children: r }) => e(W, { className: "ul-card__button-checkmark", disabled: t, onClick: a, type: "button", children: [e("svg", { fill: "none", height: "10", viewBox: "0 0 13 10", width: "13", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M11.5 1.5L4.5 8.5L1 5", stroke: "#ffffff", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) }), r || "Ok"] }), ht = ({ className: t, next: a, properties: r, questionId: n, type: s }) => { const { useMobileStyling: i, border: l } = $((_) => ({ useMobileStyling: _.useMobileStyling, border: _.border })), [u, d] = O(!1), [v, y] = O(""), [o, h] = O(!1), x = r == null ? void 0 : r.collectName, f = (r == null ? void 0 : r.nameLabelText) || "Full Name", g = (r == null ? void 0 : r.consentText) || "I agree to the stated conditions", S = (r == null ? void 0 : r.submitButtonText) || "Submit", N = !!v.trim(), q = u && (!x || N), E = (_, Q = !1) => { _.preventDefault(), _.stopPropagation(); let A = null; if (!Q) { if (!q) return void h(!0); A = { submitted: !0 }, x && (A.name = v); } a({ value: A, questionId: n, type: s }, !!Q || q); }; return e("div", { className: R(t, "ul-card__consent-legal", "fade-in-transition"), children: e(J, { embeddedType: "pdf", properties: r, children: e(re, { children: [e("div", { className: "sprig-stretch", children: [e(Te, { allowTextEntry: !1, border: l, error: o && !u, id: "consent", isRadio: !1, isSelected: u, label: g, onUserInputChanged: ({ selected: _ }) => { _ !== u && d(!u); }, useMobileStyling: i }), x && e("input", { "aria-label": f, "aria-placeholder": f, className: R(j("ul-consent-legal__name-input", i)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (_) => { _.currentTarget.style.borderColor = o && !N ? be : Ne; }, onFocus: (_) => { _.currentTarget.style.borderColor = o && !N ? be : l; }, onInput: (_) => { _.preventDefault(), _.stopPropagation(), y(_.currentTarget.value); }, placeholder: f, style: o && !N ? { borderColor: be } : {}, tabIndex: 0, value: v })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(ae, { isDisabled: !q, onClick: (_) => E(new SubmitEvent(_.type)), children: X({ buttonText: S }) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (_) => E(new SubmitEvent(_.type), !0), children: Se(r) })] })] }) }) }, n); }, gt = () => { const { destroy: t, forceBrandedLogo: a } = $((r) => ({ destroy: r.destroy, forceBrandedLogo: r.forceBrandedLogo })); return te(() => { setTimeout(() => { t(Ie); }, a ? 4e3 : 2e3); }, [t, a]), e("div", { className: "end-of-survey-text", children: "End of survey" }); }, vt = ({ activeValue: t, border: a, icon: r, enableCspTrustedTypes: n, isPressed: s, range: i, scaleLabelType: l, selectedValue: u, setSelectedValue: d, setActiveValue: v, setIsPressed: y, useMobileStyling: o, value: h, viewDocument: x }) => { const f = `option-${h}`, g = l === "number", S = l === "star", N = l === "smiley", q = g && h === t || h === u, [E, _] = (() => { const c = S && u !== null && h <= u; return S && h <= t || N && h === t || c || h === t || h === u ? [a, s || c || h === u ? 1 : 0.3] : ["", 1]; })(), Q = ce(() => { const c = { borderColor: q ? E : "", fillOpacity: q ? "" : _, zIndex: q ? 3 : "auto", color: u === h ? "#fff" : "" }; return g ? { ...c, backgroundColor: u === h ? E : "" } : { ...c, color: S || N || u === h ? E : "" }; }, [q, E, _, u, h, g, S, N]), A = ce(() => pt((({ icon: c, scaleLabelType: p, value: k, selectedValue: m }) => { if (p === "smiley" && k === m) { let b = 0; return c.replace(/black/g, () => ++b == 1 ? "black" : "white"); } return c; })({ icon: r, scaleLabelType: l, value: h, selectedValue: u }), n), [n, r, l, u, h]); return e("button", { "aria-label": g ? void 0 : String(h), className: (() => { switch (l) { case "star": return R(j("likert-star", o), j(`likert-star-${h}`, o)); case "smiley": return R(j("likert-smiley", o), j(`likert-smiley-${h}`, o)); default: return h === i ? R(j("likert-number", o), j(`likert-number-${h}`, o), j("likert-last-option", o)) : R(j("likert-number", o), j(`likert-number-${h}`, o)); } })(), dangerouslySetInnerHTML: { __html: A }, id: f, onClick: (c) => { c.preventDefault(), c.stopPropagation(), d(h); }, onKeyDown: (c) => { var m, b; const p = x.querySelectorAll(`.likert-${l ?? "number"}`), k = h - 1; c.key === "ArrowRight" ? (m = p[k + 1]) == null || m.focus() : c.key === "ArrowLeft" ? (b = p[k - 1]) == null || b.focus() : c.key !== "Enter" && c.key !== " " || (c.preventDefault(), c.stopPropagation(), d(h)); }, onPointerDown: () => y(!0), onPointerEnter: () => v(h), onPointerLeave: () => { v(-1), y(!1); }, style: Q, tabIndex: 0 }); }, bt = ({ className: t, labels: a, next: r, properties: n, questionId: s, type: i }) => { const { border: l, useMobileStyling: u, viewDocument: d, enableCspTrustedTypes: v } = $((p) => ({ border: p.border, useMobileStyling: p.useMobileStyling, viewDocument: p.viewDocument, enableCspTrustedTypes: p.enableCspTrustedTypes })), [y, o] = O(-1), [h, x] = O(!1), [f, g] = O(null), S = a && a.left, N = a && a.right; let q; const { range: E, scaleLabelType: _, ratingIcons: Q } = n; E && (q = Number(E)); const A = q || 5, c = (p) => { var k, m; switch (_) { case "star": return (k = Q[0]) == null ? void 0 : k.svg; case "smiley": return (m = Q[p]) == null ? void 0 : m.svg; default: return String(p + 1); } }; return e("form", { className: R(t, "ul-card--likert", "fade-in-transition"), children: e(J, { properties: n, children: [e(ne, { children: [e("div", { "aria-label": `Rating (1 - ${A})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(A)].map((p, k) => { const m = k + 1; return e(vt, { activeValue: y, border: l, enableCspTrustedTypes: v, icon: c(k), isPressed: h, range: A, scaleLabelType: _, selectedValue: f, setActiveValue: o, setIsPressed: x, setSelectedValue: g, useMobileStyling: u, value: m, viewDocument: d }, k); }) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: S }), e("span", { children: N })] })] }), e(re, { children: e(ae, { isDisabled: f === null && n.required, onClick: () => r({ value: f, questionId: s, type: i }, !0), children: X(n) }) })] }) }, s); }, yt = ({ columns: t, onSelect: a, options: r, selectedOptions: n }) => { const s = ee([]), { border: i, useMobileStyling: l } = $((h) => ({ border: h.border, useMobileStyling: h.useMobileStyling })), u = r.findIndex((h) => n[h.id] === null), [d, v] = O(u), y = oe((h, x) => { a(h, x); const f = d + 1, g = r[f]; g && n[g.id] === null && v(f); }, [a, r, n, d]), o = oe((h, x) => { const f = d === h; return e(Ye, { animate: !0, header: x.label, isOpen: f, onClick: () => { var g; return v(f && !((g = window.UserLeap) != null && g.isMobileSDK) ? -1 : h); }, ref: (g) => { g && (s.current[h] = g); }, showHeaderCheck: n[x.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: t.map((g) => e(Te, { allowTextEntry: !1, ariaLabel: `${x.label}-${g.label}`, border: i, error: !1, id: `${x.id}-${g.value}`, isRadio: !0, isSelected: n[x.id] === g.value, label: g.label, onUserInputChanged: () => y(x.id, g.value), useMobileStyling: l }, g.label)) }) }, x.id); }, [i, t, d, y, n, l]); return e("div", { children: r.map((h, x) => o(x, h)) }); }, ft = ({ className: t, next: a, options: r, properties: n, questionId: s, type: i, onSubmitButtonClick: l }) => { const u = n.matrixColumn, d = n.required, v = (f) => { f.preventDefault(), f.stopPropagation(), a({ value: o, questionId: s, type: i }, !0), l && l(); }, y = r.reduce((f, g) => (f[g.id] = null, f), {}), [o, h] = O(y); return e("form", { className: R(t, "ul-card__matrix", "fade-in-transition"), id: "text-form", onSubmit: v, children: e(J, { properties: n, children: [e(ne, { children: e(yt, { columns: u, onSelect: (f, g) => { h((S) => ({ ...S, [f]: g })); }, options: r, selectedOptions: o }) }), e(re, { children: e(ae, { isDisabled: (x = o, d && Object.values(x).every((f) => f == null)), onClick: () => v(new SubmitEvent("submit")), children: X(n) }) })] }) }, s); var x; }, Ae = ({ className: t, onSubmit: a, options: r = [], properties: n, questionId: s, type: i, showIndividualSubmit: l = !1, onSubmitButtonClick: u }) => { const { border: d, useMobileStyling: v } = $((m) => ({ border: m.border, useMobileStyling: m.useMobileStyling })), y = r.reduce((m, b) => (m[b.id] = { isSelected: !1 }, m), {}), [o, h] = O(y), x = i === "multiplechoice", f = n.required, g = r.find((m) => { var b; return (b = m.optionProperties) == null ? void 0 : b.noneOfTheAbove; }), S = (m) => Object.entries(m).some(([b, I]) => { var H; const P = r.find((F) => `${F.id}` === b), L = I.userText === void 0 || I.userText.trim() === ""; return ((H = P == null ? void 0 : P.optionProperties) == null ? void 0 : H.allowsTextEntry) && L && I.isSelected; }), N = (m) => Object.values(m).filter((b) => b.isSelected).length, q = n.minSelect && n.minSelect > 0 && n.maxSelectMode === pe.Range && N(o) < n.minSelect && (f || N(o) > 0), E = (m) => S(m) || f && !N(m) || !((b) => { const { minSelect: I = 0, maxSelect: P = 1 / 0, maxSelectMode: L } = n, H = N(b); switch (L) { case pe.Maximum: return H <= P; case pe.Range: return H === 0 || H >= I; default: return !0; } })(m), _ = Object.entries(o).some(([m, b]) => { var I, P; return b.isSelected && ((P = (I = r.find((L) => `${L.id}` === m)) == null ? void 0 : I.optionProperties) == null ? void 0 : P.allowsTextEntry); }), Q = l && (!x || _), A = (m) => { k(m.id, m.selected, m.userText, m.noneOfTheAbove); }, c = (m) => { var b; return (n == null ? void 0 : n.maxSelectMode) !== pe.Unlimited && N(o) === (n == null ? void 0 : n.maxSelect) && !((b = o[m]) != null && b.isSelected); }, p = () => { a(o, !0), u && u(); }, k = (m, b, I, P) => { const L = Object.assign({}, o); if ((x || P) && b) for (const H of Object.values(L)) H.isSelected = !1, delete H.userText; else g && !P && o[g.id].isSelected && (L[g.id].isSelected = !1); L[m] = { isSelected: b, userText: I }, h(L); }; return e("form", { className: R(t, "ul-card--multiple", "fade-in-transition"), id: "text-form", onSubmit: p, children: e(J, { properties: n, children: [e(ne, { children: [n.isDropdown ? e(at, { disabledOptions: r.filter((m) => c(m.id)), dropdownFooter: q ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [N(o), "/", n.minSelect] }) : void 0, isMultiSelect: !x, multiselectText: n.dropdownMultiselectedText ?? "choices selected", onChange: (m) => { const b = { ...o }; for (const I of r) m.includes(I) ? b[I.id].isSelected = !0 : b[I.id].isSelected = !1; h(b); }, options: r, placeholderText: n.dropdownPlaceholderText ?? (x ? "Select choice" : "Select choice(s)"), value: r.filter((m) => o[m.id].isSelected) }) : e("div", { className: R(j("ul-card__choices", v)), role: x ? "radiogroup" : "group", children: [r.map(({ id: m, label: b, value: I, optionProperties: P }) => { var V, z; const L = `${m}`, { allowsTextEntry: H, noneOfTheAbove: F } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...P }; return e(Te, { allowTextEntry: H, border: d, disabled: c(L), error: (G = o, S(G)), id: L, isRadio: x, isSelected: !!((V = o[L]) != null && V.isSelected), label: b, noneOfTheAbove: F, onUserInputChanged: A, promptText: (P == null ? void 0 : P.otherOptionPlaceholder) || "Please specify", text: (z = o[m]) == null ? void 0 : z.userText, useMobileStyling: v, value: I }, L); var G; }), !!q && e("div", { className: "ul-card__min-select-counter", children: [N(o), "/", n.minSelect] })] }), Q && e(st, { handleSubmit: p, isSubmitDisabled: E(o) })] }), e(re, { children: e(ae, { isDisabled: E(o), onClick: p, children: X(n) }) })] }) }, s); }, kt = (t) => { const { questionId: a, type: r, next: n, options: s } = t; return e(Ae, { ...t, onSubmit: (i, l) => { const u = Object.entries(i).find(([, h]) => h.isSelected) || [void 0, void 0], [d, v] = u, y = s.find((h) => `${h.id}` === d), o = v != null && v.userText ? { [d]: { userText: v.userText } } : null; n({ value: y && d ? { [d]: y.value } : {}, secondaryValue: o, questionId: a, type: r }, l); } }); }, xt = (t) => { const { questionId: a, type: r, next: n } = t; return e(Ae, { ...t, onSubmit: (s, i) => { const l = Object.entries(s).reduce((d, [v, y]) => (d[v] = y.isSelected, d), {}), u = Object.entries(s).reduce((d, [v, y]) => { if (!y.userText) return d; const o = d || {}; return o[v] = { userText: y.userText }, o; }, null); n({ value: l, secondaryValue: u, questionId: a, type: r }, i); } }); }, Ct = ({ className: t, labels: a, properties: r, next: n, questionId: s, type: i }) => { const [l, u] = O(null), { border: d, useMobileStyling: v, viewDocument: y } = $((x) => ({ border: x.border, useMobileStyling: x.useMobileStyling, viewDocument: x.viewDocument })), o = a && a.left, h = a && a.right; return e("form", { className: R(t, "ul-card--nps", "fade-in-transition"), children: e(J, { properties: r, children: [e(ne, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((x, f) => e("button", { className: R(j("nps-number", v), j(`nps-number-${f}`, v)), id: `option-${f}`, onClick: (g) => { g.preventDefault(), g.stopPropagation(), u(f); }, onKeyDown: (g) => { var N, q; const S = y.querySelectorAll("button.nps-number"); g.key === "ArrowRight" ? (N = S[f + 1]) == null || N.focus() : g.key === "ArrowLeft" ? (q = S[f - 1]) == null || q.focus() : g.key !== "Enter" && g.key !== " " || (g.preventDefault(), g.stopPropagation(), u(f)); }, onPointerDown: (g) => { g.currentTarget.style.zIndex = "2", g.currentTarget.style.borderColor = d; }, onPointerLeave: (g) => { g.currentTarget.style.zIndex = "auto", g.currentTarget.style.borderColor = Ne; }, style: l === f ? { backgroundColor: d, color: "#fff" } : void 0, tabIndex: 0, children: f }, f)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: o }), e("span", { children: h })] })] }), e(re, { children: e(ae, { isDisabled: l === null && r.required, onClick: () => n({ value: l, questionId: s, type: i }, !0), children: X(r) }) })] }) }, s); }, St = ({ className: t, next: a, properties: r, questionId: n, type: s, onSubmitButtonClick: i }) => { const { border: l, useMobileStyling: u, update: d } = $((S) => ({ border: S.border, useMobileStyling: S.useMobileStyling, update: S.update })), [v, y] = O(""), o = ee(null), h = v.trim(), x = r.required === !0 && !h, f = it(o, () => d()), g = r && r.openTextPlaceholder ? r.openTextPlaceholder : ""; return e("form", { className: R(t, "ul-card-text", "fade-in-transition"), id: "text-form", children: e(J, { properties: r, children: e("div", { className: "ul-card-text", children: [e(ne, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": g, className: R(j("ul-card-text__input", u)), "data-gramm": "false", maxLength: 5e3, name: "text", onBlur: (S) => { S.currentTarget.style.borderColor = Ne; }, onChange: (S) => { const { value: N } = S.currentTarget; f(), S.preventDefault(), S.stopPropagation(), y(N); }, onFocus: (S) => { S.currentTarget.style.borderColor = l; }, placeholder: g, ref: o, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(de, { className: "footer", html: r.footerHtml })] }), e(re, { children: e(ae, { isDisabled: x, onClick: (S) => { S.preventDefault(), S.stopPropagation(); const N = r.required !== !0 || h.length > 0; a({ value: v, questionId: n, type: s }, N), i && i(); }, children: X(r) }) })] }) }) }, n); }, Tt = ({ className: t, labels: a, next: r, properties: n, questionId: s, type: i, onSubmitButtonClick: l, options: u }) => { const d = ee(null), v = ee(0), y = ee(0), o = ee(null), h = ee(!1), x = ee([]), [f, g] = O(() => (n == null ? void 0 : n.required) === !0), [S, N] = O(() => u.map((C) => ({ ...C, rank: null }))), q = ce(() => Array.from({ length: u.length }, (C, w) => w + 1), [u.length]), { useMobileStyling: E, isPreview: _, headers: Q } = $((C) => ({ useMobileStyling: C.useMobileStyling, isPreview: C.isPreview, headers: C.headers })), A = (Q == null ? void 0 : Q["userleap-platform"]) === "android", c = E && !_ && !A, p = !c && !A, k = (C, w) => { N((D) => { const T = parseInt(w), U = D.map((M) => ({ ...M })); U.some((M) => M.rank == null) && U.forEach((M, se) => M.rank = se + 1); const Y = U.findIndex((M) => M.id === C); if (Y === -1) return D; const B = U[Y].rank; return T < B ? U.forEach((M) => { M.id !== C && M.rank >= T && M.rank < B && (M.rank = M.rank + 1); }) : T > B && U.forEach((M) => { M.id !== C && M.rank > B && M.rank <= T && (M.rank = M.rank - 1); }), U[Y].rank = T, U.sort((M, se) => M.rank - se.rank), F(), U; }); }, m = (C, w) => { for (let D = 0; D < x.current.length; D++) { const T = x.current[D]; if (!T || T === o.current) continue; const U = T.getBoundingClientRect(); if (C >= U.left && C <= U.right && w >= U.top && w <= U.bottom) return { element: T, index: D }; } return null; }, b = (C) => (w) => { if (!c) return; w.preventDefault(), w.stopPropagation(), h.current = !0, d.current = C; const D = w.touches[0]; v.current = D.clientY, y.current = D.clientY; const T = w.currentTarget.closest(".ul-card-rank__option"); T && (o.current = T, T.classList.add("is-dragging")); }, I = (C) => { if (!c || !h.current || d.current === null) return; C.preventDefault(), C.stopPropagation(); const w = C.touches[0]; y.current = w.clientY; const D = y.current - v.current; o.current && (o.current.style.transform = `translateY(${D}px)`, o.current.style.zIndex = "1000"), x.current.forEach((U) => { U && U !== o.current && U.classList.remove("is-drop-target"); }); const T = m(w.clientX, w.clientY); T && T.element.classList.add("is-drop-target"); }, P = (C) => { if (!c || !h.current || d.current === null) return; C.preventDefault(), C.stopPropagation(); const w = C.changedTouches[0], D = m(w.clientX, w.clientY); o.current && (o.current.style.transform = "", o.current.style.zIndex = "", o.current.classList.remove("is-dragging")), x.current.forEach((T) => { T && T.classList.remove("is-drop-target"); }), D && D.index !== d.current && L(d.current, D.index), d.current = null, o.current = null, h.current = !1; }, L = (C, w) => { N((D) => { const T = D.map((Y) => ({ ...Y })), [U] = T.splice(C, 1); return T.splice(w, 0, U), T.forEach((Y, B) => { Y.rank = B + 1; }), F(), T; }); }, H = (C) => { const w = {}; C.reduce((D, T) => (D[T.id] = T.rank, D), w), r({ value: w, questionId: s, type: i }, !0); }, F = () => { g(!1); }, { left: G, right: V } = a, z = u.length, ue = (C) => { C.preventDefault(), C.currentTarget.classList.add("is-drop-target"); }, je = (C) => { C.currentTarget.classList.remove("is-drop-target"); }, Ze = (C) => { d.current = null, C.currentTarget.classList.remove("is-dragging"); }; return e("form", { className: R(t, "ul-card-rank", "fade-in-transition"), onSubmit: (C) => { C.preventDefault(), H(S), l && l(); }, children: e(J, { properties: n, children: e(he, A ? { children: [e(ne, { children: e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", G] }) }), e("ol", { className: "ul-card-rank__list", children: S.map(({ id: C, label: w, rank: D }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${w}`, className: R("ul-card-rank__select", D == null && "ul-card-rank__select--placeholder"), name: `rank[${C}]`, onChange: (T) => k(C, T.currentTarget.value), value: D ?? "", children: [D == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), q.map((T) => e("option", { className: "ul-card-rank__select-option", value: T, children: T }, `${T}-${s}`))] }), e("span", { children: w })] }, C)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [z, " - ", V] }) })] }) }), e(re, { children: e("div", { className: "ul-card__button-wrapper", children: e(W, { disabled: f, children: X(n) }) }) })] } : { children: [e(ne, { children: e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", G] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: A ? void 0 : (C) => { C.preventDefault(), C.dataTransfer && (C.dataTransfer.dropEffect = "move"); }, children: S.map(({ id: C, label: w, rank: D }, T) => { return e("li", { className: "ul-card-rank__option", draggable: !!p || void 0, onDragEnd: p ? Ze : void 0, onDragEnter: p ? ue : void 0, onDragLeave: p ? je : void 0, onDragStart: p ? (Y = T, (B) => { d.current = Y, B.dataTransfer && (B.dataTransfer.effectAllowed = "move", B.dataTransfer.setData("text/plain", String(Y)), B.currentTarget.classList.add("is-dragging")); }) : void 0, onDrop: p ? (U = T, (B) => { var se, qe; B.preventDefault(), B.currentTarget.classList.remove("is-drop-target"); const M = d.current; d.current = null, (qe = (se = B.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : se.querySelector(".is-dragging")) == null || qe.classList.remove("is-dragging"), M != null && M !== U && L(M, U); }) : void 0, ref: (B) => x.current[T] = B, children: [e("select", { "aria-label": `Rank for ${w}`, className: R("ul-card-rank__select", D == null && "ul-card-rank__select--placeholder"), name: `rank[${C}]`, onChange: (B) => k(C, B.currentTarget.value), value: D ?? "", children: [D == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), q.map((B) => e("option", { className: "ul-card-rank__select-option", value: B, children: B }, B))] }), e("span", { children: w }), !A && e("button", { "aria-label": `Drag ${w} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: c ? P : void 0, onTouchMove: c ? I : void 0, onTouchStart: c ? b(T) : void 0, title: "Drag to reorder", type: "button", children: e("svg", { fill: "none", height: "17", viewBox: "0 0 16 17", width: "16", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M5.75 11.625C6.37132 11.625 6.875 12.1287 6.875 12.75C6.875 13.3713 6.37132 13.875 5.75 13.875C5.12868 13.875 4.625 13.3713 4.625 12.75C4.625 12.1287 5.12868 11.625 5.75 11.625ZM10.25 11.625C10.8713 11.625 11.375 12.1287 11.375 12.75C11.375 13.3713 10.8713 13.875 10.25 13.875C9.62868 13.875 9.125 13.3713 9.125 12.75C9.125 12.1287 9.62868 11.625 10.25 11.625ZM5.75 7.375C6.37132 7.375 6.875 7.87868 6.875 8.5C6.875 9.12132 6.37132 9.625 5.75 9.625C5.12868 9.625 4.625 9.12132 4.625 8.5C4.625 7.87868 5.12868 7.375 5.75 7.375ZM10.25 7.375C10.8713 7.375 11.375 7.87868 11.375 8.5C11.375 9.12132 10.8713 9.625 10.25 9.625C9.62868 9.625 9.125 9.12132 9.125 8.5C9.125 7.87868 9.62868 7.375 10.25 7.375ZM5.75 3.125C6.37132 3.125 6.875 3.62868 6.875 4.25C6.875 4.87132 6.37132 5.375 5.75 5.375C5.12868 5.375 4.625 4.87132 4.625 4.25C4.625 3.62868 5.12868 3.125 5.75 3.125ZM10.25 3.125C10.8713 3.125 11.375 3.62868 11.375 4.25C11.375 4.87132 10.8713 5.375 10.25 5.375C9.62868 5.375 9.125 4.87132 9.125 4.25C9.125 3.62868 9.62868 3.125 10.25 3.125Z", fill: "currentColor" }) }) })] }, C); var U, Y; }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [z, " - ", V] }) })] }) }), e(re, { children: e("div", { className: "ul-card__button-wrapper", children: e(W, { disabled: f, children: X(n) }) }) })] }) }) }, s); }, ke = 1, Be = 2, $e = 3, me = (t) => t.type === "av_permission", Pe = (t) => t.type === "screen_permission", Oe = (t, a) => t === void 0 ? ke : t ? ((r, n) => !(me(n) ? n.permissionDescriptors : []).includes("camera") || r.getVideoTracks().length > 0)(t, a) ? $e : ke : Be, Le = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => { }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, K = ze((t) => ({ ...Le, reset: () => { t(Le); }, updatePage: (a) => { t(a); } })); function xe({ currentPage: t, pages: a }) { const { avStream: r, recordingMediaTypes: n, updatePage: s } = K.getState(), { recorderEventEmitter: i } = $.getState(); i.emit("av.permission", { "permission.descriptors": t.permissionDescriptors, "stream.ready": (l, u) => { if (r === l) return; let d = t; if (l && !t.permissionDescriptors.includes("camera")) { const v = a.indexOf(t), y = u != null && u.active ? v + 2 : v + 1; u != null && u.active && n && i.emit("begin.recording", { "recording.media.types": n, "start.recording.callback": (o) => s({ mediaRecordingUids: o }) }), d = a[y]; } s({ currentPage: d, avStream: l }); } }); } function Ce({ status: t }) { const { nextQuestion: a, passthroughData: r, mediaRecordingUids: n, reset: s } = K.getState(), { recorderEventEmitter: i, handleUploadUpdate: l, index: u } = $.getState(), d = { value: { taskStatus: t }, type: "recordedtask", questionId: (r == null ? void 0 : r.questionId) || 1 }; r && i.emit("finish.task", { "begin.callback": (v) => { l({ mediaRecordingUid: v, isSubmitted: !0, progressPct: 0, isComplete: !1 }); }, "progress.callback": (v, y) => { l({ mediaRecordingUid: v, progressPct: y.detail, isSubmitted: !1, isComplete: !1 }); }, "upload.callback": (v) => { v && l({ mediaRecordingUid: v, isComplete: !0, isSubmitted: !0, progressPct: 100 }); }, "passthrough.data": r, "current.index": u, "task.response": d, "task.complete.callback": (v) => { d.value.taskDurationMillisecond = v, n && (d.value.mediaRecordingUids = n), s(), a(d); } }); } function we({ pages: t, setIsRequestingPermission: a }) { const { recorderEventEmitter: r, eventEmitFn: n } = $.getState(), { updatePage: s, currentPage: i, recordingMediaTypes: l, screenPermissionRequested: u } = K.getState(); if (!i) return; const d = t.indexOf(i); switch (i.type) { case "av_permission": { const v = u ? d + 2 : d + 1; return u && l && r.emit("begin.recording", { "recording.media.types": l, "start.recording.callback": (y) => { s({ mediaRecordingUids: y }); } }), void s({ currentPage: t[v] }); } case "screen_permission": return void r.emit("screen.permission", { "screen.permission.requested": a, "stream.ready.callback": (v, y) => { const o = y ? t[d + 1] : i; y && l && r.emit("begin.recording", { "recording.media.types": l, "start.recording.callback": (h) => { s({ captureStream: y, mediaRecordingUids: h }); } }), s({ currentPage: o, screenPermissionRequested: !0, captureStream: y }); } }); case "start_task": return n("recorded.task.start"), r.emit("recorded.task.start"), r.emit("start.task"), void s({ currentPage: t[d + 1], screenPermissionRequested: !0 }); case "complete_task": return; } } const Qe = "ul-permission-graphics-container", He = "ul-permission-body", Fe = R(Qe, "ul_recorded-task-inset-spacing"), ge = R("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Ge = ({ richTextBody: t }) => e(de, { className: "ul-rich-text-body", html: t, id: "ul-task-detail-container" }), ve = ({ required: t, skipButtonText: a, bottom: r = !1 }) => t ? null : e(W, { className: R(r && "ul-skip-button-below", "ul-button-inactive"), onClick: Ce.bind(null, { status: "abandoned" }), children: a || "Skip" }), De = (t) => { const { avStream: a, captureStream: r, recordingMediaTypes: n, updatePage: s } = K.getState(), i = (n == null ? void 0 : n.includes("audio")) || (n == null ? void 0 : n.includes("video")); te(() => { const l = setInterval(() => { i && a && !a.active ? s({ avStream: null, currentPage: t[0] }) : r && r.active || s({ captureStream: void 0, currentPage: t[i ? 1 : 0] }); }, 1e3); return () => clearInterval(l); }, [a, r, i, t, n, s]); }, _t = ({ content: t, pages: a, required: r }) => { const { buttonText: n, skipButtonText: s, taskDetail: i } = t; return De(a), e("div", { className: "ul-task-page", children: [i && e(Ge, { richTextBody: i }), e("div", { className: ge, children: [e(W, { onClick: we.bind(null, { pages: a }), children: n }), e(ve, { required: r, skipButtonText: s })] })] }, "start-task"); }, Nt = ({ content: t, pages: a, properties: r }) => { const { buttonText: n, skipButtonText: s } = t; return De(a), e("div", { className: "ul-task-page", children: [t.taskDetail && e(Ge, { richTextBody: t.taskDetail }), e(J, { properties: r, children: e("div", { className: ge, children: [e(W, { className: "ul-complete-task-button", onClick: Ce.bind(null, { status: "completed" }), children: n }), e(W, { className: R("ul-button-inactive"), onClick: Ce.bind(null, { status: "given.up" }), children: s })] }) })] }, "complete-task"); }, It = ({ content: t, pages: a, required: r }) => { const { buttonText: n, skipButtonText: s } = t, [i] = $((d) => [d.tabTitle]), [l, u] = O(!1); return e("div", { children: [e("div", { className: Fe, children: [e("p", { style: { marginTop: "auto" }, children: t.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: He, children: i }) })] }), e("div", { className: r ? "" : ge, children: [e(W, { disabled: l, onClick: we.bind(null, { pages: a, setIsRequestingPermission: u }), children: n }), e(ve, { required: r, skipButtonText: s })] })] }); }, wt = ({ content: t }) => e(de, { className: R(Qe, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: t.svg }, "ul-permission-request-graphic"), Dt = ({ content: t, pages: a, required: r }) => { const { permissionDeniedHeadline: n, permissionDeniedBody: s, skipButtonText: i, tryAgainButtonText: l } = t, u = me(a[0]) ? a[0] : null; return te(() => { const d = setInterval(() => { u !== null && xe({ currentPage: u, pages: a }); }, 1e3); return () => clearInterval(d); }, [u, a]), u ? e("div", { children: [e("div", { className: Fe, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: n }), e("span", { className: He, children: s })] }) }), e("div", { className: ge, children: [e(W, { onClick: xe.bind(null, { currentPage: u, pages: a }), children: l }), e(ve, { required: r, skipButtonText: i })] })] }) : null; }, qt = ({ stream: t }) => e("video", { autoPlay: !0, className: R("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (a) => { a && (a.srcObject = t || null); } }), Pt = ({ content: t, pages: a, required: r }) => { const { skipButtonText: n } = t, { avStream: s } = K.getState(); return De(a), e("div", { children: [e(qt, { stream: s }), e("div", { className: "ul-vertical-button-container-center", children: [e(W, { onClick: we.bind(null, { pages: a }), children: t.buttonText }), e(ve, { bottom: !0, required: r, skipButtonText: n })] })] }); }, Lt = ({ properties: t }) => { const { pages: a, required: r } = t, { avStream: n, currentPage: s } = K.getState(); if (s === void 0) return null; switch (s == null ? void 0 : s.type) { case "av_permission": { const i = Oe(n, s); return i === ke ? e(wt, { content: s }) : e(i === Be ? Dt : Pt, { content: s, pages: a, required: r }); } case "screen_permission": return e(It, { content: s, pages: a, required: r }); case "start_task": return e(_t, { content: s, pages: a, required: r }); case "complete_task": return e(Nt, { content: s, pages: a, properties: t }); default: return null; } }, Rt = ({ className: t, properties: a, next: r, questionId: n }) => { const s = $(), { surveyId: i, responseGroupUid: l, userId: u } = s, d = K(), { screenPermissionRequested: v } = d, y = K((g) => g.avStream); let o = K((g) => g.currentPage); o || (o = function({ pages: g, userId: S, responseGroupUid: N, surveyId: q, questionId: E, next: _ }) { const { updatePage: Q } = K.getState(), { eventEmitFn: A, recorderEventEmitter: c } = $.getState(), p = { questionId: E, surveyId: q, visitorId: S, responseGroupUid: N }; let k = 0; c.emit("recorded.task.permission.screen"), A("recorded.task.permission.screen"), c.emit("permission.status", { "permission.status.callback": (b, I, P, L) => { const H = g[k], { type: F } = H, G = ["screen"]; if (me(H)) { const { permissionDescriptors: V } = H, z = V == null ? void 0 : V.includes("microphone"), ue = V == null ? void 0 : V.includes("camera"); z && G.push("audio"), ue && G.push("video"), (b != null && b.active && !ue || b != null && b.active && I) && k++; } Pe(g[k]) && P && (k++, c.emit("begin.recording", { "recording.media.types": G, "start.recording.callback": (V) => Q({ mediaRecordingUids: V }) })), Q({ currentPage: g[k], avStream: b, screenPermissionRequested: P, nextQuestion: _, type: F, passthroughData: p, recordingMediaTypes: G, captureStream: L }); } }); const m = g[k]; return m.type === "av_permission" && xe({ currentPage: m, pages: g }), m; }({ questionId: n, surveyId: i, next: (g) => { r(g, !0); }, pages: a.pages, responseGroupUid: l, userId: u })); let h = o.headline, x = o.captionText; const f = Oe(y, o); return Pe(o) && v && (h = o.permissionDeniedHeadline, x = o.permissionDeniedCaptionText), me(o) && f === $e && (h = o.permissionGrantedHeadline, x = o.permissionGrantedCaptionText), e("div", { className: R(t, "ul-center-horizontally", "fade-in-transition"), children: [e(_e, { isRequired: a == null ? void 0 : a.required, message: h, properties: { captionText: x } }), e(ne, { children: e(Lt, { properties: a }) })] }); }, Mt = ({ className: t, next: a, properties: r, questionId: n, type: s }) => { const { visitorAttributes: i, isLongFormSurvey: l } = $((y) => ({ visitorAttributes: y.visitorAttributes, isLongFormSurvey: Ee(y.studyType) })), u = (y, o = !1) => { a({ value: o ? { skipped: !0 } : void 0, questionId: n, type: s }, !0); }, d = ot(r && r.buttonUrl, i), v = l && r.promptActionType === Ke.NO_BUTTON; return e("div", { className: R(t, "ul-card__text-url-prompt", "fade-in-transition"), children: e(J, { properties: r, children: !v && e("div", { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: d, id: "ul-card-text__button", onClick: u, onKeyPress: (y) => { y.key !== "Enter" && y.key !== " " || a({ value: void 0, questionId: n, type: s }, !0); }, rel: "noreferrer", role: d ? "link" : "button", tabIndex: 0, target: "_blank", children: X(r) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (y) => u(0, !0), children: Se(r) })] }) }) }) }, n); }, Ut = ({ className: t, questionId: a }) => { const { border: r, destroy: n, endCard: s, forceBrandedLogo: i } = $((d) => ({ border: d.border, destroy: d.destroy, endCard: d.endCard, forceBrandedLogo: d.forceBrandedLogo })); te(() => { setTimeout(() => { n(Ie); }, i ? 4e3 : 2e3); }, [n, i]); const l = s && s.subheader ? e("p", { className: "ul-caption", children: s.subheader }) : null, u = s && s.headline ? s.headline : ""; return e("div", { className: R(t, "ul-card--thanks", "fade-in-transition"), children: e("div", { children: e("div", { className: "ul-card--thanks-content", children: [e("div", { className: "ul-thanks-check", children: e("svg", { "aria-labelledby": "title", fill: "none", height: "99", viewBox: "0 0 81 99", width: "81", xmlns: "http://www.w3.org/2000/svg", children: [e("path", { clipRule: "evenodd", d: "M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z", fill: r, fillRule: "evenodd" }), e("path", { clipRule: "evenodd", d: "M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z", fill: r, fillRule: "evenodd" }), e("path", { d: "M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z", fill: "black", fillOpacity: "0.2" })] }) }), e(_e, { message: u }), l] }) }) }, a); }, Et = () => e("div", { className: "thinking-dots-container", children: e("div", { className: "thinking-dot" }) }), At = ({ className: t }) => { const { uploadProgress: a } = $((i) => ({ uploadProgress: i.uploadProgress })); let r, n; Object.values(a).filter((i) => i.isSubmitted).length > 1 ? (r = "Your responses are processing", n = "Please keep this tab open until your responses are fully processed.") : (r = "Your response is processing", n = "Please keep this tab open until your response is fully processed."); const s = Math.round(Math.min(99, ...Object.values(a).filter((i) => i.isSubmitted).map((i) => i.progressPct || 0))); return e("div", { className: R(t, "ul-card--uploading", "fade-in-transition"), children: [e("div", { "aria-busy": "true", "aria-label": "Processing...", "aria-live": "polite", className: "ul-loading-spinner-container", role: "progressbar", children: e("div", { className: "ul-loading-spinner", children: [e("div", { className: "first" }), e("div", { className: "second" }), e("div", { className: "third" }), e("div", { className: "fourth" })] }) }), e(_e, { message: `${r} (${s}% complete)` }), e("p", { className: "ul-caption", children: n })] }); }, Re = 0, Me = 1, Bt = ({ className: t, next: a, properties: r, questionId: n, type: s }) => { const i = `ul-card-video__player_recorder-q${n}`, { apiURL: l, envId: u, handleUploadUpdate: d, headers: v, responseGroupUid: y, surveyId: o, viewDocument: h, visitorId: x } = $((p) => ({ apiURL: p.apiURL, envId: p.envId, handleUploadUpdate: p.handleUploadUpdate, headers: p.headers, responseGroupUid: p.responseGroupUid, surveyId: p.surveyId, viewDocument: p.viewDocument, visitorId: p.userId })), [f, g] = O(!1), [S, N] = O(null), [q, E] = O(null), [_, Q] = O(Re), A = (p, k) => { p === Z.UPLOAD_STARTED ? (N(k[Z.UPLOAD_ID]), E(k[Z.MEDIA_RECORDING_UID]), g(!0)) : p === Z.DELETE ? (N(null), E(null), g(!1)) : p === Z.UPLOAD_PROGRESS ? isNaN(k[Z.UPLOAD_PROGRESS_PCT]) ? d({ mediaRecordingUid: k[Z.MEDIA_RECORDING_UID], isComplete: !0 }) : d({ mediaRecordingUid: k[Z.MEDIA_RECORDING_UID], progressPct: k[Z.UPLOAD_PROGRESS_PCT] }) : p === Z.UPLOAD_FINISHED && d({ mediaRecordingUid: k[Z.MEDIA_RECORDING_UID], isComplete: !0 }); }, c = (p) => { p.preventDefault(), p.stopPropagation(), document.getElementById(i) && dt(i), S && q ? (d({ mediaRecordingUid: q, isSubmitted: !0 }), a({ value: { mediaRecordingUid: q }, questionId: n, type: s }, !0)) : a({ value: null, questionId: n, type: s }, !0); }; return e("form", { className: R(t, "ul-card--video", "fade-in-transition"), id: "ul-video-interview-form", children: [e(ne, { children: [e("div", { id: "ul-question-player-container", style: { display: _ === Re ? "" : "none" }, children: e(J, { properties: r, children: e("button", { className: "ul-video-btn ul-record-response-btn", onClick: (p) => { p.preventDefault(), p.stopPropagation(), document.getElementById(i) && lt(i), Q(Me); } }) }) }), e("div", { style: { display: _ === Me ? "block" : "none" }, children: e("div", { id: "ul-recorder-player-container", ref: (p) => { if (p && p.children.length === 0) { const k = ct(i, { surveyId: o, responseGroupUid: y, questionId: n, visitorId: x, envId: u }, l, A, void 0, { ...v, "x-ul-video-recorder-origin": "sdk" }, r.mediaType === Z.MEDIA_TYPE_AUDIO, h); p.appendChild(k); } } }) })] }), e(re, { children: [e(ae, { isDisabled: !!r.required && !f, onClick: c, children: X(r) }), e("button", { className: "ul-card-text__button ul-button-inactive ul-card-skip__button", id: "ul-card-video__skip_button", onClick: c, style: { ...r.required ? { display: "none" } : {}, ...f ? { display: "none" } : {} }, children: Se(r) })] })] }); }, le = (t) => t.type === "aidynamicfollowup" || t.type === "aidynamicstandalone", ye = (t) => { var a; return le(t) && ((a = t.props) == null ? void 0 : a.loading) === fe.inFlight; }, Ve = (t) => t.type === "thanks" || t.type === "uploading", $t = ({ card: t, avatars: a, isThinking: r, isCurrentQuestion: n, currentQuestionBubbleRef: s }) => { const i = ((l) => "properties" in l.props && l.props.properties && "questionHtml" in l.props.properties && l.props.properties.questionHtml ? { content: l.props.properties.questionHtml, isHtml: !0 } : "message" in l.props ? { content: l.props.message, isHtml: !1 } : { content: "Question", isHtml: !1 })(t); return e(ie, { avatars: a, isLeft: !0, message: { id: `question-${t.name}`, type: "question", content: i.content }, ref: n ? s : null, children: r ? e(Et, {}) : e(he, { children: [i.isHtml ? e(de, { className: "chat-message-text", html: i.content }) : e("div", { className: "chat-message-text", children: i.content }), t.type === "videovoice" && e(mt, { properties: t.props, questionId: t.name, surveyVideoUrl: t.props.properties.videoUrl })] }) }); }, Ot = ({ card: t, avatars: a }) => { const r = ((n) => { if (!("properties" in n.props) || !n.props.properties || typeof n.props.properties != "object") return null; const s = n.props.properties, i = [{ key: "captionHtml", isHtml: !0 }, { key: "captionText", isHtml: !1 }, { key: "richTextBody", isHtml: !0 }, { key: "body", isHtml: !1 }]; for (const { key: l, isHtml: u } of i) { const d = s[l]; if (typeof d != "string") continue; const v = d.trim(); if (v) { if (u && !v.replaceAll(/<[^>]*>/g, "").trim()) continue; return { content: v, isHtml: u }; } } return null; })(t); return r ? e(ie, { avatars: a, hideAvatar: !0, isLeft: !0, message: { id: `caption-${t.name}`, type: "question", content: r.content }, children: r.isHtml ? e(de, { className: "chat-message-text", html: r.content }) : e("div", { className: "chat-message-text", children: r.content }) }) : null; }, Qt = ({ card: t, userResponse: a, avatars: r }) => { const n = ((s, i) => { if ((s.type === "open" || s.type === "aidynamicfollowup" || s.type === "aidynamicstandalone") && i && typeof i == "object" && "value" in i) return i.value; })(t, a); return e("div", { className: "chat-bubble-container chat-right", children: [e("div", { className: "chat-bubble chat-bubble-right chat-bubble-text-only", children: e("div", { className: "chat-message-text", children: n || e("div", { className: "chat-message-no-response", children: "No response" }) }) }), e("img", { alt: "User Avatar", className: "chat-avatar chat-avatar-right", srcSet: `${r.respondentAvatar["1x"]} 1x, ${r.respondentAvatar["2x"]} 2x` })] }); }, Ht = ({ card: t, avatars: a, isCurrentQuestion: r, currentQuestionBubbleRef: n }) => { const { endCard: s } = $((i) => ({ endCard: i.endCard })); return e(he, { children: [e(ie, { avatars: a, isLeft: !0, message: { id: `thanks-${t.name}`, type: "question", content: (s == null ? void 0 : s.headline) ?? "Great! Thank you for your participation." }, ref: r ? n : null }), (s == null ? void 0 : s.subheader) && e(ie, { avatars: a, hideAvatar: !0, isLeft: !0, message: { id: `caption-${t.name}`, type: "question", content: s.subheader } }), e(gt, {})] }); }, Ft = ({ card: t, cardIndex: a, index: r, avatars: n, cardResponses: s, questionThinkingStates: i, startingQuestionIdx: l, currentQuestionBubbleRef: u, handleCardResponse: d }) => { const v = a === r, y = a < r, o = Ve(t); if (o) return e(Ht, { avatars: n, card: t, currentQuestionBubbleRef: u, isCurrentQuestion: v }); const h = `${t.name}`, x = s.get(h), f = t.type === "open" || t.type === "aidynamicfollowup" || t.type === "aidynamicstandalone", g = i.get(h); if (t.type === "aidynamicfollowup" && (t.props.loading === fe.failure || t.props.loading === void 0) || t.type === "aidynamicstandalone" && t.props.loading === fe.failure) return e(he, {}); const S = (a > (l ?? 0) || le(t)) && t.type !== "thanks" && t.type !== "uploading" && (g === !0 || g === void 0); return e(Ue.Fragment, { children: [e($t, { avatars: n, card: t, currentQuestionBubbleRef: u, isCurrentQuestion: v, isThinking: S }), !S && e(Ot, { avatars: n, card: t }), y && f ? e(Qt, { avatars: n, card: t, userResponse: x }) : (!y || !f) && !S && e(ie, { avatars: n, isLeft: !1, message: { id: `card-${t.name}`, type: "card", content: "" }, children: e("div", { className: "chat-card-container", children: e(Vt, { card: t, className: o ? "chat-thanks-card" : "chat-card", isAnswered: y, next: v ? d : () => { } }) }) })] }, `question-card-${t.name}`); }, ie = Ue.forwardRef(({ message: t, isLeft: a = !1, children: r, avatars: n, hideAvatar: s = !1 }, i) => { const l = a ? "chat-bubble-left" : "chat-bubble-right"; return e("div", { className: `chat-bubble-container ${a ? "chat-left" : "chat-right"}${a && s ? " chat-no-avatar" : ""}`, ref: i, children: [a && !s && e("img", { alt: "AI Avatar", className: "chat-avatar chat-avatar-left", srcSet: `${n.agentAvatar["1x"]} 1x, ${n.agentAvatar["2x"]} 2x` }), e("div", { className: `chat-bubble ${l}`, children: r || e("div", { className: "chat-message-text", children: t.content }) }), !a && !s && e("img", { alt: "User Avatar", className: "chat-avatar chat-avatar-right", srcSet: `${n.respondentAvatar["1x"]} 1x, ${n.respondentAvatar["2x"]} 2x` })] }); }); ie.displayName = "ChatBubble"; const Gt = () => { const t = $((r) => r.close), a = ce(() => () => t(Ie), [t]); return e("div", { "aria-label": "Close button", className: "conversational-close-btn", onClick: a, onKeyPress: (r) => { r.key === "Enter" && a(); }, role: "button", tabIndex: 0, children: e("svg", { fill: "none", height: "16px", viewBox: "0 0 13 13", width: "16px", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M2.54964 1.78369L1.78369 2.54964L5.73405 6.5L1.78369 10.4504L2.54964 11.2163L6.5 7.26595L10.4504 11.2163L11.2163 10.4504L7.26595 6.5L11.2163 2.54964L10.4504 1.78369L6.5 5.73405L2.54964 1.78369Z", fill: "#262136" }) }) }); }, Vt = ({ card: t, next: a, className: r = "", isAnswered: n = !1 }) => { const s = { className: n ? `${r} answered-card` : r, next: n ? () => { } : a, questionId: t.name, type: t.type, isAnswered: n }; switch (t.type) { case "consentlegal": return e(ht, { ...s, ...t.props }); case "likert": return e(bt, { ...s, ...t.props })