@sprig-technologies/sprig-browser 2.42.1 → 2.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,604 +0,0 @@
1
- import { a as O, u as e, h as V, c as R, b as j, e as X, f as xe, p as ne, F as ce, _ as ee, T as le, A as Fe, g as he, i as Ze, j as Ye, k as De, l as ze, m as Ke, n as Xe, w as Me, o as We } from "./view-q6KAoLll.js";
2
- import { v as Je, R as F, B as W, M as J, Q as te, O as Ce, a as re, b as pe, S as et, L as tt, u as rt, H as de, c as Se, g as nt, P as at, p as st, d as it, s as ot } from "./getAttributedUrl-BkFxZZq1.js";
3
- import { b as be, D as Te, A as _e, g as lt } from "./core-D9RfS2Z8.js";
4
- import { t as Ue } from "./metricsReporter-DqmmYkn-.js";
5
- const ct = ({ properties: t, surveyVideoUrl: a, questionId: r }) => {
6
- const n = `ul-card-video__question_player-q${r}`, { apiURL: s, viewDocument: i } = O((l) => ({ apiURL: l.apiURL, viewDocument: l.viewDocument }));
7
- return e("div", { id: n, ref: (l) => {
8
- if (l && l.children.length === 0 && !t.properties.hideRecordedPrompt) {
9
- const u = Je(n, { src: a, type: "application/x-mpegURL" }, void 0, t.properties.mediaType === F.MEDIA_TYPE_AUDIO, s, i);
10
- l.appendChild(u);
11
- }
12
- } });
13
- }, se = ({ 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"] }), dt = ({ className: t, next: a, properties: r, questionId: n, type: s }) => {
14
- const { useMobileStyling: i, border: l } = O((_) => ({ useMobileStyling: _.useMobileStyling, border: _.border })), [u, c] = V(!1), [v, y] = V(""), [o, m] = V(!1), k = r == null ? void 0 : r.collectName, f = (r == null ? void 0 : r.nameLabelText) || "Full Name", h = (r == null ? void 0 : r.consentText) || "I agree to the stated conditions", S = (r == null ? void 0 : r.submitButtonText) || "Submit", N = !!v.trim(), P = u && (!k || N), E = (_, G = !1) => {
15
- _.preventDefault(), _.stopPropagation();
16
- let A = null;
17
- if (!G) {
18
- if (!P) return void m(!0);
19
- A = { submitted: !0 }, k && (A.name = v);
20
- }
21
- a({ value: A, questionId: n, type: s }, !!G || P);
22
- };
23
- return e("div", { className: R(t, "ul-card__consent-legal", "fade-in-transition"), children: e(J, { embeddedType: "pdf", properties: r, children: e(te, { children: [e("div", { className: "sprig-stretch", children: [e(Ce, { allowTextEntry: !1, border: l, error: o && !u, id: "consent", isRadio: !1, isSelected: u, label: h, onUserInputChanged: ({ selected: _ }) => {
24
- _ !== u && c(!u);
25
- }, useMobileStyling: i }), k && 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: (_) => {
26
- _.currentTarget.style.borderColor = o && !N ? be : Te;
27
- }, onFocus: (_) => {
28
- _.currentTarget.style.borderColor = o && !N ? be : l;
29
- }, onInput: (_) => {
30
- _.preventDefault(), _.stopPropagation(), y(_.currentTarget.value);
31
- }, 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(se, { isDisabled: !P, 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: xe(r) })] })] }) }) }, n);
32
- }, ut = () => {
33
- const { destroy: t, forceBrandedLogo: a } = O((r) => ({ destroy: r.destroy, forceBrandedLogo: r.forceBrandedLogo }));
34
- return ne(() => {
35
- setTimeout(() => {
36
- t(_e);
37
- }, a ? 4e3 : 2e3);
38
- }, [t, a]), e("div", { className: "end-of-survey-text", children: "End of survey" });
39
- }, pt = ({ activeValue: t, border: a, icon: r, enableCspTrustedTypes: n, isPressed: s, range: i, scaleLabelType: l, selectedValue: u, setSelectedValue: c, setActiveValue: v, setIsPressed: y, useMobileStyling: o, value: m, viewDocument: k }) => {
40
- const f = `option-${m}`, h = l === "number", S = l === "star", N = l === "smiley", P = h && m === t || m === u, [E, _] = (() => {
41
- const d = S && u !== null && m <= u;
42
- return S && m <= t || N && m === t || d || m === t || m === u ? [a, s || d || m === u ? 1 : 0.3] : ["", 1];
43
- })(), G = ce(() => {
44
- const d = { borderColor: P ? E : "", fillOpacity: P ? "" : _, zIndex: P ? 3 : "auto", color: u === m ? "#fff" : "" };
45
- return h ? { ...d, backgroundColor: u === m ? E : "" } : { ...d, color: S || N || u === m ? E : "" };
46
- }, [P, E, _, u, m, h, S, N]), A = ce(() => lt((({ icon: d, scaleLabelType: p, value: x, selectedValue: g }) => {
47
- if (p === "smiley" && x === g) {
48
- let b = 0;
49
- return d.replace(/black/g, () => ++b == 1 ? "black" : "white");
50
- }
51
- return d;
52
- })({ icon: r, scaleLabelType: l, value: m, selectedValue: u }), n), [n, r, l, u, m]);
53
- return e("button", { "aria-label": h ? void 0 : String(m), className: (() => {
54
- switch (l) {
55
- case "star":
56
- return R(j("likert-star", o), j(`likert-star-${m}`, o));
57
- case "smiley":
58
- return R(j("likert-smiley", o), j(`likert-smiley-${m}`, o));
59
- default:
60
- return m === i ? R(j("likert-number", o), j(`likert-number-${m}`, o), j("likert-last-option", o)) : R(j("likert-number", o), j(`likert-number-${m}`, o));
61
- }
62
- })(), dangerouslySetInnerHTML: { __html: A }, id: f, onClick: (d) => {
63
- d.preventDefault(), d.stopPropagation(), c(m);
64
- }, onKeyDown: (d) => {
65
- var g, b;
66
- const p = k.querySelectorAll(`.likert-${l ?? "number"}`), x = m - 1;
67
- d.key === "ArrowRight" ? (g = p[x + 1]) == null || g.focus() : d.key === "ArrowLeft" ? (b = p[x - 1]) == null || b.focus() : d.key !== "Enter" && d.key !== " " || (d.preventDefault(), d.stopPropagation(), c(m));
68
- }, onPointerDown: () => y(!0), onPointerEnter: () => v(m), onPointerLeave: () => {
69
- v(-1), y(!1);
70
- }, style: G, tabIndex: 0 });
71
- }, mt = ({ className: t, labels: a, next: r, properties: n, questionId: s, type: i }) => {
72
- const { border: l, useMobileStyling: u, viewDocument: c, enableCspTrustedTypes: v } = O((p) => ({ border: p.border, useMobileStyling: p.useMobileStyling, viewDocument: p.viewDocument, enableCspTrustedTypes: p.enableCspTrustedTypes })), [y, o] = V(-1), [m, k] = V(!1), [f, h] = V(null), S = a && a.left, N = a && a.right;
73
- let P;
74
- const { range: E, scaleLabelType: _, ratingIcons: G } = n;
75
- E && (P = Number(E));
76
- const A = P || 5, d = (p) => {
77
- var x, g;
78
- switch (_) {
79
- case "star":
80
- return (x = G[0]) == null ? void 0 : x.svg;
81
- case "smiley":
82
- return (g = G[p]) == null ? void 0 : g.svg;
83
- default:
84
- return String(p + 1);
85
- }
86
- };
87
- return e("form", { className: R(t, "ul-card--likert", "fade-in-transition"), children: e(J, { properties: n, children: [e(re, { children: [e("div", { "aria-label": `Rating (1 - ${A})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(A)].map((p, x) => {
88
- const g = x + 1;
89
- return e(pt, { activeValue: y, border: l, enableCspTrustedTypes: v, icon: d(x), isPressed: m, range: A, scaleLabelType: _, selectedValue: f, setActiveValue: o, setIsPressed: k, setSelectedValue: h, useMobileStyling: u, value: g, viewDocument: c }, x);
90
- }) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: S }), e("span", { children: N })] })] }), e(te, { children: e(se, { isDisabled: f === null && n.required, onClick: () => r({ value: f, questionId: s, type: i }, !0), children: X(n) }) })] }) }, s);
91
- }, ht = ({ columns: t, onSelect: a, options: r, selectedOptions: n }) => {
92
- const s = ee([]), { border: i, useMobileStyling: l } = O((m) => ({ border: m.border, useMobileStyling: m.useMobileStyling })), u = r.findIndex((m) => n[m.id] === null), [c, v] = V(u), y = le((m, k) => {
93
- a(m, k);
94
- const f = c + 1, h = r[f];
95
- h && n[h.id] === null && v(f);
96
- }, [a, r, n, c]), o = le((m, k) => {
97
- const f = c === m;
98
- return e(Fe, { animate: !0, header: k.label, isOpen: f, onClick: () => {
99
- var h;
100
- return v(f && !((h = window.UserLeap) != null && h.isMobileSDK) ? -1 : m);
101
- }, ref: (h) => {
102
- h && (s.current[m] = h);
103
- }, showHeaderCheck: n[k.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: t.map((h) => e(Ce, { allowTextEntry: !1, ariaLabel: `${k.label}-${h.label}`, border: i, error: !1, id: `${k.id}-${h.value}`, isRadio: !0, isSelected: n[k.id] === h.value, label: h.label, onUserInputChanged: () => y(k.id, h.value), useMobileStyling: l }, h.label)) }) }, k.id);
104
- }, [i, t, c, y, n, l]);
105
- return e("div", { children: r.map((m, k) => o(k, m)) });
106
- }, gt = ({ className: t, next: a, options: r, properties: n, questionId: s, type: i, onSubmitButtonClick: l }) => {
107
- const u = n.matrixColumn, c = n.required, v = (f) => {
108
- f.preventDefault(), f.stopPropagation(), a({ value: o, questionId: s, type: i }, !0), l && l();
109
- }, y = r.reduce((f, h) => (f[h.id] = null, f), {}), [o, m] = V(y);
110
- return e("form", { className: R(t, "ul-card__matrix", "fade-in-transition"), id: "text-form", onSubmit: v, children: e(J, { properties: n, children: [e(re, { children: e(ht, { columns: u, onSelect: (f, h) => {
111
- m((S) => ({ ...S, [f]: h }));
112
- }, options: r, selectedOptions: o }) }), e(te, { children: e(se, { isDisabled: (k = o, c && Object.values(k).every((f) => f == null)), onClick: () => v(new SubmitEvent("submit")), children: X(n) }) })] }) }, s);
113
- var k;
114
- }, Ee = ({ className: t, onSubmit: a, options: r = [], properties: n, questionId: s, type: i, showIndividualSubmit: l = !1, onSubmitButtonClick: u }) => {
115
- const { border: c, useMobileStyling: v } = O((g) => ({ border: g.border, useMobileStyling: g.useMobileStyling })), y = r.reduce((g, b) => (g[b.id] = { isSelected: !1 }, g), {}), [o, m] = V(y), k = i === "multiplechoice", f = n.required, h = r.find((g) => {
116
- var b;
117
- return (b = g.optionProperties) == null ? void 0 : b.noneOfTheAbove;
118
- }), S = (g) => Object.entries(g).some(([b, I]) => {
119
- var Q;
120
- const w = r.find((z) => `${z.id}` === b), L = I.userText === void 0 || I.userText.trim() === "";
121
- return ((Q = w == null ? void 0 : w.optionProperties) == null ? void 0 : Q.allowsTextEntry) && L && I.isSelected;
122
- }), N = (g) => Object.values(g).filter((b) => b.isSelected).length, P = n.minSelect && n.minSelect > 0 && n.maxSelectMode === pe.Range && N(o) < n.minSelect && (f || N(o) > 0), E = (g) => S(g) || f && !N(g) || !((b) => {
123
- const { minSelect: I = 0, maxSelect: w = 1 / 0, maxSelectMode: L } = n, Q = N(b);
124
- switch (L) {
125
- case pe.Maximum:
126
- return Q <= w;
127
- case pe.Range:
128
- return Q === 0 || Q >= I;
129
- default:
130
- return !0;
131
- }
132
- })(g), _ = Object.entries(o).some(([g, b]) => {
133
- var I, w;
134
- return b.isSelected && ((w = (I = r.find((L) => `${L.id}` === g)) == null ? void 0 : I.optionProperties) == null ? void 0 : w.allowsTextEntry);
135
- }), G = l && (!k || _), A = (g) => {
136
- x(g.id, g.selected, g.userText, g.noneOfTheAbove);
137
- }, d = (g) => {
138
- var b;
139
- return (n == null ? void 0 : n.maxSelectMode) !== pe.Unlimited && N(o) === (n == null ? void 0 : n.maxSelect) && !((b = o[g]) != null && b.isSelected);
140
- }, p = () => {
141
- a(o, !0), u && u();
142
- }, x = (g, b, I, w) => {
143
- const L = Object.assign({}, o);
144
- if ((k || w) && b) for (const Q of Object.values(L)) Q.isSelected = !1, delete Q.userText;
145
- else h && !w && o[h.id].isSelected && (L[h.id].isSelected = !1);
146
- L[g] = { isSelected: b, userText: I }, m(L);
147
- };
148
- return e("form", { className: R(t, "ul-card--multiple", "fade-in-transition"), id: "text-form", onSubmit: p, children: e(J, { properties: n, children: [e(re, { children: [n.isDropdown ? e(et, { disabledOptions: r.filter((g) => d(g.id)), dropdownFooter: P ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [N(o), "/", n.minSelect] }) : void 0, isMultiSelect: !k, multiselectText: n.dropdownMultiselectedText ?? "choices selected", onChange: (g) => {
149
- const b = { ...o };
150
- for (const I of r) g.includes(I) ? b[I.id].isSelected = !0 : b[I.id].isSelected = !1;
151
- m(b);
152
- }, options: r, placeholderText: n.dropdownPlaceholderText ?? (k ? "Select choice" : "Select choice(s)"), value: r.filter((g) => o[g.id].isSelected) }) : e("div", { className: R(j("ul-card__choices", v)), role: k ? "radiogroup" : "group", children: [r.map(({ id: g, label: b, value: I, optionProperties: w }) => {
153
- var H, Z;
154
- const L = `${g}`, { allowsTextEntry: Q, noneOfTheAbove: z } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...w };
155
- return e(Ce, { allowTextEntry: Q, border: c, disabled: d(L), error: ($ = o, S($)), id: L, isRadio: k, isSelected: !!((H = o[L]) != null && H.isSelected), label: b, noneOfTheAbove: z, onUserInputChanged: A, promptText: (w == null ? void 0 : w.otherOptionPlaceholder) || "Please specify", text: (Z = o[g]) == null ? void 0 : Z.userText, useMobileStyling: v, value: I }, L);
156
- var $;
157
- }), !!P && e("div", { className: "ul-card__min-select-counter", children: [N(o), "/", n.minSelect] })] }), G && e(tt, { handleSubmit: p, isSubmitDisabled: E(o) })] }), e(te, { children: e(se, { isDisabled: E(o), onClick: p, children: X(n) }) })] }) }, s);
158
- }, vt = (t) => {
159
- const { questionId: a, type: r, next: n, options: s } = t;
160
- return e(Ee, { ...t, onSubmit: (i, l) => {
161
- const u = Object.entries(i).find(([, m]) => m.isSelected) || [void 0, void 0], [c, v] = u, y = s.find((m) => `${m.id}` === c), o = v != null && v.userText ? { [c]: { userText: v.userText } } : null;
162
- n({ value: y && c ? { [c]: y.value } : {}, secondaryValue: o, questionId: a, type: r }, l);
163
- } });
164
- }, bt = (t) => {
165
- const { questionId: a, type: r, next: n } = t;
166
- return e(Ee, { ...t, onSubmit: (s, i) => {
167
- const l = Object.entries(s).reduce((c, [v, y]) => (c[v] = y.isSelected, c), {}), u = Object.entries(s).reduce((c, [v, y]) => {
168
- if (!y.userText) return c;
169
- const o = c || {};
170
- return o[v] = { userText: y.userText }, o;
171
- }, null);
172
- n({ value: l, secondaryValue: u, questionId: a, type: r }, i);
173
- } });
174
- }, yt = ({ className: t, labels: a, properties: r, next: n, questionId: s, type: i }) => {
175
- const [l, u] = V(null), { border: c, useMobileStyling: v, viewDocument: y } = O((k) => ({ border: k.border, useMobileStyling: k.useMobileStyling, viewDocument: k.viewDocument })), o = a && a.left, m = a && a.right;
176
- return e("form", { className: R(t, "ul-card--nps", "fade-in-transition"), children: e(J, { properties: r, children: [e(re, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((k, f) => e("button", { className: R(j("nps-number", v), j(`nps-number-${f}`, v)), id: `option-${f}`, onClick: (h) => {
177
- h.preventDefault(), h.stopPropagation(), u(f);
178
- }, onKeyDown: (h) => {
179
- var N, P;
180
- const S = y.querySelectorAll("button.nps-number");
181
- h.key === "ArrowRight" ? (N = S[f + 1]) == null || N.focus() : h.key === "ArrowLeft" ? (P = S[f - 1]) == null || P.focus() : h.key !== "Enter" && h.key !== " " || (h.preventDefault(), h.stopPropagation(), u(f));
182
- }, onPointerDown: (h) => {
183
- h.currentTarget.style.zIndex = "2", h.currentTarget.style.borderColor = c;
184
- }, onPointerLeave: (h) => {
185
- h.currentTarget.style.zIndex = "auto", h.currentTarget.style.borderColor = Te;
186
- }, style: l === f ? { backgroundColor: c, color: "#fff" } : void 0, tabIndex: 0, children: f }, f)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: o }), e("span", { children: m })] })] }), e(te, { children: e(se, { isDisabled: l === null && r.required, onClick: () => n({ value: l, questionId: s, type: i }, !0), children: X(r) }) })] }) }, s);
187
- }, ft = ({ className: t, next: a, properties: r, questionId: n, type: s, onSubmitButtonClick: i }) => {
188
- const { border: l, useMobileStyling: u, update: c } = O((S) => ({ border: S.border, useMobileStyling: S.useMobileStyling, update: S.update })), [v, y] = V(""), o = ee(null), m = v.trim(), k = r.required === !0 && !m, f = rt(o, () => c()), h = r && r.openTextPlaceholder ? r.openTextPlaceholder : "";
189
- 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(re, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": h, className: R(j("ul-card-text__input", u)), "data-gramm": "false", maxLength: 5e3, name: "text", onBlur: (S) => {
190
- S.currentTarget.style.borderColor = Te;
191
- }, onChange: (S) => {
192
- const { value: N } = S.currentTarget;
193
- f(), S.preventDefault(), S.stopPropagation(), y(N);
194
- }, onFocus: (S) => {
195
- S.currentTarget.style.borderColor = l;
196
- }, placeholder: h, ref: o, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(de, { className: "footer", html: r.footerHtml })] }), e(te, { children: e(se, { isDisabled: k, onClick: (S) => {
197
- S.preventDefault(), S.stopPropagation();
198
- const N = r.required !== !0 || m.length > 0;
199
- a({ value: v, questionId: n, type: s }, N), i && i();
200
- }, children: X(r) }) })] }) }) }, n);
201
- }, kt = ({ className: t, labels: a, next: r, properties: n, questionId: s, type: i, onSubmitButtonClick: l, options: u }) => {
202
- const c = ee(null), v = ee(0), y = ee(0), o = ee(null), m = ee(!1), k = ee([]), [f, h] = V(() => (n == null ? void 0 : n.required) === !0), [S, N] = V(() => u.map((C) => ({ ...C, rank: null }))), P = ce(() => Array.from({ length: u.length }, (C, D) => D + 1), [u.length]), { useMobileStyling: E, isPreview: _, headers: G } = O((C) => ({ useMobileStyling: C.useMobileStyling, isPreview: C.isPreview, headers: C.headers })), A = (G == null ? void 0 : G["userleap-platform"]) === "android", d = E && !_ && !A, p = !d && !A, x = (C, D) => {
203
- N((q) => {
204
- const T = parseInt(D), U = q.map((M) => ({ ...M }));
205
- U.some((M) => M.rank == null) && U.forEach((M, ie) => M.rank = ie + 1);
206
- const Y = U.findIndex((M) => M.id === C);
207
- if (Y === -1) return q;
208
- const B = U[Y].rank;
209
- return T < B ? U.forEach((M) => {
210
- M.id !== C && M.rank >= T && M.rank < B && (M.rank = M.rank + 1);
211
- }) : T > B && U.forEach((M) => {
212
- M.id !== C && M.rank > B && M.rank <= T && (M.rank = M.rank - 1);
213
- }), U[Y].rank = T, U.sort((M, ie) => M.rank - ie.rank), z(), U;
214
- });
215
- }, g = (C, D) => {
216
- for (let q = 0; q < k.current.length; q++) {
217
- const T = k.current[q];
218
- if (!T || T === o.current) continue;
219
- const U = T.getBoundingClientRect();
220
- if (C >= U.left && C <= U.right && D >= U.top && D <= U.bottom) return { element: T, index: q };
221
- }
222
- return null;
223
- }, b = (C) => (D) => {
224
- if (!d) return;
225
- D.preventDefault(), D.stopPropagation(), m.current = !0, c.current = C;
226
- const q = D.touches[0];
227
- v.current = q.clientY, y.current = q.clientY;
228
- const T = D.currentTarget.closest(".ul-card-rank__option");
229
- T && (o.current = T, T.classList.add("is-dragging"));
230
- }, I = (C) => {
231
- if (!d || !m.current || c.current === null) return;
232
- C.preventDefault(), C.stopPropagation();
233
- const D = C.touches[0];
234
- y.current = D.clientY;
235
- const q = y.current - v.current;
236
- o.current && (o.current.style.transform = `translateY(${q}px)`, o.current.style.zIndex = "1000"), k.current.forEach((U) => {
237
- U && U !== o.current && U.classList.remove("is-drop-target");
238
- });
239
- const T = g(D.clientX, D.clientY);
240
- T && T.element.classList.add("is-drop-target");
241
- }, w = (C) => {
242
- if (!d || !m.current || c.current === null) return;
243
- C.preventDefault(), C.stopPropagation();
244
- const D = C.changedTouches[0], q = g(D.clientX, D.clientY);
245
- o.current && (o.current.style.transform = "", o.current.style.zIndex = "", o.current.classList.remove("is-dragging")), k.current.forEach((T) => {
246
- T && T.classList.remove("is-drop-target");
247
- }), q && q.index !== c.current && L(c.current, q.index), c.current = null, o.current = null, m.current = !1;
248
- }, L = (C, D) => {
249
- N((q) => {
250
- const T = q.map((Y) => ({ ...Y })), [U] = T.splice(C, 1);
251
- return T.splice(D, 0, U), T.forEach((Y, B) => {
252
- Y.rank = B + 1;
253
- }), z(), T;
254
- });
255
- }, Q = (C) => {
256
- const D = {};
257
- C.reduce((q, T) => (q[T.id] = T.rank, q), D), r({ value: D, questionId: s, type: i }, !0);
258
- }, z = () => {
259
- h(!1);
260
- }, { left: $, right: H } = a, Z = u.length, ae = (C) => {
261
- C.preventDefault(), C.currentTarget.classList.add("is-drop-target");
262
- }, ue = (C) => {
263
- C.currentTarget.classList.remove("is-drop-target");
264
- }, je = (C) => {
265
- c.current = null, C.currentTarget.classList.remove("is-dragging");
266
- };
267
- return e("form", { className: R(t, "ul-card-rank", "fade-in-transition"), onSubmit: (C) => {
268
- C.preventDefault(), Q(S), l && l();
269
- }, children: e(J, { properties: n, children: e(he, A ? { children: [e(re, { children: e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", $] }) }), e("ol", { className: "ul-card-rank__list", children: S.map(({ id: C, label: D, rank: q }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${D}`, className: R("ul-card-rank__select", q == null && "ul-card-rank__select--placeholder"), name: `rank[${C}]`, onChange: (T) => x(C, T.currentTarget.value), value: q ?? "", children: [q == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), P.map((T) => e("option", { className: "ul-card-rank__select-option", value: T, children: T }, `${T}-${s}`))] }), e("span", { children: D })] }, C)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [Z, " - ", H] }) })] }) }), e(te, { children: e("div", { className: "ul-card__button-wrapper", children: e(W, { disabled: f, children: X(n) }) }) })] } : { children: [e(re, { children: e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", $] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: A ? void 0 : (C) => {
270
- C.preventDefault(), C.dataTransfer && (C.dataTransfer.dropEffect = "move");
271
- }, children: S.map(({ id: C, label: D, rank: q }, T) => {
272
- return e("li", { className: "ul-card-rank__option", draggable: !!p || void 0, onDragEnd: p ? je : void 0, onDragEnter: p ? ae : void 0, onDragLeave: p ? ue : void 0, onDragStart: p ? (Y = T, (B) => {
273
- c.current = Y, B.dataTransfer && (B.dataTransfer.effectAllowed = "move", B.dataTransfer.setData("text/plain", String(Y)), B.currentTarget.classList.add("is-dragging"));
274
- }) : void 0, onDrop: p ? (U = T, (B) => {
275
- var ie, we;
276
- B.preventDefault(), B.currentTarget.classList.remove("is-drop-target");
277
- const M = c.current;
278
- c.current = null, (we = (ie = B.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : ie.querySelector(".is-dragging")) == null || we.classList.remove("is-dragging"), M != null && M !== U && L(M, U);
279
- }) : void 0, ref: (B) => k.current[T] = B, children: [e("select", { "aria-label": `Rank for ${D}`, className: R("ul-card-rank__select", q == null && "ul-card-rank__select--placeholder"), name: `rank[${C}]`, onChange: (B) => x(C, B.currentTarget.value), value: q ?? "", children: [q == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), P.map((B) => e("option", { className: "ul-card-rank__select-option", value: B, children: B }, B))] }), e("span", { children: D }), !A && e("button", { "aria-label": `Drag ${D} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: d ? w : void 0, onTouchMove: d ? I : void 0, onTouchStart: d ? 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);
280
- var U, Y;
281
- }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [Z, " - ", H] }) })] }) }), e(te, { children: e("div", { className: "ul-card__button-wrapper", children: e(W, { disabled: f, children: X(n) }) }) })] }) }) }, s);
282
- }, ye = 1, Ae = 2, Be = 3, me = (t) => t.type === "av_permission", qe = (t) => t.type === "screen_permission", $e = (t, a) => t === void 0 ? ye : t ? ((r, n) => !(me(n) ? n.permissionDescriptors : []).includes("camera") || r.getVideoTracks().length > 0)(t, a) ? Be : ye : Ae, Pe = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
283
- }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, K = Ze((t) => ({ ...Pe, reset: () => {
284
- t(Pe);
285
- }, updatePage: (a) => {
286
- t(a);
287
- } }));
288
- function fe({ currentPage: t, pages: a }) {
289
- const { avStream: r, recordingMediaTypes: n, updatePage: s } = K.getState(), { recorderEventEmitter: i } = O.getState();
290
- i.emit("av.permission", { "permission.descriptors": t.permissionDescriptors, "stream.ready": (l, u) => {
291
- if (r === l) return;
292
- let c = t;
293
- if (l && !t.permissionDescriptors.includes("camera")) {
294
- const v = a.indexOf(t), y = u != null && u.active ? v + 2 : v + 1;
295
- u != null && u.active && n && i.emit("begin.recording", { "recording.media.types": n, "start.recording.callback": (o) => s({ mediaRecordingUids: o }) }), c = a[y];
296
- }
297
- s({ currentPage: c, avStream: l });
298
- } });
299
- }
300
- function ke({ status: t }) {
301
- const { nextQuestion: a, passthroughData: r, mediaRecordingUids: n, reset: s } = K.getState(), { recorderEventEmitter: i, handleUploadUpdate: l, index: u } = O.getState(), c = { value: { taskStatus: t }, type: "recordedtask", questionId: (r == null ? void 0 : r.questionId) || 1 };
302
- r && i.emit("finish.task", { "begin.callback": (v) => {
303
- l({ mediaRecordingUid: v, isSubmitted: !0, progressPct: 0, isComplete: !1 });
304
- }, "progress.callback": (v, y) => {
305
- l({ mediaRecordingUid: v, progressPct: y.detail, isSubmitted: !1, isComplete: !1 });
306
- }, "upload.callback": (v) => {
307
- v && l({ mediaRecordingUid: v, isComplete: !0, isSubmitted: !0, progressPct: 100 });
308
- }, "passthrough.data": r, "current.index": u, "task.response": c, "task.complete.callback": (v) => {
309
- c.value.taskDurationMillisecond = v, n && (c.value.mediaRecordingUids = n), s(), a(c);
310
- } });
311
- }
312
- function Ne({ pages: t, setIsRequestingPermission: a }) {
313
- const { recorderEventEmitter: r, eventEmitFn: n } = O.getState(), { updatePage: s, currentPage: i, recordingMediaTypes: l, screenPermissionRequested: u } = K.getState();
314
- if (!i) return;
315
- const c = t.indexOf(i);
316
- switch (i.type) {
317
- case "av_permission": {
318
- const v = u ? c + 2 : c + 1;
319
- return u && l && r.emit("begin.recording", { "recording.media.types": l, "start.recording.callback": (y) => {
320
- s({ mediaRecordingUids: y });
321
- } }), void s({ currentPage: t[v] });
322
- }
323
- case "screen_permission":
324
- return void r.emit("screen.permission", { "screen.permission.requested": a, "stream.ready.callback": (v, y) => {
325
- const o = y ? t[c + 1] : i;
326
- y && l && r.emit("begin.recording", { "recording.media.types": l, "start.recording.callback": (m) => {
327
- s({ captureStream: y, mediaRecordingUids: m });
328
- } }), s({ currentPage: o, screenPermissionRequested: !0, captureStream: y });
329
- } });
330
- case "start_task":
331
- return n("recorded.task.start"), r.emit("recorded.task.start"), r.emit("start.task"), void s({ currentPage: t[c + 1], screenPermissionRequested: !0 });
332
- case "complete_task":
333
- return;
334
- }
335
- }
336
- const Oe = "ul-permission-graphics-container", Qe = "ul-permission-body", He = R(Oe, "ul_recorded-task-inset-spacing"), ge = R("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Ve = ({ 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: ke.bind(null, { status: "abandoned" }), children: a || "Skip" }), Ie = (t) => {
337
- 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"));
338
- ne(() => {
339
- const l = setInterval(() => {
340
- i && a && !a.active ? s({ avStream: null, currentPage: t[0] }) : r && r.active || s({ captureStream: void 0, currentPage: t[i ? 1 : 0] });
341
- }, 1e3);
342
- return () => clearInterval(l);
343
- }, [a, r, i, t, n, s]);
344
- }, xt = ({ content: t, pages: a, required: r }) => {
345
- const { buttonText: n, skipButtonText: s, taskDetail: i } = t;
346
- return Ie(a), e("div", { className: "ul-task-page", children: [i && e(Ve, { richTextBody: i }), e("div", { className: ge, children: [e(W, { onClick: Ne.bind(null, { pages: a }), children: n }), e(ve, { required: r, skipButtonText: s })] })] }, "start-task");
347
- }, Ct = ({ content: t, pages: a, properties: r }) => {
348
- const { buttonText: n, skipButtonText: s } = t;
349
- return Ie(a), e("div", { className: "ul-task-page", children: [t.taskDetail && e(Ve, { richTextBody: t.taskDetail }), e(J, { properties: r, children: e("div", { className: ge, children: [e(W, { className: "ul-complete-task-button", onClick: ke.bind(null, { status: "completed" }), children: n }), e(W, { className: R("ul-button-inactive"), onClick: ke.bind(null, { status: "given.up" }), children: s })] }) })] }, "complete-task");
350
- }, St = ({ content: t, pages: a, required: r }) => {
351
- const { buttonText: n, skipButtonText: s } = t, [i] = O((c) => [c.tabTitle]), [l, u] = V(!1);
352
- return e("div", { children: [e("div", { className: He, children: [e("p", { style: { marginTop: "auto" }, children: t.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Qe, children: i }) })] }), e("div", { className: r ? "" : ge, children: [e(W, { disabled: l, onClick: Ne.bind(null, { pages: a, setIsRequestingPermission: u }), children: n }), e(ve, { required: r, skipButtonText: s })] })] });
353
- }, Tt = ({ content: t }) => e(de, { className: R(Oe, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: t.svg }, "ul-permission-request-graphic"), _t = ({ content: t, pages: a, required: r }) => {
354
- const { permissionDeniedHeadline: n, permissionDeniedBody: s, skipButtonText: i, tryAgainButtonText: l } = t, u = me(a[0]) ? a[0] : null;
355
- return ne(() => {
356
- const c = setInterval(() => {
357
- u !== null && fe({ currentPage: u, pages: a });
358
- }, 1e3);
359
- return () => clearInterval(c);
360
- }, [u, a]), u ? e("div", { children: [e("div", { className: He, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: n }), e("span", { className: Qe, children: s })] }) }), e("div", { className: ge, children: [e(W, { onClick: fe.bind(null, { currentPage: u, pages: a }), children: l }), e(ve, { required: r, skipButtonText: i })] })] }) : null;
361
- }, Nt = ({ stream: t }) => e("video", { autoPlay: !0, className: R("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (a) => {
362
- a && (a.srcObject = t || null);
363
- } }), It = ({ content: t, pages: a, required: r }) => {
364
- const { skipButtonText: n } = t, { avStream: s } = K.getState();
365
- return Ie(a), e("div", { children: [e(Nt, { stream: s }), e("div", { className: "ul-vertical-button-container-center", children: [e(W, { onClick: Ne.bind(null, { pages: a }), children: t.buttonText }), e(ve, { bottom: !0, required: r, skipButtonText: n })] })] });
366
- }, wt = ({ properties: t }) => {
367
- const { pages: a, required: r } = t, { avStream: n, currentPage: s } = K.getState();
368
- if (s === void 0) return null;
369
- switch (s == null ? void 0 : s.type) {
370
- case "av_permission": {
371
- const i = $e(n, s);
372
- return i === ye ? e(Tt, { content: s }) : e(i === Ae ? _t : It, { content: s, pages: a, required: r });
373
- }
374
- case "screen_permission":
375
- return e(St, { content: s, pages: a, required: r });
376
- case "start_task":
377
- return e(xt, { content: s, pages: a, required: r });
378
- case "complete_task":
379
- return e(Ct, { content: s, pages: a, properties: t });
380
- default:
381
- return null;
382
- }
383
- }, Dt = ({ className: t, properties: a, next: r, questionId: n }) => {
384
- const s = O(), { surveyId: i, responseGroupUid: l, userId: u } = s, c = K(), { screenPermissionRequested: v } = c, y = K((h) => h.avStream);
385
- let o = K((h) => h.currentPage);
386
- o || (o = function({ pages: h, userId: S, responseGroupUid: N, surveyId: P, questionId: E, next: _ }) {
387
- const { updatePage: G } = K.getState(), { eventEmitFn: A, recorderEventEmitter: d } = O.getState(), p = { questionId: E, surveyId: P, visitorId: S, responseGroupUid: N };
388
- let x = 0;
389
- d.emit("recorded.task.permission.screen"), A("recorded.task.permission.screen"), d.emit("permission.status", { "permission.status.callback": (b, I, w, L) => {
390
- const Q = h[x], { type: z } = Q, $ = ["screen"];
391
- if (me(Q)) {
392
- const { permissionDescriptors: H } = Q, Z = H == null ? void 0 : H.includes("microphone"), ae = H == null ? void 0 : H.includes("camera");
393
- Z && $.push("audio"), ae && $.push("video"), (b != null && b.active && !ae || b != null && b.active && I) && x++;
394
- }
395
- qe(h[x]) && w && (x++, d.emit("begin.recording", { "recording.media.types": $, "start.recording.callback": (H) => G({ mediaRecordingUids: H }) })), G({ currentPage: h[x], avStream: b, screenPermissionRequested: w, nextQuestion: _, type: z, passthroughData: p, recordingMediaTypes: $, captureStream: L });
396
- } });
397
- const g = h[x];
398
- return g.type === "av_permission" && fe({ currentPage: g, pages: h }), g;
399
- }({ questionId: n, surveyId: i, next: (h) => {
400
- r(h, !0);
401
- }, pages: a.pages, responseGroupUid: l, userId: u }));
402
- let m = o.headline, k = o.captionText;
403
- const f = $e(y, o);
404
- return qe(o) && v && (m = o.permissionDeniedHeadline, k = o.permissionDeniedCaptionText), me(o) && f === Be && (m = o.permissionGrantedHeadline, k = o.permissionGrantedCaptionText), e("div", { className: R(t, "ul-center-horizontally", "fade-in-transition"), children: [e(Se, { isRequired: a == null ? void 0 : a.required, message: m, properties: { captionText: k } }), e(re, { children: e(wt, { properties: a }) })] });
405
- }, qt = ({ className: t, next: a, properties: r, questionId: n, type: s }) => {
406
- const { visitorAttributes: i, isLongFormSurvey: l } = O((y) => ({ visitorAttributes: y.visitorAttributes, isLongFormSurvey: Ue(y.studyType) })), u = (y, o = !1) => {
407
- a({ value: o ? { skipped: !0 } : void 0, questionId: n, type: s }, !0);
408
- }, c = nt(r && r.buttonUrl, i), v = l && r.promptActionType === at.NO_BUTTON;
409
- 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: c, id: "ul-card-text__button", onClick: u, onKeyPress: (y) => {
410
- y.key !== "Enter" && y.key !== " " || a({ value: void 0, questionId: n, type: s }, !0);
411
- }, rel: "noreferrer", role: c ? "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: xe(r) })] }) }) }) }, n);
412
- }, Pt = ({ className: t, questionId: a }) => {
413
- const { border: r, destroy: n, endCard: s, forceBrandedLogo: i } = O((c) => ({ border: c.border, destroy: c.destroy, endCard: c.endCard, forceBrandedLogo: c.forceBrandedLogo }));
414
- ne(() => {
415
- setTimeout(() => {
416
- n(_e);
417
- }, i ? 4e3 : 2e3);
418
- }, [n, i]);
419
- const l = s && s.subheader ? e("p", { className: "ul-caption", children: s.subheader }) : null, u = s && s.headline ? s.headline : "";
420
- 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(Se, { message: u }), l] }) }) }, a);
421
- }, Lt = () => e("div", { className: "thinking-dots-container", children: e("div", { className: "thinking-dot" }) }), Rt = ({ className: t }) => {
422
- const { uploadProgress: a } = O((i) => ({ uploadProgress: i.uploadProgress }));
423
- let r, n;
424
- 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.");
425
- const s = Math.round(Math.min(99, ...Object.values(a).filter((i) => i.isSubmitted).map((i) => i.progressPct || 0)));
426
- 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(Se, { message: `${r} (${s}% complete)` }), e("p", { className: "ul-caption", children: n })] });
427
- }, Le = 0, Re = 1, Mt = ({ className: t, next: a, properties: r, questionId: n, type: s }) => {
428
- const i = `ul-card-video__player_recorder-q${n}`, { apiURL: l, envId: u, handleUploadUpdate: c, headers: v, responseGroupUid: y, surveyId: o, viewDocument: m, visitorId: k } = O((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, h] = V(!1), [S, N] = V(null), [P, E] = V(null), [_, G] = V(Le), A = (p, x) => {
429
- p === F.UPLOAD_STARTED ? (N(x[F.UPLOAD_ID]), E(x[F.MEDIA_RECORDING_UID]), h(!0)) : p === F.DELETE ? (N(null), E(null), h(!1)) : p === F.UPLOAD_PROGRESS ? isNaN(x[F.UPLOAD_PROGRESS_PCT]) ? c({ mediaRecordingUid: x[F.MEDIA_RECORDING_UID], isComplete: !0 }) : c({ mediaRecordingUid: x[F.MEDIA_RECORDING_UID], progressPct: x[F.UPLOAD_PROGRESS_PCT] }) : p === F.UPLOAD_FINISHED && c({ mediaRecordingUid: x[F.MEDIA_RECORDING_UID], isComplete: !0 });
430
- }, d = (p) => {
431
- p.preventDefault(), p.stopPropagation(), document.getElementById(i) && ot(i), S && P ? (c({ mediaRecordingUid: P, isSubmitted: !0 }), a({ value: { mediaRecordingUid: P }, questionId: n, type: s }, !0)) : a({ value: null, questionId: n, type: s }, !0);
432
- };
433
- return e("form", { className: R(t, "ul-card--video", "fade-in-transition"), id: "ul-video-interview-form", children: [e(re, { children: [e("div", { id: "ul-question-player-container", style: { display: _ === Le ? "" : "none" }, children: e(J, { properties: r, children: e("button", { className: "ul-video-btn ul-record-response-btn", onClick: (p) => {
434
- p.preventDefault(), p.stopPropagation(), document.getElementById(i) && st(i), G(Re);
435
- } }) }) }), e("div", { style: { display: _ === Re ? "block" : "none" }, children: e("div", { id: "ul-recorder-player-container", ref: (p) => {
436
- if (p && p.children.length === 0) {
437
- const x = it(i, { surveyId: o, responseGroupUid: y, questionId: n, visitorId: k, envId: u }, l, A, void 0, { ...v, "x-ul-video-recorder-origin": "sdk" }, r.mediaType === F.MEDIA_TYPE_AUDIO, m);
438
- p.appendChild(x);
439
- }
440
- } }) })] }), e(te, { children: [e(se, { isDisabled: !!r.required && !f, onClick: d, children: X(r) }), e("button", { className: "ul-card-text__button ul-button-inactive ul-card-skip__button", id: "ul-card-video__skip_button", onClick: d, style: { ...r.required ? { display: "none" } : {}, ...f ? { display: "none" } : {} }, children: xe(r) })] })] });
441
- }, Ge = (t) => t.type === "thanks" || t.type === "uploading", Ut = ({ card: t, avatars: a, isThinking: r, isCurrentQuestion: n, currentQuestionBubbleRef: s }) => {
442
- 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);
443
- return e(oe, { avatars: a, isLeft: !0, message: { id: `question-${t.name}`, type: "question", content: i.content }, ref: n ? s : null, children: r ? e(Lt, {}) : 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(ct, { properties: t.props, questionId: t.name, surveyVideoUrl: t.props.properties.videoUrl })] }) });
444
- }, Et = ({ card: t, avatars: a }) => {
445
- const r = ((n) => {
446
- if (!("properties" in n.props) || !n.props.properties || typeof n.props.properties != "object") return null;
447
- const s = n.props.properties, i = [{ key: "captionHtml", isHtml: !0 }, { key: "captionText", isHtml: !1 }, { key: "richTextBody", isHtml: !0 }, { key: "body", isHtml: !1 }];
448
- for (const { key: l, isHtml: u } of i) {
449
- const c = s[l];
450
- if (typeof c != "string") continue;
451
- const v = c.trim();
452
- if (v) {
453
- if (u && !v.replaceAll(/<[^>]*>/g, "").trim()) continue;
454
- return { content: v, isHtml: u };
455
- }
456
- }
457
- return null;
458
- })(t);
459
- return r ? e(oe, { 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;
460
- }, At = ({ card: t, userResponse: a, avatars: r }) => {
461
- const n = ((s, i) => {
462
- if (s.type === "open" && i && typeof i == "object" && "value" in i) return i.value;
463
- })(t, a);
464
- 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` })] });
465
- }, Bt = ({ card: t, avatars: a, isCurrentQuestion: r, currentQuestionBubbleRef: n }) => {
466
- const { endCard: s } = O((i) => ({ endCard: i.endCard }));
467
- return e(he, { children: [e(oe, { 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(oe, { avatars: a, hideAvatar: !0, isLeft: !0, message: { id: `caption-${t.name}`, type: "question", content: s.subheader } }), e(ut, {})] });
468
- }, $t = ({ card: t, cardIndex: a, index: r, avatars: n, cardResponses: s, questionThinkingStates: i, startingQuestionIdx: l, currentQuestionBubbleRef: u, handleCardResponse: c }) => {
469
- const v = a === r, y = a < r, o = Ge(t);
470
- if (o) return e(Bt, { avatars: n, card: t, currentQuestionBubbleRef: u, isCurrentQuestion: v });
471
- const m = `${t.name}`, k = s.get(m), f = t.type === "open", h = i.get(m);
472
- if (t.type === "aidynamicfollowup" && (t.props.loading === null || t.props.loading === void 0)) return e(he, {});
473
- const S = a > (l ?? 0) && t.type !== "thanks" && t.type !== "uploading" && (h === !0 || h === void 0);
474
- return e(Me.Fragment, { children: [e(Ut, { avatars: n, card: t, currentQuestionBubbleRef: u, isCurrentQuestion: v, isThinking: S }), !S && e(Et, { avatars: n, card: t }), y && f ? e(At, { avatars: n, card: t, userResponse: k }) : (!y || !f) && !S && e(oe, { avatars: n, isLeft: !1, message: { id: `card-${t.name}`, type: "card", content: "" }, children: e("div", { className: "chat-card-container", children: e(Qt, { card: t, className: o ? "chat-thanks-card" : "chat-card", isAnswered: y, next: v ? c : () => {
475
- } }) }) })] }, `question-card-${t.name}`);
476
- }, oe = Me.forwardRef(({ message: t, isLeft: a = !1, children: r, avatars: n, hideAvatar: s = !1 }, i) => {
477
- const l = a ? "chat-bubble-left" : "chat-bubble-right";
478
- 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` })] });
479
- });
480
- oe.displayName = "ChatBubble";
481
- const Ot = () => {
482
- const t = O((r) => r.close), a = ce(() => () => t(_e), [t]);
483
- return e("div", { "aria-label": "Close button", className: "conversational-close-btn", onClick: a, onKeyPress: (r) => {
484
- r.key === "Enter" && a();
485
- }, 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" }) }) });
486
- }, Qt = ({ card: t, next: a, className: r = "", isAnswered: n = !1 }) => {
487
- const s = { className: n ? `${r} answered-card` : r, next: n ? () => {
488
- } : a, questionId: t.name, type: t.type, isAnswered: n };
489
- switch (t.type) {
490
- case "consentlegal":
491
- return e(dt, { ...s, ...t.props });
492
- case "likert":
493
- return e(mt, { ...s, ...t.props });
494
- case "matrix":
495
- return e(gt, { ...s, ...t.props });
496
- case "multiplechoice":
497
- return e(vt, { ...s, ...t.props });
498
- case "multipleselect":
499
- return e(bt, { ...s, ...t.props });
500
- case "nps":
501
- return e(yt, { ...s, ...t.props });
502
- case "aidynamicfollowup":
503
- case "open":
504
- return e(ft, { ...s, type: t.type, ...t.props });
505
- case "rankorder":
506
- return e(kt, { ...s, ...t.props });
507
- case "recordedtask":
508
- return e(Dt, { ...s, ...t.props });
509
- case "texturlprompt":
510
- return e(qt, { ...s, ...t.props });
511
- case "thanks":
512
- return e(Pt, { ...s, ...t.props });
513
- case "uploading":
514
- return e(Rt, { ...s, ...t.props });
515
- case "videovoice":
516
- return e(Mt, { ...s, ...t.props });
517
- default:
518
- return null;
519
- }
520
- }, Ft = ({ cards: t, next: a, previousResponses: r }) => {
521
- const { cardResponses: n, setCardResponse: s } = (() => {
522
- const [d, p] = V(/* @__PURE__ */ new Map());
523
- return { cardResponses: d, setCardResponse: le((x, g) => {
524
- p((b) => new Map(b).set(x, g));
525
- }, []) };
526
- })(), { index: i, isLongFormSurvey: l, avatars: u, showSurveyBrand: c, forceBrandedLogo: v, marketingUrlLink: y, startingQuestionIdx: o, viewDocument: m, createDynamicQuestion: k, update: f } = O((d) => ({ index: d.index, isLongFormSurvey: Ue(d.studyType), avatars: d.avatars, forceBrandedLogo: d.forceBrandedLogo, startingQuestionIdx: d.startingQuestionIdx, showSurveyBrand: d.showSurveyBrand, marketingUrlLink: Ye({ marketingUrl: d.marketingUrl, slugName: d.slugName, surveyId: d.surveyId, forceBrandedLogo: d.forceBrandedLogo }), viewDocument: d.viewDocument, createDynamicQuestion: d.createDynamicQuestion, update: d.update })), { currentQuestionBubbleRef: h, scrollToCurrentQuestion: S } = (({ viewDocument: d }) => {
527
- const p = ee(null), x = le(() => {
528
- const g = d.querySelector(".ul-card-main-content");
529
- if (p.current && g && g instanceof HTMLElement) {
530
- const b = p.current.offsetTop - g.offsetTop - 16;
531
- g.scrollTo({ top: Math.max(0, b), behavior: "smooth" });
532
- }
533
- }, []);
534
- return { currentQuestionBubbleRef: p, scrollToCurrentQuestion: x };
535
- })({ viewDocument: m }), N = ((d, p, x) => {
536
- const [g, b] = V(/* @__PURE__ */ new Map());
537
- return ne(() => {
538
- if (d.length > 0 && p < d.length) {
539
- const I = d[p], w = `${I.name}`, L = ($) => $.type === "aidynamicfollowup", Q = ($) => {
540
- var H;
541
- if (p > 0) {
542
- const Z = d[p - 1];
543
- if (L(Z)) {
544
- const ae = `${Z.name}`, ue = !!((H = Z.props) != null && H.loading);
545
- if ($.get(ae) !== ue) return new Map($).set(ae, ue);
546
- }
547
- }
548
- return $;
549
- };
550
- if (p <= (x ?? 0) || Ge(I)) return b(($) => Q(new Map($).set(w, !1)));
551
- b(($) => {
552
- const H = !L(I) || !!I.props.loading;
553
- return Q(new Map($).set(w, H));
554
- });
555
- const z = setTimeout(() => {
556
- b(($) => {
557
- const H = !!L(I) && !!I.props.loading;
558
- return Q(new Map($).set(w, H));
559
- });
560
- }, 1e3);
561
- return () => clearTimeout(z);
562
- }
563
- }, [p, d, x]), g;
564
- })(t, i, o), P = ((d, p) => {
565
- const [x, g] = V(() => /* @__PURE__ */ new Set([d]));
566
- return ne(() => {
567
- g((b) => new Set(b).add(d));
568
- }, [d]), ne(() => {
569
- const b = p ?? 0;
570
- b > 0 && g((I) => {
571
- const w = new Set(I);
572
- for (let L = 0; L <= b; L++) w.add(L);
573
- return w;
574
- });
575
- }, [p]), x;
576
- })(i, o), E = ce(() => ({ ...r, ...De(t.map((d, p) => {
577
- var x, g;
578
- return { ...d, value: p < i ? ((x = n.get(`${d.name}`)) == null ? void 0 : x.value) ?? null : null, secondaryValue: p < i ? ((g = n.get(`${d.name}`)) == null ? void 0 : g.secondaryValue) ?? null : null };
579
- })) }), [r, n, t, i]);
580
- ze(E);
581
- const _ = Ke(t, E);
582
- ne(() => {
583
- requestAnimationFrame(() => {
584
- S();
585
- }), f();
586
- }, [i, S, N, f]);
587
- const G = le((d, p) => {
588
- if (!p) return;
589
- const x = _[i];
590
- if (!x) return;
591
- const g = `${x.name}`;
592
- s(g, d);
593
- const b = { ...d, questionText: We(x) };
594
- if (x.childId && (b == null ? void 0 : b.value) != null) {
595
- const I = De([x].map((w) => ({ ...w, value: (b == null ? void 0 : b.value) ?? null, secondaryValue: (b == null ? void 0 : b.secondaryValue) ?? null })));
596
- k({ parentQuestionId: x.name, parentResponseConfig: I });
597
- }
598
- a([b]);
599
- }, [_, i, a, s]), A = _.map((d, p) => ({ card: d, cardIndex: p })).filter(({ cardIndex: d }) => P.has(d));
600
- return e("div", { className: "conversational-ui ul-conversational-ui", "data-testid": "ui-container", children: [!l && e(Ot, {}), e("div", { className: "chat-container", children: e("div", { className: "chat-messages", children: A.map(({ card: d, cardIndex: p }) => e($t, { avatars: u, card: d, cardIndex: p, cardResponses: n, currentQuestionBubbleRef: h, handleCardResponse: G, index: i, questionThinkingStates: N, startingQuestionIdx: o }, `question-card-${d.name}`)) }) }), l && e("div", { className: "long-form-question-footer-container-logo", children: c && e(Xe, { forceBrandedLogo: v, marketingUrlLink: y }) })] });
601
- };
602
- export {
603
- Ft as default
604
- };