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