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